com.sun.faban.harness.engine
Class RunQ

java.lang.Object
  extended by com.sun.faban.harness.engine.RunQ

public class RunQ
extends Object

This class implements the Faban RunQ. It provides methods to add a run, delete a run and to get a list of all the runs in the RunQ.

Author:
Ramesh Ramachandran

Field Summary
static int BENCHNAME
          Benchmark name field index in the run queue listing.
static int DESCRIPTION
          Description field index in the run queue listing.
static int RUNSEQ
          Run seqeunce field index in the run queue listing.
 
Method Summary
 String addRun(String user, String profile, BenchmarkDescription desc)
          Adds a Run to the runq.
 boolean deleteRun(String runId)
          Deletes the run with the specified runId from the runq.
 void exit()
          Method to stop the run daemon before unloading Faban Engine servlet.
 Run fetchNextRun(String runId)
          Moves the run from the queue into the output directory.
 String getCurrentBenchmark()
          Obtains the short name of the current benchmark run.
 String getCurrentRunId()
          Obtains the run id of the current run.
static RunQ getHandle()
          Singleton initializer for runQ and runDaemon.
 String getRunDaemonStatus()
          Reports the status of the RunDaemonThread.
 String killCurrentRun(String runId, String user)
          Method to stop the current benchamark run.
static String[] listPending()
          Obtains the list of pending runs in the run queue.
 String[][] listRunQ()
          Returns a list of the runs currently in the runq.
 NameValuePair<Long> nextRunAge(long minAge)
          Obtains the name and age of the next run, in milliseconds since submitted, if the age is more than minAge.
 boolean startRunDaemon()
          Starts/restarts the run daemon.
 boolean stopRunDaemon()
          Stops/suspends the run daemon.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RUNSEQ

public static final int RUNSEQ
Run seqeunce field index in the run queue listing.

See Also:
Constant Field Values

BENCHNAME

public static final int BENCHNAME
Benchmark name field index in the run queue listing.

See Also:
Constant Field Values

DESCRIPTION

public static final int DESCRIPTION
Description field index in the run queue listing.

See Also:
Constant Field Values
Method Detail

getHandle

public static RunQ getHandle()
Singleton initializer for runQ and runDaemon.

Returns:
runQ

addRun

public String addRun(String user,
                     String profile,
                     BenchmarkDescription desc)
              throws IOException
Adds a Run to the runq. Creates a directory for the run in the runq directory and stores the parameter repository in it. It also notifies the RunDaemon thread of the newly added run. All operations on the runq directory are synchronized through the use of the LockFileMonitor class.

Parameters:
user - The user name or id if logged in, or null
profile - Profile name for this run
desc - The description of the benchmark to run
Returns:
The run id of the run just added
Throws:
IOException - There was a problem accessing the run queue directory

deleteRun

public boolean deleteRun(String runId)
Deletes the run with the specified runId from the runq. Does not take any action if such a run is not found or is already being executed by the runDaemon thread.

Parameters:
runId - the runId of the run to be deleted
Returns:
Whether or not the run was successfully deleted from the queue

listRunQ

public String[][] listRunQ()
Returns a list of the runs currently in the runq. The list is an array of run sequence, benchmark name, and description.

Returns:
an array of RunInfo objects.

listPending

public static String[] listPending()
Obtains the list of pending runs in the run queue. This is the list of formatted runids. This is a convenience method and it internally calls listRunQ.

Returns:
The list of pending runs

getRunDaemonStatus

public String getRunDaemonStatus()
Reports the status of the RunDaemonThread.

Returns:
String representing the current status of the run daemon.

startRunDaemon

public boolean startRunDaemon()
Starts/restarts the run daemon.

Returns:
Whether the run daemon is started

stopRunDaemon

public boolean stopRunDaemon()
Stops/suspends the run daemon.

Returns:
Whether the run daemon is successfully stopped

getCurrentRunId

public String getCurrentRunId()
Obtains the run id of the current run.

Returns:
The run id of the current run, or null if there is no ccurrent run

getCurrentBenchmark

public String getCurrentBenchmark()
Obtains the short name of the current benchmark run.

Returns:
The benchmark's short name

killCurrentRun

public String killCurrentRun(String runId,
                             String user)
Method to stop the current benchamark run.

Parameters:
runId - The run id to kill - this is for safety
user - The current user name, or null if security is disabled
Returns:
current run name.

fetchNextRun

public Run fetchNextRun(String runId)
                 throws RunEntryException,
                        IOException,
                        ClassNotFoundException
Moves the run from the queue into the output directory. This function is normally done by the run daemon with the exception of a submission proxy where the run daemon is not run. The RunRetriever servlet will call to fetch this run to run on a remote system instead. If the given run id does not match the id of the next run, some inconsistencies have happened. The method returns null in this case.

Parameters:
runId - The id of the run in question.
Returns:
The run object representing this run
Throws:
RunEntryException - There is an error in the run queue entry
IOException
ClassNotFoundException

nextRunAge

public NameValuePair<Long> nextRunAge(long minAge)
Obtains the name and age of the next run, in milliseconds since submitted, if the age is more than minAge.

Parameters:
minAge - The minimum run age to return.
Returns:
The age of the next run, or null if there is no next run or the next run is younger than the given age

exit

public void exit()
Method to stop the run daemon before unloading Faban Engine servlet.