# Class BackupManager

java.lang.Object
org.apache.catalina.util.LifecycleBase
org.apache.catalina.util.LifecycleMBeanBase
org.apache.catalina.session.ManagerBase
org.apache.catalina.ha.session.ClusterManagerBase
org.apache.catalina.ha.session.BackupManager

All Implemented Interfaces:
  `MBeanRegistration, DistributedManager, ClusterManager, JmxEnabled, Lifecycle, Manager, AbstractReplicatedMap.MapOwner`

public class BackupManager extends ClusterManagerBase implements AbstractReplicatedMap.MapOwner, DistributedManager
Cluster session manager that provides backup session replication. Each session has one primary and one backup node.

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from class ManagerBase

  `ManagerBase.SessionTiming`

  ### Nested classes/interfaces inherited from interface Lifecycle

  `Lifecycle.SingleUse`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected static final long`
  `DEFAULT_REPL_TIMEOUT`
  Default replication timeout in milliseconds.
  `protected String`
  `name`
  The name of this manager
  `protected static final StringManager`
  `sm`
  The string manager for this package.

  ### Fields inherited from class ClusterManagerBase

  `cluster`

  ### Fields inherited from class ManagerBase

  `duplicates, expiredSessions, maxActive, maxActiveSessions, processExpiresFrequency, processingTime, rejectedSessions, secureRandomAlgorithm, secureRandomClass, secureRandomProvider, sessionCounter, sessionCreationTiming, sessionExpirationTiming, sessionIdGenerator, sessionIdGeneratorClass, sessionMaxAliveTime, sessions, support, TIMING_STATS_CACHE_SIZE`

  ### Fields inherited from interface Lifecycle

  `AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BackupManager()`
  Constructor, just calls super()

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ClusterManager`
  `cloneFromTemplate()`
  Creates a clone of this manager from a template configuration.
  `Session`
  `createEmptySession()`
  Get a session from the recycled ones or create a new empty one.
  `long`
  `getAccessTimeout()`
  Returns the access timeout for the replication map.
  `int`
  `getActiveSessionsFull()`
  Returns the total session count for primary, backup and proxy.
  `String[]`
  `getInvalidatedSessions()`
  When the manager expires session not tied to a request.
  `String`
  `getMapName()`
  Returns the name of the replication map.
  `int`
  `getMapSendOptions()`
  Returns the channel send options for the replication map.
  `String`
  `getMapSendOptionsName()`
  returns the SendOptions as a comma separated list of names
  `String`
  `getName()`
  Returns the descriptive short name of this Manager implementation.
  `long`
  `getRpcTimeout()`
  Returns the RPC timeout for replication messages.
  `Set<String>`
  `getSessionIdsFull()`
  Returns the list of all sessions IDS (primary, backup and proxy).
  `boolean`
  `isTerminateOnStartFailure()`
  Returns whether the map will terminate on start failure.
  `void`
  `messageDataReceived(ClusterMessage msg)`
  A message was received from another node, this is the callback method to implement if you are interested in receiving replication messages.
  `void`
  `objectMadePrimary(Object key, Object value)`
  Called when an object becomes primary on this node.
  `ClusterMessage`
  `requestCompleted(String sessionId)`
  When the request has been completed, the replication valve will notify the manager, and the manager will decide whether any replication is needed or not.
  `void`
  `setAccessTimeout(long accessTimeout)`
  Sets the access timeout for the replication map.
  `void`
  `setMapSendOptions(int mapSendOptions)`
  Sets the channel send options for the replication map.
  `void`
  `setMapSendOptions(String mapSendOptions)`
  Sets the channel send options for the replication map from a string.
  `void`
  `setName(String name)`
  Set the name of the manager, at host /context name and at engine hostname+/context
  `void`
  `setRpcTimeout(long rpcTimeout)`
  Sets the RPC timeout for replication messages.
  `void`
  `setTerminateOnStartFailure(boolean terminateOnStartFailure)`
  Sets whether to terminate the map on start failure.
  `protected void`
  `startInternal()`
  Start this component and implement the requirements of `LifecycleBase.startInternal()`.
  `protected void`
  `stopInternal()`
  Stop this component and implement the requirements of `LifecycleBase.stopInternal()`.

  ### Methods inherited from class ClusterManagerBase

  `clone, getClassLoaders, getClassLoaders, getCluster, getDeltaRequestPool, getReplicationStream, getReplicationStream, isNotifyListenersOnReplication, isRecordAllActions, load, registerSessionAtReplicationValve, setCluster, setNotifyListenersOnReplication, setRecordAllActions, unload`

  ### Methods inherited from class ManagerBase

  `add, addPropertyChangeListener, backgroundProcess, changeSessionId, changeSessionId, createSession, expireSession, findSession, findSessions, generateSessionId, getActiveSessions, getClassName, getContext, getCreationTime, getCreationTimestamp, getDomainInternal, getDuplicates, getEngine, getExpiredSessions, getJvmRoute, getLastAccessedTime, getLastAccessedTimestamp, getMaxActive, getMaxActiveSessions, getNewSession, getNotifyAttributeListenerOnUnchangedValue, getNotifyBindingListenerOnUnchangedValue, getObjectNameKeyProperties, getPersistAuthentication, getProcessExpiresFrequency, getProcessingTime, getRejectedSessions, getSecureRandomAlgorithm, getSecureRandomClass, getSecureRandomProvider, getSession, getSessionActivityCheck, getSessionAttribute, getSessionAttributeNameFilter, getSessionAttributeNamePattern, getSessionAttributeValueClassNameFilter, getSessionAttributeValueClassNamePattern, getSessionAverageAliveTime, getSessionCounter, getSessionCreateRate, getSessionExpireRate, getSessionIdGenerator, getSessionLastAccessAtStart, getSessionMaxAliveTime, getThisAccessedTime, getThisAccessedTimestamp, getWarnOnSessionAttributeFilterFailure, initInternal, listSessionIds, processExpires, remove, remove, removePropertyChangeListener, rotateSessionId, setContext, setDuplicates, setExpiredSessions, setMaxActive, setMaxActiveSessions, setNotifyAttributeListenerOnUnchangedValue, setNotifyBindingListenerOnUnchangedValue, setPersistAuthentication, setProcessExpiresFrequency, setProcessingTime, setSecureRandomAlgorithm, setSecureRandomClass, setSecureRandomProvider, setSessionActivityCheck, setSessionAttributeNameFilter, setSessionAttributeValueClassNameFilter, setSessionCounter, setSessionIdGenerator, setSessionLastAccessAtStart, setSessionMaxAliveTime, setWarnOnSessionAttributeFilterFailure, toString, updateSessionMaxAliveTime, willAttributeDistribute`

  ### Methods inherited from class LifecycleMBeanBase

  `destroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregister`

  ### Methods inherited from class LifecycleBase

  `addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface Manager

  `add, addPropertyChangeListener, backgroundProcess, changeSessionId, createSession, findSession, findSessions, getActiveSessions, getContext, getExpiredSessions, getMaxActive, getNotifyAttributeListenerOnUnchangedValue, getNotifyBindingListenerOnUnchangedValue, getRejectedSessions, getSessionActivityCheck, getSessionAverageAliveTime, getSessionCounter, getSessionCreateRate, getSessionExpireRate, getSessionIdGenerator, getSessionLastAccessAtStart, getSessionMaxAliveTime, remove, remove, removePropertyChangeListener, rotateSessionId, setContext, setExpiredSessions, setMaxActive, setNotifyAttributeListenerOnUnchangedValue, setNotifyBindingListenerOnUnchangedValue, setSessionActivityCheck, setSessionCounter, setSessionIdGenerator, setSessionLastAccessAtStart, setSessionMaxAliveTime, willAttributeDistribute`

- ## Field Details

  - ### sm

    protected static final StringManager sm
    The string manager for this package.

  - ### DEFAULT_REPL_TIMEOUT

    protected static final long DEFAULT_REPL_TIMEOUT
    Default replication timeout in milliseconds.
    See Also:
      - Constant Field Values

  - ### name

    protected String name
    The name of this manager

- ## Constructor Details

  - ### BackupManager

    public BackupManager()
    Constructor, just calls super()

- ## Method Details

  - ### messageDataReceived

    public void messageDataReceived(ClusterMessage msg)
    Description copied from interface: `ClusterManager`
    A message was received from another node, this is the callback method to implement if you are interested in receiving replication messages.
    Specified by:
      `messageDataReceived` in interface `ClusterManager`
    Parameters:
      `msg` - - the message received.

  - ### requestCompleted

    public ClusterMessage requestCompleted(String sessionId)
    Description copied from interface: `ClusterManager`
    When the request has been completed, the replication valve will notify the manager, and the manager will decide whether any replication is needed or not. If there is a need for replication, the manager will create a session message and that will be replicated. The cluster determines where it gets sent.
    Specified by:
      `requestCompleted` in interface `ClusterManager`
    Parameters:
      `sessionId` - - the sessionId that just completed.
    Returns:
      a SessionMessage to be sent.

  - ### objectMadePrimary

    public void objectMadePrimary(Object key, Object value)
    Description copied from interface: `AbstractReplicatedMap.MapOwner`
    Called when an object becomes primary on this node.
    Specified by:
      `objectMadePrimary` in interface `AbstractReplicatedMap.MapOwner`
    Parameters:
      `key` - The key of the object
      `value` - The value of the object

  - ### createEmptySession

    public Session createEmptySession()
    Description copied from interface: `Manager`
    Get a session from the recycled ones or create a new empty one. The PersistentManager manager does not need to create session data because it reads it from the Store.
    Specified by:
      `createEmptySession` in interface `Manager`
    Overrides:
      `createEmptySession` in class `ManagerBase`
    Returns:
      An empty Session object

  - ### getName

    public String getName()
    Description copied from class: `ManagerBase`
    Returns the descriptive short name of this Manager implementation.
    Specified by:
      `getName` in interface `ClusterManager`
    Overrides:
      `getName` in class `ManagerBase`
    Returns:
      The descriptive short name of this Manager implementation.

  - ### startInternal

    protected void startInternal() throws LifecycleException
    Start this component and implement the requirements of `LifecycleBase.startInternal()`. Starts the cluster communication channel, this will connect with the other nodes in the cluster, and request the current session state to be transferred to this node.
    Overrides:
      `startInternal` in class `ClusterManagerBase`
    Throws:
      `LifecycleException` - if this component detects a fatal error that prevents this component from being used

  - ### getMapName

    public String getMapName()
    Returns the name of the replication map.
    Returns:
      the map name

  - ### stopInternal

    protected void stopInternal() throws LifecycleException
    Stop this component and implement the requirements of `LifecycleBase.stopInternal()`. This will disconnect the cluster communication channel and stop the listener thread.
    Overrides:
      `stopInternal` in class `ClusterManagerBase`
    Throws:
      `LifecycleException` - if this component detects a fatal error that prevents this component from being used

  - ### setName

    public void setName(String name)
    Description copied from interface: `ClusterManager`
    Set the name of the manager, at host /context name and at engine hostname+/context
    Specified by:
      `setName` in interface `ClusterManager`
    Parameters:
      `name` - The manager name

  - ### setMapSendOptions

    public void setMapSendOptions(int mapSendOptions)
    Sets the channel send options for the replication map.
    Parameters:
      `mapSendOptions` - the send options as an integer flag

  - ### setMapSendOptions

    public void setMapSendOptions(String mapSendOptions)
    Sets the channel send options for the replication map from a string.
    Parameters:
      `mapSendOptions` - the send options as a comma-separated string

  - ### getMapSendOptions

    public int getMapSendOptions()
    Returns the channel send options for the replication map.
    Returns:
      the send options as an integer flag

  - ### getMapSendOptionsName

    public String getMapSendOptionsName()
    returns the SendOptions as a comma separated list of names
    Returns:
      a comma separated list of the option names

  - ### setRpcTimeout

    public void setRpcTimeout(long rpcTimeout)
    Sets the RPC timeout for replication messages.
    Parameters:
      `rpcTimeout` - the timeout in milliseconds

  - ### getRpcTimeout

    public long getRpcTimeout()
    Returns the RPC timeout for replication messages.
    Returns:
      the timeout in milliseconds

  - ### setTerminateOnStartFailure

    public void setTerminateOnStartFailure(boolean terminateOnStartFailure)
    Sets whether to terminate the map on start failure.
    Parameters:
      `terminateOnStartFailure` - `true` to terminate on start failure

  - ### isTerminateOnStartFailure

    public boolean isTerminateOnStartFailure()
    Returns whether the map will terminate on start failure.
    Returns:
      `true` if the map will terminate on start failure

  - ### getAccessTimeout

    public long getAccessTimeout()
    Returns the access timeout for the replication map.
    Returns:
      the access timeout in milliseconds

  - ### setAccessTimeout

    public void setAccessTimeout(long accessTimeout)
    Sets the access timeout for the replication map.
    Parameters:
      `accessTimeout` - the access timeout in milliseconds

  - ### getInvalidatedSessions

    public String[] getInvalidatedSessions()
    Description copied from interface: `ClusterManager`
    When the manager expires session not tied to a request. The cluster will periodically ask for a list of sessions that should expire and that should be sent across the wire.
    Specified by:
      `getInvalidatedSessions` in interface `ClusterManager`
    Returns:
      String[] The invalidated sessions

  - ### cloneFromTemplate

    public ClusterManager cloneFromTemplate()
    Description copied from interface: `ClusterManager`
    Creates a clone of this manager from a template configuration.
    Specified by:
      `cloneFromTemplate` in interface `ClusterManager`
    Returns:
      a clone of a template manager configuration

  - ### getActiveSessionsFull

    public int getActiveSessionsFull()
    Description copied from interface: `DistributedManager`
    Returns the total session count for primary, backup and proxy.
    Specified by:
      `getActiveSessionsFull` in interface `DistributedManager`
    Returns:
      The total session count across the cluster.

  - ### getSessionIdsFull

    public Set<String> getSessionIdsFull()
    Description copied from interface: `DistributedManager`
    Returns the list of all sessions IDS (primary, backup and proxy).
    Specified by:
      `getSessionIdsFull` in interface `DistributedManager`
    Returns:
      The complete set of sessions IDs across the cluster.