org.infinispan.distribution.ch
Class TopologyAwareConsistentHash

java.lang.Object
  extended by org.infinispan.distribution.ch.AbstractConsistentHash
      extended by org.infinispan.distribution.ch.AbstractWheelConsistentHash
          extended by 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

Nested Class Summary
static class TopologyAwareConsistentHash.Externalizer
           
 
Field Summary
 
Fields inherited from class org.infinispan.distribution.ch.AbstractWheelConsistentHash
addresses, addressToHashIds, positions
 
Fields inherited from class org.infinispan.distribution.ch.AbstractConsistentHash
caches, topologyInfo
 
Constructor Summary
TopologyAwareConsistentHash()
           
 
Method Summary
 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.
 List<Address> getStateProvidersOnLeave(Address leaver, int replCount)
          Returns the nodes that need will replicate their state if the specified node crashes.
 List<Address> locate(Object key, int replCount)
          Locates a key, given a replication count (number of copies).
 
Methods inherited from class org.infinispan.distribution.ch.AbstractWheelConsistentHash
getBackupsForNode, getCaches, getHashId, getHashSpace, getNormalizedHash, setCaches, toString
 
Methods inherited from class org.infinispan.distribution.ch.AbstractConsistentHash
getTopologyInfo, isKeyLocalToAddress, locateAll, setTopologyInfo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TopologyAwareConsistentHash

public TopologyAwareConsistentHash()
Method Detail

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 locate
replCount - 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.


Google Analytics

Copyright © 2010 JBoss, a division of Red Hat. All Rights Reserved.