|
||||||||||
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> |
getCaches()
Should return a collection of cache addresses in the cluster. |
int |
getDistance(Address a1,
Address a2)
Calculates the logical distance between two addresses. |
boolean |
isAdjacent(Address a1,
Address a2)
Tests whether two addresses are logically next to each other in the hash space. |
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. |
Method Detail |
---|
void setCaches(List<Address> caches)
caches
- caches in cluster.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
int getDistance(Address a1, Address a2)
a1
- address to testa2
- address to test
boolean isAdjacent(Address a1, Address a2)
a1
- address to testa2
- address to test
boolean isKeyLocalToAddress(Address a, Object key, int replCount)
a
- address to testkey
- key to testreplCount
- repl count
|
Google Analytics | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |