com.sun.faban.driver.engine
Class AgentImpl

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by com.sun.faban.driver.engine.AgentImpl
All Implemented Interfaces:
Agent, Serializable, Runnable, Remote, Unreferenced

public class AgentImpl
extends UnicastRemoteObject
implements Agent, Unreferenced, Runnable

AgentImpl executes the driver threads of any given subtype. It receives commands from the Master. The AgentImpl is responsible for spawning and managing threads, synchronizing between the threads and aggregating the stats from all threads.

Author:
Shanti Subramanyam
See Also:
Agent, AgentThread, Serialized Form

Field Summary
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Method Summary
 void abortRun()
          Contacts the master to abort the run.
 void configure(Master master, RunInfo runInfo, int driverType, Timer timer)
          Configures each agents with the properties passed.
 int getId()
          Obtains the id of this agent.
 Metrics getResults()
          Report stats from a run Each thread's result is obtained by calling that thread's getResult() All these results are then aggregated by calling one of the thread's getAggregateResult method.
 void join()
          Waits for all the threads to terminate.
 void kill()
          This method kills off the current run.
static void main(String[] argv)
          AgentImpl's main method.
 void postRun()
          Invokes the post run method on thread 0 of each driver agent 0, if postRun is configured.
 void run()
          Starts the driver threads for this agent, possibly in it's own thread.
 void setStartTime(int time)
          Sets the actual run start time.
 void startThreads()
          Start all the driver threads.
 void terminate()
          Terminates all leftover threads remaining at the end of the run.
 void unreferenced()
          When this instance is unreferenced the application must exit.
 void waitForThreadStart()
          Wait until all threads are started.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

configure

public void configure(Master master,
                      RunInfo runInfo,
                      int driverType,
                      Timer timer)
               throws RemoteException
Configures each agents with the properties passed.

Specified by:
configure in interface Agent
Parameters:
master - the remote interface to the Master
runInfo - run information passed by Master
driverType -
timer - BenchmarkDefinition Start time
Throws:
RemoteException

startThreads

public void startThreads()
Start all the driver threads.

Specified by:
startThreads in interface Agent

run

public void run()
Starts the driver threads for this agent, possibly in it's own thread.

Specified by:
run in interface Runnable
See Also:
Runnable.run()

getId

public int getId()
Obtains the id of this agent.

Specified by:
getId in interface Agent
Returns:
The id of this agent.

abortRun

public void abortRun()
Contacts the master to abort the run. Don't kill until master calls kill.


waitForThreadStart

public void waitForThreadStart()
Wait until all threads are started.

Specified by:
waitForThreadStart in interface Agent

setStartTime

public void setStartTime(int time)
Sets the actual run start time.

Specified by:
setStartTime in interface Agent
Parameters:
time - The relative millisec time of the benchmark start

kill

public void kill()
This method kills off the current run. It terminates all threads.

Specified by:
kill in interface Agent

terminate

public void terminate()
Terminates all leftover threads remaining at the end of the run. Logs the stack trace for all these threads but does not actually wait for the threads to terminate (join). Terminate is called while join is hanging on some thread that refuses to terminate.

Specified by:
terminate in interface Agent

getResults

public Metrics getResults()
Report stats from a run Each thread's result is obtained by calling that thread's getResult() All these results are then aggregated by calling one of the thread's getAggregateResult method.

Specified by:
getResults in interface Agent
Returns:
results
See Also:
Metrics

join

public void join()
Waits for all the threads to terminate.

Specified by:
join in interface Agent

postRun

public void postRun()
Invokes the post run method on thread 0 of each driver agent 0, if postRun is configured.

Specified by:
postRun in interface Agent

unreferenced

public void unreferenced()
When this instance is unreferenced the application must exit.

Specified by:
unreferenced in interface Unreferenced

main

public static void main(String[] argv)
AgentImpl's main method.

Parameters:
argv - the arguments passed to the java command