curator-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Kanter <rkan...@cloudera.com>
Subject Re: Order of ServiceInstances
Date Tue, 20 Aug 2013 22:08:38 GMT
Ok thanks.
According to the ZK documentation, getChildren() says its not sorted and no
guarantee is made about its order.



On Tue, Aug 20, 2013 at 2:54 PM, Jordan Zimmerman <
jordan@jordanzimmerman.com> wrote:

> What is the order of the ServiceInstances returned by
> ServiceDiscovery#queryForInstances(String name)?
>
> Whatever order ZooKeeper's getChildren() returns it. Which, AFAIK, is
> undefined.
>
> Also what's the order returned by ServiceCache#getInstances()?
>
> Because it uses PatchChildrenCache internally, this returns instances
> sorted by path.
>
> P.S. Curator has made my work with ZooKeeper much easier :) thanks!
>
> :)
>
>
> On Aug 20, 2013, at 2:44 PM, Robert Kanter <rkanter@cloudera.com> wrote:
>
> Hi,
>
> 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).
>
> thanks
> - Robert
>
>
> P.S. Curator has made my work with ZooKeeper much easier :) thanks!
>
>
>

Mime
View raw message