com.sun.slamd.client
Class ClientSideJob

java.lang.Object
  extended bycom.sun.slamd.client.ClientSideJob

public class ClientSideJob
extends java.lang.Object

This class defines a "client-side" job. It is a representation of a job that is held by the client, having no knowledge of anything on the server side). All methods implemented in this class operate on the local version of the job only and have no direct impact on the execution of the job that may be occurring concurrently on other clients.


Constructor Summary
ClientSideJob(ClientMessageWriter messageWriter, java.lang.String classPath, java.lang.String jobClass, int threadsPerClient, int duration, int collectionInterval, ParameterList parameters, boolean useCustomClassLoader, boolean enableRealTimeStats, RealTimeStatReporter statReporter)
          Creates a new client-side job that is only to be used as a standalone job (i.e., to run without a server).
ClientSideJob(Client client, java.lang.String jobID, java.lang.String jobClass, int threadsPerClient, java.util.Date startTime, java.util.Date stopTime, int clientNumber, int duration, int collectionInterval, int threadStartupDelay, ParameterList parameters, boolean useCustomClassLoader, boolean enableRealTimeStats, RealTimeStatReporter statReporter)
          Creates a new client-side job with the provided information.
 
Method Summary
 boolean enableRealTimeStats()
          Indicates whether this job should collect statistical data in real time.
 void forcefullyStop(int stopReason)
          Attempts to forcefully stop execution of the job by interrupting the thread.
 int getActiveThreadCount()
          Retrieves the number of threads that are currently active.
 int getActualDuration()
          Retrieves the total length of time in seconds that the job was running.
 long getActualStartTime()
          Retrieves the time at which this job actually started running.
 long getActualStopTime()
          Retrieves the time at which this job actually stopped running.
 int getCollectionInterval()
          Retrieves the length of time in seconds that should be used as the statistics collection interval.
 int getDuration()
          Retrieves the maximum length of time in seconds that this job should be allowed to run.
 java.lang.String getJobClass()
          Retrieves the name of the Java class that should be invoked to run this job.
 java.lang.String getJobID()
          Retrieves the job ID for this job.
 int getJobState()
          Retrieves the state of this job.
 java.lang.String[] getLogMessages()
          Retrieves an array containing all of the messages that have been logged for this job.
 ParameterList getParameters()
          Retrieves the list of job-specific parameters associated with this job.
 long getScheduledStartTime()
          Retrieves the time at which this job has been scheduled to start.
 java.util.Date getStartTime()
          Retrieves the time at which this job should start running.
 RealTimeStatReporter getStatReporter()
          Retrieves the stat reporter that should be used to report real-time statistical data.
 StatTracker[] getStatTrackers(boolean aggregateThreadData)
          Retrieves the stat tracker information for this job.
 java.util.Date getStopTime()
          Retrieves the time at which this job should stop running.
 int getThreadsPerClient()
          Retrieves the number of threads that should be started on each client running this job.
 boolean isDone()
          Indicates whether this job has been completed or is otherwise stopped for some reason.
 void logMessage(java.lang.String threadID, java.lang.String message)
          Writes a new message from the specified thread into the list of messages to log.
 void setJobState(int jobState)
          Specifies the job state to use for this job.
 int start()
          Attempts to start processing on the job.
 int startAndWait()
          Starts processing on the job and waits until that processing is complete.
 int stop(int stopReason)
          Attempts to stop processing on the job.
 int stopAndWait(int stopReason)
          Attempts to stop processing on the job and will not return until the job state indicates that it is no longer running.
 void threadDone(JobClass jobThread)
          Indicates that the specified thread is no longer running.
 void writeVerbose(java.lang.String message)
          Writes the provided message to the client message writer using the verbose setting (so the message will not be displayed if the client is not operating in verbose mode).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientSideJob

public ClientSideJob(Client client,
                     java.lang.String jobID,
                     java.lang.String jobClass,
                     int threadsPerClient,
                     java.util.Date startTime,
                     java.util.Date stopTime,
                     int clientNumber,
                     int duration,
                     int collectionInterval,
                     int threadStartupDelay,
                     ParameterList parameters,
                     boolean useCustomClassLoader,
                     boolean enableRealTimeStats,
                     RealTimeStatReporter statReporter)
Creates a new client-side job with the provided information.

Parameters:
client - The client with which this job is associated.
jobID - The job ID for this job.
jobClass - The name of the Java class that should be executed to run this job.
threadsPerClient - The number of threads that should be used to run this job.
startTime - The time at which this job is supposed to start.
stopTime - The time at which this job is supposed to stop.
clientNumber - The client number associated with this job.
duration - The maximum length of time in seconds that this job should run.
collectionInterval - The length of time in seconds that should be used for the statistics collection interval.
threadStartupDelay - The delay in milliseconds that should be used when creating the individual client threads.
parameters - The list of job-specific parameters that control how this job should operate.
useCustomClassLoader - Indicates whether the custom job class loader should be used to load job classes.
enableRealTimeStats - Indicates whether this job should report statistics in real-time.
statReporter - The stat reporter that should be used to report real-time statistics.

ClientSideJob

public ClientSideJob(ClientMessageWriter messageWriter,
                     java.lang.String classPath,
                     java.lang.String jobClass,
                     int threadsPerClient,
                     int duration,
                     int collectionInterval,
                     ParameterList parameters,
                     boolean useCustomClassLoader,
                     boolean enableRealTimeStats,
                     RealTimeStatReporter statReporter)
Creates a new client-side job that is only to be used as a standalone job (i.e., to run without a server).

Parameters:
messageWriter - The message writer that will be used to write messages regarding the progress of job execution.
classPath - The directory on the filesystem in which job class files may be found.
jobClass - The name of the Java class that should be used to run this job.
threadsPerClient - The number of threads to use to run the job.
duration - The maximum length of time in seconds that the job should be allowed to run.
collectionInterval - The length of time in seconds that should be used for the statistics collection interval.
parameters - The list of job-specific parameters that control how this job should operate.
useCustomClassLoader - Indicates whether the custom job class loader should be used to load job classes.
enableRealTimeStats - Indicates whether this job should report statistics in real-time.
statReporter - The stat reporter that should be used to report real-time statistics.
Method Detail

getJobID

public java.lang.String getJobID()
Retrieves the job ID for this job.

Returns:
The job ID for this job.

getJobClass

public java.lang.String getJobClass()
Retrieves the name of the Java class that should be invoked to run this job.

Returns:
The name of the Java class that should be invoked to run this job.

getThreadsPerClient

public int getThreadsPerClient()
Retrieves the number of threads that should be started on each client running this job.

Returns:
The number of threads that should be started on each client running this job.

getStartTime

public java.util.Date getStartTime()
Retrieves the time at which this job should start running.

Returns:
The time at which this job should start running.

getScheduledStartTime

public long getScheduledStartTime()
Retrieves the time at which this job has been scheduled to start.

Returns:
The time at which this job has been scheduled to start.

getActualStartTime

public long getActualStartTime()
Retrieves the time at which this job actually started running.

Returns:
The time at which this job actually started running.

getStopTime

public java.util.Date getStopTime()
Retrieves the time at which this job should stop running.

Returns:
The time at which this job should stop running.

getActualStopTime

public long getActualStopTime()
Retrieves the time at which this job actually stopped running.

Returns:
The time at which this job actually stopped running.

getDuration

public int getDuration()
Retrieves the maximum length of time in seconds that this job should be allowed to run.

Returns:
The maximum length of time in seconds that this job should be allowed to run.

getActualDuration

public int getActualDuration()
Retrieves the total length of time in seconds that the job was running.

Returns:
The total length of time in seconds that the job was running.

getCollectionInterval

public int getCollectionInterval()
Retrieves the length of time in seconds that should be used as the statistics collection interval.

Returns:
The length of time in seconds that should be used as the statistics collection interval.

enableRealTimeStats

public boolean enableRealTimeStats()
Indicates whether this job should collect statistical data in real time.

Returns:
true if the client should collect statistical data in real time, or false if not.

getStatReporter

public RealTimeStatReporter getStatReporter()
Retrieves the stat reporter that should be used to report real-time statistical data.

Returns:
The stat reporter that should be used to report real-time statistical data, or null if no reporting should be done.

getParameters

public ParameterList getParameters()
Retrieves the list of job-specific parameters associated with this job.

Returns:
The list of job-specific parameters associated with this job.

startAndWait

public int startAndWait()
Starts processing on the job and waits until that processing is complete. This method is intended for use by standalone clients that do not actually communicate with a SLAMD server.

Returns:
The response code from the start operation.

start

public int start()
Attempts to start processing on the job.

Returns:
The result code from the attempted start operation.

stop

public int stop(int stopReason)
Attempts to stop processing on the job.

Parameters:
stopReason - The reason that the job is to be stopped.
Returns:
The result code from the attempted stop operation.

stopAndWait

public int stopAndWait(int stopReason)
Attempts to stop processing on the job and will not return until the job state indicates that it is no longer running.

Parameters:
stopReason - The reason that the job is to be stopped.
Returns:
The result code from the attempted stop operation.

forcefullyStop

public final void forcefullyStop(int stopReason)
Attempts to forcefully stop execution of the job by interrupting the thread. This should only be used if the job is not responding to normal stop requests, most likely because it is blocked.

Parameters:
stopReason - The stop reason that should be used for the job.

getJobState

public int getJobState()
Retrieves the state of this job.

Returns:
The state of this job.

setJobState

public void setJobState(int jobState)
Specifies the job state to use for this job.

Parameters:
jobState - The job state to use for this job.

getActiveThreadCount

public int getActiveThreadCount()
Retrieves the number of threads that are currently active.

Returns:
The number of threads that are currently active.

getStatTrackers

public StatTracker[] getStatTrackers(boolean aggregateThreadData)
Retrieves the stat tracker information for this job.

Parameters:
aggregateThreadData - Indicates whether the data collected by each thread should be aggregated before returning the results.
Returns:
The stat tracker information for this job.

getLogMessages

public java.lang.String[] getLogMessages()
Retrieves an array containing all of the messages that have been logged for this job.

Returns:
An array containing all of the messages that have been logged for this job.

writeVerbose

public void writeVerbose(java.lang.String message)
Writes the provided message to the client message writer using the verbose setting (so the message will not be displayed if the client is not operating in verbose mode). The specified message will not be written to the SLAMD log.

Parameters:
message - The message to be written.

logMessage

public void logMessage(java.lang.String threadID,
                       java.lang.String message)
Writes a new message from the specified thread into the list of messages to log. Note that the messages will not actually be logged into the SLAMD server's log until they are sent back to the server in a status response or job completed message in order to cut down on the network traffic and reduce latency associated with job processing.

Parameters:
threadID - The ID of the thread logging this message.
message - The message to be logged.

threadDone

public void threadDone(JobClass jobThread)
Indicates that the specified thread is no longer running. This removes the thread from the active thread list and once all threads have completed performs the appropriate job cleanup work.

Parameters:
jobThread - The job thread that has finished.

isDone

public boolean isDone()
Indicates whether this job has been completed or is otherwise stopped for some reason. A job will not be considered done if it was never started.

Returns:
true if the job is done, or false if not.