public class ReplicatedConsistentHashFactory extends Object implements ConsistentHashFactory<ReplicatedConsistentHash>
| Modifier and Type | Class and Description |
|---|---|
static class |
ReplicatedConsistentHashFactory.Externalizer |
| Constructor and Description |
|---|
ReplicatedConsistentHashFactory() |
| Modifier and Type | Method and Description |
|---|---|
ReplicatedConsistentHash |
create(int numOwners,
int numSegments,
List<Address> members,
Map<Address,Float> capacityFactors)
Create a new consistent hash instance.
|
boolean |
equals(Object other) |
ReplicatedConsistentHash |
fromPersistentState(ScopedPersistentState state)
Recreates a ConsistentHash from a previously stored persistent state.
|
int |
hashCode() |
ReplicatedConsistentHash |
rebalance(ReplicatedConsistentHash baseCH)
Create a new consistent hash instance, based on an existing instance, but balanced according to
the implementation's rules.
|
ReplicatedConsistentHash |
union(ReplicatedConsistentHash ch1,
ReplicatedConsistentHash ch2)
Creates a union of two compatible ConsistentHashes (use the same hashing function and have the same configuration
parameters).
|
ReplicatedConsistentHash |
updateMembers(ReplicatedConsistentHash baseCH,
List<Address> newMembers,
Map<Address,Float> actualCapacityFactors)
Updates an existing consistent hash instance to remove owners that are not in the
newMembers list. |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitcreatepublic ReplicatedConsistentHash create(int numOwners, int numSegments, List<Address> members, Map<Address,Float> capacityFactors)
ConsistentHashFactorycreate in interface ConsistentHashFactory<ReplicatedConsistentHash>numOwners - The ideal number of owners for each key. The created consistent hash
can have more or less owners, but each key will have at least one owner.numSegments - Number of hash-space segments. The implementation may round up the number
of segments for performance, or may ignore the parameter altogether.members - A list of addresses representing the new cache members.capacityFactors - The capacity factor of each member. Determines the relative capacity of each node compared
to the others. The implementation may ignore this parameter.
If null, all the members are assumed to have a capacity factor of 1.public ReplicatedConsistentHash fromPersistentState(ScopedPersistentState state)
ConsistentHashFactoryPersistentUUIDs instead so they will need to be replacedfromPersistentState in interface ConsistentHashFactory<ReplicatedConsistentHash>state - the state to restorepublic ReplicatedConsistentHash updateMembers(ReplicatedConsistentHash baseCH, List<Address> newMembers, Map<Address,Float> actualCapacityFactors)
ConsistentHashFactorynewMembers list.
If a segment has at least one owner in newMembers, this method will not add another owner.
This guarantees that the new consistent hash can be used immediately, without transferring any state.
If a segment has no owners in newMembers and the ConsistentHash implementation
(e.g. DefaultConsistentHash) requires
at least one owner for each segment, this method may add one or more owners for that segment.
Since the data in that segment was lost, the new consistent hash can still be used without transferring state.
updateMembers in interface ConsistentHashFactory<ReplicatedConsistentHash>baseCH - An existing consistent hash instance, should not be nullnewMembers - A list of addresses representing the new cache members.actualCapacityFactors - The capacity factor of each member. Determines the relative capacity of each node compared
to the others. The implementation may ignore this parameter.
If null, all the members are assumed to have a capacity factor of 1.ConsistentHash instance, or baseCH if the existing instance
does not need any changes.public ReplicatedConsistentHash rebalance(ReplicatedConsistentHash baseCH)
ConsistentHashFactoryrebalance in interface ConsistentHashFactory<ReplicatedConsistentHash>baseCH - An existing consistent hash instance, should not be nullConsistentHash instance, or baseCH if the existing instance
does not need any changes.public ReplicatedConsistentHash union(ReplicatedConsistentHash ch1, ReplicatedConsistentHash ch2)
ConsistentHashFactoryThe owners of a segment s in union(ch1, ch2) will include both the owners of s
in ch1 and the owners of s in ch2, so a cache can switch from using
union(ch1, ch2) to using ch2 without transferring any state.
union in interface ConsistentHashFactory<ReplicatedConsistentHash>Copyright © 2021 JBoss by Red Hat. All rights reserved.