Package akka.routing
Class ConsistentHash<T>
- java.lang.Object
 - 
- akka.routing.ConsistentHash<T>
 
 
- 
public class ConsistentHash<T> extends java.lang.ObjectConsistent Hashing node ring implementation.A good explanation of Consistent Hashing: https://tom-e-white.com/2007/11/consistent-hashing.html
Note that toString of the ring nodes are used for the node hash, i.e. make sure it is different for different nodes.
 
- 
- 
Constructor Summary
Constructors Constructor Description ConsistentHash() 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ConsistentHash<T>$colon$minus(T node)Removes a node from the node ring.ConsistentHash<T>$colon$plus(T node)Adds a node to the node ring.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 ConsistentHashbooleanisEmpty()Is the node ring empty, i.e.TnodeFor(byte[] key)Get the node responsible for the data key.TnodeFor(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.intvirtualNodesFactor() 
 - 
 
- 
- 
Method Detail
- 
apply
public static <T> ConsistentHash<T> apply(scala.collection.Iterable<T> nodes, int virtualNodesFactor, scala.reflect.ClassTag<T> evidence$2)
 
- 
create
public static <T> ConsistentHash<T> create(java.lang.Iterable<T> nodes, int virtualNodesFactor)
Java API: Factory method to create a ConsistentHash 
- 
virtualNodesFactor
public int virtualNodesFactor()
 
- 
$colon$plus
public ConsistentHash<T> $colon$plus(T node)
Adds a node to the node ring. Note that the instance is immutable and this operation returns a new instance. 
- 
add
public ConsistentHash<T> add(T node)
Java API: Adds a node to the node ring. Note that the instance is immutable and this operation returns a new instance. 
- 
$colon$minus
public ConsistentHash<T> $colon$minus(T node)
Removes a node from the node ring. Note that the instance is immutable and this operation returns a new instance. 
- 
remove
public ConsistentHash<T> remove(T node)
Java API: Removes a node from the node ring. Note that the instance is immutable and this operation returns a new instance. 
- 
nodeFor
public T nodeFor(byte[] key)
Get the node responsible for the data key. Can only be used if nodes exists in the node ring, otherwise throwsIllegalStateException 
- 
nodeFor
public T nodeFor(java.lang.String key)
Get the node responsible for the data key. Can only be used if nodes exists in the node ring, otherwise throwsIllegalStateException 
- 
isEmpty
public boolean isEmpty()
Is the node ring empty, i.e. no nodes added or all removed. 
 - 
 
 -