Discussion:
[omniORB] How to create a Persistance Corba server
Mahanta, Dhruba
2010-11-17 18:42:34 UTC
Permalink
Hi



Requirement: Corba server should be persistent so that even if the Corba
server application restarted, or the computer hosting Corba server is
rebooted, Corba Client application need not be reinitialized.



Server Side Implementation:



main()

{

CORBA::ORB_var objCorbaOrb;

objCorbaOrb = CORBA::ORB_init(argc, argv);

CORBA::Object_var obj =
objCorbaOrb->resolve_initial_references("omniINSPOA");

PortableServer::POA_var rootPOA =
PortableServer::POA::_narrow(obj);



CServerObj* pSvr = new CServerObj();

PortableServer::POAManager_var objPOAManager =
rootPOA->the_POAManager();

PortableServer::ObjectId_var myObjID =
PortableServer::string_to_ObjectId("IMC.context/Diagnostics.Object");

rootPOA->activate_object_with_id(myObjID, pSvr);

obj = rootPOA->servant_to_reference(pSvr);



if( !bindObjectToName(objCorbaOrb, obj) )

return 1;

CosNaming::NamingContext_var rootContext;



// Obtain a reference to the root context of the Name service:

CORBA::Object_var obj;

obj = objCorbaOrb->resolve_initial_references("NameService");

// Narrow the reference returned.

rootContext = CosNaming::NamingContext::_narrow(obj);



// Bind a context to the root context:

CosNaming::Name contextName;

contextName.length(1);

contextName[0].id = (const char*) "IMC"; // string copied

contextName[0].kind = (const char*) "context"; // string copied

CosNaming::NamingContext_var testContext;

// Bind the context to root.

testContext = rootContext->bind_new_context(contextName);



// Bind objref

CosNaming::Name objectName;

objectName.length(1);

objectName[0].id = (const char*) "Diagnostics"; // string
copied

objectName[0].kind = (const char*) "Object"; // string copied

testContext->bind(objectName, obj);



pSvr->_remove_ref();

objPOAManager->activate();

objCorbaOrb->run();

}





Client Side Implementation



main()

{



std::string szCorbaName = "corbaname::";

std::string szCorbaId =
":2809#IMC.context/Diagnostics.Object";



szCorbaName += szIPAddress;

szCorbaName += szCorbaId;



int nArg = 0;

m_objORB = CORBA::ORB_init(nArg, NULL);

CORBA::Object_var obj =
m_objORB->string_to_object(szCorbaName.c_str());

if( CORBA::is_nil(obj) )

{

return false;

}



m_objServerObj = IServerObj::_narrow(obj);



if( CORBA::is_nil(m_objServerObj) )

{

return false;

}

}





Problem:

When the client is freshly initialized the communication object
(m_objServerObj in the client code) there is no issue. But once server
goes down or rebooted, existing client object(m_objServerObj)

fails to invoke server calls for the first time, but if I try(somehow)
to make the invoke call for 2nd time on the same client object it
succeeds.



Can someone help me to figure out what could be the issue here.







Regards

Dhruba

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20101117/2971bfd7/attachment.htm
Duncan Grisby
2010-11-19 20:30:19 UTC
Permalink
Post by Mahanta, Dhruba
Requirement: Corba server should be persistent so that even if the
Corba server application restarted, or the computer hosting Corba
server is rebooted, Corba Client application need not be
reinitialized.
As well as using a persistent policy POA (which you are, by using the
omniINSPOA), you must pin down the port the server listens on.
Otherwise, the server will listen on a different port chosen by the OS
each time it starts. You need to give an endPoint parameter:

http://omniorb.sourceforge.net/omni41/omniORB/omniORB008.html#toc42

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Mahanta, Dhruba
2010-11-20 12:28:43 UTC
Permalink
Hi Duncan

Thanks for your quick response. As you suggested, I do that to specify the IP and Port while initializing as below:

CORBA::ORB_var objCorbaOrb;
string strIP, strPort;

GetIPPort(strIP, strPort);
string strConfiguredIP_Port = "giop:tcp:" + strIP + ":" + strPort;
const char* options[][2] = { { "endPoint", strConfiguredIP_Port.c_str() }, { 0, 0 } };

objCorbaOrb = CORBA::ORB_init(argc, argv, "omniORB4", options);

I did not mention the above part in my early code snip shot in order to keep it short.

But still it did not worked as expected. Please help to figure out the issue.


Regards
Dhruba

-----Original Message-----
From: Duncan Grisby [mailto:***@grisby.org]
Sent: Friday, November 19, 2010 8:00 PM
To: Mahanta, Dhruba
Cc: omniORB-***@omniorb-support.com
Subject: Re: [omniORB] How to create a Persistance Corba server
Post by Mahanta, Dhruba
Requirement: Corba server should be persistent so that even if the
Corba server application restarted, or the computer hosting Corba
server is rebooted, Corba Client application need not be
reinitialized.
As well as using a persistent policy POA (which you are, by using the
omniINSPOA), you must pin down the port the server listens on.
Otherwise, the server will listen on a different port chosen by the OS
each time it starts. You need to give an endPoint parameter:

http://omniorb.sourceforge.net/omni41/omniORB/omniORB008.html#toc42

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Duncan Grisby
2010-11-24 22:23:36 UTC
Permalink
[...]
Post by Mahanta, Dhruba
But still it did not worked as expected. Please help to figure out the issue.
Please get a trace from the client with these options:

-ORBtraceLevel 25 -ORBtraceInvocations 1 -ORBtraceInvocationReturns 1
-ORBtraceThreadId 1 -ORBtraceTime 1

That will show what's going on and should give some clues to the
problem.

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Mahanta, Dhruba
2010-11-23 21:46:06 UTC
Permalink
Hi Duncan

Can I have some guidance to find the root cause?
Otherwise, can you suggest some example code where I can refer.

Regards
Dhruba

-----Original Message-----
From: Mahanta, Dhruba
Sent: Saturday, November 20, 2010 11:58 AM
To: 'Duncan Grisby'
Cc: omniORB-***@omniorb-support.com
Subject: RE: [omniORB] How to create a Persistance Corba server

Hi Duncan

Thanks for your quick response. As you suggested, I do that to specify the IP and Port while initializing as below:

CORBA::ORB_var objCorbaOrb;
string strIP, strPort;

GetIPPort(strIP, strPort);
string strConfiguredIP_Port = "giop:tcp:" + strIP + ":" + strPort;
const char* options[][2] = { { "endPoint", strConfiguredIP_Port.c_str() }, { 0, 0 } };

objCorbaOrb = CORBA::ORB_init(argc, argv, "omniORB4", options);

I did not mention the above part in my early code snip shot in order to keep it short.

But still it did not worked as expected. Please help to figure out the issue.


Regards
Dhruba

-----Original Message-----
From: Duncan Grisby [mailto:***@grisby.org]
Sent: Friday, November 19, 2010 8:00 PM
To: Mahanta, Dhruba
Cc: omniORB-***@omniorb-support.com
Subject: Re: [omniORB] How to create a Persistance Corba server
Post by Mahanta, Dhruba
Requirement: Corba server should be persistent so that even if the
Corba server application restarted, or the computer hosting Corba
server is rebooted, Corba Client application need not be
reinitialized.
As well as using a persistent policy POA (which you are, by using the
omniINSPOA), you must pin down the port the server listens on.
Otherwise, the server will listen on a different port chosen by the OS
each time it starts. You need to give an endPoint parameter:

http://omniorb.sourceforge.net/omni41/omniORB/omniORB008.html#toc42

Cheers,

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