Use bisection to find the position within the ring, as in ketama.
According to my benchmarking this is faster than the guess/refine
algorithm for rings with 100 locations, i.e. 16000 ring nodes requiring
at most 14 bisection iterations.
Change-Id: I6042f382de093081971b5ec210eda8dfa74988f2
This scheme avoids disruptive re-hashing when a node is
ejected; only the adjectent clockwise sector is affected,
the later taking responsibility for the former. Addition
of new nodes is likewise less disruptive.
When used with MD5, this maps keys the same as libketama.
Also:
* Make HashRing::getLocations() faster by guessing the
sector list index and moving clockwise/counter-clockwise.
* Made HashRing Serializable for more robust storage.
* Allow for different hash functions to be specified.
Note:
* This makes PoolCounterRedis use the new hash scheme.
* Likewise for JobQueueFederated (for job de-duplication).
Switching from one mode to the other will cause some of
duplicated effort from old jobs only temporarily.
Change-Id: Iff432a4e5dc3fb40b2dda70fb3dbe9dda0b74933