Package org.infinispan.topology
Class ClusterCacheStatus
- java.lang.Object
-
- org.infinispan.topology.ClusterCacheStatus
-
- All Implemented Interfaces:
org.infinispan.partitionhandling.impl.AvailabilityStrategyContext
public class ClusterCacheStatus extends Object implements org.infinispan.partitionhandling.impl.AvailabilityStrategyContext
Keeps track of a cache's status: members, current/pending consistent hashes, and rebalance status- Since:
- 5.2
- Author:
- Dan Berindei
-
-
Field Summary
Fields Modifier and Type Field Description static intINITIAL_REBALANCE_IDstatic intINITIAL_TOPOLOGY_ID
-
Constructor Summary
Constructors Constructor Description ClusterCacheStatus(EmbeddedCacheManager cacheManager, String cacheName, org.infinispan.partitionhandling.impl.AvailabilityStrategy availabilityStrategy, RebalanceType rebalanceType, ClusterTopologyManager clusterTopologyManager, Transport transport, PersistentUUIDManager persistentUUIDManager, org.infinispan.util.logging.events.EventLogManager eventLogManager, Optional<ScopedPersistentState> state, boolean resolveConflictsOnMerge)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConsistentHashcalculateConflictHash(ConsistentHash preferredHash, Set<ConsistentHash> distinctHashes, List<Address> actualMembers)voidconfirmRebalancePhase(Address member, int receivedTopologyId)protected CacheTopologycreateInitialCacheTopology()voiddoHandleClusterView(int viewId)CacheStatusResponsedoJoin(Address joiner, CacheJoinInfo joinInfo)booleandoLeave(Address leaver)voiddoMergePartitions(Map<Address,CacheStatusResponse> statusResponses)voidforceAvailabilityMode(AvailabilityMode newAvailabilityMode)voidforceRebalance()AvailabilityModegetAvailabilityMode()StringgetCacheName()Map<Address,Float>getCapacityFactors()CacheTopologygetCurrentTopology()List<Address>getExpectedMembers()The members of the cache.CacheJoinInfogetJoinInfo()RebalancingStatusgetRebalancingStatus()CacheTopologygetStableTopology()Whenever a new cache topology without apendingCHand with at leastnumOwnersowners for each segment is installed, and the cache isAvailabilityMode.AVAILABLE, the current cache topology is marked as the stable topology.booleanisDistributed()booleanisRebalanceEnabled()booleanisRebalanceInProgress()booleanisTotalOrder()voidqueueConflictResolution(CacheTopology conflictTopology, Set<Address> preferredNodes)Initiates conflict resolution using the conflictTopology, which should have already been broadcast via {@link this#updateTopologiesAfterMerge(CacheTopology, CacheTopology, AvailabilityMode)}voidqueueRebalance(List<Address> newMembers)Queue (or start) a rebalance.booleanresolveConflictsOnMerge()booleanrestartConflictResolution(List<Address> members)If CR is in progress, then this method cancels the current CR and starts a new CR phase with an updated topology based upon newMembers and the previously queued CR topologyprotected CacheTopologyrestoreCacheTopology(ScopedPersistentState state)voidsetInitialTopologyId(int initialTopologyId)voidsetRebalanceEnabled(boolean enabled)voidshutdownCache()voidstartQueuedRebalance()StringtoString()voidupdateAvailabilityMode(List<Address> actualMembers, AvailabilityMode newAvailabilityMode, boolean cancelRebalance)Enter a new availability mode.voidupdateCurrentTopology(List<Address> newMembers)Use the configuredConsistentHashFactoryto create a new CH with the givenmembers, but do not start a rebalance.voidupdateTopologiesAfterMerge(CacheTopology currentTopology, CacheTopology stableTopology, AvailabilityMode availabilityMode)Updates both the stable and the current topologies.
-
-
-
Field Detail
-
INITIAL_TOPOLOGY_ID
public static final int INITIAL_TOPOLOGY_ID
- See Also:
- Constant Field Values
-
INITIAL_REBALANCE_ID
public static final int INITIAL_REBALANCE_ID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ClusterCacheStatus
public ClusterCacheStatus(EmbeddedCacheManager cacheManager, String cacheName, org.infinispan.partitionhandling.impl.AvailabilityStrategy availabilityStrategy, RebalanceType rebalanceType, ClusterTopologyManager clusterTopologyManager, Transport transport, PersistentUUIDManager persistentUUIDManager, org.infinispan.util.logging.events.EventLogManager eventLogManager, Optional<ScopedPersistentState> state, boolean resolveConflictsOnMerge)
-
-
Method Detail
-
getJoinInfo
public CacheJoinInfo getJoinInfo()
- Specified by:
getJoinInfoin interfaceorg.infinispan.partitionhandling.impl.AvailabilityStrategyContext
-
getExpectedMembers
public List<Address> getExpectedMembers()
Description copied from interface:org.infinispan.partitionhandling.impl.AvailabilityStrategyContextThe members of the cache. Includes nodes which have tried to join the cache but are not yet part of the currentCacheTopology. Does not include nodes which have left the cluster (either gracefully or abruptly) but are still in the current topology.- Specified by:
getExpectedMembersin interfaceorg.infinispan.partitionhandling.impl.AvailabilityStrategyContext
-
queueRebalance
public void queueRebalance(List<Address> newMembers)
Description copied from interface:org.infinispan.partitionhandling.impl.AvailabilityStrategyContextQueue (or start) a rebalance. Use the configuredConsistentHashFactoryto create a new balanced consistent hash with the given members. If there is no rebalance in progress, start a rebalance right away. If there is a rebalance in progress, queue another rebalance. If there is a rebalance in the queue as well, it will be replaced with the new one. IfnewConsistentHash == null, remove any queued rebalance.- Specified by:
queueRebalancein interfaceorg.infinispan.partitionhandling.impl.AvailabilityStrategyContext
-
isTotalOrder
public boolean isTotalOrder()
-
isDistributed
public boolean isDistributed()
-
getCapacityFactors
public Map<Address,Float> getCapacityFactors()
- Specified by:
getCapacityFactorsin interfaceorg.infinispan.partitionhandling.impl.AvailabilityStrategyContext
-
getCurrentTopology
public CacheTopology getCurrentTopology()
- Specified by:
getCurrentTopologyin interfaceorg.infinispan.partitionhandling.impl.AvailabilityStrategyContext- Returns:
- The current cache topology.
-
getStableTopology
public CacheTopology getStableTopology()
Description copied from interface:org.infinispan.partitionhandling.impl.AvailabilityStrategyContextWhenever a new cache topology without apendingCHand with at leastnumOwnersowners for each segment is installed, and the cache isAvailabilityMode.AVAILABLE, the current cache topology is marked as the stable topology. The same happens when a rebalance is scheduled to start, but it doesn't do anything because the current topology is already balanced.- Specified by:
getStableTopologyin interfaceorg.infinispan.partitionhandling.impl.AvailabilityStrategyContext- Returns:
- The last stable cache topology. May be
null.
-
getAvailabilityMode
public AvailabilityMode getAvailabilityMode()
- Specified by:
getAvailabilityModein interfaceorg.infinispan.partitionhandling.impl.AvailabilityStrategyContext- Returns:
- The current availability mode.
-
updateAvailabilityMode
public void updateAvailabilityMode(List<Address> actualMembers, AvailabilityMode newAvailabilityMode, boolean cancelRebalance)
Description copied from interface:org.infinispan.partitionhandling.impl.AvailabilityStrategyContextEnter a new availability mode.- Specified by:
updateAvailabilityModein interfaceorg.infinispan.partitionhandling.impl.AvailabilityStrategyContext
-
updateTopologiesAfterMerge
public void updateTopologiesAfterMerge(CacheTopology currentTopology, CacheTopology stableTopology, AvailabilityMode availabilityMode)
Description copied from interface:org.infinispan.partitionhandling.impl.AvailabilityStrategyContextUpdates both the stable and the current topologies. Does not install the current topology on the cache members.- Specified by:
updateTopologiesAfterMergein interfaceorg.infinispan.partitionhandling.impl.AvailabilityStrategyContext
-
isRebalanceInProgress
public boolean isRebalanceInProgress()
-
getRebalancingStatus
public RebalancingStatus getRebalancingStatus()
-
confirmRebalancePhase
public void confirmRebalancePhase(Address member, int receivedTopologyId) throws Exception
- Throws:
Exception
-
doHandleClusterView
public void doHandleClusterView(int viewId)
-
updateCurrentTopology
public void updateCurrentTopology(List<Address> newMembers)
Description copied from interface:org.infinispan.partitionhandling.impl.AvailabilityStrategyContextUse the configuredConsistentHashFactoryto create a new CH with the givenmembers, but do not start a rebalance. Members missing from the current topology are ignored.- Specified by:
updateCurrentTopologyin interfaceorg.infinispan.partitionhandling.impl.AvailabilityStrategyContext
-
doMergePartitions
public void doMergePartitions(Map<Address,CacheStatusResponse> statusResponses)
-
getCacheName
public String getCacheName()
- Specified by:
getCacheNamein interfaceorg.infinispan.partitionhandling.impl.AvailabilityStrategyContext
-
doJoin
public CacheStatusResponse doJoin(Address joiner, CacheJoinInfo joinInfo) throws Exception
- Throws:
Exception
-
restoreCacheTopology
protected CacheTopology restoreCacheTopology(ScopedPersistentState state)
-
createInitialCacheTopology
protected CacheTopology createInitialCacheTopology()
-
startQueuedRebalance
public void startQueuedRebalance()
-
isRebalanceEnabled
public boolean isRebalanceEnabled()
-
setRebalanceEnabled
public void setRebalanceEnabled(boolean enabled)
-
forceRebalance
public void forceRebalance()
-
forceAvailabilityMode
public void forceAvailabilityMode(AvailabilityMode newAvailabilityMode)
-
setInitialTopologyId
public void setInitialTopologyId(int initialTopologyId)
-
resolveConflictsOnMerge
public boolean resolveConflictsOnMerge()
- Specified by:
resolveConflictsOnMergein interfaceorg.infinispan.partitionhandling.impl.AvailabilityStrategyContext- Returns:
- true if
PartitionHandlingConfiguration.mergePolicy()!= null
-
calculateConflictHash
public ConsistentHash calculateConflictHash(ConsistentHash preferredHash, Set<ConsistentHash> distinctHashes, List<Address> actualMembers)
- Specified by:
calculateConflictHashin interfaceorg.infinispan.partitionhandling.impl.AvailabilityStrategyContext- Parameters:
preferredHash- the base consistent hashdistinctHashes- a set of all hashes to be utilised as part of the conflict resolution hashactualMembers- a set of all valid addresses- Returns:
- the hash to be utilised as a pending CH during Phase.CONFLICT_RESOLUTION
-
queueConflictResolution
public void queueConflictResolution(CacheTopology conflictTopology, Set<Address> preferredNodes)
Description copied from interface:org.infinispan.partitionhandling.impl.AvailabilityStrategyContextInitiates conflict resolution using the conflictTopology, which should have already been broadcast via {@link this#updateTopologiesAfterMerge(CacheTopology, CacheTopology, AvailabilityMode)}- Specified by:
queueConflictResolutionin interfaceorg.infinispan.partitionhandling.impl.AvailabilityStrategyContext- Parameters:
conflictTopology- the topology to use during conflict resolutionpreferredNodes- the addresses that belong to the preferred partition as determined by theAvailabilityStrategy
-
restartConflictResolution
public boolean restartConflictResolution(List<Address> members)
Description copied from interface:org.infinispan.partitionhandling.impl.AvailabilityStrategyContextIf CR is in progress, then this method cancels the current CR and starts a new CR phase with an updated topology based upon newMembers and the previously queued CR topology- Specified by:
restartConflictResolutionin interfaceorg.infinispan.partitionhandling.impl.AvailabilityStrategyContext- Parameters:
members- the latest members of the current view- Returns:
- true if conflict resolution was restarted due to the newMembers
-
-