edu.wpi.prc.templates.java.science
Class ScienceApplicationClient

java.lang.Object
  extended by edu.wpi.prc.templates.java.common.Client
      extended by edu.wpi.prc.templates.java.science.ScienceApplicationClient

public class ScienceApplicationClient
extends Client

The ScienceApplicationClient is an XML-RPC client with added functionality that is needed by the science application. This class has methods for saving and retrieving checkpoints.

Author:
James Baldassari

Field Summary
private static ScienceApplicationClient client
           
private static java.lang.String DEFAULT_SERVER_ADDRESS
           
private  boolean doCheckpointing
           
private static int EXIT_ERROR
           
private static java.lang.String GET_CHECKPOINT_RPC_NAME
           
private static java.lang.String SAVE_CHECKPOINT_RPC_NAME
           
 
Constructor Summary
private ScienceApplicationClient()
          Default constructor.
 
Method Summary
 byte[] getCheckpoint()
          Retrieves the last checkpoint from the project client.
static ScienceApplicationClient instance()
           
 boolean saveCheckpoint(byte[] data)
          Sends a checkpoint to the project client, which then writes it out to disk.
 void setCheckpointing(boolean doCheckpointing)
          Enables or disables the use of checkpointing.
private  void shutdown()
          Exits the entire process because an unrecoverable error occurred.
 
Methods inherited from class edu.wpi.prc.templates.java.common.Client
executeRPC, executeRPCUntilSuccess, setServerAddress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXIT_ERROR

private static final int EXIT_ERROR
See Also:
Constant Field Values

DEFAULT_SERVER_ADDRESS

private static final java.lang.String DEFAULT_SERVER_ADDRESS
See Also:
Constant Field Values

GET_CHECKPOINT_RPC_NAME

private static final java.lang.String GET_CHECKPOINT_RPC_NAME
See Also:
Constant Field Values

SAVE_CHECKPOINT_RPC_NAME

private static final java.lang.String SAVE_CHECKPOINT_RPC_NAME
See Also:
Constant Field Values

doCheckpointing

private boolean doCheckpointing

client

private static ScienceApplicationClient client
Constructor Detail

ScienceApplicationClient

private ScienceApplicationClient()
Default constructor. This constructor is private because the ScienceApplicationClient is a singleton.

Method Detail

setCheckpointing

public void setCheckpointing(boolean doCheckpointing)
Enables or disables the use of checkpointing. Checkpointing should not be used when computing a spot-check result.

Parameters:
doCheckpointing - True to enable checkpointing, false to disable it.

saveCheckpoint

public boolean saveCheckpoint(byte[] data)
Sends a checkpoint to the project client, which then writes it out to disk. If checkpointing is disabled, no action is taken.

Parameters:
data - The checkpoint data to be sent.
Returns:
Returns true if the checkpoint was successfully written; returns false if an error occurred or checkpointing was disabled.

getCheckpoint

public byte[] getCheckpoint()
Retrieves the last checkpoint from the project client. The saveCheckpoint() method should have been called before this method. If checkpointing is disabled, no action is taken.

Returns:
Returns the checkpoint data returned by the client; returns null if no checkpoint was found or if checkpointing was disabled.

shutdown

private void shutdown()
Exits the entire process because an unrecoverable error occurred.


instance

public static ScienceApplicationClient instance()
Returns:
Returns the singleton instance of the ScienceApplicationClient class.