Archived

This forum has been archived. Please start a new discussion on GitHub.

Ice.Default.Locator

xdm
xdm La Coruña, Spain
Is correct to changue the Ice.Default.Locator ant run time int this way
communicator()->getProperties()->setProperty(
   "Ice.Default.Locator",
   "IcePack/Locator:default -h www.myserver.com -p 9090);

thanks

Comments

  • dwayne
    dwayne St. John's, Newfoundland
    Hi,

    Setting the "Ice.Default.Locator" property programatically as you have done will only affect the default locator setting for communicators you create after setting the property, it will not affect any communicators which have already been created.

    If you want to change the default locator for an already exisiting communicator you would need to do something like the following.
    LocatorPrx locator = LocatorPrx::uncheckedCast(communicator->stringToProxy("IcePack/Locator:default -h www.myserver.com -p 9090"));
    communicator->setDefaultLocator(locator);
    

    Regards,
    Dwayne
  • xdm
    xdm La Coruña, Spain
    Hello dwayne thanks for your quick replay


    i have a problem

    1) I create a communicator with no default locator

    2) I create a proxy to locator object and setDefaultLocator in my communicator

    3) I create a proxy to IcePack::Query with ic->stringToProxy("IcePack/Query");

    this steps seems to work ok

    but if i create a proxy to and invalid locator and call ic->setDefaultLocator(Locator) and then call ic->stringToProxy("IcePack/Query");

    i receive a valid IcePack/Query

    whit invalid locator proxy i refer to a proxy create with stringToProxy to a wrong ip or port

    if this the expected behavior in ice when create a proxy using stringToProxy ? if yes what is the correct way to recreate and allredy created proxy

    thanks again and sorry for my poor english
  • matthew
    matthew NL, Canada
    xdm wrote:
    Hello dwayne thanks for your quick replay


    i have a problem

    1) I create a communicator with no default locator

    2) I create a proxy to locator object and setDefaultLocator in my communicator

    3) I create a proxy to IcePack::Query with ic->stringToProxy("IcePack/Query");

    this steps seems to work ok

    but if i create a proxy to and invalid locator and call ic->setDefaultLocator(Locator) and then call ic->stringToProxy("IcePack/Query");

    i receive a valid IcePack/Query

    whit invalid locator proxy i refer to a proxy create with stringToProxy to a wrong ip or port

    if this the expected behavior in ice when create a proxy using stringToProxy ? if yes what is the correct way to recreate and allredy created proxy

    thanks again and sorry for my poor english

    Sorry, I don't understand what you are trying to do. Perhaps if you provided the code that does not work we could tell if this is the expected behaviour.

    Regards, Matthew
  • xdm
    xdm La Coruña, Spain
    Hello

    what i trying to do is that my client app conncect to a new IcePack server and get a new proxy to ChatServer/ChatServer in the new IcePack

    I have multiple ChatServers but in diferenct IcePack deplyoment ChatServer service is allways register whit ChatServer/ChatServer identity

    when a clien want to connecto to other ChatServer he pass hostName and portNumber to connectToServer that is sow in next lines
    void ChatClientView::connectToServer(QString hostName,QString portNumber)
    {
    	try
    	{
    		emit writeToStatus("try connect to server: "+hostName+" port: "+portNumber);
    		Ice::Identity chatServerId=Ice::stringToIdentity("ChatServer/ChatServer");
    
    		Ice::LocatorPrx locator;
    		locator = Ice::LocatorPrx::uncheckedCast(
    		ic->stringToProxy("IcePack/Locator -t:tcp -h "+hostName+" -p "+portNumber));
    		ic->setDefaultLocator(locator);
    		emit writeToStatus("Ice.Default.Locator set OK");
    		IcePack::QueryPrx queryPx=IcePack::QueryPrx::checkedCast(
    			ic->stringToProxy("IcePack/Query"));
    		emit writeToStatus("IcePackQueryPrx retrieve OK");
    		emit writeToStatus("from default locator proxy: " + 
                      ic->proxyToString(ic->getDefaultLocator()));
    
    		server=Oz::Chat::ChatServerPrx::uncheckedCast(
    			queryPx->findObjectById(chatServerId));
    
    		emit writeToStatus("connecting ok to server: " + 
                     hostName + " port: " + portNumber);
    	}
    	catch(...)
    	{
    
    	}
    }
    


    It seems like when i create a proxy calling communicator().->stringToProxy sunsequents attempts to create the same string proxy return the the first created proxy and stringToProxy is not aware of setDefaultLocator changes.

    is this the expected behaviour?

    how can i force communicator()->stringToProxy to recreate this proxys whit the new default locator.

    thanks
  • benoit
    benoit Rennes, France
    Hi,

    Proxies created after changing the default locator should be associated to this new locator (proxies created before will still be associated to the previous default locator).

    It's still not quite clear to me what is not working. What exactly is failing and how do you figure out that the proxy returned after chaging the default locator is the same as the previous one?

    Could you perhaps send us a small compilable example that demonstrates the problem? Please, also tell us which Ice version and operating system you're using. Thanks!

    Benoit.
  • xdm
    xdm La Coruña, Spain
    Hi

    I using Ice-2.1.0 and gentoo-linux gcc-3.3.5

    I figure that the proxy is the same but the second call that i make to setDefaultLocator i pass an invalid proxy locator (and ip of my network that is not use for any service) and after this i call to create ic->stringToProxy("IcePack/Query") and i obtain a valide IcePack::QueryPrx and if i call
    queryPx->findObjectById(Ice::stringToIdentity("ChatServer/ChatServer")) i obtain a proxy to ChatServer service

    if i set a not valid proxy for default locator the first time that i execute the client app IcePack/Query is not returned as i expect.

    I'll try to test this code in a few hours whit new Ice-2.1.1 and i post here the obtaining result if i continue observer this problem under 2.1.1 i try to write a small compatible example that demostrate it.

    thanks for all
  • benoit
    benoit Rennes, France
    Thanks, I believe I know what the problem is now.

    The Ice runtime keeps a cache per locator where it stores the endpoint information of indirect proxies (such as "IcePack/Query"). Two locators are considered to be the same if the identity portion of the locator proxy is the same. This is most likely what is happening for you, for example: "IcePack/Locator:tcp -h host1 -p 10000" and "IcePack/Locator:tcp -h host2invalid -p 12000" are considered to reference the same locator since the identity is the same.

    The solution is to use different identities for the each deployed locator (e.g.: IcePack/Locator1, IcePack/Locator2, etc). This way, the Ice runtime will maintain 2 different caches for each locator. However, I'm afraid it's currently not possible to configure the locator identity with IcePack :( We will fix this, thanks for the report!

    Benoit.
  • xdm
    xdm La Coruña, Spain
    Hi beniot

    I test it under Ice-2.1.1 and the result are the same, i can live whit out this feature because at this time its only a test program with one server.

    I expect this can work in a next relase of ice, in other case i chage the code as you say to have diferent identies

    thanks for explain me what the problem is