Class ScatteredConsistentHashFactory
- java.lang.Object
-
- org.infinispan.distribution.ch.impl.AbstractConsistentHashFactory<ScatteredConsistentHash>
-
- org.infinispan.distribution.ch.impl.ScatteredConsistentHashFactory
-
- All Implemented Interfaces:
ConsistentHashFactory<ScatteredConsistentHash>
public class ScatteredConsistentHashFactory extends AbstractConsistentHashFactory<ScatteredConsistentHash>
Based onDefaultConsistentHashFactory.- Since:
- 9.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classScatteredConsistentHashFactory.Builderstatic classScatteredConsistentHashFactory.Externalizer
-
Constructor Summary
Constructors Constructor Description ScatteredConsistentHashFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ScatteredConsistentHashcreate(int numOwners, int numSegments, List<Address> members, Map<Address,Float> capacityFactors)Create a new consistent hash instance.booleanequals(Object other)ScatteredConsistentHashfromPersistentState(ScopedPersistentState state)Recreates a ConsistentHash from a previously stored persistent state.inthashCode()ScatteredConsistentHashrebalance(ScatteredConsistentHash baseCH)Create a new consistent hash instance, based on an existing instance, but balanced according to the implementation's rules.protected voidrebalanceBuilder(ScatteredConsistentHashFactory.Builder builder)protected voidreplacePrimaryOwners(ScatteredConsistentHashFactory.Builder builder)ScatteredConsistentHashunion(ScatteredConsistentHash dch1, ScatteredConsistentHash dch2)Merges two consistent hash objects that have the same number of segments, numOwners and hash function.ScatteredConsistentHashupdateMembers(ScatteredConsistentHash baseCH, List<Address> actualMembers, Map<Address,Float> actualCapacityFactors)Leavers are removed and segments without owners are assigned new owners.-
Methods inherited from class org.infinispan.distribution.ch.impl.AbstractConsistentHashFactory
checkCapacityFactors, findNewPrimaryOwner, findWorstPrimaryOwner
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.infinispan.distribution.ch.ConsistentHashFactory
create
-
-
-
-
Method Detail
-
create
public ScatteredConsistentHash create(int numOwners, int numSegments, List<Address> members, Map<Address,Float> capacityFactors)
Description copied from interface:ConsistentHashFactoryCreate a new consistent hash instance. The consistent hash will be balanced.- Parameters:
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. Ifnull, all the members are assumed to have a capacity factor of 1.
-
fromPersistentState
public ScatteredConsistentHash fromPersistentState(ScopedPersistentState state)
Description copied from interface:ConsistentHashFactoryRecreates a ConsistentHash from a previously stored persistent state. The returned ConsistentHash will not have proper addresses, butPersistentUUIDs instead so they will need to be replaced- Parameters:
state- the state to restore
-
updateMembers
public ScatteredConsistentHash updateMembers(ScatteredConsistentHash baseCH, List<Address> actualMembers, Map<Address,Float> actualCapacityFactors)
Leavers are removed and segments without owners are assigned new owners. Joiners might get some of the un-owned segments but otherwise they are not taken into account (that should happen during a rebalance).- Parameters:
baseCH- An existing consistent hash instance, should not benullactualMembers- 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. Ifnull, all the members are assumed to have a capacity factor of 1.- Returns:
-
rebalance
public ScatteredConsistentHash rebalance(ScatteredConsistentHash baseCH)
Description copied from interface:ConsistentHashFactoryCreate a new consistent hash instance, based on an existing instance, but balanced according to the implementation's rules.- Parameters:
baseCH- An existing consistent hash instance, should not benull- Returns:
- A new
ConsistentHashinstance, orbaseCHif the existing instance does not need any changes.
-
union
public ScatteredConsistentHash union(ScatteredConsistentHash dch1, ScatteredConsistentHash dch2)
Merges two consistent hash objects that have the same number of segments, numOwners and hash function. For each segment, the primary owner of the first CH has priority, the other primary owners become backups.
-
rebalanceBuilder
protected void rebalanceBuilder(ScatteredConsistentHashFactory.Builder builder)
-
replacePrimaryOwners
protected void replacePrimaryOwners(ScatteredConsistentHashFactory.Builder builder)
-
-