Results 1 to 9 of 9

Thread: Ice.Default.Locator

  1. #1
    xdm's Avatar
    xdm
    xdm is offline ZeroC Staff
    Name: Jose Gutierrez de la Concha
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Sep 2003
    Location
    La Coruņa, Spain
    Posts
    588

    Ice.Default.Locator

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

  2. #2
    dwayne's Avatar
    dwayne is offline ZeroC Staff
    Name: Dwayne Boone
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Jan 2005
    Location
    St. John's, Newfoundland
    Posts
    397
    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.

    Code:
    LocatorPrx locator = LocatorPrx::uncheckedCast(communicator->stringToProxy("IcePack/Locator:default -h www.myserver.com -p 9090"));
    communicator->setDefaultLocator(locator);
    Regards,
    Dwayne

  3. #3
    xdm's Avatar
    xdm
    xdm is offline ZeroC Staff
    Name: Jose Gutierrez de la Concha
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Sep 2003
    Location
    La Coruņa, Spain
    Posts
    588
    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

  4. #4
    matthew's Avatar
    matthew is offline ZeroC Staff
    Name: Matthew Newhook
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Feb 2003
    Location
    NL, Canada
    Posts
    1,458
    Quote Originally Posted by xdm
    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

  5. #5
    xdm's Avatar
    xdm
    xdm is offline ZeroC Staff
    Name: Jose Gutierrez de la Concha
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Sep 2003
    Location
    La Coruņa, Spain
    Posts
    588
    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

    Code:
    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

  6. #6
    benoit's Avatar
    benoit is offline ZeroC Staff
    Name: Benoit Foucher
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Rennes, France
    Posts
    2,196
    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.

  7. #7
    xdm's Avatar
    xdm
    xdm is offline ZeroC Staff
    Name: Jose Gutierrez de la Concha
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Sep 2003
    Location
    La Coruņa, Spain
    Posts
    588
    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("ChatServe r/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

  8. #8
    benoit's Avatar
    benoit is offline ZeroC Staff
    Name: Benoit Foucher
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Rennes, France
    Posts
    2,196
    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.

  9. #9
    xdm's Avatar
    xdm
    xdm is offline ZeroC Staff
    Name: Jose Gutierrez de la Concha
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Sep 2003
    Location
    La Coruņa, Spain
    Posts
    588
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Ice Default Logger usage
    By danleepw in forum Help Center
    Replies: 1
    Last Post: 05-07-2010, 02:42 AM
  2. Ice.Default.Locator and stand-alone IceBox service
    By aerskine in forum Help Center
    Replies: 2
    Last Post: 02-19-2009, 03:21 PM
  3. What is the default priority of the Ice thread ?
    By russule in forum Help Center
    Replies: 5
    Last Post: 06-03-2007, 10:36 PM
  4. Specifying a default locator without a config file
    By mefoster in forum Help Center
    Replies: 1
    Last Post: 03-01-2007, 05:10 AM
  5. set string to default in .ice file???
    By shadowdog in forum Help Center
    Replies: 3
    Last Post: 03-10-2006, 09:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •