Interface SessionStateManager
-
public interface SessionStateManager
The session state manager provides the means to handle internal states of running applications. This allows to resume an application if it has been suspended or even if it has crashed.
Savepoints are similar to checkpoints in database management systems. An application may write a savepoint whenever it wants to. A savepoint should contain all data, the application needs to restore its current point of execution. This may be done explicitly after a suspend request or just arbitrary. The latter allows to restart an application after a crash just as if it has been suspended at its most recent savepoint.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description String
getLastSavepoint(SessionToken session, UUID instanceLogId, int nodeId, int iteration)
Gets the name of most recent valid savepoint stored for the activity identified by the designated instance, node and node iteration.List<String>
getSavepoints(SessionToken session, UUID instanceLogId, int nodeId, int iteration)
Gets all savepoints (except of the implicit savepoint) stored for the activity identified by the designated instance, node and node iteration.byte[]
retrieveSessionState(SessionToken session, String savepoint, UUID instanceLogId, int nodeId, int iteration)
Retrieves the state of a running application as abyte[]
so that (the state of) the suspended application/session can be restored.ServerStream
retrieveSessionStateIncrementally(SessionToken session, String savepoint, UUID instanceLogId, int nodeId, int iteration)
Retrieves the state of a running application as aServerStream
so that (the state of) the suspended application/session can be restored.void
storeSessionState(SessionToken session, String savepoint, UUID instanceLogId, int nodeId, int iteration, byte[] sessionState)
Stores the state of a running application so that the application can be suspended, this resembles hibernating a system.
-
-
-
Method Detail
-
getLastSavepoint
String getLastSavepoint(SessionToken session, UUID instanceLogId, int nodeId, int iteration)
Gets the name of most recent valid savepoint stored for the activity identified by the designated instance, node and node iteration. This can be used to resume an application that has crashed but has stored savepoints.- Parameters:
session
- The session which is used to check for access rights on this method.instanceLogId
- The (unchangeable) log ID of the process instance which runs the application.nodeId
- The ID of the node which houses the application.iteration
- The current iteration count of the executed node.- Returns:
- The name of the most recent savepoint for the designated
session/activity,
null
if the session/activity has not been suspended yet or did not provide a savepoint when suspending.
-
getSavepoints
List<String> getSavepoints(SessionToken session, UUID instanceLogId, int nodeId, int iteration)
Gets all savepoints (except of the implicit savepoint) stored for the activity identified by the designated instance, node and node iteration.- Parameters:
session
- The session which is used to check for access rights on this method.instanceLogId
- The (unchangeable) log ID of the process instance which runs the application.nodeId
- The ID of the node which houses the application.iteration
- The current iteration count of the executed node.- Returns:
- The names of all stored savepoints for the designated session/activity (except of the implicit savepoint) in the order they have been created, that is the latest savepoint will be the at the end of the list.
-
storeSessionState
void storeSessionState(SessionToken session, String savepoint, UUID instanceLogId, int nodeId, int iteration, byte[] sessionState)
Stores the state of a running application so that the application can be suspended, this resembles hibernating a system. The application needs to serialise its state to abyte[]
which is saved by the DataManager. The easiest way to create an appropriate array is using aByteArrayOutputStream
and anObjectOutputStream
.- Parameters:
session
- The session which is used to check for access rights on this method and to retrieve the agent and the corresponding organisational position working with the application.savepoint
- The name of the savepoint. If there is already a savepoint of this name, it will be overwritten. This must not be the empty string! If this isnull
, the implicit savepoint will be used (and possibly overwritten).instanceLogId
- The (unchangeable) log ID of the process instance which runs the application.nodeId
- The ID of the node which houses the application.iteration
- The current iteration count of the executed node.sessionState
- The state of the session or application as anbyte[]
ornull
.
-
retrieveSessionState
byte[] retrieveSessionState(SessionToken session, String savepoint, UUID instanceLogId, int nodeId, int iteration)
Retrieves the state of a running application as abyte[]
so that (the state of) the suspended application/session can be restored.- Parameters:
session
- The session which is used to check for access rights on this method.savepoint
- The ID of the savepoint which is to be retrieved. This must not be the empty string! If this isnull
, the implicit savepoint will be used.instanceLogId
- The (unchangeable) log ID of the process instance which runs the application.nodeId
- The ID of the node which houses the application.iteration
- The current iteration count of the executed node.- Returns:
- The state of the session or application as
byte[]
. If no application data has been stored, an empty array will be returned.
-
retrieveSessionStateIncrementally
ServerStream retrieveSessionStateIncrementally(SessionToken session, String savepoint, UUID instanceLogId, int nodeId, int iteration)
Retrieves the state of a running application as aServerStream
so that (the state of) the suspended application/session can be restored. The server input stream does not provide the complete content of the underlying session state but a proxy object requesting the content incrementally when transfered via the communication.- Parameters:
session
- The session which is used to check for access rights on this method.savepoint
- The ID of the savepoint which is to be retrieved. This must not be the empty string! If this isnull
, the implicit savepoint will be used.instanceLogId
- The (unchangeable) log ID of the process instance which runs the application.nodeId
- The ID of the node which houses the application.iteration
- The current iteration count of the executed node.- Returns:
- The state of the session or application as
ServerStream
, that is, clients do not retrieve all of the content of the stream at once but incrementally. If no application data has been stored, an empty stream will be returned. The caller is responsible for closing.
-
-