public class PartitionerConsistentHash extends Object implements ConsistentHash
| Constructor and Description |
|---|
PartitionerConsistentHash(ConsistentHash ch,
KeyPartitioner keyPartitioner) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
Hash |
getHashFunction() |
KeyPartitioner |
getKeyPartitioner() |
List<Address> |
getMembers()
Should return the addresses of the nodes used to create this consistent hash.
|
int |
getNumOwners() |
int |
getNumSegments() |
Set<Integer> |
getPrimarySegmentsForOwner(Address owner)
Returns the segments that this cache member is the primary owner for.
|
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.
|
int |
hashCode() |
boolean |
isKeyLocalToNode(Address nodeAddress,
Object key)
Test to see whether a key is owned by a given node.
|
boolean |
isReplicated() |
boolean |
isSegmentLocalToNode(Address nodeAddress,
int segmentId)
Check if a segment is local to a given member.
|
List<Address> |
locateOwnersForSegment(int segmentId) |
Address |
locatePrimaryOwnerForSegment(int segmentId) |
void |
toScopedState(ScopedPersistentState state)
Writes this ConsistentHash to the specified scoped state.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitlocateAllOwners, locateOwners, locatePrimaryOwnerpublic PartitionerConsistentHash(ConsistentHash ch, KeyPartitioner keyPartitioner)
public int getNumSegments()
getNumSegments in interface ConsistentHashpublic int getNumOwners()
getNumOwners in interface ConsistentHashpublic List<Address> getMembers()
ConsistentHashgetMembers 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 boolean isSegmentLocalToNode(Address nodeAddress, int segmentId)
ConsistentHashImplementation note: normally key-based method are implemented based on segment-based methods. Here, however, we need a default implementation for the segment-based method for backwards-compatibility reasons.
isSegmentLocalToNode in interface ConsistentHashpublic boolean isReplicated()
isReplicated in interface ConsistentHashtrue if every member owns every segment. This allows callers to skip computing the
segment of a key in some cases.public Set<Integer> getSegmentsForOwner(Address owner)
ConsistentHashgetSegmentsForOwner in interface ConsistentHashowner - the address of the memberpublic Set<Integer> getPrimarySegmentsForOwner(Address owner)
ConsistentHashgetPrimarySegmentsForOwner in interface ConsistentHashowner - the address of the memberpublic String getRoutingTableAsString()
ConsistentHashgetRoutingTableAsString in interface ConsistentHashpublic 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 otherwisepublic Hash getHashFunction()
getHashFunction in interface ConsistentHashpublic KeyPartitioner getKeyPartitioner()
public void toScopedState(ScopedPersistentState state)
ConsistentHashtoScopedState in interface ConsistentHashstate - the state to which this ConsistentHash will be writtenCopyright © 2024 JBoss, a division of Red Hat. All rights reserved.