|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ConsistentHash
A consistent hash algorithm implementation. Implementations would typically be constructed via reflection so should implement a public, no-arg constructor.
Method Summary | |
---|---|
List<Address> |
getBackupsForNode(Address node,
int replCount)
Returns the nodes that backup data for the supplied node including the node itself. |
List<Address> |
getCaches()
Should return a collection of cache addresses in the cluster. |
int |
getHashId(Address a)
Returns the value between 0 and the hash space limit, or hash id, for a particular address. |
int |
getHashSpace()
Returns the hash space constant for this consistent hash algorithm class. |
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. |
List<Address> |
locate(Object key,
int replCount)
Locates a key, given a replication count (number of copies). |
Map<Object,List<Address>> |
locateAll(Collection<Object> keys,
int replCount)
The logical equivalent of calling locate(Object, int) multiple times for each key in the collection of
keys. |
void |
setCaches(List<Address> caches)
Sets the collection of cache addresses in the cluster. |
void |
setTopologyInfo(TopologyInfo topologyInfo)
Sets cluster topology information that can be used by CH to improve fault tolerance by smart choosing of backups. |
Method Detail |
---|
void setCaches(List<Address> caches)
caches
- caches in cluster.void setTopologyInfo(TopologyInfo topologyInfo)
List<Address> getCaches()
List<Address> locate(Object key, int replCount)
key
- key to locatereplCount
- replication count (number of copies)
setCaches(java.util.List)
. Should never be null, and should contain replCount elements or the max
number of caches available, whichever is smaller.Map<Object,List<Address>> locateAll(Collection<Object> keys, int replCount)
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 locate(Object,
int)
.
keys
- keys to locatereplCount
- replication count (number of copies) for each key
boolean isKeyLocalToAddress(Address a, Object key, int replCount)
a
- address to testkey
- key to testreplCount
- repl count
int getHashId(Address a)
int getHashSpace()
List<Address> getStateProvidersOnLeave(Address leaver, int replCount)
Pre: leaver must be present in the caches known to this CH, as returned by getCaches()
leaver
- the node that leaves the clusterreplCount
- List<Address> getStateProvidersOnJoin(Address joiner, int replCount)
List<Address> getBackupsForNode(Address node, int replCount)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |