Package org.infinispan.topology
Class LocalTopologyManagerImpl
- java.lang.Object
-
- org.infinispan.topology.LocalTopologyManagerImpl
-
- All Implemented Interfaces:
GlobalStateProvider,LocalTopologyManager
public class LocalTopologyManagerImpl extends Object implements LocalTopologyManager, GlobalStateProvider
TheLocalTopologyManagerimplementation.- 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.<T> TexecuteOnCoordinatorRetry(org.infinispan.commands.ReplicableCommand command, int viewId)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)voidhandleCacheShutdown(String cacheName)Handles the local operations related to gracefully shutting down a cachevoidhandleRebalance(String cacheName, CacheTopology cacheTopology, int viewId, Address sender)Performs the state transfer.voidhandleStableTopologyUpdate(String cacheName, CacheTopology newStableTopology, Address sender, int viewId)Update the stable cache topology.ManagerStatusResponsehandleStatusRequest(int viewId)Recovers the current topology information for all running caches and returns it to the coordinator.voidhandleTopologyUpdate(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.booleanisTotalOrderCache(String cacheName)Checks if the cache defined bycacheNameis using total order.CacheTopologyjoin(String cacheName, CacheJoinInfo joinInfo, CacheTopologyHandler stm, org.infinispan.partitionhandling.impl.PartitionHandlingManager phm)Forwards the join request to the coordinator.voidleave(String cacheName)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()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 CacheTopology join(String cacheName, CacheJoinInfo joinInfo, CacheTopologyHandler stm, org.infinispan.partitionhandling.impl.PartitionHandlingManager phm) throws Exception
Description copied from interface:LocalTopologyManagerForwards the join request to the coordinator.- Specified by:
joinin interfaceLocalTopologyManager- Returns:
- The current consistent hash.
- Throws:
Exception
-
leave
public void leave(String cacheName)
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. This must be >= than the one when rebalance starts.throwable-nullunless local rebalance ended because of an error.
-
handleStatusRequest
public 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
-
handleTopologyUpdate
public void handleTopologyUpdate(String cacheName, CacheTopology cacheTopology, AvailabilityMode availabilityMode, int viewId, Address sender) throws InterruptedException
Description copied from interface:LocalTopologyManagerUpdates the current and/or pending consistent hash, without transferring any state.- Specified by:
handleTopologyUpdatein interfaceLocalTopologyManager- Throws:
InterruptedException
-
handleStableTopologyUpdate
public 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 void handleRebalance(String cacheName, CacheTopology cacheTopology, int viewId, Address sender) throws InterruptedException
Description copied from interface:LocalTopologyManagerPerforms the state transfer.- Specified by:
handleRebalancein interfaceLocalTopologyManager- Throws:
InterruptedException
-
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.
-
isTotalOrderCache
public boolean isTotalOrderCache(String cacheName)
Description copied from interface:LocalTopologyManagerChecks if the cache defined bycacheNameis using total order. If this component is not running or thecacheNameis not defined, it returnsfalse.- Specified by:
isTotalOrderCachein interfaceLocalTopologyManager- Returns:
trueif the cache is using the total order protocol,falseotherwise.
-
isRebalancingEnabled
public boolean isRebalancingEnabled() throws ExceptionDescription copied from interface:LocalTopologyManagerChecks whether rebalancing is enabled for the entire cluster.- Specified by:
isRebalancingEnabledin interfaceLocalTopologyManager- Throws:
Exception
-
setRebalancingEnabled
public void setRebalancingEnabled(boolean enabled) throws ExceptionDescription copied from interface:LocalTopologyManagerEnable or disable rebalancing in the entire cluster.- Specified by:
setRebalancingEnabledin interfaceLocalTopologyManager- Throws:
Exception
-
isCacheRebalancingEnabled
public boolean isCacheRebalancingEnabled(String cacheName) throws Exception
Description copied from interface:LocalTopologyManagerChecks whether rebalancing is enabled for the specified cache.- Specified by:
isCacheRebalancingEnabledin interfaceLocalTopologyManager- Throws:
Exception
-
executeOnCoordinatorRetry
public <T> T executeOnCoordinatorRetry(org.infinispan.commands.ReplicableCommand command, int viewId) throws Exception- Throws:
Exception
-
setCacheRebalancingEnabled
public void setCacheRebalancingEnabled(String cacheName, boolean enabled) throws Exception
Description copied from interface:LocalTopologyManagerEnable or disable rebalancing for the specified cache.- Specified by:
setCacheRebalancingEnabledin interfaceLocalTopologyManager- Throws:
Exception
-
getRebalancingStatus
public RebalancingStatus getRebalancingStatus(String cacheName) throws Exception
Description copied from interface:LocalTopologyManagerRetrieve the rebalancing status for the specified cache- Specified by:
getRebalancingStatusin interfaceLocalTopologyManager- Throws:
Exception
-
getClusterAvailability
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) throws Exception
Description copied from interface:LocalTopologyManagerUpdates the availability state of a cache (for the entire cluster).- Specified by:
setCacheAvailabilityin interfaceLocalTopologyManager- Throws:
Exception
-
cacheShutdown
public void cacheShutdown(String name) throws Exception
Description copied from interface:LocalTopologyManagerInitiates a cluster-wide cache shutdown for the specified cache- Specified by:
cacheShutdownin interfaceLocalTopologyManager- Throws:
Exception
-
handleCacheShutdown
public 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
-
-