Home Help Center

Try to use two Locators

peter.lawreypeter.lawrey Member Peter LawreyOrganization: MLPProject: Setup development
I have production and development environment. I want development to be as independant as possible but a few things must come from production.

So I have set these properties
Ice.Default.Locator=IceGrid/Locator -h dev_server -p 4601
b2b_prod.Locator=IceGrid/Locator -h prod_server -p 4601
Ice.Trace.Location=2
Ice.Trace.Protocol=1

The "b2b_prod" adapter is running fine in production but it always fails to find it in development.

How can I tell from the logs.
- whether the Locator property is being used, or is the default is used?
- which locator is used for b2b_prod?

How do I fix this issue?

Comments

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    With these settings, you instruct the object adapter b2b_prod to register its endpoints with the prod locator. The Ice.Default.Locator property will instruct other adapters (if any) to register their endpoints with the dev locator and will also be used by Ice proxies to resolve endpoints of indirect proxies.

    The object adapter won't register with both locators, is this what you expected? It only supports registration with a single object adapter. If you need to register the object adapter with multiple locators, you'll need to do it manually using the Ice::LocatorRegistry API.

    Are you sure you want to expose all the Ice objects from the production adapter as-is in the development environment however? Another option would be to create a separate object adapter dedicated to the development environment. This might provide greater flexibility if for example you want to turn-off development environment access to your production server.

    Finally, you shouldn't use the same identity for 2 different Ice locators. You should use different instance names for each of your IceGrid deployment.

    Cheers,
    Benoit.
  • peter.lawreypeter.lawrey Member Peter LawreyOrganization: MLPProject: Setup development
    benoit wrote: »
    With these settings, you instruct the object adapter b2b_prod to register its endpoints with the prod locator. The Ice.Default.Locator property will instruct other adapters (if any) to register their endpoints with the dev locator and will also be used by Ice proxies to resolve endpoints of indirect proxies.

    This many be my confusion. b2b_prod is already regsitered with the prod instance. What I want is to use this registration in a service with registers in the dev instance.
    benoit wrote: »
    If you need to register the object adapter with multiple locators, you'll need to do it manually
    I want to use the service in multiple environments. (As a client, not expose the same service implicitly to multiple enviroment) i.e. the service provider is only registered with one locator, but is used in multiple enviroments.
    benoit wrote: »
    Another option would be to create a separate object adapter dedicated to the development environment. This might provide greater flexibility if for example you want to turn-off development environment access to your production server.
    I could do this, but it doesn't solve the problem which is that I need a way to connect to the service in the production enviroment to "replicate" it in development.
    benoit wrote: »
    Finally, you shouldn't use the same identity for 2 different Ice locators. You should use different instance names for each of your IceGrid deployment.
    I have seen mention of this before but no actual examples of what to name them. The link you gave me is useful. Can I just call them
    IceGrid.InstanceName=DevIceGrid/Locator
    
    Ice.Default.Locator=DevIceGrid/Locator:tcp -h devserver -p 4061
    b2b_prod.Locator=IceGrid/Locator:tcp -h prodserver -p 4061
    

    Thank you for your reply,
    Peter.
  • peter.lawreypeter.lawrey Member Peter LawreyOrganization: MLPProject: Setup development
    IceGrid.InstanceName=DevIceGrid/Locator
    
    Ice.Default.Locator=DevIceGrid/Locator:tcp -h devserver -p 4061
    b2b_prod.Locator=IceGrid/Locator:tcp -h prodserver -p 4061
    

    I have tried these settings. I can see that b2b_prod is registered in the IceGrid Gui when I connect to the production IceGrid/Locator, but it complains NotRegisteredException when I use these settings.
  • peter.lawreypeter.lawrey Member Peter LawreyOrganization: MLPProject: Setup development
    What appears to work is to check if it is a property first or a string if its not. There doesn't appear to be a single method which does this.
        public static ObjectPrx acquireProxy(Communicator communicator, String service) {
            ObjectPrx prx;
            try {
                // check if it has been overridden
                prx = communicator.propertyToProxy(service);
                // force it to connect to check if its valid.
                prx.ice_ids();
            } catch (NoEndpointException e) {
                prx = communicator.stringToProxy(service);
            }
            return prx;
        }
    

    In the config file you need to have
    Ice.Default.Locator=DevIceGrid/Locator:tcp -h devgrid -p 4061
    
    [email protected][email protected]_prod
    [email protected]_prod.Locator=IceGrid/Locator:tcp -h prodgrid -p 4061
    
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    The instance name should be "DevIceGrid" not "DevIceGrid/Locator":
    IceGrid.InstanceName=DevIceGrid
    

    The proxy for the locator will then be "DevIceGrid/Locator:tcp -h devserver -p 4061".

    If your goal is to access your production service from a client which is configured with the default locator of the development environment, you could specify explicitly the locator proxy of the production environment on the proxy of the service. This can be achieve with the proxy ice_locator method for example. See here in the Ice manual for additional details.

    Cheers,
    Benoit.
Sign In or Register to comment.