Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 07-07-2007
bwvb bwvb is offline
Registered User
 
Name: Bertwim van Beest
Organization: myself
Project: Concurrent processing of images
 
Join Date: Jul 2007
Posts: 8
IceGrid sessions, Glacier2 and factory objects?

Working with Glacier2 is still puzzling me. Any help is greatly appreciated.
As a variation on the IceGrid/"sayHello()" example, I extended the Demo module with a "HelloFactory":
Quote:
module Demo
{
interface Hello {
["cpp:const"] idempotent string sayHello();
void shutdown();
};
interface HelloFactory {
["cpp:const"] Hello* createHello( string name );
};
};
On the server side, I created a Hello object and a HelloFactory object, which I both made available as allocatable to the icegrid session. So there are two ways to say hello: either via a call "sayHello()" directly on the allocated "Hello" object, or via a call to a freshly created Hello object from the allocated factory.

Here comes my problem:
Without using the Glacier2 router, both ways work as expected. However, with the Glacier2 router in place, the sayHello() call directly on the allocated Hello object still works, but the alternative via the factory yields an exception:
Quote:
Outgoing.cpp:388: Ice::ObjectNotExistException:
object does not exist:
identity: `CCBF3961-B714-47D1-88AA-808A2DD75BFC'
facet:
operation: sayHello
What am I doing wrong?
Below follow some details

On the client, a session is obtained via
Quote:
if(communicator()->getDefaultRouter())
{
Ice::RouterPrx defaultRouter = communicator()->getDefaultRouter();
_router = Glacier2::RouterPrx::checkedCast(defaultRouter);
_session = IceGrid::SessionPrx::checkedCast(_router->createSession( "foo", "bar" ));
}
else
{
IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast(
communicator()->stringToProxy("DemoIceGrid/Registry"));
_session = registry->createSession( "foo", "bar" );
}
where the branch is selected by setting either
Quote:
Ice.Default.Router=Allocate.Glacier2/router:tcp -p 12001
(use glacier2: only works partially) or
Quote:
Ice.Default.Locator=DemoIceGrid/Locator:default -p 12000
(no glacier2: ok!) in the client configuration file.
Also on the client, I select between the direct approach and the factory using a boolean "withFactory":
Quote:
HelloPrx hello;

if (withFactory)
{
HelloFactoryPrx hf = HelloFactoryPrx::checkedCast(_session->allocateObjectByType(":emo::HelloFactory"));
hello = hf->createHello( "<foo>" );
}
else
{
hello = HelloPrx::checkedCast(_session->allocateObjectByType(":emo::Hello"));
}

hello->sayHello();
Finally,
The server side implementation looks like:
Quote:
int Server::run(int, char* [])
{
Ice::PropertiesPtr properties = communicator()->getProperties();
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Hello");

std::string srvId = properties->getProperty("Ice.ServerId");
Ice::Identity id = communicator()->stringToIdentity(properties->getProperty("Identity"));
adapter->add( new HelloI( srvId ), id );

id = communicator()->stringToIdentity(properties->getProperty("Identity2"));
adapter->add( new HelloFactoryI, id );

adapter->activate();
communicator()->waitForShutdown();
return EXIT_SUCCESS;
}
The descriptor file reads:
Quote:
<icegrid>
<application name="Allocate">
<server-template id="AllocateServer">
<parameter name="index"/>
<server id="AllocateServer-${index}" exe="/home/bertwim/develop/gapps/Linux-2.6/benoitS" activation="on-demand">
<adapter name="Hello" endpoints="tcp" register-process="true">
<allocatable identity="hello-${index}" type=":emo::Hello" property="Identity"/>
<allocatable identity="hf-${index}" type=":emo::HelloFactory" property="Identity2"/>
</adapter>
</server>
</server-template>
<server-template id="Glacier2">
<parameter name="instance-name" default="${application}.Glacier2"/>
<parameter name="client-endpoints"/>
<parameter name="server-endpoints"/>
<parameter name="session-timeout" default="30"/>
<server id="${instance-name}" exe="glacier2router" activation="always">
<properties>
<property name="Glacier2.Client.Endpoints" value="${client-endpoints}"/>
<property name="Glacier2.Server.Endpoints" value="${server-endpoints}"/>
<property name="Glacier2.Admin.Endpoints" value="tcp -h 127.0.0.1"/>
<property name="Glacier2.Admin.RegisterProcess" value="1"/>
<property name="Glacier2.InstanceName" value="${instance-name}"/>
<property name="Glacier2.SessionTimeout" value="${session-timeout}"/>
<property name="Glacier2.PermissionsVerifier" value="${instance-name}/NullPermissionsVerifier"/>
<property name="Glacier2.SessionManager" value="DemoIceGrid/SessionManager"/>
</properties>
</server>
</server-template>
<node name="localhost">
<server-instance template="AllocateServer" index="1"/>
<server-instance template="AllocateServer" index="2"/>
<server-instance template="Glacier2" client-endpoints="tcp -p 12001" server-endpoints="tcp"/>
</node>
</application>
</icegrid>
Reply With Quote
  #2 (permalink)  
Old 07-07-2007
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,088
I suspect what is going on is the Glacier2 filtering rules are kicking in and denying access to the factory created hello object. To fix this issue you need to add the identity of the allocated object to the Glacier2 identity filter. You can see the Ice manual for full details on this. I also recommend you read my article "Custom Sessions and IceGrid" in issue 19 of the Connections newsletter for an example.
Reply With Quote
  #3 (permalink)  
Old 07-09-2007
benoit's Avatar
benoit benoit is offline
ZeroC Staff
 
Name: Benoit Foucher
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Rennes, France
Posts: 1,564
As Matthew pointed out, the problem is most likely that Glacier2 filtering only allows invocations on allocated objects (see 38.14.3 Allocating Servers and Objects).

To allow your client to access objects created by the factory, you can interpose a session like described by Matthew's article from the Connections newsletter issue #19. This interposed session will allow you to disable the default filtering or to add your own filtering.

Another option is to mark the server as allocatable by adding allocatable="true" to the XML server element. With this attribute set, the allocation of the factory object will cause the allocation of the server and will alter the Glacier2 filtering to allow invocations on the objects from the "Hello" object adapter of the allocated server.

Cheers,
Benoit.
Reply With Quote
  #4 (permalink)  
Old 07-09-2007
bwvb bwvb is offline
Registered User
 
Name: Bertwim van Beest
Organization: myself
Project: Concurrent processing of images
 
Join Date: Jul 2007
Posts: 8
The allocatable="true" hint you gave worked.
Thanks.
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
IceGrid sessions mwilson Help Center 1 03-19-2007 04:14 PM
Multiple objects with IceGrid lucsat Help Center 3 01-16-2007 12:35 PM
Glacier2, IceGrid, and Load Balancing seth Help Center 15 11-06-2006 12:03 PM
Glacier2 multiple sessions per user xdm Help Center 9 02-08-2006 04:58 PM
Destroying sessions with Glacier2 Wayetender Help Center 1 07-31-2005 06:40 PM


All times are GMT -4. The time now is 11:54 PM.


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