@Immutable public class ScatteredConsistentHash extends AbstractConsistentHash
ConsistentHashFactory.updateMembers(CH, java.util.List<org.infinispan.remoting.transport.Address>, java.util.Map<org.infinispan.remoting.transport.Address, java.lang.Float>)
is called and the result
is sent in CH_UPDATE. Such topology is installed and later during rebalance, a diff of segments
between the installed and new (rebalancing) topology is computed. If we assigned all the owners
right in updateMembers, this diff would be empty.Modifier and Type | Class and Description |
---|---|
static class |
ScatteredConsistentHash.Externalizer |
capacityFactors, members, STATE_CAPACITY_FACTOR, STATE_CAPACITY_FACTORS, STATE_NUM_SEGMENTS
Constructor and Description |
---|
ScatteredConsistentHash(int numSegments,
List<Address> members,
Map<Address,Float> capacityFactors,
Address[] segmentOwners,
boolean isRebalanced) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
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.
|
Set<Integer> |
getSegmentsForOwner(Address owner)
Returns the segments owned by a cache member.
|
int |
hashCode() |
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) |
ConsistentHash |
remapAddresses(UnaryOperator<Address> remapper)
Returns a new ConsistentHash with the addresses remapped according to the provided
UnaryOperator . |
void |
toScopedState(ScopedPersistentState state)
Writes this ConsistentHash to the specified scoped state.
|
String |
toString() |
ScatteredConsistentHash |
union(ScatteredConsistentHash sch2)
Prefers owners from the second hash -> effectively this will make pendingCH == unionCH (I think)
|
checkSameHashAndSegments, getCapacityFactors, getMembers, mergeLists, parseCapacityFactors, parseHashFunction, parseMembers, parseNumSegments, remapCapacityFactors, remapMembers, unionCapacityFactors
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
isReplicated
public int getNumSegments()
public Set<Integer> getSegmentsForOwner(Address owner)
ConsistentHash
owner
- the address of the memberpublic Set<Integer> getPrimarySegmentsForOwner(Address owner)
ConsistentHash
owner
- the address of the memberpublic List<Address> locateOwnersForSegment(int segmentId)
public Address locatePrimaryOwnerForSegment(int segmentId)
locateOwnersForSegment(segmentId).get(0)
but is more efficientpublic boolean isSegmentLocalToNode(Address nodeAddress, int segmentId)
ConsistentHash
Implementation 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.
public String getRoutingTableAsString()
ConsistentHash
public ScatteredConsistentHash union(ScatteredConsistentHash sch2)
public void toScopedState(ScopedPersistentState state)
ConsistentHash
PersistentUUID
stoScopedState
in interface ConsistentHash
toScopedState
in class AbstractConsistentHash
state
- the state to which this ConsistentHash will be writtenpublic ConsistentHash remapAddresses(UnaryOperator<Address> remapper)
ConsistentHash
UnaryOperator
.
If an address cannot me remapped (i.e. the remapper returns null) this method should return null.remapper
- the remapper which given an address replaces it with another oneCopyright © 2021 JBoss by Red Hat. All rights reserved.