public class ReplicatedConsistentHash extends Object implements ConsistentHash
ConsistentHash for replicated caches.
The hash-space has several segments owned by all members and the primary ownership of each segment is evenly
spread between members.| Modifier and Type | Class and Description |
|---|---|
static class |
ReplicatedConsistentHash.Externalizer |
| Constructor and Description |
|---|
ReplicatedConsistentHash(Hash hashFunction,
List<Address> members,
int[] primaryOwners) |
| Modifier and Type | Method and Description |
|---|---|
Hash |
getHashFunction() |
List<Address> |
getMembers()
Should return the addresses of the nodes used to create this consistent hash.
|
int |
getNumOwners() |
int |
getNumSegments() |
String |
getRoutingTableAsString()
Returns a string containing all the segments and their associated addresses.
|
int |
getSegment(Object key) |
Set<Integer> |
getSegmentsForOwner(Address owner)
Returns the segments owned by a cache member.
|
boolean |
isKeyLocalToNode(Address nodeAddress,
Object key)
Test to see whether a key is owned by a given node.
|
Set<Address> |
locateAllOwners(Collection<Object> keys)
The logical equivalent of calling
ConsistentHash.locateOwners(java.lang.Object) multiple times for each key in the collection of
keys and merging the results. |
List<Address> |
locateOwners(Object key)
Finds all the owners of a key.
|
List<Address> |
locateOwnersForSegment(int segmentId) |
Address |
locatePrimaryOwner(Object key)
Should be equivalent to return the first element of
ConsistentHash.locateOwners(java.lang.Object). |
Address |
locatePrimaryOwnerForSegment(int segmentId) |
String |
toString() |
public int getNumSegments()
getNumSegments in interface ConsistentHashpublic int getNumOwners()
getNumOwners in interface ConsistentHashpublic List<Address> getMembers()
ConsistentHashgetMembers in interface ConsistentHashpublic Hash getHashFunction()
getHashFunction in interface ConsistentHashpublic int getSegment(Object key)
getSegment in interface ConsistentHashpublic List<Address> locateOwnersForSegment(int segmentId)
locateOwnersForSegment in interface ConsistentHashpublic Address locatePrimaryOwnerForSegment(int segmentId)
locatePrimaryOwnerForSegment in interface ConsistentHashlocateOwnersForSegment(segmentId).get(0) but is more efficientpublic Set<Integer> getSegmentsForOwner(Address owner)
ConsistentHashgetSegmentsForOwner in interface ConsistentHashowner - the address of the memberpublic String getRoutingTableAsString()
ConsistentHashgetRoutingTableAsString in interface ConsistentHashpublic Address locatePrimaryOwner(Object key)
ConsistentHashConsistentHash.locateOwners(java.lang.Object).
Useful as a performance optimization, as this is a frequently needed information.locatePrimaryOwner in interface ConsistentHashkey - key to locatepublic List<Address> locateOwners(Object key)
ConsistentHashlocateOwners in interface ConsistentHashkey - key to locatenull, and it will always have at least 1 element.public Set<Address> locateAllOwners(Collection<Object> keys)
ConsistentHashConsistentHash.locateOwners(java.lang.Object) multiple times for each key in the collection of
keys and merging the results. Implementations may be optimised for such a bulk lookup.locateAllOwners in interface ConsistentHashkeys - keys to locate.public boolean isKeyLocalToNode(Address nodeAddress, Object key)
ConsistentHashisKeyLocalToNode in interface ConsistentHashnodeAddress - address of the node to testkey - key to testtrue if the key is mapped to the address; false otherwiseCopyright © 2014 JBoss, a division of Red Hat. All Rights Reserved.