Class PeriodicRecovery

java.lang.Object
java.lang.Thread
com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery
All Implemented Interfaces:
Runnable

public class PeriodicRecovery extends Thread
Threaded object to perform the periodic recovery. Instantiated in the RecoveryManager. The work is actually completed by the recovery modules. These modules are dynamically loaded. The modules to load are specified by properties beginning with "RecoveryExtension"

n.b. recovery scans may be performed by this object (it is a thread and may be started as a background task) and by other ad hoc threads

Version:
$Id: PeriodicRecovery.java 2342 2006-03-30 13:06:17Z $
Author:
  • Field Details

    • _defaultBackoffPeriod

      public static final int _defaultBackoffPeriod
      default value for _backoffPeriod if not specified via RecoveryEnvironmentBean
      See Also:
    • _defaultRecoveryPeriod

      public static final int _defaultRecoveryPeriod
      default value for _recoveryPeriod if not specified via RecoveryEnvironmentBean
      See Also:
  • Constructor Details

    • PeriodicRecovery

      public PeriodicRecovery(boolean threaded, boolean useListener)
      Parameters:
      threaded -
      useListener - if true, start a socket based listener.
  • Method Details

    • shutdown

      public void shutdown(boolean async)
      initiate termination of the periodic recovery thread and stop any subsequent scan requests from proceeding. this switches the recovery operation mode to TERMINATED. if a scan is in progress when this method is called and has not yet started phase 2 of its scan it will be forced to return before completing phase 2.
      Parameters:
      async - false if the calling thread should wait for any in-progress scan to complete before returning
    • suspendScan

      public PeriodicRecovery.Mode suspendScan(boolean async)
      make all scanning operations suspend. This switches the recovery operation mode to SUSPENDED. Any attempt to start a new scan either by an ad hoc threads or by the periodic recovery thread will suspend its thread until the mode changes. If a scan is in progress when this method is called it will complete its scan without suspending.
      Parameters:
      async - false if the calling thread should wait for any in-progress scan to complete before returning
      Returns:
      the previous mode before attempting the suspend
    • resumeScan

      public void resumeScan()
      resume scanning operations This switches the recovery operation mode from SUSPENDED to RESUMED. Any threads which suspended when they tried to start a scan will be woken up by this transition.
    • getServerSocket

      public ServerSocket getServerSocket() throws IOException
      Returns:
      a bound server socket corresponding to the recovery manager
      Throws:
      IOException - if the host name is unknown or the endpoint has already been bound
    • run

      public void run()
      Implements the background thread which performs the periodic recovery
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
    • doWork

      public final void doWork()
      Perform a recovery scan on all registered modules. Caveats: if a scan is already in progress this method will wait for it to complete otherwise it will perform its own scan before returning. If scanning is suspended this will require waiting for scanning to resume.
    • wakeUp

      public void wakeUp()
      called by the listener worker to wake the periodic recovery thread and get it to start a scan if one is not already in progress
    • addModule

      public final void addModule(RecoveryModule module)
      Add the specified module to the end of the recovery module list. There is no way to specify relative ordering of recovery modules with respect to modules loaded via the property file.
      Parameters:
      module - The module to append.
    • removeModule

      public final void removeModule(RecoveryModule module, boolean waitOnScan)
      remove a recovery module from the recovery modules list
      Parameters:
      module - the module to be removed
      waitOnScan - true if the remove operation should wait for any in-progress scan to complete
    • removeAllModules

      public final void removeAllModules(boolean waitOnScan)
      Remove all modules.
      Parameters:
      waitOnScan - true if the remove operation should wait for any in-progress scan to complete.
    • getModules

      public final Vector<RecoveryModule> getModules()
      return a copy of the current recovery modules list
      Returns:
      a copy of the the recovery modules list.
    • getListener

      public Listener getListener()
    • getMode

      public PeriodicRecovery.Mode getMode()
      fetch the current recovery operation mode either ENABLED, SUSPENDED or TERMINATED Caveats: must only be called while synchronized on _stateLock
      Returns:
      the current recovery operation mode