com.sun.faban.harness.engine
Class RunDaemon

java.lang.Object
  extended by com.sun.faban.harness.engine.RunDaemon
All Implemented Interfaces:
Runnable

public class RunDaemon
extends Object
implements Runnable

This class implements the RunDaemon thread. The runq object notifies this thread whenever a new run is added to the runq. The RunDaemon thread picks the next run for execution and checks the runType file. If it is a benchmark run, it instantiates the GenericBenchmark object to execute the benchmark in a separate thread and waits for it to complete. If it is a command then it uses the runCommand object to execute the same.

Author:
Ramesh Ramachandran

Constructor Summary
RunDaemon(RunQLock runqLock)
          Constructor.
 
Method Summary
 void exit()
          Exits the RunDaemon.
 Run fetchNextRun(String name)
          Fetches the next run from the run queue and places it into the output to be executed.
 String getCurrentRunBenchmark()
          Obtains the short name of the current benchmark run.
 String getCurrentRunId()
          Obtains the run id of the current run.
 String getRunDaemonThreadStatus()
          Obtains RunDaemon thread status.
 String killCurrentRun(String runId, String user)
          To abort the currently executing benchmark run.
 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 resumeRunDaemonThread()
          Called by RunQ's resumeRunDaemon method.
 void run()
          The run method for the RunDaemonThread.
 boolean suspendRunDaemonThread()
          Called by RunQ's stopRunDaemon method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RunDaemon

public RunDaemon(RunQLock runqLock)
Constructor.

Parameters:
runqLock - the monitor object used to syncronize on the runq
Method Detail

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

fetchNextRun

public Run fetchNextRun(String name)
                 throws RunEntryException,
                        IOException,
                        ClassNotFoundException
Fetches the next run from the run queue and places it into the output to be executed.

Parameters:
name - The name of the run to fetch
Returns:
The run object for the next run
Throws:
RunEntryException - The next run entry is incomplete
IOException - There is an error reading the entry
ClassNotFoundException - Could not find the benchmark class for the run.

run

public void run()
The run method for the RunDaemonThread. It loops indefinitely and blocks when there are no runs in the runq. It continues when notified of a new run by the RunQ object.

Specified by:
run in interface Runnable

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

getCurrentRunBenchmark

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

Returns:
The benchmark's short name

killCurrentRun

public String killCurrentRun(String runId,
                             String user)
To abort the currently executing benchmark run.

Parameters:
runId - The name of the run
user - The user killing the run
Returns:
The run name being killed

exit

public void exit()
Exits the RunDaemon.


getRunDaemonThreadStatus

public String getRunDaemonThreadStatus()
Obtains RunDaemon thread status.

Returns:
status of RunDaemon thread

suspendRunDaemonThread

public boolean suspendRunDaemonThread()
Called by RunQ's stopRunDaemon method.

Returns:
Whether or not the suspend succeeded

resumeRunDaemonThread

public boolean resumeRunDaemonThread()
Called by RunQ's resumeRunDaemon method.

Returns:
Whether or not the resume succeeded