Package org.infinispan.topology
Class ClusterCacheStatus
java.lang.Object
org.infinispan.topology.ClusterCacheStatus
- All Implemented Interfaces:
AvailabilityStrategyContext
Keeps track of a cache's status: members, current/pending consistent hashes, and rebalance status
- Since:
- 5.2
- Author:
- Dan Berindei
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
-
Constructor Summary
ConstructorDescriptionClusterCacheStatus
(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
Modifier and TypeMethodDescriptioncalculateConflictHash
(ConsistentHash preferredHash, Set<ConsistentHash> distinctHashes, List<Address> actualMembers) void
confirmRebalancePhase
(Address member, int receivedTopologyId) protected CacheTopology
void
doHandleClusterView
(int viewId) doJoin
(Address joiner, CacheJoinInfo joinInfo) void
doMergePartitions
(Map<Address, CacheStatusResponse> statusResponses) forceAvailabilityMode
(AvailabilityMode newAvailabilityMode) void
The members of the cache.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
boolean
boolean
void
manuallyUpdateAvailabilityMode
(List<Address> actualMembers, AvailabilityMode mode, boolean cancelRebalance) Enter a new availability mode manually.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
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
boolean
setCurrentTopologyAsStable
(boolean force) void
setInitialTopologyId
(int initialTopologyId) setRebalanceEnabled
(boolean enabled) void
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 Details
-
INITIAL_TOPOLOGY_ID
public static final int INITIAL_TOPOLOGY_ID- See Also:
-
INITIAL_REBALANCE_ID
public static final int INITIAL_REBALANCE_ID- See Also:
-
-
Constructor Details
-
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 Details
-
getJoinInfo
- Specified by:
getJoinInfo
in interfaceAvailabilityStrategyContext
-
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
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
- Specified by:
getCapacityFactors
in interfaceAvailabilityStrategyContext
-
getCurrentTopology
- Specified by:
getCurrentTopology
in interfaceAvailabilityStrategyContext
- Returns:
- The current cache topology.
-
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
- 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
-
manuallyUpdateAvailabilityMode
public void manuallyUpdateAvailabilityMode(List<Address> actualMembers, AvailabilityMode mode, boolean cancelRebalance) Description copied from interface:AvailabilityStrategyContext
Enter a new availability mode manually.- Specified by:
manuallyUpdateAvailabilityMode
in interfaceAvailabilityStrategyContext
-
isManuallyDegraded
public boolean isManuallyDegraded()- Specified by:
isManuallyDegraded
in interfaceAvailabilityStrategyContext
- Returns:
- true if manually set to
AvailabilityMode.DEGRADED_MODE
, and false, otherwise.
-
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
-
confirmRebalancePhase
- Throws:
Exception
-
doHandleClusterView
public void doHandleClusterView(int viewId) -
updateCurrentTopology
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
-
toString
-
doMergePartitions
-
getCacheName
- Specified by:
getCacheName
in interfaceAvailabilityStrategyContext
-
doJoin
-
restoreCacheTopology
-
setCurrentTopologyAsStable
public boolean setCurrentTopologyAsStable(boolean force) -
createInitialCacheTopology
-
doLeave
- Throws:
Exception
-
startQueuedRebalance
public void startQueuedRebalance() -
isRebalanceEnabled
public boolean isRebalanceEnabled() -
setRebalanceEnabled
-
forceRebalance
public void forceRebalance() -
forceAvailabilityMode
-
shutdownCache
-
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
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
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
-