Class AsynchronousStateSaver

java.lang.Object
com.nt.udc.util.state.StateSaver
com.nt.udc.util.state.AsynchronousStateSaver
All Implemented Interfaces:
IntegerCallback

public class AsynchronousStateSaver extends StateSaver implements IntegerCallback
The class will save the state of a set of registered Objects. The saving is done asynchronously, in that a new Thread is created for each call to save the Objects' state. Therefore, a call to "saveState()" requests the state to be saved - it does not guarantee the state will be saved within the time frame of that call. Also, all processing Objects are "frozen" will the StateFreezer prior to saving the state.
  • Constructor Details

    • AsynchronousStateSaver

      public AsynchronousStateSaver(LoggerIfc logger, File baseStateDir, Object stateLock, StateFreezer freezer, TimedStateMerger stateMerger)
      Creates an AsynchronousStateSaver Object.
      Parameters:
      logger - Logger for warnings and errors.
      baseStateDir - Location of state sub-directories.
      stateLock - Lock required to obtain before saving the state. This ensures no other state-related routines will be operating.
      freezer - Used to freeze all processing Objects.
      stateMerger - Used to merge the state directories.
  • Method Details

    • shutdown

      public void shutdown()
      Stops the state saving Thread.
    • saveState

      public void saveState(Callback stateSavedCallback)
      Requests the state of the registered Objects to be saved, and returns immediately. A separate thread will actually call "saveState()" on the registered Objects.
    • callback

      public void callback(int callbackValue)
      Tells this Objects that a save state thread has completed.
      Specified by:
      callback in interface IntegerCallback