Archived

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

How to get endpoints from locator table in client?

I trace the locator info get from the IceGrid:

-- 15-7-28 15:13:27:510 Client: Locator: searching for object by id
object = feidao/testService
-- 15-7-28 15:13:27:542 Client: Locator: searching for adapter by id
adapter = testService
-- 15-7-28 15:13:27:579 Client: Locator: retrieved endpoints from locator, adding to locator table
adapter = testService
endpoints = tcp -h 192.168.2.103 -p 59689 -t 60000:tcp -h 192.168.2.103 -p 59703 -t 60000:tcp -h 192.168.2.103 -p 59696 -t 60000

Now I want to get these endpoints info. I don't want to choose them in Ramdon or Ordered.
I think i can get them by [ proxy.ice_getEndpoints() ], but there is no info.

both client and server are in Java.
thanks.

Comments

  • xdm
    xdm La Coruña, Spain
    getInfo is part of the endpoint API, you can call getInfo in each of the returned endpoints. see https://doc.zeroc.com/display/Ice36/Ice-Endpoint
  • Is that means I only can get the endpoint info after I create the connection?
    I have did it ,but in this way ,I can't get the full locator info ,cause it choose endpoints in Ramdom or Ordered to create the connetion.


    MessageEndpointPrx proxy= MessageEndpointPrxHelper.checkedCast(communicator().stringToProxy("feidao/testService").ice_connectionId(ramdom));
    proxy.ice_getConnection().getEndpoint()

    in this way ,i just get one endpoint in ramdom one time.
    I want to get the full locator info ,and make a custom client load balancing.
  • xdm
    xdm La Coruña, Spain
    Note that ice_getEndpoints() on an indirect proxy always returns an empty list of endpoints, if you really want to get the endpoints you will need to manually resolve them with the locator.
    Ice.ObjectPrx proxy = communicator.getDefaultLocator().findAdapterById(proxy.ice_getAdapterId());
    Ice.Endpoint[] endpoints = proxy.ice_getEndpoints();
    
  • Thank you very much!
  • benoit
    benoit Rennes, France
    Hi,

    An indirect proxy such as "feidao/testService" has indeed no endpoints so calling ice_getEndpoints() on such a proxy will always return an empty list of endpoints. As José indicated, you need to resolve manually the endpoints by calling on the locator directly.

    For a well-known proxy, you can use:
    Ice.ObjectPrx proxy = communicator.getDefaultLocator().findObjectById(pr oxy.ice_getIdentity());
    if(!proxy.ice_getAdapterId().isEmpty())
    {
        proxy = communicator.getDefaultLocator().findAdapterById(p roxy.ice_getAdapterId());
    }
    Ice.Endpoint[] endpoints = proxy.ice_getEndpoints();
    

    You can also use the IceGrid::Query interface to retrieve the proxies of each replica, see https://doc.zeroc.com/display/Ice36/...ObjectReplicas for more information on this.

    That being said, I'm curious as to why you need to do this in the client. What strategy do you need for sorting the replicas?

    Note also that Ice 3.6 now provides a way to implement custom load balancing with an IceGrid plugin. Did you consider using this instead? See https://doc.zeroc.com/display/Ice36/...cingStrategies for more information on custom load balancing.

    Cheers,
    Benoit.
  • Because,this client is a enterance service on icebox in our business system.
    the real client may be a high parallel webserver. and after the enterance service may be a heavy task.
    but the IceGrid load balancing only works at the client call the locate service, or I use [ .ice_connectionId(ramdom)) ] in ramdom selection without cache.

    so i try to make a load balancing in client.