Discussion:
[omniORB] activate_object_with_id Returns None
Marco Ferreira
2008-04-23 22:38:39 UTC
Permalink
Hey all.

I'm trying to have my corba server objects to be accessible with
something like:
corbaloc::host/object

After reading and googling (allot) I can't make this work. The problem
is, when I try to activate_object_with_id, this function doesn't return
me any usable value, just None (using python)

Any help would be greatly appreciated. Thanks
BaileyK at schneider.com ()
2008-04-24 02:31:30 UTC
Permalink
use the POA's id_to_reference() method to get a reference to the newly
activated CORBA object if you need it. Otherwise just try to contact the
object using the corbaloc URI. Make sure the poa_manager is activated.


---
Kendall Bailey
Engineering & Research
Post by Marco Ferreira
Hey all.
I'm trying to have my corba server objects to be accessible with
corbaloc::host/object
After reading and googling (allot) I can't make this work. The problem
is, when I try to activate_object_with_id, this function doesn't return
me any usable value, just None (using python)
Any help would be greatly appreciated. Thanks
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
Wernke Zur Borg
2008-04-24 12:21:53 UTC
Permalink
Hi Marco,

First make sure you use a POA with IdAssignmentPolicy = USER_ID. With
omniORB you can use the predefined "omniINSPOA" for that.

Secondly, the return type of activate_object_with_id() is void, so you
can't get anything out of it anyway.

Cheers, Wernke
Post by BaileyK at schneider.com ()
use the POA's id_to_reference() method to get a reference to the newly
activated CORBA object if you need it. Otherwise just try to
contact the
object using the corbaloc URI. Make sure the poa_manager is
activated.
---
Kendall Bailey
Engineering & Research
Post by Marco Ferreira
Hey all.
I'm trying to have my corba server objects to be accessible with
corbaloc::host/object
After reading and googling (allot) I can't make this work.
The problem
Post by Marco Ferreira
is, when I try to activate_object_with_id, this function
doesn't return
Post by Marco Ferreira
me any usable value, just None (using python)
Any help would be greatly appreciated. Thanks
Fischer, Clemens
2008-04-24 14:51:03 UTC
Permalink
Hi, here's a small example:
----------------------------------------
IDL in Test.idl:
module Test
{
interface Intf
{
void print_text(in string text);
};
};
----------------------------------------
Server code in TestServer.py:
from omniORB import CORBA
import Test
import Test__POA
import sys

class TestIntfImpl(Test__POA.Intf):
def print_text(self, text):
print text

orb = CORBA.ORB_init(sys.argv)
poa = orb.resolve_initial_references("omniINSPOA")
poa._get_the_POAManager().activate()

servant = TestIntfImpl()
poa.activate_object_with_id("TestIntf", servant)

try:
orb.run()
except:
pass

poa.deactivate_object("TestIntf")
----------------------------------------
Client code in TestClient.py:
from omniORB import CORBA
import Test
import sys

orb = CORBA.ORB_init(sys.argv)
obj = orb.string_to_object(sys.argv[1])._narrow(Test.Intf)
obj.print_text(sys.argv[2])
----------------------------------------

Run the server by 'python TestServer.py -ORBendPoint :::12345' (or any other valid endpoint). Then run the client by
'python TestClient.py corbaloc:iiop:localhost:12345/TestIntf Hello' and see what happens.

Cheers
Clemens

-----Urspr?ngliche Nachricht-----
Von: omniorb-list-***@omniorb-support.com [mailto:omniorb-list-***@omniorb-support.com] Im Auftrag von Marco Ferreira
Gesendet: Mittwoch, 23. April 2008 18:38
An: omniorb-***@omniorb-support.com
Betreff: [omniORB] activate_object_with_id Returns None

Hey all.

I'm trying to have my corba server objects to be accessible with
something like:
corbaloc::host/object

After reading and googling (allot) I can't make this work. The problem
is, when I try to activate_object_with_id, this function doesn't return
me any usable value, just None (using python)

Any help would be greatly appreciated. Thanks
Marco Ferreira
2008-04-24 18:58:25 UTC
Permalink
Thanks for all the replies.

I have tried different ways to get to the result I want, but the problem
pressists.

Needed result: to be able to contact the corba objects through corbaloc
URI's

Solution one:
Use the omniINSPOA POA
Problem:
Can't get the client to touch the objects (OBJECT_NOT_EXIST)

Solution two:
Use omniMapper to map the object names to correct IOR's
Problem:
When client contacts the corbaloc URI, omniMapper stays on some kind
of infinite loop with return LOCATION_FORWARD


I've tried your example Fischer, and some more while googling, and they
all work.
Mine just seems to want to be left alone in the corner :|
Silly & Chrischi
2008-04-24 19:06:26 UTC
Permalink
Hello,

I create an object with a factory-method. What have i had to call on the client, do destroy the object on the server? Every class has an destructor but I don't know what to call to start the destructor.

Thank you.
Michael
2008-04-24 19:21:53 UTC
Permalink
Post by Silly & Chrischi
Hello,
I create an object with a factory-method. What have i had to call on the client, do destroy the object on the server? Every class has an destructor but I don't know what to call to start the destructor.
Thank you.
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
You have to create an explicit destroy method on the object (also in IDL), that:
- deactivates the object in the poa
- deletes the object

(you might want to use RefCountServantBase and make destroy just decrement the reference
count and set a deleted flag on the object)

Make sure you do not shoot yourself in multi threading scenarios.

Example:
IDL:
interface Xyz
{
unsigned long getId();
void destroy();
};

class Xyz_impl: virtual public POA_Test::Xyz, virtual public
PortableServer::RefCountServantBase
{
ZThread::RecursiveMutex _lock;
bool _destroyed;
PortableServer::POA_ptr _poa;

public:
...
CORBA::ULong getId()
{
ZThread::Guard<ZThread::RecursiveMutex> g(_lock);
if (_destroyed) throw CORBA::OBJECT_NOT_EXIST();
// do sth useful
}

void destroy()
{
ZThread::Guard<ZThread::RecursiveMutex> g(_lock);
if (_destroyed) return; // might also want to throw here
// .. cleanup
_destroyed = true;
if (!_poa->non_existent())
{
PortableServer::ObjectId_var oid = _poa->servant_to_id(this);
_poa->deactivate_object(oid);
}
}
}


Please note that this example is out of context and might not work 1:1 in your setup
Silly &amp; Chrischi
2008-05-09 15:30:01 UTC
Permalink
Hello,

what do I have to include to use ZThread::RecursiveMutex?
Andi t doesn't work. I tested your code send to me and I put in the destructor of my object the following:

Administrator_impl::~Administrator_impl(void) {
cout << "destroy";
delete mysql_;
}

But I don't see the "destroy" in my console. And the next, if I set my object in the client to admin->destroy(); I can woork with this object later on, but I thought it doesn't exists anymore. So what do I do wrong?

Thanks.

-----Urspr?ngliche Nachricht-----
Von: Michael [mailto:***@bindone.de]
Gesendet: Donnerstag, 24. April 2008 15:22
An: ***@gmx.li
Cc: omniorb-***@omniorb-support.com
Betreff: Re: [omniORB] Destroy objects
Post by Silly &amp; Chrischi
Hello,
I create an object with a factory-method. What have i had to call on the client, do destroy the object on the server? Every class has an destructor but I don't know what to call to start the destructor.
Thank you.
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
You have to create an explicit destroy method on the object (also in IDL), that:
- deactivates the object in the poa
- deletes the object

(you might want to use RefCountServantBase and make destroy just decrement the reference
count and set a deleted flag on the object)

Make sure you do not shoot yourself in multi threading scenarios.

Example:
IDL:
interface Xyz
{
unsigned long getId();
void destroy();
};

class Xyz_impl: virtual public POA_Test::Xyz, virtual public
PortableServer::RefCountServantBase
{
ZThread::RecursiveMutex _lock;
bool _destroyed;
PortableServer::POA_ptr _poa;

public:
...
CORBA::ULong getId()
{
ZThread::Guard<ZThread::RecursiveMutex> g(_lock);
if (_destroyed) throw CORBA::OBJECT_NOT_EXIST();
// do sth useful
}

void destroy()
{
ZThread::Guard<ZThread::RecursiveMutex> g(_lock);
if (_destroyed) return; // might also want to throw here
// .. cleanup
_destroyed = true;
if (!_poa->non_existent())
{
PortableServer::ObjectId_var oid = _poa->servant_to_id(this);
_poa->deactivate_object(oid);
}
}
}


Please note that this example is out of context and might not work 1:1 in your setup
Michael
2008-05-09 15:45:47 UTC
Permalink
ZThread is a threading library, you could of course use any other locking mechanism (boost
threads, plain pthreads, omnithreads whatever).

Did your servant inherit from PortableServer::RefCountServantBase?

If it does, my example code is lacking a call to _remove_ref, so at the end of the destroy
function you should add:
_remove_ref()
(I'm sorry I forgot about that, the example I gave you is from a Servant Locator
implementation which handles this differently).

Assuming you created the object correctly, this should bring the reference count down to 1
(it is 2 before, because the poa increased it), after the destroy method has been left,
the orb will call remove_ref as well, bringing the reference count down to 0, which will
trigger the destructor to be called.

You can call _refcount_value() any time to check what the current reference count is. Also
make sure you understand which calls increase the reference count (like activate does,
explictely or implicitely when calling _this() on an unactivated object)

cheers
michael
Post by Silly &amp; Chrischi
Hello,
what do I have to include to use ZThread::RecursiveMutex?
Administrator_impl::~Administrator_impl(void) {
cout << "destroy";
delete mysql_;
}
But I don't see the "destroy" in my console. And the next, if I set my object in the client to admin->destroy(); I can woork with this object later on, but I thought it doesn't exists anymore. So what do I do wrong?
Thanks.
-----Urspr?ngliche Nachricht-----
Gesendet: Donnerstag, 24. April 2008 15:22
Betreff: Re: [omniORB] Destroy objects
Post by Silly &amp; Chrischi
Hello,
I create an object with a factory-method. What have i had to call on the client, do destroy the object on the server? Every class has an destructor but I don't know what to call to start the destructor.
Thank you.
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
- deactivates the object in the poa
- deletes the object
(you might want to use RefCountServantBase and make destroy just decrement the reference
count and set a deleted flag on the object)
Make sure you do not shoot yourself in multi threading scenarios.
interface Xyz
{
unsigned long getId();
void destroy();
};
class Xyz_impl: virtual public POA_Test::Xyz, virtual public
PortableServer::RefCountServantBase
{
ZThread::RecursiveMutex _lock;
bool _destroyed;
PortableServer::POA_ptr _poa;
...
CORBA::ULong getId()
{
ZThread::Guard<ZThread::RecursiveMutex> g(_lock);
if (_destroyed) throw CORBA::OBJECT_NOT_EXIST();
// do sth useful
}
void destroy()
{
ZThread::Guard<ZThread::RecursiveMutex> g(_lock);
if (_destroyed) return; // might also want to throw here
// .. cleanup
_destroyed = true;
if (!_poa->non_existent())
{
PortableServer::ObjectId_var oid = _poa->servant_to_id(this);
_poa->deactivate_object(oid);
}
}
}
Please note that this example is out of context and might not work 1:1 in your setup
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
Marco Ferreira
2008-04-24 19:29:45 UTC
Permalink
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20080424/05bdb811/attachment.htm
Fischer, Clemens
2008-04-24 20:11:29 UTC
Permalink
Hi Michael,

when you try out the corbaloc approach, make sure the following is true:



1. the servant gets activated in omniINSPOA with a defined object
id string, TestIntf in my example
2. omniINSPOA's POAManager is activated
3. the server listens on a defined endpoint, :::12345 in my
example, which is equivalent to giop:tcp:localhost:12345
4. the client uses exactly the same endpoint and object id string
in it's corbaloc reference, here corbaloc:iiop:localhost:12345/TestIntf
5. obvious, but: client narrows it's object reference to the same
interface that the servant implements.



Cheers

Clemens



________________________________

Von: omniorb-list-***@omniorb-support.com
[mailto:omniorb-list-***@omniorb-support.com] Im Auftrag von Marco
Ferreira
Gesendet: Donnerstag, 24. April 2008 15:29
An: omniorb-***@omniorb-support.com
Betreff: Re: [omniORB] activate_object_with_id Returns None



Hello Michael.

First, I'm using Python to implement this server.

Michael wrote:

Hi Marco,

didn't really follow the thread, but

Marco Ferreira wrote:


Thanks for all the replies.

I have tried different ways to get to the result I want, but the
problem
pressists.

Needed result: to be able to contact the corba objects through
corbaloc
URI's

Solution one:
Use the omniINSPOA POA
Problem:
Can't get the client to touch the objects (OBJECT_NOT_EXIST)


Did you try sth like this?

CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

PortableServer::POAManager_var pman = rootpoa->the_POAManager();
PortableServer::LifespanPolicy_var lifespan2 =
rootpoa->create_lifespan_policy(PortableServer::PERSISTENT);
PortableServer::IdAssignmentPolicy_var assign =
rootpoa->create_id_assignment_policy(PortableServer::USER_ID);

CORBA::PolicyList policy_list;
policy_list.length(2);
policy_list[0] = PortableServer::LifespanPolicy::_duplicate(lifespan2);
policy_list[1] = PortableServer::IdAssignmentPolicy::_duplicate(assign);


CORBA::Object_var obj = orb->resolve_initial_references("omniINSPOA");
PortableServer::POA_var omniINSPOA=PortableServer::POA::_narrow(obj);

MyImpl* m = new MyImpl();
PortableServer::ObjectId_var myId =
PortableServer::string_to_ObjectId("SomeObjectId")
omniINSPOA->activate_object_with_id(myId, m);

pman = omniINSPOA->the_POAManager();
pman->activate();
orb->run();

Then start the server using a fixed endpoint:
startmyserver -ORBendPoint giop:tcp:127.0.0.1:11173

and access it through a corbaloc uri:
corbaloc::127.0.0.1:11173/SomeObjectId


On my searches I have came across the solution you just suggested, thing
is



PortableServer doesn't have any method by the name "string_to_ObjectId".
I'd think it's missing cause it's useless on python?

Anyway, i did try something like that, but client always got
object_not_exist.

Using omniMapper, here part of it:
IncBaseServiceObjKey
IOR:010000001e00000049444c3a496e636f676e69746f2f42617365536572766963653a
312e30000000010000000000000064000000010102000e00000031302e3133382e313034
2e39310015dc0e000000feb16a0f48000053c50000000000000002000000000000000800
00000100000000545441010000001c000000010000000100010001000000010001050901
01000100000009010100

And here's what omniMapper daemon outputs:
omniORB: Server accepted connection from giop:tcp:10.138.104.91:44786
omniORB: AsyncInvoker: thread id = 2 has started. Total threads = 3
omniORB: Scavenger task execute.
omniORB: AsyncInvoker: thread id = 3 has started. Total threads = 3
omniORB: giopWorker task execute.
omniORB: Accepted connection from giop:tcp:10.138.104.91:44786 because
of this rule: "* unix,ssl,tcp"
omniORB: inputMessage: from giop:tcp:10.138.104.91:44786 118 bytes
omniORB:
4749 4f50 0100 0100 6a00 0000 0100 0000 GIOP....j.......
0100 0000 0c00 0000 0100 0000 0100 0100 ................
0901 0100 0100 0000 0100 0000 1400 0000 ................
496e 6342 6173 6553 6572 7669 6365 4f62 IncBaseServiceOb
6a4b 6579 0600 0000 5f69 735f 6100 0000 jKey...._is_a...
0000 0000 1e00 0000 4944 4c3a 496e 636f ........IDL:Inco
676e 6974 6f2f 4261 7365 5365 7276 6963 gnito/BaseServic
653a 312e 3000 e:1.0.
omniORB: Dispatching remote call '_is_a' to: key<IncBaseServiceObjKey>
(active)
Mapping `IncBaseServiceObjKey' to
IOR:010000001e00000049444c3a496e636f676e69746f2f42617365536572766963653a
312e30000000010000000000000064000000010102000e00000031302e3133382e313034
2e39310015dc0e000000feb16a0f48000053c50000000000000002000000000000000800
00000100000000545441010000001c000000010000000100010001000000010001050901
01000100000009010100
omniORB: Implementation of '_is_a' generated LOCATION_FORWARD.
omniORB: sendChunk: to giop:tcp:10.138.104.91:44786 172 bytes
omniORB:
4749 4f50 0100 0101 a000 0000 0000 0000 GIOP............
0100 0000 0300 0000 1e00 0000 4944 4c3a ............IDL:
496e 636f 676e 6974 6f2f 4261 7365 5365 Incognito/BaseSe
7276 6963 653a 312e 3000 0000 0100 0000 rvice:1.0.......
0000 0000 6400 0000 0101 0200 0e00 0000 ....d...........
3130 2e31 3338 2e31 3034 2e39 3100 15dc 10.138.104.91...
0e00 0000 feb1 6a0f 4800 0053 c500 0000 ......j.H..S....
0000 0000 0200 0000 0000 0000 0800 0000 ................
0100 0000 0054 5441 0100 0000 1c00 0000 .....TTA........
0100 0000 0100 0100 0100 0000 0100 0105 ................
0901 0100 0100 0000 0901 0100 ............
omniORB: Server connection refcount = 1
omniORB: Server connection refcount = 0
omniORB: Server close connection from giop:tcp:10.138.104.91:44786









Solution two:
Use omniMapper to map the object names to correct
IOR's
Problem:
When client contacts the corbaloc URI, omniMapper
stays on some kind
of infinite loop with return LOCATION_FORWARD


Same problem imho, the location_forward is created because of
object_not_exist




I've tried your example Fischer, and some more while
googling, and they
all work.
Mine just seems to want to be left alone in the corner
:|

_______________________________________________
omniORB-list mailing list
omniORB-***@omniorb-support.com

http://www.omniorb-support.com/mailman/listinfo/omniorb-list







-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20080424/7884a4bb/attachment-0001.htm
Michael
2008-04-24 21:01:37 UTC
Permalink
Hi Marco,

could you provide your source code (stripped down IDL and python code). Would make this a
lot easier. Which versions of omniorb are ou using (4.1.2 and py 3.2?)

You're right about string_to_objectid - it's not needed in python, you can just pass
strings as objectids.

cheers
michael
Post by Fischer, Clemens
Hello Michael.
First, I'm using Python to implement this server.
Post by Wernke Zur Borg
Hi Marco,
didn't really follow the thread, but
Post by Marco Ferreira
Thanks for all the replies.
I have tried different ways to get to the result I want, but the problem
pressists.
Needed result: to be able to contact the corba objects through corbaloc
URI's
Use the omniINSPOA POA
Can't get the client to touch the objects (OBJECT_NOT_EXIST)
Did you try sth like this?
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
PortableServer::POAManager_var pman = rootpoa->the_POAManager();
PortableServer::LifespanPolicy_var lifespan2 =
rootpoa->create_lifespan_policy(PortableServer::PERSISTENT);
PortableServer::IdAssignmentPolicy_var assign =
rootpoa->create_id_assignment_policy(PortableServer::USER_ID);
CORBA::PolicyList policy_list;
policy_list.length(2);
policy_list[0] = PortableServer::LifespanPolicy::_duplicate(lifespan2);
policy_list[1] = PortableServer::IdAssignmentPolicy::_duplicate(assign);
CORBA::Object_var obj = orb->resolve_initial_references("omniINSPOA");
PortableServer::POA_var omniINSPOA=PortableServer::POA::_narrow(obj);
MyImpl* m = new MyImpl();
PortableServer::ObjectId_var myId = PortableServer::string_to_ObjectId("SomeObjectId")
omniINSPOA->activate_object_with_id(myId, m);
pman = omniINSPOA->the_POAManager();
pman->activate();
orb->run();
startmyserver -ORBendPoint giop:tcp:127.0.0.1:11173
corbaloc::127.0.0.1:11173/SomeObjectId
On my searches I have came across the solution you just suggested, thing is
PortableServer doesn't have any method by the name "string_to_ObjectId". I'd think it's missing cause it's useless on python?
Anyway, i did try something like that, but client always got object_not_exist.
IncBaseServiceObjKey IOR:010000001e00000049444c3a496e636f676e69746f2f42617365536572766963653a312e30000000010000000000000064000000010102000e00000031302e3133382e3130342e39310015dc0e000000feb16a0f48000053c5000000000000000200000000000000080000000100000000545441010000001c00000001000000010001000100000001000105090101000100000009010100
omniORB: Server accepted connection from giop:tcp:10.138.104.91:44786
omniORB: AsyncInvoker: thread id = 2 has started. Total threads = 3
omniORB: Scavenger task execute.
omniORB: AsyncInvoker: thread id = 3 has started. Total threads = 3
omniORB: giopWorker task execute.
omniORB: Accepted connection from giop:tcp:10.138.104.91:44786 because of this rule: "* unix,ssl,tcp"
omniORB: inputMessage: from giop:tcp:10.138.104.91:44786 118 bytes
4749 4f50 0100 0100 6a00 0000 0100 0000 GIOP....j.......
0100 0000 0c00 0000 0100 0000 0100 0100 ................
0901 0100 0100 0000 0100 0000 1400 0000 ................
496e 6342 6173 6553 6572 7669 6365 4f62 IncBaseServiceOb
6a4b 6579 0600 0000 5f69 735f 6100 0000 jKey...._is_a...
0000 0000 1e00 0000 4944 4c3a 496e 636f ........IDL:Inco
676e 6974 6f2f 4261 7365 5365 7276 6963 gnito/BaseServic
653a 312e 3000 e:1.0.
omniORB: Dispatching remote call '_is_a' to: key<IncBaseServiceObjKey> (active)
Mapping `IncBaseServiceObjKey' to IOR:010000001e00000049444c3a496e636f676e69746f2f42617365536572766963653a312e30000000010000000000000064000000010102000e00000031302e3133382e3130342e39310015dc0e000000feb16a0f48000053c5000000000000000200000000000000080000000100000000545441010000001c00000001000000010001000100000001000105090101000100000009010100
omniORB: Implementation of '_is_a' generated LOCATION_FORWARD.
omniORB: sendChunk: to giop:tcp:10.138.104.91:44786 172 bytes
4749 4f50 0100 0101 a000 0000 0000 0000 GIOP............
496e 636f 676e 6974 6f2f 4261 7365 5365 Incognito/BaseSe
7276 6963 653a 312e 3000 0000 0100 0000 rvice:1.0.......
0000 0000 6400 0000 0101 0200 0e00 0000 ....d...........
3130 2e31 3338 2e31 3034 2e39 3100 15dc 10.138.104.91...
0e00 0000 feb1 6a0f 4800 0053 c500 0000 ......j.H..S....
0000 0000 0200 0000 0000 0000 0800 0000 ................
0100 0000 0054 5441 0100 0000 1c00 0000 .....TTA........
0100 0000 0100 0100 0100 0000 0100 0105 ................
0901 0100 0100 0000 0901 0100 ............
omniORB: Server connection refcount = 1
omniORB: Server connection refcount = 0
omniORB: Server close connection from giop:tcp:10.138.104.91:44786
Post by Wernke Zur Borg
Post by Marco Ferreira
Use omniMapper to map the object names to correct IOR's
When client contacts the corbaloc URI, omniMapper stays on some kind
of infinite loop with return LOCATION_FORWARD
Same problem imho, the location_forward is created because of object_not_exist
Post by Marco Ferreira
I've tried your example Fischer, and some more while googling, and they
all work.
Mine just seems to want to be left alone in the corner :|
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
------------------------------------------------------------------------
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
Marco Ferreira
2008-04-24 21:29:03 UTC
Permalink
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20080424/6bfd4f46/attachment.htm
Michael
2008-04-24 21:38:35 UTC
Permalink
Without a fixed endpoint it wont work.
You could also set the fixed endpoint by using an environment variable
Sorry, I can't do that since it's corporate material.
poa = orb.resolve_initial_references("omniINSPOA")
poa._get_the_POAManager().activate()
base_service_inst = BaseService_i(poa, client_orb)
(...)
log.debug("Activating objects:")
log.debug(" ...%s"% servant)
poa.activate_object_with_id(servant, interface_inst_list[servant])
# Block for ever (or until the ORB is shut down)
orb.run()
* The server .py uses optparse to handle command line options (like
debugging), so i can't use that "-ORBendPoint :::12345".
Do i really need to set it? If so, is there another way to do so?
Post by Wernke Zur Borg
Post by Fischer, Clemens
obj = orb.string_to_object("corbaloc::127.0.0.1/IncBaseServiceObjKey")
obj = obj._narrow(interface.Incognito.BaseService)
omniORB: Invoke '_is_a' on remote: key<IncBaseServiceObjKey>
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/omniORB/CORBA.py", line 667, in _narrow
return _omnipy.narrow(self, dest._NP_RepositoryId)
omniORB.CORBA.TRANSIENT: Minor: 0x41540002, COMPLETED_NO.
Post by Wernke Zur Borg
Hi Marco,
could you provide your source code (stripped down IDL and python code). Would make this a
lot easier. Which versions of omniorb are ou using (4.1.2 and py 3.2?)
You're right about string_to_objectid - it's not needed in python, you can just pass
strings as objectids.
cheers
michael
Post by Fischer, Clemens
Hello Michael.
First, I'm using Python to implement this server.
Hi Marco,
didn't really follow the thread, but
Post by Marco Ferreira
Thanks for all the replies.
I have tried different ways to get to the result I want, but the problem
pressists.
Needed result: to be able to contact the corba objects through corbaloc
URI's
Use the omniINSPOA POA
Can't get the client to touch the objects (OBJECT_NOT_EXIST)
Did you try sth like this?
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
PortableServer::POAManager_var pman = rootpoa->the_POAManager();
PortableServer::LifespanPolicy_var lifespan2 =
rootpoa->create_lifespan_policy(PortableServer::PERSISTENT);
PortableServer::IdAssignmentPolicy_var assign =
rootpoa->create_id_assignment_policy(PortableServer::USER_ID);
CORBA::PolicyList policy_list;
policy_list.length(2);
policy_list[0] = PortableServer::LifespanPolicy::_duplicate(lifespan2);
policy_list[1] = PortableServer::IdAssignmentPolicy::_duplicate(assign);
CORBA::Object_var obj = orb->resolve_initial_references("omniINSPOA");
PortableServer::POA_var omniINSPOA=PortableServer::POA::_narrow(obj);
MyImpl* m = new MyImpl();
PortableServer::ObjectId_var myId = PortableServer::string_to_ObjectId("SomeObjectId")
omniINSPOA->activate_object_with_id(myId, m);
pman = omniINSPOA->the_POAManager();
pman->activate();
orb->run();
startmyserver -ORBendPoint giop:tcp:127.0.0.1:11173
corbaloc::127.0.0.1:11173/SomeObjectId
On my searches I have came across the solution you just suggested, thing is
PortableServer doesn't have any method by the name "string_to_ObjectId". I'd think it's missing cause it's useless on python?
Anyway, i did try something like that, but client always got object_not_exist.
IncBaseServiceObjKey IOR:010000001e00000049444c3a496e636f676e69746f2f42617365536572766963653a312e30000000010000000000000064000000010102000e00000031302e3133382e3130342e39310015dc0e000000feb16a0f48000053c5000000000000000200000000000000080000000100000000545441010000001c00000001000000010001000100000001000105090101000100000009010100
omniORB: Server accepted connection from giop:tcp:10.138.104.91:44786
omniORB: AsyncInvoker: thread id = 2 has started. Total threads = 3
omniORB: Scavenger task execute.
omniORB: AsyncInvoker: thread id = 3 has started. Total threads = 3
omniORB: giopWorker task execute.
omniORB: Accepted connection from giop:tcp:10.138.104.91:44786 because of this rule: "* unix,ssl,tcp"
omniORB: inputMessage: from giop:tcp:10.138.104.91:44786 118 bytes
4749 4f50 0100 0100 6a00 0000 0100 0000 GIOP....j.......
0100 0000 0c00 0000 0100 0000 0100 0100 ................
0901 0100 0100 0000 0100 0000 1400 0000 ................
496e 6342 6173 6553 6572 7669 6365 4f62 IncBaseServiceOb
6a4b 6579 0600 0000 5f69 735f 6100 0000 jKey...._is_a...
0000 0000 1e00 0000 4944 4c3a 496e 636f ........IDL:Inco
676e 6974 6f2f 4261 7365 5365 7276 6963 gnito/BaseServic
653a 312e 3000 e:1.0.
omniORB: Dispatching remote call '_is_a' to: key<IncBaseServiceObjKey> (active)
Mapping `IncBaseServiceObjKey' to IOR:010000001e00000049444c3a496e636f676e69746f2f42617365536572766963653a312e30000000010000000000000064000000010102000e00000031302e3133382e3130342e39310015dc0e000000feb16a0f48000053c5000000000000000200000000000000080000000100000000545441010000001c00000001000000010001000100000001000105090101000100000009010100
omniORB: Implementation of '_is_a' generated LOCATION_FORWARD.
omniORB: sendChunk: to giop:tcp:10.138.104.91:44786 172 bytes
4749 4f50 0100 0101 a000 0000 0000 0000 GIOP............
496e 636f 676e 6974 6f2f 4261 7365 5365 Incognito/BaseSe
7276 6963 653a 312e 3000 0000 0100 0000 rvice:1.0.......
0000 0000 6400 0000 0101 0200 0e00 0000 ....d...........
3130 2e31 3338 2e31 3034 2e39 3100 15dc 10.138.104.91...
0e00 0000 feb1 6a0f 4800 0053 c500 0000 ......j.H..S....
0000 0000 0200 0000 0000 0000 0800 0000 ................
0100 0000 0054 5441 0100 0000 1c00 0000 .....TTA........
0100 0000 0100 0100 0100 0000 0100 0105 ................
0901 0100 0100 0000 0901 0100 ............
omniORB: Server connection refcount = 1
omniORB: Server connection refcount = 0
omniORB: Server close connection from giop:tcp:10.138.104.91:44786
Post by Marco Ferreira
Use omniMapper to map the object names to correct IOR's
When client contacts the corbaloc URI, omniMapper stays on some kind
of infinite loop with return LOCATION_FORWARD
Same problem imho, the location_forward is created because of object_not_exist
Post by Marco Ferreira
I've tried your example Fischer, and some more while googling, and they
all work.
Mine just seems to want to be left alone in the corner :|
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
------------------------------------------------------------------------
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
Fischer, Clemens
2008-04-24 21:42:18 UTC
Permalink
Hi Marco,



take a closer look at activate_object_with_id.

The first parameter must be an object id string, the second one a
servant object (a python object).



Cheers

Clemens



________________________________

Von: omniorb-list-***@omniorb-support.com
[mailto:omniorb-list-***@omniorb-support.com] Im Auftrag von Marco
Ferreira
Gesendet: Donnerstag, 24. April 2008 17:29
An: Michael
Cc: omniorb-***@omniorb-support.com
Betreff: Re: [omniORB] activate_object_with_id Returns None



Sorry, I can't do that since it's corporate material.

I've re-written my code again to handle the omniINSPOA, here's a sample
of the code:

poa = orb.resolve_initial_references("omniINSPOA")
poa._get_the_POAManager().activate()

base_service_inst = BaseService_i(poa, client_orb)
(...)
log.debug("Activating objects:")
for servant in interface_inst_list:
log.debug(" ...%s"% servant)
poa.activate_object_with_id(servant,
interface_inst_list[servant])

# Block for ever (or until the ORB is shut down)
orb.run()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20080424/43da2036/attachment-0001.htm
Marco Ferreira
2008-04-24 21:52:03 UTC
Permalink
Hey Fischer.

interface_inst_list is a dictionary like: { 'servant_name': servant_object }

Therefor the usage: poa.activate_object_with_id(servant, interface_inst_list[servant])


I'm using it correctly, right?


Michael:

Would it work if the endPoint is defined at omniORB4.cfg ?
Post by Wernke Zur Borg
Hi Marco,
take a closer look at activate_object_with_id.
The first parameter must be an object id string, the second one a
servant object (a python object).
Cheers
Clemens
________________________________
Ferreira
Gesendet: Donnerstag, 24. April 2008 17:29
An: Michael
Betreff: Re: [omniORB] activate_object_with_id Returns None
Sorry, I can't do that since it's corporate material.
I've re-written my code again to handle the omniINSPOA, here's a sample
poa = orb.resolve_initial_references("omniINSPOA")
poa._get_the_POAManager().activate()
base_service_inst = BaseService_i(poa, client_orb)
(...)
log.debug("Activating objects:")
log.debug(" ...%s"% servant)
poa.activate_object_with_id(servant,
interface_inst_list[servant])
# Block for ever (or until the ORB is shut down)
orb.run()
Thomas Lockhart
2008-04-24 23:12:55 UTC
Permalink
Sorry, I can't do that since it's corporate material.
Well that is too bad. Showing a test case really is the only way to
support people who are trying to help you.
* The server .py uses optparse to handle command line options (like
debugging), so i can't use that "-ORBendPoint :::12345".
Call ORB_init() before looking at the rest of your command line and that
will strip out the ORB arguments.

- Tom
Michael
2008-04-24 23:56:32 UTC
Permalink
I would agree here, Marco, can you please provide the essentials of your code, meaning:
IDL: Your factory interface that should contain one method (like void dummy())
Python code: The code your using to create the servant etc.

This cannot be corporate material (actually if it was, our support would be as well.. :)
since I would consider that prior art.

Otherwise it gets extremely hard to help you, especially since we told you all the theory
behind it already.

cheers
michael
Post by Thomas Lockhart
Sorry, I can't do that since it's corporate material.
Well that is too bad. Showing a test case really is the only way to
support people who are trying to help you.
* The server .py uses optparse to handle command line options (like
debugging), so i can't use that "-ORBendPoint :::12345".
Call ORB_init() before looking at the rest of your command line and that
will strip out the ORB arguments.
- Tom
Fischer, Clemens
2008-04-25 14:48:50 UTC
Permalink
Hi Marco,



take a closer look at activate_object_with_id.

The first parameter must be an object id string, the second one a
servant object (a python object).



Cheers

Clemens



________________________________

Von: omniorb-list-***@omniorb-support.com
[mailto:omniorb-list-***@omniorb-support.com] Im Auftrag von Marco
Ferreira
Gesendet: Donnerstag, 24. April 2008 17:29
An: Michael
Cc: omniorb-***@omniorb-support.com
Betreff: Re: [omniORB] activate_object_with_id Returns None



Sorry, I can't do that since it's corporate material.

I've re-written my code again to handle the omniINSPOA, here's a sample
of the code:

poa = orb.resolve_initial_references("omniINSPOA")
poa._get_the_POAManager().activate()

base_service_inst = BaseService_i(poa, client_orb)
(...)
log.debug("Activating objects:")
for servant in interface_inst_list:
log.debug(" ...%s"% servant)
poa.activate_object_with_id(servant,
interface_inst_list[servant])

# Block for ever (or until the ORB is shut down)
orb.run()


Issues:

* The server .py uses optparse to handle command line options
(like debugging), so i can't use that "-ORBendPoint :::12345".

Do i really need to set it? If so, is there another way to do
so?
obj =
orb.string_to_object("corbaloc::127.0.0.1/IncBaseServiceObjKey")
obj = obj._narrow(interface.Incognito.BaseService)
omniORB: Invoke '_is_a' on remote: key<IncBaseServiceObjKey>
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/omniORB/CORBA.py", line
667, in _narrow
return _omnipy.narrow(self, dest._NP_RepositoryId)
omniORB.CORBA.TRANSIENT: Minor: 0x41540002, COMPLETED_NO.




Michael wrote:

Hi Marco,

could you provide your source code (stripped down IDL and python code).
Would make this a
lot easier. Which versions of omniorb are ou using (4.1.2 and py 3.2?)

You're right about string_to_objectid - it's not needed in python, you
can just pass
strings as objectids.

cheers
michael

Marco Ferreira wrote:


Hello Michael.

First, I'm using Python to implement this server.

Michael wrote:


Hi Marco,

didn't really follow the thread, but

Marco Ferreira wrote:



Thanks for all the replies.

I have tried different ways to get to the result
I want, but the problem
pressists.

Needed result: to be able to contact the corba
objects through corbaloc
URI's

Solution one:
Use the omniINSPOA POA
Problem:
Can't get the client to touch the objects
(OBJECT_NOT_EXIST)



Did you try sth like this?

CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

PortableServer::POAManager_var pman =
rootpoa->the_POAManager();
PortableServer::LifespanPolicy_var lifespan2 =

rootpoa->create_lifespan_policy(PortableServer::PERSISTENT);
PortableServer::IdAssignmentPolicy_var assign =

rootpoa->create_id_assignment_policy(PortableServer::USER_ID);

CORBA::PolicyList policy_list;
policy_list.length(2);
policy_list[0] =
PortableServer::LifespanPolicy::_duplicate(lifespan2);
policy_list[1] =
PortableServer::IdAssignmentPolicy::_duplicate(assign);


CORBA::Object_var obj =
orb->resolve_initial_references("omniINSPOA");
PortableServer::POA_var
omniINSPOA=PortableServer::POA::_narrow(obj);

MyImpl* m = new MyImpl();
PortableServer::ObjectId_var myId =
PortableServer::string_to_ObjectId("SomeObjectId")
omniINSPOA->activate_object_with_id(myId, m);

pman = omniINSPOA->the_POAManager();
pman->activate();
orb->run();

Then start the server using a fixed endpoint:
startmyserver -ORBendPoint giop:tcp:127.0.0.1:11173

and access it through a corbaloc uri:
corbaloc::127.0.0.1:11173/SomeObjectId



On my searches I have came across the solution you just
suggested, thing is

PortableServer doesn't have any method by the name
"string_to_ObjectId". I'd think it's missing cause it's useless on
python?

Anyway, i did try something like that, but client always got
object_not_exist.

Using omniMapper, here part of it:
IncBaseServiceObjKey
IOR:010000001e00000049444c3a496e636f676e69746f2f42617365536572766963653a
312e30000000010000000000000064000000010102000e00000031302e3133382e313034
2e39310015dc0e000000feb16a0f48000053c50000000000000002000000000000000800
00000100000000545441010000001c000000010000000100010001000000010001050901
01000100000009010100

And here's what omniMapper daemon outputs:
omniORB: Server accepted connection from
giop:tcp:10.138.104.91:44786
omniORB: AsyncInvoker: thread id = 2 has started. Total threads
= 3
omniORB: Scavenger task execute.
omniORB: AsyncInvoker: thread id = 3 has started. Total threads
= 3
omniORB: giopWorker task execute.
omniORB: Accepted connection from giop:tcp:10.138.104.91:44786
because of this rule: "* unix,ssl,tcp"
omniORB: inputMessage: from giop:tcp:10.138.104.91:44786 118
bytes
omniORB:
4749 4f50 0100 0100 6a00 0000 0100 0000 GIOP....j.......
0100 0000 0c00 0000 0100 0000 0100 0100 ................
0901 0100 0100 0000 0100 0000 1400 0000 ................
496e 6342 6173 6553 6572 7669 6365 4f62 IncBaseServiceOb
6a4b 6579 0600 0000 5f69 735f 6100 0000 jKey...._is_a...
0000 0000 1e00 0000 4944 4c3a 496e 636f ........IDL:Inco
676e 6974 6f2f 4261 7365 5365 7276 6963 gnito/BaseServic
653a 312e 3000 e:1.0.
omniORB: Dispatching remote call '_is_a' to:
key<IncBaseServiceObjKey> (active)
Mapping `IncBaseServiceObjKey' to
IOR:010000001e00000049444c3a496e636f676e69746f2f42617365536572766963653a
312e30000000010000000000000064000000010102000e00000031302e3133382e313034
2e39310015dc0e000000feb16a0f48000053c50000000000000002000000000000000800
00000100000000545441010000001c000000010000000100010001000000010001050901
01000100000009010100
omniORB: Implementation of '_is_a' generated LOCATION_FORWARD.
omniORB: sendChunk: to giop:tcp:10.138.104.91:44786 172 bytes
omniORB:
4749 4f50 0100 0101 a000 0000 0000 0000 GIOP............
0100 0000 0300 0000 1e00 0000 4944 4c3a ............IDL:
496e 636f 676e 6974 6f2f 4261 7365 5365 Incognito/BaseSe
7276 6963 653a 312e 3000 0000 0100 0000 rvice:1.0.......
0000 0000 6400 0000 0101 0200 0e00 0000 ....d...........
3130 2e31 3338 2e31 3034 2e39 3100 15dc 10.138.104.91...
0e00 0000 feb1 6a0f 4800 0053 c500 0000 ......j.H..S....
0000 0000 0200 0000 0000 0000 0800 0000 ................
0100 0000 0054 5441 0100 0000 1c00 0000 .....TTA........
0100 0000 0100 0100 0100 0000 0100 0105 ................
0901 0100 0100 0000 0901 0100 ............
omniORB: Server connection refcount = 1
omniORB: Server connection refcount = 0
omniORB: Server close connection from
giop:tcp:10.138.104.91:44786









Solution two:
Use omniMapper to map the object names to
correct IOR's
Problem:
When client contacts the corbaloc URI,
omniMapper stays on some kind
of infinite loop with return LOCATION_FORWARD



Same problem imho, the location_forward is created
because of object_not_exist




I've tried your example Fischer, and some more
while googling, and they
all work.
Mine just seems to want to be left alone in the
corner :|

_______________________________________________
omniORB-list mailing list
omniORB-***@omniorb-support.com

http://www.omniorb-support.com/mailman/listinfo/omniorb-list








------------------------------------------------------------------------

_______________________________________________
omniORB-list mailing list
omniORB-***@omniorb-support.com
http://www.omniorb-support.com/mailman/listinfo/omniorb-list







-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20080424/f3c4f576/attachment-0001.htm
Fischer, Clemens
2008-04-25 15:26:28 UTC
Permalink
Hi, please ignore this last mail. It was hold back since yesterday by
the omniORB mailing list daemon due to too large size.



________________________________

Von: omniorb-list-***@omniorb-support.com
[mailto:omniorb-list-***@omniorb-support.com] Im Auftrag von
Fischer, Clemens
Gesendet: Donnerstag, 24. April 2008 17:40
An: Marco Ferreira; Michael
Cc: omniorb-***@omniorb-support.com
Betreff: AW: [omniORB] activate_object_with_id Returns None



Hi Marco,



take a closer look at activate_object_with_id.

The first parameter must be an object id string, the second one a
servant object (a python object).



Cheers

Clemens



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20080425/d6f16899/attachment.htm
Loading...