Class TimedStateMerger

java.lang.Object
com.nt.udc.util.state.StateMerger
com.nt.udc.util.state.TimedStateMerger
All Implemented Interfaces:
ActionListener, EventListener

public class TimedStateMerger extends StateMerger implements ActionListener
This class is responsible for merging state directories together into a single merged directory. A timer has been provided for those situations where a periodic merge needs to occur. Otherwise, one may call for a merge explicitly. In order to prevent unnecessary merges when using the periodic merge timer, the merge timer will set a flag that the merge was successful. The flag prevents a merge from occurring, unless one has been requested. The user must call "setMergeNeeded()" if a merge is needed.
  • Constructor Details

    • TimedStateMerger

      public TimedStateMerger(LoggerIfc logger, File baseStateDir, Object stateLock, StateFreezer freezer)
      Creates a state directory merger.
      Parameters:
      logger - Logger for warnings or errors.
      baseStateDir - Root directory that holds the state directories.
      stateLock - Lock needed when trying to merge states. This will prevent any other threads from modifying the state while merging.
      stateFreezer - Used for freezing the state of the routine.
  • Method Details

    • start

      public void start()
      Starts the merge timer.
    • shutdown

      public void shutdown()
      Shuts down the merge timer, and closes any other resources that are associated with the merger.
    • setMergeDelay

      public void setMergeDelay(int delay)
      Sets the merge timer's delay.
      Parameters:
      delay - Delay, in ms.
    • setMergeNeeded

      public void setMergeNeeded()
      Sets a flag to tell the periodic merge that a merge is required.
    • actionPerformed

      public void actionPerformed(ActionEvent ae)
      Responds for the periodic merging Thread.
      Specified by:
      actionPerformed in interface ActionListener
    • mergeState

      public void mergeState()
      Merges all the existing states.