curator-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Kanter <>
Subject Order of ServiceInstances
Date Tue, 20 Aug 2013 21:44:30 GMT

What is the order of the ServiceInstances returned by
ServiceDiscovery#queryForInstances(String name)?  Also what's the order
returned by ServiceCache#getInstances()?

The context is I have some IDs and I want to assign them to different
instances on the service discovery based on modding the ID by the number of
ServiceInstances (in other words, each ID will be assigned to exactly one
ServiceInstance).  I'd like to use the order in which the services
registered with ZooKeeper as their index (that is, the first service that
registers is 0, the second is 1, etc).  I can accomplish this by checking
the ServiceInstance#getRegistrationTimeUTC() for each ServiceInstance to
determine the ordering, but it would be easier and faster if the returned
Collection was already in that order (which is what I'm hoping).

- Robert

P.S. Curator has made my work with ZooKeeper much easier :) thanks!

View raw message