Package org.infinispan.topology
Class ClusterCacheStatus
- java.lang.Object
-
- org.infinispan.topology.ClusterCacheStatus
-
- All Implemented Interfaces:
AvailabilityStrategyContext
public class ClusterCacheStatus extends Object implements 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 int
INITIAL_REBALANCE_ID
static int
INITIAL_TOPOLOGY_ID
-
Constructor Summary
Constructors Constructor Description ClusterCacheStatus(EmbeddedCacheManager cacheManager, GlobalComponentRegistry gcr, String cacheName, AvailabilityStrategy availabilityStrategy, org.infinispan.statetransfer.RebalanceType rebalanceType, ClusterTopologyManagerImpl 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 ConsistentHash
calculateConflictHash(ConsistentHash preferredHash, Set<ConsistentHash> distinctHashes, List<Address> actualMembers)
void
confirmRebalancePhase(Address member, int receivedTopologyId)
protected CacheTopology
createInitialCacheTopology()
void
doHandleClusterView(int viewId)
CacheStatusResponse
doJoin(Address joiner, CacheJoinInfo joinInfo)
CompletionStage<Void>
doLeave(Address leaver)
void
doMergePartitions(Map<Address,CacheStatusResponse> statusResponses)
CompletionStage<Void>
forceAvailabilityMode(AvailabilityMode newAvailabilityMode)
void
forceRebalance()
AvailabilityMode
getAvailabilityMode()
String
getCacheName()
Map<Address,Float>
getCapacityFactors()
CacheTopology
getCurrentTopology()
List<Address>
getExpectedMembers()
The members of the cache.CacheJoinInfo
getJoinInfo()
RebalancingStatus
getRebalancingStatus()
CacheTopology
getStableTopology()
Whenever a new cache topology without apendingCH
and with at leastnumOwners
owners for each segment is installed, and the cache isAvailabilityMode.AVAILABLE
, the current cache topology is marked as the stable topology.boolean
isRebalanceEnabled()
boolean
isRebalanceInProgress()
void
queueConflictResolution(CacheTopology conflictTopology, Set<Address> preferredNodes)
Initiates conflict resolution using the conflictTopology, which should have already been broadcast via {@link this#updateTopologiesAfterMerge(CacheTopology, CacheTopology, AvailabilityMode)}void
queueRebalance(List<Address> newMembers)
Queue (or start) a rebalance.boolean
resolveConflictsOnMerge()
boolean
restartConflictResolution(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 CacheTopology
restoreCacheTopology(ScopedPersistentState state)
void
setInitialTopologyId(int initialTopologyId)
CompletionStage<Void>
setRebalanceEnabled(boolean enabled)
CompletionStage<Void>
shutdownCache()
void
startQueuedRebalance()
String
toString()
void
updateAvailabilityMode(List<Address> actualMembers, AvailabilityMode newAvailabilityMode, boolean cancelRebalance)
Enter a new availability mode.void
updateCurrentTopology(List<Address> newMembers)
Use the configuredConsistentHashFactory
to create a new CH with the givenmembers
, but do not start a rebalance.void
updateTopologiesAfterMerge(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, GlobalComponentRegistry gcr, String cacheName, AvailabilityStrategy availabilityStrategy, org.infinispan.statetransfer.RebalanceType rebalanceType, ClusterTopologyManagerImpl 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:
getJoinInfo
in interfaceAvailabilityStrategyContext
-
getExpectedMembers
public List<Address> getExpectedMembers()
Description copied from interface:AvailabilityStrategyContext
The 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:
getExpectedMembers
in interfaceAvailabilityStrategyContext
-
queueRebalance
public void queueRebalance(List<Address> newMembers)
Description copied from interface:AvailabilityStrategyContext
Queue (or start) a rebalance. Use the configuredConsistentHashFactory
to 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:
queueRebalance
in interfaceAvailabilityStrategyContext
-
getCapacityFactors
public Map<Address,Float> getCapacityFactors()
- Specified by:
getCapacityFactors
in interfaceAvailabilityStrategyContext
-
getCurrentTopology
public CacheTopology getCurrentTopology()
- Specified by:
getCurrentTopology
in interfaceAvailabilityStrategyContext
- Returns:
- The current cache topology.
-
getStableTopology
public CacheTopology getStableTopology()
Description copied from interface:AvailabilityStrategyContext
Whenever a new cache topology without apendingCH
and with at leastnumOwners
owners 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:
getStableTopology
in interfaceAvailabilityStrategyContext
- Returns:
- The last stable cache topology. May be
null
.
-
getAvailabilityMode
public AvailabilityMode getAvailabilityMode()
- Specified by:
getAvailabilityMode
in interfaceAvailabilityStrategyContext
- Returns:
- The current availability mode.
-
updateAvailabilityMode
public void updateAvailabilityMode(List<Address> actualMembers, AvailabilityMode newAvailabilityMode, boolean cancelRebalance)
Description copied from interface:AvailabilityStrategyContext
Enter a new availability mode.- Specified by:
updateAvailabilityMode
in interfaceAvailabilityStrategyContext
-
updateTopologiesAfterMerge
public void updateTopologiesAfterMerge(CacheTopology currentTopology, CacheTopology stableTopology, AvailabilityMode availabilityMode)
Description copied from interface:AvailabilityStrategyContext
Updates both the stable and the current topologies. Does not install the current topology on the cache members.- Specified by:
updateTopologiesAfterMerge
in interfaceAvailabilityStrategyContext
-
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:AvailabilityStrategyContext
Use the configuredConsistentHashFactory
to create a new CH with the givenmembers
, but do not start a rebalance. Members missing from the current topology are ignored.- Specified by:
updateCurrentTopology
in interfaceAvailabilityStrategyContext
-
doMergePartitions
public void doMergePartitions(Map<Address,CacheStatusResponse> statusResponses)
-
getCacheName
public String getCacheName()
- Specified by:
getCacheName
in interfaceAvailabilityStrategyContext
-
doJoin
public CacheStatusResponse doJoin(Address joiner, CacheJoinInfo joinInfo)
-
restoreCacheTopology
protected CacheTopology restoreCacheTopology(ScopedPersistentState state)
-
createInitialCacheTopology
protected CacheTopology createInitialCacheTopology()
-
doLeave
public CompletionStage<Void> doLeave(Address leaver) throws Exception
- Throws:
Exception
-
startQueuedRebalance
public void startQueuedRebalance()
-
isRebalanceEnabled
public boolean isRebalanceEnabled()
-
setRebalanceEnabled
public CompletionStage<Void> setRebalanceEnabled(boolean enabled)
-
forceRebalance
public void forceRebalance()
-
forceAvailabilityMode
public CompletionStage<Void> forceAvailabilityMode(AvailabilityMode newAvailabilityMode)
-
shutdownCache
public CompletionStage<Void> shutdownCache() throws Exception
- Throws:
Exception
-
setInitialTopologyId
public void setInitialTopologyId(int initialTopologyId)
-
resolveConflictsOnMerge
public boolean resolveConflictsOnMerge()
- Specified by:
resolveConflictsOnMerge
in interfaceAvailabilityStrategyContext
- Returns:
- true if
PartitionHandlingConfiguration.mergePolicy()
!= null
-
calculateConflictHash
public ConsistentHash calculateConflictHash(ConsistentHash preferredHash, Set<ConsistentHash> distinctHashes, List<Address> actualMembers)
- Specified by:
calculateConflictHash
in interfaceAvailabilityStrategyContext
- 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:AvailabilityStrategyContext
Initiates conflict resolution using the conflictTopology, which should have already been broadcast via {@link this#updateTopologiesAfterMerge(CacheTopology, CacheTopology, AvailabilityMode)}- Specified by:
queueConflictResolution
in interfaceAvailabilityStrategyContext
- 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:AvailabilityStrategyContext
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 topology- Specified by:
restartConflictResolution
in interfaceAvailabilityStrategyContext
- Parameters:
members
- the latest members of the current view- Returns:
- true if conflict resolution was restarted due to the newMembers
-
-