ptolemy.backtrack
Class Checkpoint

java.lang.Object
  extended by ptolemy.backtrack.Checkpoint

public class Checkpoint
extends java.lang.Object

The class of checkpoint objects. A checkpoint object represents the smallest entity on which checkpoints are created and managed. It monitors one or more objects. When the rollback(long, boolean) function is called, all the monitored objects are rolled back to their previous states, defined by a timestamp.

Since:
Ptolemy II 5.1
Version:
$Id: Checkpoint.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Thomas Feng
Accepted Rating:
Red (tfeng)
Proposed Rating:
Red (tfeng)

Field Summary
private  CheckpointState _state
          The current state of the checkpoint object.
 
Constructor Summary
Checkpoint(Rollbackable object)
          Construct a checkpoint object with an initial object in its monitored object list.
 
Method Summary
 void addObject(Rollbackable object)
          Add an object to the monitored object list.
 void commit(long timestamp)
          Commit the changes on all the monitored objects up to the given timestamp.
 long createCheckpoint()
          Create a new checkpoint and return its handle.
 long getTimestamp()
          Get the current timestamp (also considered as the last created handle).
 boolean isCheckpointing()
          Test if the checkpointing facility is running.
 void removeObject(Rollbackable object)
          Remove an object from the monitored object list.
 void rollback(long timestamp)
          Rollback all the monitored objects to their previous states defined by the given timestamp (or, handle).
 void rollback(long timestamp, boolean trim)
          Rollback all the monitored objects to their previous states defined by the given timestamp (or, handle).
 void setCheckpoint(Checkpoint checkpoint)
          Set this checkpoint object to be the same as the given checkpoint object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_state

private CheckpointState _state
The current state of the checkpoint object.

Constructor Detail

Checkpoint

public Checkpoint(Rollbackable object)
Construct a checkpoint object with an initial object in its monitored object list.

Parameters:
object - The first object to be placed in the list, or null if the list is intended to be empty.
Method Detail

addObject

public void addObject(Rollbackable object)
Add an object to the monitored object list.

Parameters:
object - The object to be added.

commit

public void commit(long timestamp)
Commit the changes on all the monitored objects up to the given timestamp. Records of changes with timestamps less than the given timestamp are deleted.

Parameters:
timestamp - The timestamp.

createCheckpoint

public long createCheckpoint()
Create a new checkpoint and return its handle. The current timestamp is increased by one before the it (as a handle) is returned.

Returns:
The handle of the newly created checkpoint.

getTimestamp

public long getTimestamp()
Get the current timestamp (also considered as the last created handle).

Returns:
The current timestamp.

isCheckpointing

public boolean isCheckpointing()
Test if the checkpointing facility is running.

Returns:
true if the checkpointing facility is running.

removeObject

public void removeObject(Rollbackable object)
Remove an object from the monitored object list.

Parameters:
object - The object to be removed.

rollback

public void rollback(long timestamp)
Rollback all the monitored objects to their previous states defined by the given timestamp (or, handle). The records used in the rollback are automatically deleted. This is the same as rollback(timestamp, true).

Parameters:
timestamp - The timestamp taken at a previous time.
See Also:
rollback(long, boolean)

rollback

public void rollback(long timestamp,
                     boolean trim)
Rollback all the monitored objects to their previous states defined by the given timestamp (or, handle).

Parameters:
timestamp - The timestamp taken at a previous time.
trim - Whether to delete the records used for the rollback.

setCheckpoint

public void setCheckpoint(Checkpoint checkpoint)
Set this checkpoint object to be the same as the given checkpoint object. The set of objects monitored by this checkpoint object is merged with those monitored by the given checkpoint.

Parameters:
checkpoint - The given checkpoint object to be merged with this one.