public class ConsistentHash<T>
extends java.lang.Object
A good explanation of Consistent Hashing: http://weblogs.java.net/blog/tomwhite/archive/2007/11/consistent_hash.html
Note that toString of the ring nodes are used for the node hash, i.e. make sure it is different for different nodes.
Modifier and Type | Method and Description |
---|---|
ConsistentHash<T> |
add(T node)
Java API: Adds a node to the node ring.
|
static <T> ConsistentHash<T> |
apply(scala.collection.Iterable<T> nodes,
int virtualNodesFactor,
scala.reflect.ClassTag<T> evidence$2) |
static <T> ConsistentHash<T> |
create(java.lang.Iterable<T> nodes,
int virtualNodesFactor)
Java API: Factory method to create a ConsistentHash
|
boolean |
isEmpty()
Is the node ring empty, i.e.
|
T |
nodeFor(byte[] key)
Get the node responsible for the data key.
|
T |
nodeFor(java.lang.String key)
Get the node responsible for the data key.
|
ConsistentHash<T> |
remove(T node)
Java API: Removes a node from the node ring.
|
int |
virtualNodesFactor() |
public static <T> ConsistentHash<T> apply(scala.collection.Iterable<T> nodes, int virtualNodesFactor, scala.reflect.ClassTag<T> evidence$2)
public static <T> ConsistentHash<T> create(java.lang.Iterable<T> nodes, int virtualNodesFactor)
nodes
- (undocumented)virtualNodesFactor
- (undocumented)public int virtualNodesFactor()
public ConsistentHash<T> add(T node)
node
- (undocumented)public ConsistentHash<T> remove(T node)
node
- (undocumented)public T nodeFor(byte[] key)
IllegalStateException
key
- (undocumented)public T nodeFor(java.lang.String key)
IllegalStateException
key
- (undocumented)public boolean isEmpty()