org.infinispan.distribution.ch
Class DefaultConsistentHash

java.lang.Object
  extended by org.infinispan.distribution.ch.AbstractConsistentHash
      extended by org.infinispan.distribution.ch.AbstractWheelConsistentHash
          extended by org.infinispan.distribution.ch.DefaultConsistentHash
All Implemented Interfaces:
ConsistentHash

public class DefaultConsistentHash
extends AbstractWheelConsistentHash


Nested Class Summary
static class DefaultConsistentHash.Externalizer
           
 
Field Summary
 
Fields inherited from class org.infinispan.distribution.ch.AbstractWheelConsistentHash
addresses, addressToHashIds, hashFunction, positions
 
Fields inherited from class org.infinispan.distribution.ch.AbstractConsistentHash
caches, topologyInfo
 
Constructor Summary
DefaultConsistentHash()
           
 
Method Summary
 boolean equals(Object o)
           
 List<Address> getAddressOnTheWheel()
           
 int getDistance(Address a1, Address a2)
           
 List<Address> getStateProvidersOnJoin(Address self, int replCount)
          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
 List<Address> getStateProvidersOnLeave(Address leaver, int replCount)
          Returns the nodes that need will replicate their state if the specified node crashes.
 int hashCode()
           
 boolean isAdjacent(Address a1, Address a2)
           
 boolean isKeyLocalToAddress(Address target, Object key, int replCount)
          Test to see whether a key is mapped to a given address.
 List<Address> locate(Object key, int replCount)
          Locates a key, given a replication count (number of copies).
 String toString()
           
 
Methods inherited from class org.infinispan.distribution.ch.AbstractWheelConsistentHash
getBackupsForNode, getCaches, getHashId, getHashSpace, getNormalizedHash, setCaches, setHashFunction
 
Methods inherited from class org.infinispan.distribution.ch.AbstractConsistentHash
getTopologyInfo, locateAll, setTopologyInfo
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultConsistentHash

public DefaultConsistentHash()
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.

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 test
key - key to test
replCount - 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

getAddressOnTheWheel

public List<Address> getAddressOnTheWheel()

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

Google Analytics

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