Archived
This forum has been archived. Please start a new discussion on GitHub.
AdapterIds and Indirect proxies, and IcePack's Locator service
Hey Ice guys,
I wonder if you could clarify a couple of things I am struggling with?
When I create an adapter that will manage indirect proxies with either:
What I've gathered from posts and the manual is that the Ice runtime goes searching through the config file for a "name.AdapterId" property (and the "name.Endpoints" in the case of the second call). If it finds the AdapterId property it automatically registers the ObjectAdapter with the IcePack Locator service? In addition, if it finds this property the ObjectAdapter will now implictly create indirect proxies.
Are those proxies, always fully specified as an ObjectID@AdapterID proxy type? Assuming this is the case, is it correct that a client call (on this proxy) calls the Locator service and first attempts to find an endpoint with the Object identity in its registry then if this fails attempts to find the endpoint with the Object Adapter identity?
Also, am I reading it correctly that to do this programmatically (and thus avoid having the AdapterId in the config file) that I can call myAdapter->setLocator(communicator->getLocator()) before activating the myAdapter? If this is not the case is there another way to programmatically make an ObjectAdapter add itself to the Locator service?
Regards,
Ryan
I wonder if you could clarify a couple of things I am struggling with?
When I create an adapter that will manage indirect proxies with either:
communicator->createObjectAdapterWithEndpoints("name",endpoint); // this communicator->createObjectAdapter("name"); // or this
What I've gathered from posts and the manual is that the Ice runtime goes searching through the config file for a "name.AdapterId" property (and the "name.Endpoints" in the case of the second call). If it finds the AdapterId property it automatically registers the ObjectAdapter with the IcePack Locator service? In addition, if it finds this property the ObjectAdapter will now implictly create indirect proxies.
Are those proxies, always fully specified as an ObjectID@AdapterID proxy type? Assuming this is the case, is it correct that a client call (on this proxy) calls the Locator service and first attempts to find an endpoint with the Object identity in its registry then if this fails attempts to find the endpoint with the Object Adapter identity?
Also, am I reading it correctly that to do this programmatically (and thus avoid having the AdapterId in the config file) that I can call myAdapter->setLocator(communicator->getLocator()) before activating the myAdapter? If this is not the case is there another way to programmatically make an ObjectAdapter add itself to the Locator service?
Regards,
Ryan
0
Comments
-
RyanFogarty wrote:What I've gathered from posts and the manual is that the Ice runtime goes searching through the config file for a "name.AdapterId" property (and the "name.Endpoints" in the case of the second call). If it finds the AdapterId property it automatically registers the ObjectAdapter with the IcePack Locator service? In addition, if it finds this property the ObjectAdapter will now implictly create indirect proxies.
Correct, the object adapter endpoints will be registered with the Locator service when the object adapter is activated the first time.RyanFogarty wrote:Are those proxies, always fully specified as an ObjectID@AdapterID proxy type?
Yes.RyanFogarty wrote:Assuming this is the case, is it correct that a client call (on this proxy) calls the Locator service and first attempts to find an endpoint with the Object identity in its registry then if this fails attempts to find the endpoint with the Object Adapter identity?
No, that's not really correct. When a client invokes on an indirect proxy and there's no underlying connection already established, the Ice runtime will try to resolve the endpoints of the indirect proxy:- If the proxy is an "ObjectId@AdapterId" proxy, then the Ice runtime will call the locator service to retrieve the endpoints of the object adapter with the id "AdapterId". If "AdapterId" isn't known to the locator service, the invocation will raise "Ice::NotRegisteredException". Otherwise, if "AdapterId" is known to the locator, the locator service returned the endpoints and Ice attempts to establish the connection to these endpoints.
- If the proxy is an "ObjectId" proxy, the Ice runtime will call the locator service to retrieve the endpoints associated to the identity "ObjectId". If "ObjectId" isn't known to the locator service, the invocation will raise "Ice::NotRegisteredException". Otherwise, if "ObjectId" is know to the locator, the locator service returned the endpoints and Ice attempts to establish the connection to these endpoints.
RyanFogarty wrote:Also, am I reading it correctly that to do this programmatically (and thus avoid having the AdapterId in the config file) that I can call myAdapter->setLocator(communicator->getLocator()) before activating the myAdapter? If this is not the case is there another way to programmatically make an ObjectAdapter add itself to the Locator service?
No, calling setLocator on your object adapter will just inform the object adapter that it should use a specific locator to eventually register its endpoints. If you want to set the AdapterId programatically, you need to set the properties before creating the object adapter:Ice::PropertiesPtr properties = communicator->getProperties(); properties->setProperty("name.AdapterId", "AdapterId"); properties->setProperty("name.Endpoints", "default"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("name");
Hope this helps!
Benoit.0 - If the proxy is an "ObjectId@AdapterId" proxy, then the Ice runtime will call the locator service to retrieve the endpoints of the object adapter with the id "AdapterId". If "AdapterId" isn't known to the locator service, the invocation will raise "Ice::NotRegisteredException". Otherwise, if "AdapterId" is known to the locator, the locator service returned the endpoints and Ice attempts to establish the connection to these endpoints.
-
-
If the proxy is an "ObjectId@AdapterId" proxy, then the Ice runtime will call the locator service to retrieve the endpoints of the object adapter with the id "AdapterId". If "AdapterId" isn't known to the locator service, the invocation will raise "Ice::NotRegisteredException". Otherwise, if "AdapterId" is known to the locator, the locator service returned the endpoints and Ice attempts to establish the connection to these endpoints.
-
If the proxy is an "ObjectId" proxy, the Ice runtime will call the locator service to retrieve the endpoints associated to the identity "ObjectId". If "ObjectId" isn't known to the locator service, the invocation will raise "Ice::NotRegisteredException". Otherwise, if "ObjectId" is know to the locator, the locator service returned the endpoints and Ice attempts to establish the connection to these endpoints.
No, calling setLocator on your object adapter will just inform the object adapter that it should use a specific locator to eventually register its endpoints. If you want to set the AdapterId programatically, you need to set the properties before creating the object adapter:
Thanks a bunch,
Ryan0 -
Can you set the adapter id via setProperty after the communicator is initialized?
I had the same question about setting up an adapter to register itself with IcePack, without needing an entry in the properties file. The solution mentioned below grabs the PropertiesPtr from the communicator, adds the adapter info (id and endpoints) to the properties object, then asks the communicator to create the adapter. Sounds good so far.
Except that in section 27.8.2 of the manual, it says that you can't be guaranteed that any properties set after the communicator has been initialized will be noticed by the communicator. It then suggests that I get the properties before the communicator is initialied (using getDefaultProperties) and then initializing the communicator with them. That's quite a bit clunkier than the solution suggested in this thread, and I'd rather do it the way suggested.
actually, what I'd rather do is call a non-existent function:
communicator->createObjectAdapterWithEverything(name, id, endpoints)0 -
Hi Clay,
It is perfectly acceptable to set the AdapterId property just prior to calling createObjectAdapter (or createObjectAdapterWithEndpoints). The text you mentioned in section 27.8.2 is really referring to properties that the communicator checks once during initialization (such as tracing, plugins, etc.) and never checks again.
Take care,
- Mark0 -
Re: Can you set the adapter id via setProperty after the communicator is initialized?
Hi Mark,
I have a similar problem to Clay's. I'd like to programatically set the location of IcePack before registering an adapter. I read Section 27.8.2 of the manual, but I can't do what is suggested there (the getDefaultProperties trick) because I'm trying to write an IceBox service and therefore can't write any code that will be executed before the communicator is initialized.
I understood from your post that I could just set the properties I need despite what it says in Section 27.8.2 of the manual, but it doesn't seem to work.
My code looks like this:
// set property
Ice::PropertiesPtr properties = communicator->getProperties();
properties->setProperty( "Ice.Default.Locator", "<location>" )
// [ ... ]
// create the adapter
adapter = communicator->createObjectAdapter(adapterName);
But the property doesn't seem to get read, and the adapter doesn't register with IcePack. Any ideas what's happening?
Thanks in advance.0 -
The Ice.Default.Locator property is a communicator property. The communicator reads it when it's initialized to set its default locator proxy. You can get this proxy using the Ice::Communicator::getDefaultLocator() method. And you can also set it explicitly with the Ice::Communicator::setDefaultLocator() method.
If you want your object adapter to use another locator than the communicator default locator proxy, you have the following option:- Set the <name>.Locator property (where <name> if the name of your object adapter) before creating the object adapter.
- Change the object adapter locator after its creation with the Ice::ObjectAdapter::setLocator() method.
Benoit.0 - Set the <name>.Locator property (where <name> if the name of your object adapter) before creating the object adapter.
-
Benoit,
Thanks, this did the trick!
I implemented the first option (setting the <name>.Locator property).
For some reason this wouldn't work until I also set Ice.Default.Locator to the same value. Not sure why.0