public abstract class AbstractConsistentHash extends Object implements ConsistentHash
locateAll(java.util.Collection, int)
and isKeyLocalToAddress(org.infinispan.remoting.transport.Address, Object, int)
.
The versions provided here are relatively inefficient in that they call ConsistentHash.locate(Object, int)
first (and
sometimes in a loop). Depending on the algorithm used, there may be more efficient ways to achieve the same results
and in such cases the methods provided here should be overridden.
Modifier and Type | Field and Description |
---|---|
protected GroupManager |
groupManager |
Constructor and Description |
---|
AbstractConsistentHash() |
Modifier and Type | Method and Description |
---|---|
List<Address> |
getBackupsForNode(Address node,
int replCount)
Returns the nodes that backup data for the supplied node including the node itself.
|
protected Object |
getGrouping(Object key)
Get the grouping, if any, for this key.
|
List<Address> |
getStateProvidersOnJoin(Address joiner,
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.
|
boolean |
isKeyLocalToAddress(Address a,
Object key,
int replCount)
Test to see whether a key is mapped to a given address.
|
Map<Object,List<Address>> |
locateAll(Collection<Object> keys,
int replCount)
The logical equivalent of calling
ConsistentHash.locate(Object, int) multiple times for each key in the collection of
keys. |
Address |
primaryLocation(Object key)
Should be equivalent to return the first element of
ConsistentHash.locate(Object, int) . |
void |
setGroupManager(GroupManager groupManager) |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getCaches, getHashIds, locate, setCaches
protected GroupManager groupManager
public Map<Object,List<Address>> locateAll(Collection<Object> keys, int replCount)
ConsistentHash
ConsistentHash.locate(Object, int)
multiple times for each key in the collection of
keys. Implementations may be optimised for such a bulk lookup, or may just repeatedly call ConsistentHash.locate(Object,
int)
.locateAll
in interface ConsistentHash
keys
- keys to locatereplCount
- replication count (number of copies) for each keypublic boolean isKeyLocalToAddress(Address a, Object key, int replCount)
ConsistentHash
isKeyLocalToAddress
in interface ConsistentHash
a
- address to testkey
- key to testreplCount
- repl countpublic Address primaryLocation(Object key)
ConsistentHash
ConsistentHash.locate(Object, int)
.
Useful as a performance optimization, as this is a frequently needed information.primaryLocation
in interface ConsistentHash
key
- key to locatepublic void setGroupManager(GroupManager groupManager)
public List<Address> getStateProvidersOnLeave(Address leaver, int replCount)
ConsistentHash
Pre: leaver must be present in the caches known to this CH, as returned by ConsistentHash.getCaches()
getStateProvidersOnLeave
in interface ConsistentHash
leaver
- the node that leaves the clusterpublic List<Address> getStateProvidersOnJoin(Address joiner, int replCount)
ConsistentHash
getStateProvidersOnJoin
in interface ConsistentHash
public List<Address> getBackupsForNode(Address node, int replCount)
ConsistentHash
getBackupsForNode
in interface ConsistentHash
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.