|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.infinispan.distribution.ch.AbstractConsistentHash
org.infinispan.distribution.ch.AbstractWheelConsistentHash
public abstract class AbstractWheelConsistentHash
Abstract class for the wheel-based CH implementations.
This base class supports virtual nodes. To enable virtual nodes you must set
numVirtualNodes to a number > 1.
Enabling virtual nodes means that a cache will appear multiple times on the hash
wheel. If an implementation doesn't want to support this, it should override
setNumVirtualNodes(Integer) to throw an IllegalArgumentException
for values != 1.
| Nested Class Summary | |
|---|---|
static class |
AbstractWheelConsistentHash.Externalizer<T extends AbstractWheelConsistentHash>
|
| Field Summary | |
|---|---|
protected Set<Address> |
caches
|
protected Hash |
hashFunction
|
protected int |
numVirtualNodes
|
protected int[] |
positionKeys
|
protected Address[] |
positionValues
|
protected boolean |
trace
|
| Fields inherited from class org.infinispan.distribution.ch.AbstractConsistentHash |
|---|
groupManager |
| Constructor Summary | |
|---|---|
protected |
AbstractWheelConsistentHash()
|
| Method Summary | |
|---|---|
Set<Address> |
getCaches()
Should return a collection of cache addresses in the cluster. |
List<Integer> |
getHashIds(Address a)
Returns a list of values between 0 and the hash space limit, or hash id, for a particular address. |
protected Log |
getLog()
|
int |
getNormalizedHash(Object key)
|
protected int |
getPositionIndex(int normalizedHash)
|
protected Iterator<Address> |
getPositionsIterator(int normalizedHash)
Creates an iterator over the positions "map" starting at the index specified by the normalizedHash. |
boolean |
isVirtualNodesEnabled()
|
Address |
primaryLocation(Object key)
Should be equivalent to return the first element of ConsistentHash.locate(Object, int). |
void |
setCaches(Set<Address> newCaches)
Sets the collection of cache addresses in the cluster. |
void |
setHashFunction(Hash h)
|
void |
setNumVirtualNodes(Integer numVirtualNodes)
|
String |
toString()
|
| Methods inherited from class org.infinispan.distribution.ch.AbstractConsistentHash |
|---|
getBackupsForNode, getGrouping, getStateProvidersOnJoin, getStateProvidersOnLeave, isKeyLocalToAddress, locateAll, setGroupManager |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.infinispan.distribution.ch.ConsistentHash |
|---|
locate |
| Field Detail |
|---|
protected final boolean trace
protected Hash hashFunction
protected int numVirtualNodes
protected Set<Address> caches
protected int[] positionKeys
protected Address[] positionValues
| Constructor Detail |
|---|
protected AbstractWheelConsistentHash()
| Method Detail |
|---|
public void setHashFunction(Hash h)
public void setNumVirtualNodes(Integer numVirtualNodes)
public void setCaches(Set<Address> newCaches)
ConsistentHash
newCaches - A set of unique caches in cluster.public final Set<Address> getCaches()
ConsistentHash
protected final int getPositionIndex(int normalizedHash)
protected final Iterator<Address> getPositionsIterator(int normalizedHash)
normalizedHash.
public final List<Integer> getHashIds(Address a)
ConsistentHash
public final int getNormalizedHash(Object key)
public final boolean isVirtualNodesEnabled()
public String toString()
toString in class AbstractConsistentHashpublic final Address primaryLocation(Object key)
ConsistentHashConsistentHash.locate(Object, int).
Useful as a performance optimization, as this is a frequently needed information.
primaryLocation in interface ConsistentHashprimaryLocation in class AbstractConsistentHashkey - key to locate
protected Log getLog()
|
--> | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||