JavaGenes, NASA Ames. Written largely by Al Globus

gov.nasa.javaGenes.core
Class Checkpointer

java.lang.Object
  extended bygov.nasa.javaGenes.core.Checkpointer
All Implemented Interfaces:
java.io.Serializable

public class Checkpointer
extends java.lang.Object
implements java.io.Serializable

Runs a Checkpointable job. Modify static final private Checkpointer read(String f, String className, String[] arguments) when you want to evolve a new kind of data structure and have implemented the relevant classes: RunFoo FooParameters FooPopulation FooIndividual and any mutator or crossover operators necessary As a general rule, the static methods are used for checkpointing calls since these are accessible everywhere without passing the Checkpointer object around as an argument.

See Also:
Serialized Form

Field Summary
protected  boolean checkpointASAP
           
protected static Checkpointer currentCheckpointer
           
protected  int excessiveTimeBetweenCheckpointOKs
           
protected static java.lang.String filename
           
protected  java.util.Date lastCheckpointDate
           
protected  long lastOkToCheckpoint
           
protected  boolean mustPrepareToDie
           
protected  gov.nasa.javaGenes.core.Checkpointable objectToCheckpoint
           
protected  boolean readyToDieNow
           
protected  long timeBetweenCheckpoints
           
 
Method Summary
static boolean areYouPreparingToDie()
          Called by an external agency.
 boolean areYouPreparingToDieLocal()
          Not normally not called directly
static boolean areYouReadyToDie()
          Called by an external agency.
 boolean areYouReadyToDieLocal()
          Not normally not called directly
static void cancelDeath()
          Called by an external agency.
 void cancelDeathLocal()
          Not normally not called directly
static void checkpoint()
          called by a Checkpointable.
static void checkpoint(java.lang.String f)
          called by a Checkpointable.
 void checkpointLocal()
          Not normally not called directly
 void checkpointLocal(java.lang.String f)
          Not normally not called directly
static void checkpointWhenPossible()
          Called by an external agency.
 void checkpointWhenPossibleLocal()
          Not normally not called directly
static void dontCheckpoint()
          Called by an external agency.
 void dontCheckpointLocal()
          Not normally not called directly
static java.util.Date getLastCheckpointDate()
           
 java.util.Date getLastCheckpointDateLocal()
          Not normally not called directly
protected static Checkpointer getSerialized(java.lang.String filename)
           
static void main(java.lang.String[] a)
          Will restart if a checkpoint file exists, will start if not.
static void ok()
          called by a Checkpointable.
 void okLocal()
          Not normally not called directly
static void prepareToDie()
          Called by an external agency.
 void prepareToDieLocal()
          Not normally not called directly
 void printCheckpointStatistics()
          creates checkpoint_filename.statistics.txt and puts mean, standard deviation, highest, and lowest time between checkpoints.
 void restart()
          Not normally not called directly
 void start(java.lang.String[] arguments)
          Not normally not called directly
protected static void startPeriodicCheckpoint(Checkpointer current, long interval)
          starts a thread that will execute periodic checkpoints
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentCheckpointer

protected static volatile Checkpointer currentCheckpointer

objectToCheckpoint

protected volatile gov.nasa.javaGenes.core.Checkpointable objectToCheckpoint

filename

protected static volatile java.lang.String filename

excessiveTimeBetweenCheckpointOKs

protected volatile int excessiveTimeBetweenCheckpointOKs

timeBetweenCheckpoints

protected long timeBetweenCheckpoints

lastCheckpointDate

protected volatile java.util.Date lastCheckpointDate

lastOkToCheckpoint

protected volatile long lastOkToCheckpoint

checkpointASAP

protected volatile boolean checkpointASAP

mustPrepareToDie

protected volatile boolean mustPrepareToDie

readyToDieNow

protected volatile boolean readyToDieNow
Method Detail

main

public static void main(java.lang.String[] a)
Will restart if a checkpoint file exists, will start if not.


startPeriodicCheckpoint

protected static void startPeriodicCheckpoint(Checkpointer current,
                                              long interval)
starts a thread that will execute periodic checkpoints


ok

public static final void ok()
called by a Checkpointable. it's okay to checkpoint now.


checkpoint

public static final void checkpoint()
called by a Checkpointable. checkpoint immediately.


checkpoint

public static final void checkpoint(java.lang.String f)
called by a Checkpointable. checkpoint immediately to the indicated file.


checkpointWhenPossible

public static final void checkpointWhenPossible()
Called by an external agency.


dontCheckpoint

public static final void dontCheckpoint()
Called by an external agency.


prepareToDie

public static final void prepareToDie()
Called by an external agency.


areYouPreparingToDie

public static final boolean areYouPreparingToDie()
Called by an external agency.


areYouReadyToDie

public static final boolean areYouReadyToDie()
Called by an external agency.


cancelDeath

public static final void cancelDeath()
Called by an external agency. You're not going to die after all.


getLastCheckpointDate

public static final java.util.Date getLastCheckpointDate()
Returns:
date of last checkpoint, null if no checkpoint has been done since construction

start

public void start(java.lang.String[] arguments)
Not normally not called directly


restart

public void restart()
Not normally not called directly


okLocal

public final void okLocal()
Not normally not called directly


checkpointLocal

public final void checkpointLocal(java.lang.String f)
Not normally not called directly


checkpointLocal

public final void checkpointLocal()
Not normally not called directly


cancelDeathLocal

public final void cancelDeathLocal()
Not normally not called directly


checkpointWhenPossibleLocal

public final void checkpointWhenPossibleLocal()
Not normally not called directly


dontCheckpointLocal

public final void dontCheckpointLocal()
Not normally not called directly


prepareToDieLocal

public final void prepareToDieLocal()
Not normally not called directly


areYouPreparingToDieLocal

public final boolean areYouPreparingToDieLocal()
Not normally not called directly


areYouReadyToDieLocal

public final boolean areYouReadyToDieLocal()
Not normally not called directly


getLastCheckpointDateLocal

public final java.util.Date getLastCheckpointDateLocal()
Not normally not called directly


printCheckpointStatistics

public void printCheckpointStatistics()
creates checkpoint_filename.statistics.txt and puts mean, standard deviation, highest, and lowest time between checkpoints. These data may be used to determine if a Checkpointable is calling Checkpointer.ok() often enough.


getSerialized

protected static Checkpointer getSerialized(java.lang.String filename)
Returns:
the object serialized in filename

JavaGenes, NASA Ames. Written largely by Al Globus