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 int
INITIAL_REBALANCE_ID
static int
INITIAL_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 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)
boolean
doLeave(Address leaver)
void
doMergePartitions(Map<Address,CacheStatusResponse> statusResponses)
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
isDistributed()
boolean
isRebalanceEnabled()
boolean
isRebalanceInProgress()
boolean
isTotalOrder()
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)
void
setRebalanceEnabled(boolean enabled)
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, 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:
getJoinInfo
in interfaceorg.infinispan.partitionhandling.impl.AvailabilityStrategyContext
-
getExpectedMembers
public List<Address> getExpectedMembers()
Description copied from interface:org.infinispan.partitionhandling.impl.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 interfaceorg.infinispan.partitionhandling.impl.AvailabilityStrategyContext
-
queueRebalance
public void queueRebalance(List<Address> newMembers)
Description copied from interface:org.infinispan.partitionhandling.impl.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 interfaceorg.infinispan.partitionhandling.impl.AvailabilityStrategyContext
-
isTotalOrder
public boolean isTotalOrder()
-
isDistributed
public boolean isDistributed()
-
getCapacityFactors
public Map<Address,Float> getCapacityFactors()
- Specified by:
getCapacityFactors
in interfaceorg.infinispan.partitionhandling.impl.AvailabilityStrategyContext
-
getCurrentTopology
public CacheTopology getCurrentTopology()
- Specified by:
getCurrentTopology
in interfaceorg.infinispan.partitionhandling.impl.AvailabilityStrategyContext
- Returns:
- The current cache topology.
-
getStableTopology
public CacheTopology getStableTopology()
Description copied from interface:org.infinispan.partitionhandling.impl.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 interfaceorg.infinispan.partitionhandling.impl.AvailabilityStrategyContext
- Returns:
- The last stable cache topology. May be
null
.
-
getAvailabilityMode
public AvailabilityMode getAvailabilityMode()
- Specified by:
getAvailabilityMode
in 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.AvailabilityStrategyContext
Enter a new availability mode.- Specified by:
updateAvailabilityMode
in interfaceorg.infinispan.partitionhandling.impl.AvailabilityStrategyContext
-
updateTopologiesAfterMerge
public void updateTopologiesAfterMerge(CacheTopology currentTopology, CacheTopology stableTopology, AvailabilityMode availabilityMode)
Description copied from interface:org.infinispan.partitionhandling.impl.AvailabilityStrategyContext
Updates both the stable and the current topologies. Does not install the current topology on the cache members.- Specified by:
updateTopologiesAfterMerge
in 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.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 interfaceorg.infinispan.partitionhandling.impl.AvailabilityStrategyContext
-
doMergePartitions
public void doMergePartitions(Map<Address,CacheStatusResponse> statusResponses)
-
getCacheName
public String getCacheName()
- Specified by:
getCacheName
in 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:
resolveConflictsOnMerge
in 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:
calculateConflictHash
in 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.AvailabilityStrategyContext
Initiates conflict resolution using the conflictTopology, which should have already been broadcast via {@link this#updateTopologiesAfterMerge(CacheTopology, CacheTopology, AvailabilityMode)}- Specified by:
queueConflictResolution
in 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.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 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
-
-