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
TheLocalTopologyManager
implementation.- 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 void
cacheShutdown(String name)
Initiates a cluster-wide cache shutdown for the specified cachevoid
confirmRebalancePhase(String cacheName, int topologyId, int rebalanceId, Throwable throwable)
Confirm that the local cachecacheName
has finished receiving the new data for topologytopologyId
.<T> T
executeOnCoordinatorRetry(org.infinispan.commands.ReplicableCommand command, int viewId)
AvailabilityMode
getCacheAvailability(String cacheName)
Retrieves the availability state of a cache.CacheTopology
getCacheTopology(String cacheName)
String
getClusterAvailability()
PersistentUUID
getPersistentUUID()
Returns the local UUID of this node.RebalancingStatus
getRebalancingStatus(String cacheName)
Retrieve the rebalancing status for the specified cacheCacheTopology
getStableCacheTopology(String cacheName)
void
handleCacheShutdown(String cacheName)
Handles the local operations related to gracefully shutting down a cachevoid
handleRebalance(String cacheName, CacheTopology cacheTopology, int viewId, Address sender)
Performs the state transfer.void
handleStableTopologyUpdate(String cacheName, CacheTopology newStableTopology, Address sender, int viewId)
Update the stable cache topology.ManagerStatusResponse
handleStatusRequest(int viewId)
Recovers the current topology information for all running caches and returns it to the coordinator.void
handleTopologyUpdate(String cacheName, CacheTopology cacheTopology, AvailabilityMode availabilityMode, int viewId, Address sender)
Updates the current and/or pending consistent hash, without transferring any state.boolean
isCacheRebalancingEnabled(String cacheName)
Checks whether rebalancing is enabled for the specified cache.boolean
isRebalancingEnabled()
Checks whether rebalancing is enabled for the entire cluster.boolean
isTotalOrderCache(String cacheName)
Checks if the cache defined bycacheName
is using total order.CacheTopology
join(String cacheName, CacheJoinInfo joinInfo, CacheTopologyHandler stm, org.infinispan.partitionhandling.impl.PartitionHandlingManager phm)
Forwards the join request to the coordinator.void
leave(String cacheName)
Forwards the leave request to the coordinator.void
prepareForPersist(ScopedPersistentState state)
This method is invoked by theGlobalStateManager
just before persisting the global statevoid
prepareForRestore(ScopedPersistentState state)
This method is invoked by theGlobalStateManager
after starting up to notify that global state has been restored.void
preStart()
void
setCacheAvailability(String cacheName, AvailabilityMode availabilityMode)
Updates the availability state of a cache (for the entire cluster).void
setCacheRebalancingEnabled(String cacheName, boolean enabled)
Enable or disable rebalancing for the specified cache.void
setRebalancingEnabled(boolean enabled)
Enable or disable rebalancing in the entire cluster.void
start()
void
stop()
-
-
-
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:LocalTopologyManager
Forwards the join request to the coordinator.- Specified by:
join
in interfaceLocalTopologyManager
- Returns:
- The current consistent hash.
- Throws:
Exception
-
leave
public void leave(String cacheName)
Description copied from interface:LocalTopologyManager
Forwards the leave request to the coordinator.- Specified by:
leave
in interfaceLocalTopologyManager
-
confirmRebalancePhase
public void confirmRebalancePhase(String cacheName, int topologyId, int rebalanceId, Throwable throwable)
Description copied from interface:LocalTopologyManager
Confirm that the local cachecacheName
has 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:
confirmRebalancePhase
in 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
-null
unless local rebalance ended because of an error.
-
handleStatusRequest
public ManagerStatusResponse handleStatusRequest(int viewId)
Description copied from interface:LocalTopologyManager
Recovers the current topology information for all running caches and returns it to the coordinator.- Specified by:
handleStatusRequest
in interfaceLocalTopologyManager
-
handleTopologyUpdate
public void handleTopologyUpdate(String cacheName, CacheTopology cacheTopology, AvailabilityMode availabilityMode, int viewId, Address sender) throws InterruptedException
Description copied from interface:LocalTopologyManager
Updates the current and/or pending consistent hash, without transferring any state.- Specified by:
handleTopologyUpdate
in interfaceLocalTopologyManager
- Throws:
InterruptedException
-
handleStableTopologyUpdate
public void handleStableTopologyUpdate(String cacheName, CacheTopology newStableTopology, Address sender, int viewId)
Description copied from interface:LocalTopologyManager
Update the stable cache topology. Mostly needed for backup, so that a new coordinator can recover the stable topology of the cluster.- Specified by:
handleStableTopologyUpdate
in interfaceLocalTopologyManager
-
handleRebalance
public void handleRebalance(String cacheName, CacheTopology cacheTopology, int viewId, Address sender) throws InterruptedException
Description copied from interface:LocalTopologyManager
Performs the state transfer.- Specified by:
handleRebalance
in interfaceLocalTopologyManager
- Throws:
InterruptedException
-
getCacheTopology
public CacheTopology getCacheTopology(String cacheName)
- Specified by:
getCacheTopology
in interfaceLocalTopologyManager
- Returns:
- the current topology for a cache.
-
getStableCacheTopology
public CacheTopology getStableCacheTopology(String cacheName)
- Specified by:
getStableCacheTopology
in interfaceLocalTopologyManager
- Returns:
- the last stable topology for a cache.
-
isTotalOrderCache
public boolean isTotalOrderCache(String cacheName)
Description copied from interface:LocalTopologyManager
Checks if the cache defined bycacheName
is using total order. If this component is not running or thecacheName
is not defined, it returnsfalse
.- Specified by:
isTotalOrderCache
in interfaceLocalTopologyManager
- Returns:
true
if the cache is using the total order protocol,false
otherwise.
-
isRebalancingEnabled
public boolean isRebalancingEnabled() throws Exception
Description copied from interface:LocalTopologyManager
Checks whether rebalancing is enabled for the entire cluster.- Specified by:
isRebalancingEnabled
in interfaceLocalTopologyManager
- Throws:
Exception
-
setRebalancingEnabled
public void setRebalancingEnabled(boolean enabled) throws Exception
Description copied from interface:LocalTopologyManager
Enable or disable rebalancing in the entire cluster.- Specified by:
setRebalancingEnabled
in interfaceLocalTopologyManager
- Throws:
Exception
-
isCacheRebalancingEnabled
public boolean isCacheRebalancingEnabled(String cacheName) throws Exception
Description copied from interface:LocalTopologyManager
Checks whether rebalancing is enabled for the specified cache.- Specified by:
isCacheRebalancingEnabled
in 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:LocalTopologyManager
Enable or disable rebalancing for the specified cache.- Specified by:
setCacheRebalancingEnabled
in interfaceLocalTopologyManager
- Throws:
Exception
-
getRebalancingStatus
public RebalancingStatus getRebalancingStatus(String cacheName) throws Exception
Description copied from interface:LocalTopologyManager
Retrieve the rebalancing status for the specified cache- Specified by:
getRebalancingStatus
in interfaceLocalTopologyManager
- Throws:
Exception
-
getClusterAvailability
public String getClusterAvailability()
-
getCacheAvailability
public AvailabilityMode getCacheAvailability(String cacheName)
Description copied from interface:LocalTopologyManager
Retrieves the availability state of a cache.- Specified by:
getCacheAvailability
in interfaceLocalTopologyManager
-
setCacheAvailability
public void setCacheAvailability(String cacheName, AvailabilityMode availabilityMode) throws Exception
Description copied from interface:LocalTopologyManager
Updates the availability state of a cache (for the entire cluster).- Specified by:
setCacheAvailability
in interfaceLocalTopologyManager
- Throws:
Exception
-
cacheShutdown
public void cacheShutdown(String name) throws Exception
Description copied from interface:LocalTopologyManager
Initiates a cluster-wide cache shutdown for the specified cache- Specified by:
cacheShutdown
in interfaceLocalTopologyManager
- Throws:
Exception
-
handleCacheShutdown
public void handleCacheShutdown(String cacheName)
Description copied from interface:LocalTopologyManager
Handles the local operations related to gracefully shutting down a cache- Specified by:
handleCacheShutdown
in interfaceLocalTopologyManager
-
prepareForPersist
public void prepareForPersist(ScopedPersistentState state)
Description copied from interface:GlobalStateProvider
This method is invoked by theGlobalStateManager
just before persisting the global state- Specified by:
prepareForPersist
in interfaceGlobalStateProvider
-
prepareForRestore
public void prepareForRestore(ScopedPersistentState state)
Description copied from interface:GlobalStateProvider
This method is invoked by theGlobalStateManager
after starting up to notify that global state has been restored.- Specified by:
prepareForRestore
in interfaceGlobalStateProvider
-
getPersistentUUID
public PersistentUUID getPersistentUUID()
Description copied from interface:LocalTopologyManager
Returns the local UUID of this node. If global state persistence is enabled, this UUID will be saved and reused across restarts- Specified by:
getPersistentUUID
in interfaceLocalTopologyManager
-
-