org.infinispan.distribution.ch
Class DefaultConsistentHash
java.lang.Object
org.infinispan.distribution.ch.AbstractConsistentHash
org.infinispan.distribution.ch.AbstractWheelConsistentHash
org.infinispan.distribution.ch.DefaultConsistentHash
- All Implemented Interfaces:
- ConsistentHash
public class DefaultConsistentHash
- extends AbstractWheelConsistentHash
DefaultConsistentHash
public DefaultConsistentHash()
DefaultConsistentHash
public DefaultConsistentHash(Hash hash)
locate
public List<Address> locate(Object key,
int replCount)
- Description copied from interface:
ConsistentHash
- Locates a key, given a replication count (number of copies).
- Parameters:
key - key to locatereplCount - replication count (number of copies)
- Returns:
- a list of addresses where the key resides, where this list is a subset of the addresses set in
ConsistentHash.setCaches(java.util.Set). Should never be null, and should contain replCount elements or the max
number of caches available, whichever is smaller.
isKeyLocalToAddress
public boolean isKeyLocalToAddress(Address target,
Object key,
int replCount)
- Description copied from interface:
ConsistentHash
- Test to see whether a key is mapped to a given address.
- Specified by:
isKeyLocalToAddress in interface ConsistentHash- Overrides:
isKeyLocalToAddress in class AbstractConsistentHash
- Parameters:
target - address to testkey - key to testreplCount - repl count
- Returns:
- true if the key is mapped to the address; false otherwise
getDistance
public int getDistance(Address a1,
Address a2)
isAdjacent
public boolean isAdjacent(Address a1,
Address a2)
equals
public boolean equals(Object o)
- Overrides:
equals in class Object
hashCode
public int hashCode()
- Overrides:
hashCode in class Object
toString
public String toString()
- Overrides:
toString in class AbstractWheelConsistentHash
getStateProvidersOnJoin
public List<Address> getStateProvidersOnJoin(Address self,
int replCount)
- Description copied from interface:
ConsistentHash
- Returns the nodes that would act as state providers when a new node joins:
- the nodes for which the joiner is a backup
- the nodes that held joiner's state
getStateProvidersOnLeave
public List<Address> getStateProvidersOnLeave(Address leaver,
int replCount)
- Description copied from interface:
ConsistentHash
- Returns the nodes that need will replicate their state if the specified node crashes. The return collection
should contain all the nodes that backup-ed on leaver and one of the nodes which acted as a backup for the leaver .
Pre: leaver must be present in the caches known to this CH, as returned by ConsistentHash.getCaches()
- Parameters:
leaver - the node that leaves the cluster
Copyright © 2011 JBoss, a division of Red Hat. All Rights Reserved.