org.infinispan.distribution.ch
Class TopologyAwareConsistentHash
java.lang.Object
org.infinispan.distribution.ch.AbstractConsistentHash
org.infinispan.distribution.ch.AbstractWheelConsistentHash
org.infinispan.distribution.ch.TopologyAwareConsistentHash
- All Implemented Interfaces:
- ConsistentHash
public class TopologyAwareConsistentHash
- extends AbstractWheelConsistentHash
Consistent hash that is aware of cluster topology.
Design described here: http://community.jboss.org/wiki/DesigningServerHinting.
Algorithm:
- place nodes on the hash wheel based address's hash code
- For selecting owner nodes:
- pick the first one based on key's hash code
- for subsequent nodes, walk clockwise and pick nodes that have a different site id
- if not enough nodes found repeat walk again and pick nodes that have different site id and rack id
- if not enough nodes found repeat walk again and pick nodes that have different site id, rack id and machine id
- Ultimately cycle back to the first node selected, don't discard any nodes, regardless of machine id/rack
id/site id match.
- Since:
- 4.2
- Author:
- Mircea.Markus@jboss.com
TopologyAwareConsistentHash
public TopologyAwareConsistentHash()
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.List)
. Should never be null, and should contain replCount elements or the max
number of caches available, whichever is smaller.
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
getStateProvidersOnJoin
public List<Address> getStateProvidersOnJoin(Address joiner,
int replCount)
- In this situation are the same nodes providing state on join as the nodes that provide state on leave.
Copyright © 2010 JBoss, a division of Red Hat. All Rights Reserved.