Discussion:
[omniORB] omniOrbPy: any way to actively talk to two different servers on different hosts from a single python script?
wtflanders at micron.com ()
2007-04-19 03:35:41 UTC
Permalink
Skipped content of type multipart/alternative-------------- next part --------------
A non-text attachment was scrubbed...
Name: host_example_echo_nsclt.py
Type: application/octet-stream
Size: 1849 bytes
Desc: host_example_echo_nsclt.py
Url : http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20070418/5f2ad53b/host_example_echo_nsclt-0001.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: host_example_echo_nssrv.py
Type: application/octet-stream
Size: 2397 bytes
Desc: host_example_echo_nssrv.py
Url : http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20070418/5f2ad53b/host_example_echo_nssrv-0001.obj
Thomas Lockhart
2007-04-19 03:55:46 UTC
Permalink
... It doesn't work, it only talks to the echo server on the first host.
It appears the ORB in the client is static and can only talk to one
naming service host.
Static or not, the initial reference to the naming service is determined
just once. Why do you want two different naming services? You have two
servers, and you have a client which wants to talk to both servers.
Sounds to me like this calls for just one naming service with two
different entries. Have the servers register with the same naming
service and have the client look to the same naming service for both
servers and you will be happy.

Alternatively, you can contact the naming services without using the
initial reference feature and then access both naming services as you
want. But I still wonder why you would want to...

hth

- Tom
Duncan Grisby
2007-04-19 04:44:21 UTC
Permalink
The attached example modifies the echo ns samples. The client is made
into a class that accepts the system name where the echo server is
running. I then invoke two instances of the client to two different
host naming services each with the echo ns srv running on it. I
modified the echo ns srv sample to return the host name with the echoed
message. I also modified the client to accept two different host name
on the command line.
It doesn't work, it only talks to the echo server on the first host. It
appears the ORB in the client is static and can only talk to one naming
service host.
The ORB is a singleton. It is only initialised once, so you can only
give it one set of initial references.

However, there is absolutely nothing special about the initial
references, or the naming service. If you want to access multiple naming
services, just access them. There's no need to register them as initial
references. As Tom says, you quite possibly shouldn't use more than one
naming service, but if you want or need to, there's nothing stopping
you.

You can just use code like this:

orb = CORBA.ORB_init(sys.argv)

hosts = [ "host1", "host2", "host3" ]

for host in hosts:
obj = orb.string_to_object("corbaloc::%s:2809/NameService" % host)
ns = obj._narrow(CosNaming.NamingContextExt)

if ns is None:
# skip it
continue

echo = ns.resolve_str("test.mycontext/ExampleEcho.Object")
echo = echo._narrow(Example.Echo)

if echo is not None:
print echo.echoString("Hello " + host)


I've missed out the exception handling for clarity, but you should get
the idea. Not a call to resolve_initial_references in sight.

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
wtflanders at micron.com ()
2007-04-19 20:15:48 UTC
Permalink
Works Great!
I new there had to be a way.
Thanks,
Bill

-----Original Message-----
From: Duncan Grisby [mailto:***@grisby.org]
Sent: Wednesday, April 18, 2007 4:45 PM
To: wtflanders
Cc: omniorb-***@omniorb-support.com
Subject: Re: [omniORB] omniOrbPy: any way to actively talk to two
different servers on different hosts from a single python script?
The attached example modifies the echo ns samples. The client is made
into a class that accepts the system name where the echo server is
running. I then invoke two instances of the client to two different
host naming services each with the echo ns srv running on it. I
modified the echo ns srv sample to return the host name with the echoed
message. I also modified the client to accept two different host name
on the command line.
It doesn't work, it only talks to the echo server on the first host.
It
appears the ORB in the client is static and can only talk to one naming
service host.
The ORB is a singleton. It is only initialised once, so you can only
give it one set of initial references.

However, there is absolutely nothing special about the initial
references, or the naming service. If you want to access multiple naming
services, just access them. There's no need to register them as initial
references. As Tom says, you quite possibly shouldn't use more than one
naming service, but if you want or need to, there's nothing stopping
you.

You can just use code like this:

orb = CORBA.ORB_init(sys.argv)

hosts = [ "host1", "host2", "host3" ]

for host in hosts:
obj = orb.string_to_object("corbaloc::%s:2809/NameService" %
host)
ns = obj._narrow(CosNaming.NamingContextExt)

if ns is None:
# skip it
continue

echo = ns.resolve_str("test.mycontext/ExampleEcho.Object")
echo = echo._narrow(Example.Echo)

if echo is not None:
print echo.echoString("Hello " + host)


I've missed out the exception handling for clarity, but you should get
the idea. Not a call to resolve_initial_references in sight.

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Loading...