Class AbstractConsistentHash
- java.lang.Object
-
- org.infinispan.distribution.ch.impl.AbstractConsistentHash
-
- All Implemented Interfaces:
ConsistentHash
- Direct Known Subclasses:
DefaultConsistentHash,ScatteredConsistentHash
public abstract class AbstractConsistentHash extends Object implements ConsistentHash
- Author:
- Radim Vansa <rvansa@redhat.com>
-
-
Field Summary
Fields Modifier and Type Field Description protected float[]capacityFactorsprotected List<Address>membersThe membership of the cache topology that uses this CH.protected static StringSTATE_CAPACITY_FACTORprotected static StringSTATE_CAPACITY_FACTORSprotected static StringSTATE_NUM_SEGMENTS
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractConsistentHash(int numSegments, List<Address> members, float[] capacityFactors)protectedAbstractConsistentHash(int numSegments, List<Address> members, Map<Address,Float> capacityFactors)protectedAbstractConsistentHash(ScopedPersistentState state)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckSameHashAndSegments(AbstractConsistentHash dch2)Map<Address,Float>getCapacityFactors()The capacity factor of each member.List<Address>getMembers()Should return the addresses of the nodes used to create this consistent hash.protected static voidmergeLists(List<Address> dest, List<Address> src)Adds all elements fromsrclist that do not already exist indestlist to the latter.protected static float[]parseCapacityFactors(ScopedPersistentState state)protected static org.infinispan.commons.hash.HashparseHashFunction(ScopedPersistentState state)protected static List<Address>parseMembers(ScopedPersistentState state)protected static intparseNumSegments(ScopedPersistentState state)protected Map<Address,Float>remapCapacityFactors(UnaryOperator<Address> remapper)protected List<Address>remapMembers(UnaryOperator<Address> remapper)voidtoScopedState(ScopedPersistentState state)Writes this ConsistentHash to the specified scoped state.protected Map<Address,Float>unionCapacityFactors(AbstractConsistentHash ch2)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.infinispan.distribution.ch.ConsistentHash
getNumSegments, getPrimarySegmentsForOwner, getRoutingTableAsString, getSegmentsForOwner, isReplicated, isSegmentLocalToNode, locateOwnersForSegment, locatePrimaryOwnerForSegment, remapAddresses
-
-
-
-
Field Detail
-
STATE_CAPACITY_FACTOR
protected static final String STATE_CAPACITY_FACTOR
- See Also:
- Constant Field Values
-
STATE_CAPACITY_FACTORS
protected static final String STATE_CAPACITY_FACTORS
- See Also:
- Constant Field Values
-
STATE_NUM_SEGMENTS
protected static final String STATE_NUM_SEGMENTS
- See Also:
- Constant Field Values
-
members
protected final List<Address> members
The membership of the cache topology that uses this CH.
-
capacityFactors
protected final float[] capacityFactors
-
-
Constructor Detail
-
AbstractConsistentHash
protected AbstractConsistentHash(int numSegments, List<Address> members, Map<Address,Float> capacityFactors)
-
AbstractConsistentHash
protected AbstractConsistentHash(int numSegments, List<Address> members, float[] capacityFactors)
-
AbstractConsistentHash
protected AbstractConsistentHash(ScopedPersistentState state)
-
-
Method Detail
-
parseNumSegments
protected static int parseNumSegments(ScopedPersistentState state)
-
parseMembers
protected static List<Address> parseMembers(ScopedPersistentState state)
-
parseHashFunction
protected static org.infinispan.commons.hash.Hash parseHashFunction(ScopedPersistentState state)
-
parseCapacityFactors
protected static float[] parseCapacityFactors(ScopedPersistentState state)
-
toScopedState
public void toScopedState(ScopedPersistentState state)
Description copied from interface:ConsistentHashWrites this ConsistentHash to the specified scoped state. Before invoking this method, the ConsistentHash addresses will have to be replaced with their correspondingPersistentUUIDs- Specified by:
toScopedStatein interfaceConsistentHash- Parameters:
state- the state to which this ConsistentHash will be written
-
getMembers
public List<Address> getMembers()
Description copied from interface:ConsistentHashShould return the addresses of the nodes used to create this consistent hash.- Specified by:
getMembersin interfaceConsistentHash- Returns:
- set of node addresses.
-
mergeLists
protected static void mergeLists(List<Address> dest, List<Address> src)
Adds all elements fromsrclist that do not already exist indestlist to the latter.- Parameters:
dest- List where elements are addedsrc- List of elements to add - this is never modified
-
getCapacityFactors
public Map<Address,Float> getCapacityFactors()
Description copied from interface:ConsistentHashThe capacity factor of each member. Determines the relative capacity of each node compared to the others. Ifnull, all the members are assumed to have a capacity factor of 1.- Specified by:
getCapacityFactorsin interfaceConsistentHash
-
unionCapacityFactors
protected Map<Address,Float> unionCapacityFactors(AbstractConsistentHash ch2)
-
checkSameHashAndSegments
protected void checkSameHashAndSegments(AbstractConsistentHash dch2)
-
remapCapacityFactors
protected Map<Address,Float> remapCapacityFactors(UnaryOperator<Address> remapper)
-
remapMembers
protected List<Address> remapMembers(UnaryOperator<Address> remapper)
-
-