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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
assertTopologyStable
(String cacheName) Asserts the cache with the given name has a stable topology installed.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
.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.boolean
isCacheRebalancingEnabled
(String cacheName) Checks whether rebalancing is enabled for the specified cache.boolean
Checks whether rebalancing is enabled for the entire cluster.join
(String cacheName, CacheJoinInfo joinInfo, CacheTopologyHandler stm, PartitionHandlingManager phm) Forwards the join request to the coordinator.void
Forwards the leave request to the coordinator.void
This method is invoked by theGlobalStateManager
just before persisting the global statevoid
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.stableTopologyCompletion
(String cacheName) Returns aCompletionStage
that completes when the cache with the namecacheName
has a stable topology.void
start()
void
stop()
-
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:LocalTopologyManager
Forwards the join request to the coordinator.- Specified by:
join
in interfaceLocalTopologyManager
- Returns:
- The current consistent hash.
-
leave
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.rebalanceId
- the id of the current rebalancethrowable
-null
unless local rebalance ended because of an error.
-
handleStatusRequest
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
- 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:LocalTopologyManager
Updates the current and/or pending consistent hash, without transferring any state.- Specified by:
handleTopologyUpdate
in interfaceLocalTopologyManager
-
handleStableTopologyUpdate
public CompletionStage<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 CompletionStage<Void> handleRebalance(String cacheName, CacheTopology cacheTopology, int viewId, Address sender) Description copied from interface:LocalTopologyManager
Performs the state transfer.- Specified by:
handleRebalance
in interfaceLocalTopologyManager
-
getCacheTopology
- Specified by:
getCacheTopology
in interfaceLocalTopologyManager
- Returns:
- the current topology for a cache.
-
getStableCacheTopology
- Specified by:
getStableCacheTopology
in 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:LocalTopologyManager
Checks whether rebalancing is enabled for the entire cluster.- Specified by:
isRebalancingEnabled
in interfaceLocalTopologyManager
-
setRebalancingEnabled
public void setRebalancingEnabled(boolean enabled) Description copied from interface:LocalTopologyManager
Enable or disable rebalancing in the entire cluster.- Specified by:
setRebalancingEnabled
in interfaceLocalTopologyManager
-
isCacheRebalancingEnabled
Description copied from interface:LocalTopologyManager
Checks whether rebalancing is enabled for the specified cache.- Specified by:
isCacheRebalancingEnabled
in interfaceLocalTopologyManager
-
executeOnCoordinatorRetry
public CompletionStage<Object> executeOnCoordinatorRetry(ReplicableCommand command, int viewId, long endNanos) -
setCacheRebalancingEnabled
Description copied from interface:LocalTopologyManager
Enable or disable rebalancing for the specified cache.- Specified by:
setCacheRebalancingEnabled
in interfaceLocalTopologyManager
-
getRebalancingStatus
Description copied from interface:LocalTopologyManager
Retrieve the rebalancing status for the specified cache- Specified by:
getRebalancingStatus
in interfaceLocalTopologyManager
-
getClusterAvailability
@ManagedAttribute(description="Cluster availability", displayName="Cluster availability", dataType=TRAIT, writable=false) public String getClusterAvailability() -
getCacheAvailability
Description copied from interface:LocalTopologyManager
Retrieves the availability state of a cache.- Specified by:
getCacheAvailability
in interfaceLocalTopologyManager
-
setCacheAvailability
Description copied from interface:LocalTopologyManager
Updates the availability state of a cache (for the entire cluster).- Specified by:
setCacheAvailability
in interfaceLocalTopologyManager
-
cacheShutdown
Description copied from interface:LocalTopologyManager
Initiates a cluster-wide cache shutdown for the specified cache- Specified by:
cacheShutdown
in interfaceLocalTopologyManager
-
handleCacheShutdown
Description copied from interface:LocalTopologyManager
Handles the local operations related to gracefully shutting down a cache- Specified by:
handleCacheShutdown
in interfaceLocalTopologyManager
-
stableTopologyCompletion
Description copied from interface:LocalTopologyManager
Returns aCompletionStage
that completes when the cache with the namecacheName
has a stable topology. Returns null if the cache does not exist.- Specified by:
stableTopologyCompletion
in interfaceLocalTopologyManager
-
assertTopologyStable
Description copied from interface:LocalTopologyManager
Asserts the cache with the given name has a stable topology installed.- Specified by:
assertTopologyStable
in interfaceLocalTopologyManager
- Parameters:
cacheName
- : The cache name to search.
-
prepareForPersist
Description copied from interface:GlobalStateProvider
This method is invoked by theGlobalStateManager
just before persisting the global state- Specified by:
prepareForPersist
in interfaceGlobalStateProvider
-
prepareForRestore
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
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
-