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.void
manageActiveObject
(StateFreezable activeObject) Manages a single active Object.void
manageState
(StateBufferSaveable state) Adds a single StateBufferSaveable object to be managed.void
Adds a single StateDirectorySaveable object to be managed.void
manageStates
(StateBufferSaveable[] states) Adds an array of StateBufferSaveable objects for managing.void
manageStates
(StateDirectorySaveable[] states) Adds an array of StateDirectorySaveable objects for managing.void
Restores the state of all the objects currently being managed.void
This method is not supported in Asynchronous mode.void
This method requests a save state from the StateSaver.void
setMergeDelay
(int delay) Sets the delay time for the periodic directory merge.void
setStateBufferFileName
(String stateBufferFileName) Sets the current state buffer file.void
shutdown()
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:
shutdown
in 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:
setStateBufferFileName
in classStateManager
- Parameters:
stateBufferFileName
- Buffer file, containing the states.
-
manageState
Adds a single StateBufferSaveable object to be managed.- Overrides:
manageState
in classStateManager
- Parameters:
stateDirObj
- State object to manage
-
manageState
Adds a single StateDirectorySaveable object to be managed.- Overrides:
manageState
in classStateManager
- Parameters:
stateDirObj
- State object to manage
-
manageStates
Adds an array of StateBufferSaveable objects for managing.- Overrides:
manageStates
in classStateManager
- Parameters:
states
- Array of state objects
-
manageStates
Adds an array of StateDirectorySaveable objects for managing.- Overrides:
manageStates
in 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:
manageActiveObject
in classStateManager
- Parameters:
activeObject
- Object to be frozen during state save
-
saveState
This method requests a save state from the StateSaver.- Specified by:
saveState
in classStateManager
- Throws:
StateException
-
saveState
This method is not supported in Asynchronous mode.- Specified by:
saveState
in classStateManager
- Throws:
StateException
-
restoreState
Restores the state of all the objects currently being managed.- Specified by:
restoreState
in classStateManager
- Throws:
StateException
-
getType
Returns that this StateManager supports asynchronous state mode.- Specified by:
getType
in classStateManager
- Returns:
- StateManagementType, that this is asynchronous mode
-