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, GlobalStateProviderTheLocalTopologyManagerimplementation.- Since:
- 5.2
- Author:
- Dan Berindei
-
-
Constructor Summary
Constructors Constructor Description LocalTopologyManagerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.CompletionStage<Object>executeOnCoordinatorRetry(ReplicableCommand command, int viewId, long endNanos)AvailabilityModegetCacheAvailability(String cacheName)Retrieves the availability state of a cache.CacheTopologygetCacheTopology(String cacheName)StringgetClusterAvailability()PersistentUUIDgetPersistentUUID()Returns the local UUID of this node.RebalancingStatusgetRebalancingStatus(String cacheName)Retrieve the rebalancing status for the specified cacheCacheTopologygetStableCacheTopology(String cacheName)CompletionStage<Void>handleCacheShutdown(String cacheName)Handles the local operations related to gracefully shutting down a cacheCompletionStage<CacheTopology>handleJoinResponse(String cacheName, org.infinispan.topology.LocalCacheStatus cacheStatus, CacheStatusResponse initialStatus)CompletionStage<Void>handleRebalance(String cacheName, CacheTopology cacheTopology, int viewId, Address sender)Performs the state transfer.CompletionStage<Void>handleStableTopologyUpdate(String cacheName, CacheTopology newStableTopology, Address sender, int viewId)Update the stable cache topology.CompletionStage<ManagerStatusResponse>handleStatusRequest(int viewId)Recovers the current topology information for all running caches and returns it to the coordinator.CompletionStage<Void>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.booleanisRebalancingEnabled()Checks whether rebalancing is enabled for the entire cluster.CompletionStage<CacheTopology>join(String cacheName, CacheJoinInfo joinInfo, CacheTopologyHandler stm, PartitionHandlingManager phm)Forwards the join request to the coordinator.voidleave(String cacheName, long timeout)Forwards the leave request to the coordinator.voidprepareForPersist(ScopedPersistentState state)This method is invoked by theGlobalStateManagerjust before persisting the global statevoidprepareForRestore(ScopedPersistentState state)This method is invoked by theGlobalStateManagerafter starting up to notify that global state has been restored.voidpreStart()CompletionStage<CacheStatusResponse>sendJoinRequest(String cacheName, CacheJoinInfo joinInfo, long timeout, long endTime)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.voidstart()voidstop()
-
-
-
Method Detail
-
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.
-
sendJoinRequest
public CompletionStage<CacheStatusResponse> sendJoinRequest(String cacheName, CacheJoinInfo joinInfo, long timeout, long endTime)
-
handleJoinResponse
public CompletionStage<CacheTopology> handleJoinResponse(String cacheName, org.infinispan.topology.LocalCacheStatus cacheStatus, CacheStatusResponse initialStatus)
-
leave
public void leave(String cacheName, long timeout)
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
public CompletionStage<ManagerStatusResponse> handleStatusRequest(int viewId)
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
public CacheTopology getCacheTopology(String cacheName)
- Specified by:
getCacheTopologyin interfaceLocalTopologyManager- Returns:
- the current topology for a cache.
-
getStableCacheTopology
public CacheTopology getStableCacheTopology(String cacheName)
- 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
public boolean isCacheRebalancingEnabled(String cacheName)
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
public void setCacheRebalancingEnabled(String cacheName, boolean enabled)
Description copied from interface:LocalTopologyManagerEnable or disable rebalancing for the specified cache.- Specified by:
setCacheRebalancingEnabledin interfaceLocalTopologyManager
-
getRebalancingStatus
public RebalancingStatus getRebalancingStatus(String cacheName)
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
public AvailabilityMode getCacheAvailability(String cacheName)
Description copied from interface:LocalTopologyManagerRetrieves the availability state of a cache.- Specified by:
getCacheAvailabilityin interfaceLocalTopologyManager
-
setCacheAvailability
public void setCacheAvailability(String cacheName, AvailabilityMode availabilityMode)
Description copied from interface:LocalTopologyManagerUpdates the availability state of a cache (for the entire cluster).- Specified by:
setCacheAvailabilityin interfaceLocalTopologyManager
-
cacheShutdown
public void cacheShutdown(String name)
Description copied from interface:LocalTopologyManagerInitiates a cluster-wide cache shutdown for the specified cache- Specified by:
cacheShutdownin interfaceLocalTopologyManager
-
handleCacheShutdown
public CompletionStage<Void> handleCacheShutdown(String cacheName)
Description copied from interface:LocalTopologyManagerHandles the local operations related to gracefully shutting down a cache- Specified by:
handleCacheShutdownin interfaceLocalTopologyManager
-
prepareForPersist
public void prepareForPersist(ScopedPersistentState state)
Description copied from interface:GlobalStateProviderThis method is invoked by theGlobalStateManagerjust before persisting the global state- Specified by:
prepareForPersistin interfaceGlobalStateProvider
-
prepareForRestore
public void prepareForRestore(ScopedPersistentState state)
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
public PersistentUUID 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
-
-