Package com.nt.udc.util.state
Class TimedStateMerger
java.lang.Object
com.nt.udc.util.state.StateMerger
com.nt.udc.util.state.TimedStateMerger
- All Implemented Interfaces:
ActionListener,EventListener
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.
-
Field Summary
Fields inherited from class com.nt.udc.util.state.StateMerger
baseStateDir, dirCleaner, logger, mergeDirGenerator, stateBufferFileName, stateDirComp, stateDirObjArray, tmpAcceptFilter, tmpFilter -
Constructor Summary
ConstructorsConstructorDescriptionTimedStateMerger(LoggerIfc logger, File baseStateDir, Object stateLock, StateFreezer freezer) Creates a state directory merger. -
Method Summary
Modifier and TypeMethodDescriptionvoidResponds for the periodic merging Thread.voidMerges all the existing states.voidsetMergeDelay(int delay) Sets the merge timer's delay.voidSets a flag to tell the periodic merge that a merge is required.voidshutdown()Shuts down the merge timer, and closes any other resources that are associated with the merger.voidstart()Starts the merge timer.Methods inherited from class com.nt.udc.util.state.StateMerger
mergeStateData, setDirArray, setStateBufferFileName
-
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
Responds for the periodic merging Thread.- Specified by:
actionPerformedin interfaceActionListener
-
mergeState
public void mergeState()Merges all the existing states.
-