public class BalancedHashRing<T> extends java.lang.Object implements HashRing<T>
| Modifier and Type | Field and Description |
|---|---|
protected java.util.TreeMap<java.math.BigInteger,HashRingEntry> |
entryMap
Maps hash ring positions to ring entries
|
protected HashFunction<T> |
function |
protected java.math.BigInteger |
maxHash |
protected boolean |
randomize
If set to True, the first position in the hash ring is randomized.
|
| Constructor and Description |
|---|
BalancedHashRing(HashFunction<T> function)
Creates a BalancedHashRing using the provided hash function.
|
BalancedHashRing(HashFunction<T> function,
boolean randomize)
Creates a BalancedHashRing using the provided hash function.
|
| Modifier and Type | Method and Description |
|---|---|
java.math.BigInteger |
addNode(T data)
Add a node to the overlay network topology.
|
java.math.BigInteger |
locate(T data)
Determine the node that is responsible for the given data.
|
java.lang.String |
toString()
Formats the hash ring as node-to-predecessor pair Strings.
|
protected boolean randomize
protected HashFunction<T> function
protected java.math.BigInteger maxHash
protected java.util.TreeMap<java.math.BigInteger,HashRingEntry> entryMap
public BalancedHashRing(HashFunction<T> function)
function - HashFunction that defines the hash space being used.public BalancedHashRing(HashFunction<T> function, boolean randomize)
function - HashFunction that defines the hash space being used.public java.math.BigInteger addNode(T data) throws HashTopologyException, HashException
addNode in interface HashRing<T>data - unused for this hash ring; nodes are placed evenly based on
current topology characteristics. You may safely pass 'null' to this
method.HashTopologyExceptionHashExceptionpublic java.math.BigInteger locate(T data) throws HashException
HashRinglocate in interface HashRing<T>data - the data to hash againstHashExceptionpublic java.lang.String toString()
toString in class java.lang.Object