Package com.nt.udc.util.state
Class AsynchronousStateManager
java.lang.Object
com.nt.udc.util.state.StateManager
com.nt.udc.util.state.AsynchronousStateManager
The StateManager is responsible for holding a set of
StateDirectorySaveable or StateBufferSaveable Objects, and
saving/restoring those Objects when told to.
Specifically, the AsynchronousStateManager should be used when
saving states in a multi-threaded environment. Likewise, all Objects
saved/restored/frozen through use of this StateManager must support
an asynchronous series of method calls and acknowledgements.
When told, the StateManager will save to/restore from a
buffer file.
The StateManager treats all managed Objects equally - meaning,
all of the Objects must NOT be order-dependant in
saving/restoring their states. If Object's have
dependencies on one another, they must be resolved in another
manner.
-
Field Summary
Fields inherited from class com.nt.udc.util.state.StateManager
activeObjArray, activeObjListenersArray, baseStateDir, logger, scratchDir, stateBufferFileName, stateBufferObjArray, stateDirObjArray -
Constructor Summary
ConstructorsConstructorDescriptionAsynchronousStateManager(LoggerIfc logger, File scratchDir) Creates the default StateManagerAsynchronousStateManager(LoggerIfc logger, File scratchDir, String stateBufferFileName) Creates the StateManager with a buffer file. -
Method Summary
Modifier and TypeMethodDescriptiongetType()Returns that this StateManager supports asynchronous state mode.voidmanageActiveObject(StateFreezable activeObject) Manages a single active Object.voidmanageState(StateBufferSaveable state) Adds a single StateBufferSaveable object to be managed.voidAdds a single StateDirectorySaveable object to be managed.voidmanageStates(StateBufferSaveable[] states) Adds an array of StateBufferSaveable objects for managing.voidmanageStates(StateDirectorySaveable[] states) Adds an array of StateDirectorySaveable objects for managing.voidRestores the state of all the objects currently being managed.voidThis method is not supported in Asynchronous mode.voidThis method requests a save state from the StateSaver.voidsetMergeDelay(int delay) Sets the delay time for the periodic directory merge.voidsetStateBufferFileName(String stateBufferFileName) Sets the current state buffer file.voidshutdown()Shuts down the StateManager, and cleans up any remaining state-related files.
-
Constructor Details
-
AsynchronousStateManager
Creates the default StateManager- Parameters:
logger- Activity loggerscratchDir- Directory which to store state data
-
AsynchronousStateManager
Creates the StateManager with a buffer file.- Parameters:
logger- Activity loggerscratchDir- Directory which to store state data.stateBufferFileName- Buffer File name
-
-
Method Details
-
shutdown
public void shutdown()Shuts down the StateManager, and cleans up any remaining state-related files.- Overrides:
shutdownin classStateManager
-
setMergeDelay
public void setMergeDelay(int delay) Sets the delay time for the periodic directory merge.- Parameters:
delay- Time(ms) of the delay
-
setStateBufferFileName
Sets the current state buffer file.- Overrides:
setStateBufferFileNamein classStateManager- Parameters:
stateBufferFileName- Buffer file, containing the states.
-
manageState
Adds a single StateBufferSaveable object to be managed.- Overrides:
manageStatein classStateManager- Parameters:
stateDirObj- State object to manage
-
manageState
Adds a single StateDirectorySaveable object to be managed.- Overrides:
manageStatein classStateManager- Parameters:
stateDirObj- State object to manage
-
manageStates
Adds an array of StateBufferSaveable objects for managing.- Overrides:
manageStatesin classStateManager- Parameters:
states- Array of state objects
-
manageStates
Adds an array of StateDirectorySaveable objects for managing.- Overrides:
manageStatesin classStateManager- Parameters:
states- Array of state objects
-
manageActiveObject
Manages a single active Object. This Object will be told to freeze before all state saving routines occur. Note that using this method implies that there are **NO** order dependencies related to the given Object.- Overrides:
manageActiveObjectin classStateManager- Parameters:
activeObject- Object to be frozen during state save
-
saveState
This method requests a save state from the StateSaver.- Specified by:
saveStatein classStateManager- Throws:
StateException
-
saveState
This method is not supported in Asynchronous mode.- Specified by:
saveStatein classStateManager- Throws:
StateException
-
restoreState
Restores the state of all the objects currently being managed.- Specified by:
restoreStatein classStateManager- Throws:
StateException
-
getType
Returns that this StateManager supports asynchronous state mode.- Specified by:
getTypein classStateManager- Returns:
- StateManagementType, that this is asynchronous mode
-