Package org.infinispan.topology
Class LocalTopologyManagerImpl
java.lang.Object
org.infinispan.topology.LocalTopologyManagerImpl
- All Implemented Interfaces:
GlobalStateProvider,LocalTopologyManager
@MBean(objectName="LocalTopologyManager",
description="Controls the cache membership and state transfer")
public class LocalTopologyManagerImpl
extends Object
implements LocalTopologyManager, GlobalStateProvider
The
LocalTopologyManager implementation.- Since:
- 5.2
- Author:
- Dan Berindei
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidassertTopologyStable(String cacheName) Asserts the cache with the given name has a stable topology installed.voidcacheShutdown(String name) Initiates a cluster-wide cache shutdown for the specified cachevoidconfirmRebalancePhase(String cacheName, int topologyId, int rebalanceId, Throwable throwable) Confirm that the local cachecacheNamehas finished receiving the new data for topologytopologyId.executeOnCoordinatorRetry(ReplicableCommand command, int viewId, long endNanos) getCacheAvailability(String cacheName) Retrieves the availability state of a cache.getCacheTopology(String cacheName) Returns the local UUID of this node.getRebalancingStatus(String cacheName) Retrieve the rebalancing status for the specified cachegetStableCacheTopology(String cacheName) handleCacheShutdown(String cacheName) Handles the local operations related to gracefully shutting down a cachehandleRebalance(String cacheName, CacheTopology cacheTopology, int viewId, Address sender) Performs the state transfer.handleStableTopologyUpdate(String cacheName, CacheTopology newStableTopology, Address sender, int viewId) Update the stable cache topology.handleStatusRequest(int viewId) Recovers the current topology information for all running caches and returns it to the coordinator.handleTopologyUpdate(String cacheName, CacheTopology cacheTopology, AvailabilityMode availabilityMode, int viewId, Address sender) Updates the current and/or pending consistent hash, without transferring any state.booleanisCacheRebalancingEnabled(String cacheName) Checks whether rebalancing is enabled for the specified cache.booleanChecks whether rebalancing is enabled for the entire cluster.join(String cacheName, CacheJoinInfo joinInfo, CacheTopologyHandler stm, PartitionHandlingManager phm) Forwards the join request to the coordinator.voidForwards the leave request to the coordinator.voidThis method is invoked by theGlobalStateManagerjust before persisting the global statevoidThis method is invoked by theGlobalStateManagerafter starting up to notify that global state has been restored.voidpreStart()voidsetCacheAvailability(String cacheName, AvailabilityMode availabilityMode) Updates the availability state of a cache (for the entire cluster).voidsetCacheRebalancingEnabled(String cacheName, boolean enabled) Enable or disable rebalancing for the specified cache.voidsetRebalancingEnabled(boolean enabled) Enable or disable rebalancing in the entire cluster.stableTopologyCompletion(String cacheName) Returns aCompletionStagethat completes when the cache with the namecacheNamehas a stable topology.voidstart()voidstop()
-
Constructor Details
-
LocalTopologyManagerImpl
public LocalTopologyManagerImpl()
-
-
Method Details
-
preStart
public void preStart() -
start
public void start() -
stop
public void stop() -
join
public CompletionStage<CacheTopology> join(String cacheName, CacheJoinInfo joinInfo, CacheTopologyHandler stm, PartitionHandlingManager phm) Description copied from interface:LocalTopologyManagerForwards the join request to the coordinator.- Specified by:
joinin interfaceLocalTopologyManager- Returns:
- The current consistent hash.
-
leave
Description copied from interface:LocalTopologyManagerForwards the leave request to the coordinator.- Specified by:
leavein interfaceLocalTopologyManager
-
confirmRebalancePhase
public void confirmRebalancePhase(String cacheName, int topologyId, int rebalanceId, Throwable throwable) Description copied from interface:LocalTopologyManagerConfirm that the local cachecacheNamehas finished receiving the new data for topologytopologyId.The coordinator can change during the state transfer, so we make the rebalance RPC async and we send the response as a different command.
- Specified by:
confirmRebalancePhasein interfaceLocalTopologyManager- Parameters:
cacheName- the name of the cachetopologyId- the current topology id of the node at the time the rebalance is completed.rebalanceId- the id of the current rebalancethrowable-nullunless local rebalance ended because of an error.
-
handleStatusRequest
Description copied from interface:LocalTopologyManagerRecovers the current topology information for all running caches and returns it to the coordinator.- Specified by:
handleStatusRequestin interfaceLocalTopologyManager- Parameters:
viewId- The coordinator's view id
-
handleTopologyUpdate
public CompletionStage<Void> handleTopologyUpdate(String cacheName, CacheTopology cacheTopology, AvailabilityMode availabilityMode, int viewId, Address sender) Description copied from interface:LocalTopologyManagerUpdates the current and/or pending consistent hash, without transferring any state.- Specified by:
handleTopologyUpdatein interfaceLocalTopologyManager
-
handleStableTopologyUpdate
public CompletionStage<Void> handleStableTopologyUpdate(String cacheName, CacheTopology newStableTopology, Address sender, int viewId) Description copied from interface:LocalTopologyManagerUpdate the stable cache topology.Mostly needed for backup, so that a new coordinator can recover the stable topology of the cluster.
- Specified by:
handleStableTopologyUpdatein interfaceLocalTopologyManager
-
handleRebalance
public CompletionStage<Void> handleRebalance(String cacheName, CacheTopology cacheTopology, int viewId, Address sender) Description copied from interface:LocalTopologyManagerPerforms the state transfer.- Specified by:
handleRebalancein interfaceLocalTopologyManager
-
getCacheTopology
- Specified by:
getCacheTopologyin interfaceLocalTopologyManager- Returns:
- the current topology for a cache.
-
getStableCacheTopology
- Specified by:
getStableCacheTopologyin interfaceLocalTopologyManager- Returns:
- the last stable topology for a cache.
-
isRebalancingEnabled
@ManagedAttribute(description="Rebalancing enabled", displayName="Rebalancing enabled", dataType=TRAIT, writable=true) public boolean isRebalancingEnabled()Description copied from interface:LocalTopologyManagerChecks whether rebalancing is enabled for the entire cluster.- Specified by:
isRebalancingEnabledin interfaceLocalTopologyManager
-
setRebalancingEnabled
public void setRebalancingEnabled(boolean enabled) Description copied from interface:LocalTopologyManagerEnable or disable rebalancing in the entire cluster.- Specified by:
setRebalancingEnabledin interfaceLocalTopologyManager
-
isCacheRebalancingEnabled
Description copied from interface:LocalTopologyManagerChecks whether rebalancing is enabled for the specified cache.- Specified by:
isCacheRebalancingEnabledin interfaceLocalTopologyManager
-
executeOnCoordinatorRetry
public CompletionStage<Object> executeOnCoordinatorRetry(ReplicableCommand command, int viewId, long endNanos) -
setCacheRebalancingEnabled
Description copied from interface:LocalTopologyManagerEnable or disable rebalancing for the specified cache.- Specified by:
setCacheRebalancingEnabledin interfaceLocalTopologyManager
-
getRebalancingStatus
Description copied from interface:LocalTopologyManagerRetrieve the rebalancing status for the specified cache- Specified by:
getRebalancingStatusin interfaceLocalTopologyManager
-
getClusterAvailability
@ManagedAttribute(description="Cluster availability", displayName="Cluster availability", dataType=TRAIT, writable=false) public String getClusterAvailability() -
getCacheAvailability
Description copied from interface:LocalTopologyManagerRetrieves the availability state of a cache.- Specified by:
getCacheAvailabilityin interfaceLocalTopologyManager
-
setCacheAvailability
Description copied from interface:LocalTopologyManagerUpdates the availability state of a cache (for the entire cluster).- Specified by:
setCacheAvailabilityin interfaceLocalTopologyManager
-
cacheShutdown
Description copied from interface:LocalTopologyManagerInitiates a cluster-wide cache shutdown for the specified cache- Specified by:
cacheShutdownin interfaceLocalTopologyManager
-
handleCacheShutdown
Description copied from interface:LocalTopologyManagerHandles the local operations related to gracefully shutting down a cache- Specified by:
handleCacheShutdownin interfaceLocalTopologyManager
-
stableTopologyCompletion
Description copied from interface:LocalTopologyManagerReturns aCompletionStagethat completes when the cache with the namecacheNamehas a stable topology. Returns null if the cache does not exist.- Specified by:
stableTopologyCompletionin interfaceLocalTopologyManager
-
assertTopologyStable
Description copied from interface:LocalTopologyManagerAsserts the cache with the given name has a stable topology installed.- Specified by:
assertTopologyStablein interfaceLocalTopologyManager- Parameters:
cacheName- : The cache name to search.
-
prepareForPersist
Description copied from interface:GlobalStateProviderThis method is invoked by theGlobalStateManagerjust before persisting the global state- Specified by:
prepareForPersistin interfaceGlobalStateProvider
-
prepareForRestore
Description copied from interface:GlobalStateProviderThis method is invoked by theGlobalStateManagerafter starting up to notify that global state has been restored.- Specified by:
prepareForRestorein interfaceGlobalStateProvider
-
getPersistentUUID
Description copied from interface:LocalTopologyManagerReturns the local UUID of this node. If global state persistence is enabled, this UUID will be saved and reused across restarts- Specified by:
getPersistentUUIDin interfaceLocalTopologyManager
-