Interface AvailabilityStrategyContext
-
- All Known Implementing Classes:
ClusterCacheStatus
public interface AvailabilityStrategyContext
Contains information about the current state of the cache. Also allowsAvailabilityStrategy
to proceed with a rebalance, a membership update, or an availability mode change.- Author:
- Mircea Markus, Dan Berindei
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ConsistentHash
calculateConflictHash(ConsistentHash preferredHash, Set<ConsistentHash> distinctHashes, List<Address> actualMembers)
AvailabilityMode
getAvailabilityMode()
String
getCacheName()
Map<Address,Float>
getCapacityFactors()
CacheTopology
getCurrentTopology()
List<Address>
getExpectedMembers()
The members of the cache.CacheJoinInfo
getJoinInfo()
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.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> 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 topologyvoid
updateAvailabilityMode(List<Address> actualMembers, AvailabilityMode mode, 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.
-
-
-
Method Detail
-
getCacheName
String getCacheName()
-
getJoinInfo
CacheJoinInfo getJoinInfo()
-
getCurrentTopology
CacheTopology getCurrentTopology()
- Returns:
- The current cache topology.
-
getStableTopology
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. 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
List<Address> 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
void queueRebalance(List<Address> newMembers)
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.
-
updateCurrentTopology
void updateCurrentTopology(List<Address> newMembers)
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.
-
updateAvailabilityMode
void updateAvailabilityMode(List<Address> actualMembers, AvailabilityMode mode, boolean cancelRebalance)
Enter a new availability mode.
-
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
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)}- Parameters:
conflictTopology
- the topology to use during conflict resolutionpreferredNodes
- the addresses that belong to the preferred partition as determined by theAvailabilityStrategy
-
restartConflictResolution
boolean restartConflictResolution(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 topology- Parameters:
newMembers
- the latest members of the current view- Returns:
- true if conflict resolution was restarted due to the newMembers
-
-