Interface AvailabilityStrategyContext
- All Known Implementing Classes:
ClusterCacheStatus
public interface AvailabilityStrategyContext
Contains information about the current state of the cache.
Also allows
AvailabilityStrategy to proceed with a rebalance, a membership update, or an availability mode change.
Implementations should not use blocking calls.- Author:
- Mircea Markus, Dan Berindei
-
Method Summary
Modifier and TypeMethodDescriptioncalculateConflictHash(ConsistentHash preferredHash, Set<ConsistentHash> distinctHashes, List<Address> actualMembers) The members of the cache.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.booleanvoidmanuallyUpdateAvailabilityMode(List<Address> actualMembers, AvailabilityMode mode, boolean cancelRebalance) Enter a new availability mode manually.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.booleanbooleanrestartConflictResolution(List<Address> newMembers) 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 topologyvoidupdateAvailabilityMode(List<Address> actualMembers, AvailabilityMode mode, 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.
-
Method Details
-
getCacheName
String getCacheName() -
getJoinInfo
CacheJoinInfo getJoinInfo() -
getCapacityFactors
-
getCurrentTopology
CacheTopology getCurrentTopology()- Returns:
- The current cache topology.
-
getStableTopology
CacheTopology getStableTopology()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. The same happens when a rebalance is scheduled to start, but it doesn't do anything because the current topology is already balanced.- Returns:
- The last stable cache topology. May be
null.
-
getAvailabilityMode
AvailabilityMode getAvailabilityMode()- Returns:
- The current availability mode.
-
getExpectedMembers
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. -
queueRebalance
Queue (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. -
updateCurrentTopology
Use the configuredConsistentHashFactoryto create a new CH with the givenmembers, but do not start a rebalance. Members missing from the current topology are ignored. -
updateAvailabilityMode
void updateAvailabilityMode(List<Address> actualMembers, AvailabilityMode mode, boolean cancelRebalance) Enter a new availability mode. -
manuallyUpdateAvailabilityMode
void manuallyUpdateAvailabilityMode(List<Address> actualMembers, AvailabilityMode mode, boolean cancelRebalance) Enter a new availability mode manually. -
updateTopologiesAfterMerge
void updateTopologiesAfterMerge(CacheTopology currentTopology, CacheTopology stableTopology, AvailabilityMode availabilityMode) Updates both the stable and the current topologies. Does not install the current topology on the cache members. -
resolveConflictsOnMerge
boolean resolveConflictsOnMerge()- Returns:
- true if
PartitionHandlingConfiguration.mergePolicy()!= null
-
calculateConflictHash
ConsistentHash calculateConflictHash(ConsistentHash preferredHash, Set<ConsistentHash> distinctHashes, List<Address> actualMembers) - 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
Initiates conflict resolution using the conflictTopology, which should have already been broadcast via {@link this#updateTopologiesAfterMerge(CacheTopology, CacheTopology, AvailabilityMode)}- Parameters:
conflictTopology- the topology to use during conflict resolutionpreferredNodes- the addresses that belong to the preferred partition as determined by theAvailabilityStrategy
-
restartConflictResolution
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- Parameters:
newMembers- the latest members of the current view- Returns:
- true if conflict resolution was restarted due to the newMembers
-
isManuallyDegraded
boolean isManuallyDegraded()- Returns:
- true if manually set to
AvailabilityMode.DEGRADED_MODE, and false, otherwise.
-