[omniORB] ServantLocator and ForwardRequest in Python
baileyk@schneider.com
baileyk@schneider.com
Tue May 28 17:55:01 2002
I'm trying to translate some C++ code that I started working on (an
adaptive load balance service similar to one described in a paper by Doug
Schmidt) into Python since I think I'll get a prototype completed faster
that way. Below is some of the relavent pieces. I'm having trouble
getting a successful location forward to work using omniORBpy.
C++:
==============
// class declaration
class MigratorImp :
public virtual POA_PortableServer::ServantLocator
// preinvoke method snippet:
PortableServer::ForwardRequest fwd;
cout << "Migrating" << endl;
CORBA::Object_var b = // get the real object ref somehow
fwd.forward_reference =
CORBA::Object::_duplicate(b.in());
throw fwd;
// setup the POA
policies[i++] = poa->create_thread_policy(
PortableServer::SINGLE_THREAD_MODEL );
policies[i++] = poa->create_request_processing_policy(
PortableServer::USE_SERVANT_MANAGER );
policies[i++] = poa->create_servant_retention_policy(
PortableServer::NON_RETAIN );
policies[i++] = poa->create_id_assignment_policy(
PortableServer::USER_ID );
PortableServer::POA_var subpoa =
poa->create_POA( "lb_poa", mgr.in(), policies );
MigratorImp mig;
subpoa->set_servant_manager( mig._this() );
Python:
===============
#class declaration
class MigratorImp( PortableServer__POA.ServantLocator ):
# preinvoke snippet
def preinvoke(self, oid, poa, op) :
b = # get the real reference somehow
raise PortableServer.ForwardRequest(b)
# set up the POA
pol1 = [
poa.create_request_processing_policy(
PortableServer.USE_SERVANT_MANAGER ),
poa.create_servant_retention_policy(
PortableServer.NON_RETAIN ),
poa.create_id_assignment_policy(
PortableServer.USER_ID ) ]
poa1 = poa.create_POA("lb_poa", mgr, pol1)
mig = MigratorImp()
poa1.set_servant_manager( mig._this() )
The C++ code works fine ( actually I haven't tested it with omniORB, but
with Orbix2000 ). The Python server generates this trace message (at level
25)
omniORB: throw UNKNOWN from pyExceptions.cc:139
(MAYBE,UNKNOWN_SystemException)
And the client then gets this
Traceback (most recent call last):
File "ping.py", line 16, in ?
r = o1.ping()
File "/opt/ilog/dev/j00128/consol/scripts/load/load_idl.py", line 49, in
ping
return _omnipy.invoke(self, "ping", _0_DTLB.Pingable._d_ping, args)
omniORB.CORBA.UNKNOWN: Minor: UNKNOWN_SystemException, COMPLETED_MAYBE.
Has anyone implemented a ServantLocator in Python which raises a
ForwardRequest and get the right behavior?
Thanks,
Kendall