org.infinispan.distribution.ch
Class AbstractWheelConsistentHash
java.lang.Object
org.infinispan.distribution.ch.AbstractConsistentHash
org.infinispan.distribution.ch.AbstractWheelConsistentHash
- All Implemented Interfaces:
- ConsistentHash
- Direct Known Subclasses:
- DefaultConsistentHash, TopologyAwareConsistentHash
public abstract class AbstractWheelConsistentHash
- extends AbstractConsistentHash
Abstract class for the wheel-based CH implementations.
- Since:
- 4.2
- Author:
- Mircea.Markus@jboss.com
log
protected final Log log
trace
protected final boolean trace
addresses
protected ArrayList<Address> addresses
positions
protected SortedMap<Integer,Address> positions
addressToHashIds
protected Map<Address,Integer> addressToHashIds
hashFunction
protected Hash hashFunction
AbstractWheelConsistentHash
protected AbstractWheelConsistentHash()
setHashFunction
public void setHashFunction(Hash h)
setCaches
public void setCaches(List<Address> caches)
- Description copied from interface:
ConsistentHash
- Sets the collection of cache addresses in the cluster. The implementation should store these internally and use
these to locate keys.
- Specified by:
setCaches
in interface ConsistentHash
- Overrides:
setCaches
in class AbstractConsistentHash
- Parameters:
caches
- caches in cluster.
getBackupsForNode
public List<Address> getBackupsForNode(Address node,
int replCount)
- Description copied from interface:
ConsistentHash
- Returns the nodes that backup data for the supplied node including the node itself.
getCaches
public List<Address> getCaches()
- Description copied from interface:
ConsistentHash
- Should return a collection of cache addresses in the cluster.
- Returns:
- collection of cache addresses
getHashSpace
public int getHashSpace()
- Description copied from interface:
ConsistentHash
- Returns the hash space constant for this consistent hash algorithm class. This integer is often used as modulus
for arithmetic operations within the algorithm, for example, limiting the range of possible hash values.
- Returns:
- A positive integer containing the hash space constant or 0 is not supported by implementation.
getHashId
public int getHashId(Address a)
- Description copied from interface:
ConsistentHash
- Returns the value between 0 and the hash space limit, or hash id, for a particular address. If there's no such
value for an address, this method will return -1.
- Returns:
- An int between 0 and hash space if the address is present in the hash wheel, otherwise it returns -1.
getNormalizedHash
public int getNormalizedHash(Object key)
toString
public String toString()
- Overrides:
toString
in class AbstractConsistentHash
Copyright © 2011 JBoss, a division of Red Hat. All Rights Reserved.