Package org.infinispan.util
Class AbstractControlledLocalTopologyManager
- java.lang.Object
-
- org.infinispan.util.AbstractControlledLocalTopologyManager
-
- All Implemented Interfaces:
LocalTopologyManager
public abstract class AbstractControlledLocalTopologyManager extends java.lang.Object implements LocalTopologyManager
Class to be extended to allow some control over the local topology manager when testing Infinispan. Note: create before/after method lazily when need.- Since:
- 6.0
- Author:
- Pedro Ruivo
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractControlledLocalTopologyManager(LocalTopologyManager delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
beforeConfirmRebalancePhase(java.lang.String cacheName, int topologyId, java.lang.Throwable throwable)
protected void
beforeHandleRebalance(java.lang.String cacheName, CacheTopology cacheTopology, int viewId)
protected void
beforeHandleTopologyUpdate(java.lang.String cacheName, CacheTopology cacheTopology, int viewId)
void
cacheShutdown(java.lang.String name)
Initiates a cluster-wide cache shutdown for the specified cachevoid
confirmRebalancePhase(java.lang.String cacheName, int topologyId, int rebalanceId, java.lang.Throwable throwable)
Confirm that the local cachecacheName
has finished receiving the new data for topologytopologyId
.AvailabilityMode
getCacheAvailability(java.lang.String cacheName)
Retrieves the availability state of a cache.CacheTopology
getCacheTopology(java.lang.String cacheName)
PersistentUUID
getPersistentUUID()
Returns the local UUID of this node.RebalancingStatus
getRebalancingStatus(java.lang.String cacheName)
Retrieve the rebalancing status for the specified cacheCacheTopology
getStableCacheTopology(java.lang.String cacheName)
void
handleCacheShutdown(java.lang.String cacheName)
Handles the local operations related to gracefully shutting down a cachevoid
handleRebalance(java.lang.String cacheName, CacheTopology cacheTopology, int viewId, Address sender)
Performs the state transfer.void
handleStableTopologyUpdate(java.lang.String cacheName, CacheTopology cacheTopology, 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(java.lang.String cacheName, CacheTopology cacheTopology, AvailabilityMode availabilityMode, int viewId, Address sender)
Updates the current and/or pending consistent hash, without transferring any state.boolean
isCacheRebalancingEnabled(java.lang.String cacheName)
Checks whether rebalancing is enabled for the specified cache.boolean
isRebalancingEnabled()
Checks whether rebalancing is enabled for the entire cluster.boolean
isTotalOrderCache(java.lang.String cacheName)
Checks if the cache defined bycacheName
is using total order.CacheTopology
join(java.lang.String cacheName, CacheJoinInfo joinInfo, CacheTopologyHandler stm, org.infinispan.partitionhandling.impl.PartitionHandlingManager phm)
Forwards the join request to the coordinator.void
leave(java.lang.String cacheName, long timeout)
Forwards the leave request to the coordinator.void
setCacheAvailability(java.lang.String cacheName, AvailabilityMode availabilityMode)
Updates the availability state of a cache (for the entire cluster).void
setCacheRebalancingEnabled(java.lang.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
startDelegate()
void
stopDelegate()
-
-
-
Constructor Detail
-
AbstractControlledLocalTopologyManager
protected AbstractControlledLocalTopologyManager(LocalTopologyManager delegate)
-
-
Method Detail
-
join
public final CacheTopology join(java.lang.String cacheName, CacheJoinInfo joinInfo, CacheTopologyHandler stm, org.infinispan.partitionhandling.impl.PartitionHandlingManager phm) throws java.lang.Exception
Description copied from interface:LocalTopologyManager
Forwards the join request to the coordinator.- Specified by:
join
in interfaceLocalTopologyManager
- Returns:
- The current consistent hash.
- Throws:
java.lang.Exception
-
leave
public final void leave(java.lang.String cacheName, long timeout)
Description copied from interface:LocalTopologyManager
Forwards the leave request to the coordinator.- Specified by:
leave
in interfaceLocalTopologyManager
-
confirmRebalancePhase
public final void confirmRebalancePhase(java.lang.String cacheName, int topologyId, int rebalanceId, java.lang.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 final 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 final void handleTopologyUpdate(java.lang.String cacheName, CacheTopology cacheTopology, AvailabilityMode availabilityMode, int viewId, Address sender) throws java.lang.InterruptedException
Description copied from interface:LocalTopologyManager
Updates the current and/or pending consistent hash, without transferring any state.- Specified by:
handleTopologyUpdate
in interfaceLocalTopologyManager
- Throws:
java.lang.InterruptedException
-
handleRebalance
public final void handleRebalance(java.lang.String cacheName, CacheTopology cacheTopology, int viewId, Address sender) throws java.lang.InterruptedException
Description copied from interface:LocalTopologyManager
Performs the state transfer.- Specified by:
handleRebalance
in interfaceLocalTopologyManager
- Throws:
java.lang.InterruptedException
-
getCacheTopology
public final CacheTopology getCacheTopology(java.lang.String cacheName)
- Specified by:
getCacheTopology
in interfaceLocalTopologyManager
- Returns:
- the current topology for a cache.
-
handleStableTopologyUpdate
public void handleStableTopologyUpdate(java.lang.String cacheName, CacheTopology cacheTopology, 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
-
getStableCacheTopology
public CacheTopology getStableCacheTopology(java.lang.String cacheName)
- Specified by:
getStableCacheTopology
in interfaceLocalTopologyManager
- Returns:
- the last stable topology for a cache.
-
isRebalancingEnabled
public boolean isRebalancingEnabled() throws java.lang.Exception
Description copied from interface:LocalTopologyManager
Checks whether rebalancing is enabled for the entire cluster.- Specified by:
isRebalancingEnabled
in interfaceLocalTopologyManager
- Throws:
java.lang.Exception
-
setRebalancingEnabled
public void setRebalancingEnabled(boolean enabled) throws java.lang.Exception
Description copied from interface:LocalTopologyManager
Enable or disable rebalancing in the entire cluster.- Specified by:
setRebalancingEnabled
in interfaceLocalTopologyManager
- Throws:
java.lang.Exception
-
isCacheRebalancingEnabled
public boolean isCacheRebalancingEnabled(java.lang.String cacheName) throws java.lang.Exception
Description copied from interface:LocalTopologyManager
Checks whether rebalancing is enabled for the specified cache.- Specified by:
isCacheRebalancingEnabled
in interfaceLocalTopologyManager
- Throws:
java.lang.Exception
-
setCacheRebalancingEnabled
public void setCacheRebalancingEnabled(java.lang.String cacheName, boolean enabled) throws java.lang.Exception
Description copied from interface:LocalTopologyManager
Enable or disable rebalancing for the specified cache.- Specified by:
setCacheRebalancingEnabled
in interfaceLocalTopologyManager
- Throws:
java.lang.Exception
-
getRebalancingStatus
public RebalancingStatus getRebalancingStatus(java.lang.String cacheName) throws java.lang.Exception
Description copied from interface:LocalTopologyManager
Retrieve the rebalancing status for the specified cache- Specified by:
getRebalancingStatus
in interfaceLocalTopologyManager
- Throws:
java.lang.Exception
-
getCacheAvailability
public AvailabilityMode getCacheAvailability(java.lang.String cacheName)
Description copied from interface:LocalTopologyManager
Retrieves the availability state of a cache.- Specified by:
getCacheAvailability
in interfaceLocalTopologyManager
-
setCacheAvailability
public void setCacheAvailability(java.lang.String cacheName, AvailabilityMode availabilityMode) throws java.lang.Exception
Description copied from interface:LocalTopologyManager
Updates the availability state of a cache (for the entire cluster).- Specified by:
setCacheAvailability
in interfaceLocalTopologyManager
- Throws:
java.lang.Exception
-
startDelegate
public final void startDelegate()
-
stopDelegate
public final void stopDelegate()
-
isTotalOrderCache
public boolean isTotalOrderCache(java.lang.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.
-
beforeHandleTopologyUpdate
protected void beforeHandleTopologyUpdate(java.lang.String cacheName, CacheTopology cacheTopology, int viewId)
-
beforeHandleRebalance
protected void beforeHandleRebalance(java.lang.String cacheName, CacheTopology cacheTopology, int viewId)
-
beforeConfirmRebalancePhase
protected void beforeConfirmRebalancePhase(java.lang.String cacheName, int topologyId, java.lang.Throwable throwable)
-
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
-
cacheShutdown
public void cacheShutdown(java.lang.String name) throws java.lang.Exception
Description copied from interface:LocalTopologyManager
Initiates a cluster-wide cache shutdown for the specified cache- Specified by:
cacheShutdown
in interfaceLocalTopologyManager
- Throws:
java.lang.Exception
-
handleCacheShutdown
public void handleCacheShutdown(java.lang.String cacheName)
Description copied from interface:LocalTopologyManager
Handles the local operations related to gracefully shutting down a cache- Specified by:
handleCacheShutdown
in interfaceLocalTopologyManager
-
-