com.sun.faban.driver.engine
Class AgentThread

java.lang.Object
  extended by java.lang.Thread
      extended by com.sun.faban.driver.engine.AgentThread
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
CycleThread, TimeThread

public abstract class AgentThread
extends Thread

Abstract superclass for all driver threads. It provides a factory for instantiating the right implementation depending on the driver specification. Subclasses execute the provided driver, keeps track of response times, think times, transaction counts, etc.

Author:
Akara Sucharitakul

Nested Class Summary
static class AgentThread.RunState
          The various run states for an AgentThread.
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static long TIME_NOT_SET
          Constant value for specifying that the time is not set.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
AgentThread()
           
 
Method Summary
static AgentThread getInstance(String type, String agentId, int id, Class<?> driverClass, Timer timer, AgentImpl agent)
          Factory method for instantiating the right type of AgentThread.
 Metrics getResult()
          Return results of this thread.
 AgentThread.RunState getThreadState()
          Obtains the state of the current thread.
 void run()
          Entry point for starting the thread.
 void stopExecution()
          Triggers stopping and exiting of this thread.
 void waitThreadState(AgentThread.RunState state)
          Waits for a given state of the thread to arrive.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TIME_NOT_SET

public static final long TIME_NOT_SET
Constant value for specifying that the time is not set.

See Also:
Constant Field Values
Constructor Detail

AgentThread

public AgentThread()
Method Detail

getInstance

public static AgentThread getInstance(String type,
                                      String agentId,
                                      int id,
                                      Class<?> driverClass,
                                      Timer timer,
                                      AgentImpl agent)
Factory method for instantiating the right type of AgentThread.

Parameters:
type - The type of this agent
agentId - The display id of this agent
id - The id of this agent
driverClass - The driver class
timer - The timer object reference
agent - The agent calling this thread
Returns:
An instance of the AgentThread subclass.

run

public final void run()
Entry point for starting the thread. Subclasses do not override this method but override doRun instead. Run implicitly calls doRun.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

getThreadState

public AgentThread.RunState getThreadState()
Obtains the state of the current thread.

Returns:
The state of the current thread.

waitThreadState

public void waitThreadState(AgentThread.RunState state)
Waits for a given state of the thread to arrive.

Parameters:
state - The state to wait for.

getResult

public Metrics getResult()
Return results of this thread.

Returns:
Final stats

stopExecution

public void stopExecution()
Triggers stopping and exiting of this thread.