Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 03-05-2008
drumnbass drumnbass is offline
Registered User
 
Name: Seungki Min
Organization: Samsung electronics
Project: Robotics
 
Join Date: Mar 2008
Posts: 2
invocation between two services in the IceBox

Hi~

I have two services in the IceBox.
One service try to invoke a function of another service for collocation optimization.

suppose service's name is Print1 and Print2 respectively.

and I set the properties in the IceBox configuration file.

IceBox.UseSharedCommunicator.Print1=1
IceBox.UseSharedCommunicator.Print2=1

IceBox runs on single machine.

This is my code...

void
demo:rint1MessageI:rint1(const Ice::Current& current)
{

Ice::ObjectAdapterPtr objptr = current.adapter;

Ice::CommunicatorPtr ic = objptr->getCommunicator();

print2MessagePrx prx = print2MessagePrx::checkedCast(ic->stringToProxy("print2:tcp -p 9997")); /* always recieved null proxy. */

if(!prx){
std::cout << "invalid proxy..." << std::endl;
return;
}

std::cout << "this is message from Print1..." << std::endl;
prx->print2();
}

Whenever I am trying to get proxy for print2, I recieved null proxy.

But when I invoked print2 outside the IceBox with client I made, It works well.

Do I have some mistakes in my idea?
Reply With Quote
  #2 (permalink)  
Old 03-05-2008
matthew's Avatar
matthew matthew is online now
ZeroC Staff
 
Name: Matthew Newhook
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Feb 2003
Location: NL, Canada
Posts: 1,061
I'm afraid that the information you have provided is insufficient to debug your issue. However, I just modified the IceBox Ice demo to replicate your situation and it works as expected.

I've attached the modified demo to this post so you can see what I did in my test.

To ensure that the invocation uses collocation optimization I broke the call in a debugger. As expected with a shared communicator I see:

Code:
(gdb) where
#0  HelloI::sayHello (this=0x510f00) at HelloI.cpp:27
#1  0x000b444e in IceDelegateD::Demo::Hello::sayHello (this=0x511a20, __context=0x0) at Hello.cpp:458
#2  0x000b2779 in IceProxy::Demo::Hello::sayHello (this=0x5119b0, __ctx=0x0) at Hello.cpp:279
#3  0x000bb515 in IceProxy::Demo::Hello::sayHello (this=0x5119b0) at Hello.h:180
#4  0x000bb345 in HelloForwardI::forward (this=0x5100e0, c=@0xb018498c) at HelloI.cpp:21
#5  0x000b1dd1 in Demo::HelloForward::___forward (this=0x5100e0, __current=@0xb018498c) at Hello.cpp:516
#6  0x000b342d in Demo::HelloForward::__dispatch (this=0x5100e0, in=@0xb018498c, current=@0xb018498c) at Hello.cpp:542
#7  0x0029ae58 in IceInternal::Incoming::invoke ()
#8  0x002631b7 in Ice::ConnectionI::invokeAll ()
#9  0x0026b24b in Ice::ConnectionI::message ()
#10 0x003576bc in IceInternal::ThreadPool::run ()
#11 0x00358cbd in IceInternal::ThreadPool::EventHandlerThread::run ()
That is the call from the HelloForward to the Hello object avoids the network invocation. Without the shared communicator the call goes over the network as expected:

Code:
(gdb) where
#0  HelloI::sayHello (this=0x50d8a0) at HelloI.cpp:27
#1  0x000b2221 in Demo::Hello::___sayHello (this=0x50d8a0, __current=@0xb038c98c) at Hello.cpp:704
#2  0x000b3343 in Demo::Hello::__dispatch (this=0x50d8a0, in=@0xb038c98c, current=@0xb038c98c) at Hello.cpp:746
#3  0x0029ae58 in IceInternal::Incoming::invoke ()
#4  0x002631b7 in Ice::ConnectionI::invokeAll ()
#5  0x0026b24b in Ice::ConnectionI::message ()
#6  0x003576bc in IceInternal::ThreadPool::run ()
#7  0x00358cbd in IceInternal::ThreadPool::EventHandlerThread::run ()
Attached Files
File Type: gz multi.tar.gz (6.2 KB, 10 views)
Reply With Quote
  #3 (permalink)  
Old 03-05-2008
drumnbass drumnbass is offline
Registered User
 
Name: Seungki Min
Organization: Samsung electronics
Project: Robotics
 
Join Date: Mar 2008
Posts: 2
Smile Thanks But...

Thanks Metthew

I saw your code, there is much different implementations rather than I made.

my properties in config.icebox

IceBox.Service.Print=print1Service:create --Ice.Config=config.print1
IceBox.Service.Print2=print2Service:create --Ice.Config=config.print2

As you can see, I have made two different so files libprint1Service.so, libprint2Service.so respectively.

my point is invocations between functions in separated so file under collocation optimization.

This is very very important point in our project.

start() function in print1ServiceI.cpp file is

void print1ServiceI::start(const std::string& name, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq& args)
{
_adapter = communicator->createObjectAdapter(name); /* name is Print1 */
_adapter->add(new demo:rint1MessageI, communicator->stringToIdentity("print1"));
_adapter->activate();
}

start() function in print2ServiceI file is

void print2ServiceI::start(const std::string& name, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq& args)
{
_adapter = communicator->createObjectAdapter(name); /* name is Print2 */
_adapter->add(new demo2:rint2MessageI, communicator->stringToIdentity("print2"));
_adapter->activate();
}

<print1I.cpp is>

void
demorint1MessageIrint1(const Ice::Current& current)
{
Ice::ObjectAdapterPtr objptr = current.adapter;
Ice::CommunicatorPtr ic = objptr->getCommunicator();

print2MessagePrx prx = print2MessagePrx::checkedCast(ic->stringToProxy("print2:tcp -p 9997")); /* always recieved null proxy. */

if(!prx){
std::cout << "invalid proxy..." << std::endl;
return;
}

std::cout << "this is message from Print1..." << std::endl;
prx->print2();
}

<print2I.cpp is>

void
demo2:rint2MessageI:rint2(const Ice::Current& current)
{
std::cout << "This is message from print2..." << std::endl;
}

print1.ice is

module demo {
interface print1Message{
void print1();
};
};

print2.ice is

module demo2 {
interface print2Message{
void print2();
};
};

I thought services(which are contained different so file) in an IceBox have a diffrent object adapter each other, and these object adapters could share the same communicator with UseSharedCommunicator property.

Am I wrong?

in your start() funtion in HelloServiceI.cpp has created one object adapter and registered HelloForwardI servant and HelloI sevant on same object adapter. finally you made two service within one

suppose some situations....

If I got a service from someone with binary so file and I loaded this so file in my IceBox, I'd like to invoke a function in this service with my service under collocation optimization environment.
is it impossible?

sorry for my poor english..
Reply With Quote
  #4 (permalink)  
Old 03-05-2008
matthew's Avatar
matthew matthew is online now
ZeroC Staff
 
Name: Matthew Newhook
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Feb 2003
Location: NL, Canada
Posts: 1,061
Quote:
I thought services(which are contained different so file) in an IceBox have a diffrent object adapter each other, and these object adapters could share the same communicator with UseSharedCommunicator property.

Am I wrong?

in your start() funtion in HelloServiceI.cpp has created one object adapter and registered HelloForwardI servant and HelloI sevant on same object adapter. finally you made two service within one

suppose some situations....

If I got a service from someone with binary so file and I loaded this so file in my IceBox, I'd like to invoke a function in this service with my service under collocation optimization environment.
is it impossible?
I think the situation should be the same.

Using one service DLL that is loaded twice versus loading two service DLLs should not be relevant.

My example actually does create two object adapters each with a unique name (one is named Hello and the other HelloForward).

The same object being registered with both also should not matter in this case.

You can try this for yourself by changing the code:

Code:
void
HelloServiceI::start(const string& name, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq& args)
{
    _adapter = communicator->createObjectAdapter(name);
    if(name == "HelloForward")
    {
        _adapter->add(new HelloForwardI, communicator->stringToIdentity("helloforward"));
    }
    else
    {
        _adapter->add(new HelloI, communicator->stringToIdentity("hello"));
    }
    _adapter->activate();
}
If you do that you'll need to fix the config.client (change the port from 10000 to 11000), and also fix HelloI.cpp (change 10000 to 11000).

The quickest way to sort this issue out is for you to reply with a complete, self contained compilable example that demonstrates this issue. Also can you confirm your operating system, compiler and Ice version please?

Best Regards, Matthew
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Does IceBox support services implemented in python zephyr007 Comments 3 01-23-2008 09:22 AM
IceBox Determining Dependent Services Sameerrele Help Center 2 09-25-2006 01:59 PM
IceBox hosting java services in IceGrid Sameerrele Help Center 5 08-21-2006 11:56 AM
Purify and IceBox services xdm Help Center 4 06-07-2006 04:59 PM
Share endpoint between services in IceBox rspivak Help Center 2 04-14-2006 07:18 AM


All times are GMT -4. The time now is 10:41 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.