|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Thread
com.sun.slamd.job.JobClass
This class implements a thread that may be executed as a SLAMD job. Depending on the job configuration, multiple instances of this thread may operate concurrently on the same machine or across multiple machines. Anyone that wishes to implement their own custom job for SLAMD should only need to extend this class.
| Field Summary |
| Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
protected |
JobClass()
Creates a new job thread that is not running and that has not been requested to stop. |
| Method Summary | |
void |
destroy()
Provides a means for destroying this job thread if it does not respond to a graceful shutdown request. |
boolean |
enableRealTimeStats()
Indicates whether real-time statistics collection has been enabled in the client with which this job is associated. |
void |
finalizeClient()
Performs any per-client finalization that should be done for this job. |
void |
finalizeJob()
Performs any per-job finalization that should be done for this job. |
void |
finalizeThread()
Performs any per-thread finalization that should be done for this job. |
int |
getActiveThreadCount()
Retrieves the number of threads that are currently active for this job. |
java.lang.String |
getClientID()
Retrieves the client ID for this job thread. |
int |
getClientNumber()
Retrieves the client number associated with this job thread. |
ClientSideJob |
getClientSideJob()
Retrieves the client side job associated with this job class. |
ParameterList |
getClientSideParameterStubs()
Retrieves a list of parameter "stubs" that specify all the parameters that should be available to clients. |
int |
getCollectionInterval()
Retrieves the collection interval for this job thread. |
java.lang.String |
getJobCategoryName()
Retrieves the name of the category in which this job class exists. |
abstract java.lang.String |
getJobDescription()
Retrieves a description of the job performed by this job thread. |
java.lang.String |
getJobID()
Retrieves the job ID of the job with which this job thread is currently associated. |
abstract java.lang.String |
getJobName()
Retrieves the name of the job performed by this job thread. |
abstract ParameterList |
getParameterStubs()
Retrieves a list of parameter "stubs" that should be used to indicate which parameters should be passed to the initialize method. |
int |
getScheduledDuration()
Retrieves the scheduled duration for this job thread. |
long |
getShouldStopTime()
Retrieves the time at which this job should stop, either because of the duration or the stop time. |
RealTimeStatReporter |
getStatReporter()
Retrieves the real-time stat reporter that should be used for this job. |
abstract StatTracker[] |
getStatTrackers()
Retrieves the stat trackers that are maintained for this job thread. |
abstract StatTracker[] |
getStatTrackerStubs(java.lang.String clientID,
java.lang.String threadID,
int collectionInterval)
Retrieves the set of stat trackers that will be maintained by this job class. |
java.lang.String |
getThreadID()
Retrieves the thread ID for this job thread. |
int |
getThreadNumber()
Retrieves the thread number associated with this job thread. |
void |
indicateCompletedWithErrors()
Indicates that this job thread has completed, but there were errors that may impact how the results should be interpreted. |
void |
indicateStoppedDueToError()
Indicates that this job thread has been stopped because of an unrecoverable error. |
void |
initializeClient(java.lang.String clientID,
ParameterList parameters)
Performs initialization for this job on each client immediately before each thread is created to actually run the job. |
void |
initializeJob(ParameterList parameters)
Performs a one-time initialization for this job. |
void |
initializeJobThread(java.lang.String clientID,
java.lang.String threadID,
int collectionInterval,
ClientSideJob job,
int duration,
java.util.Date stopTime,
long startTimeMillis,
ParameterList parameters)
Provides the job thread with all of the information that it needs to run. |
abstract void |
initializeThread(java.lang.String clientID,
java.lang.String threadID,
int collectionInterval,
ParameterList parameters)
Initializes this job thread to be used to actually run the job on the client. |
boolean |
isDeprecated(java.lang.StringBuffer message)
Indicates whether this job class is deprecated. |
boolean |
isRunning()
Indicates whether the job is currently running. |
void |
logMessage(java.lang.String message)
Sends a status message regarding the progress of this job thread to the parent job so that it can be recorded in the SLAMD logger. |
int |
overrideCollectionInterval()
Provides a means for job classes to have a level of control over the statistics collection interval that will be used for a job. |
int |
overrideNumClients()
Provides a means for job classes to have a level of control over the number of clients that will be used to run a job. |
int |
overrideThreadsPerClient()
Provides a means for job classes to have a level of control over the number of threads per client that will be used to run a job. |
boolean |
providesParameterTest()
Indicates whether this job class implements logic that makes it possible to test the validity of job parameters before scheduling the job for execution (e.g., to see if the server is reachable using the information provided). |
void |
run()
A wrapper for the runJob method (which actually does the real
work for this job thread). |
abstract void |
runJob()
The method that does all the real work for this job. |
void |
setClientNumber(int clientNumber)
Specifies the client number to use for this job thread. |
void |
setClientSideJob(ClientSideJob job)
Sets the client-side job that should be associated with this job class. |
void |
setThreadNumber(int threadNumber)
Specifies the thread number for this job thread. |
boolean |
shouldStop()
Indicates whether the job should stop processing for any reason. |
static java.lang.String |
stackTraceToString(java.lang.Exception e)
Retrieves a string representation of the stack trace contained in the provided exception. |
void |
startJob()
Indicates that the job should start running. |
void |
stopAndWait(int stopReason)
Requests that the job stop running at the earliest convenient time, and then waits until the job has stopped completely. |
void |
stopJob(int stopReason)
Requests that the job stop running at the earliest convenient time. |
boolean |
stopRequested()
Indicates whether a request has been made to stop the job from an external source (e.g., from a call to the stopJob method). |
boolean |
testJobParameters(ParameterList parameters,
java.util.ArrayList outputMessages)
Provides a means of testing the provided job parameters to determine whether they are valid (e.g., to see if the server is reachable) before scheduling the job for execution. |
void |
validateJobInfo(int numClients,
int threadsPerClient,
int threadStartupDelay,
java.util.Date startTime,
java.util.Date stopTime,
int duration,
int collectionInterval,
ParameterList parameters)
Provides a means of validating the information used to schedule the job, including the scheduling information and list of parameters. |
void |
writeVerbose(java.lang.String message)
Writes a message to the client message writer so that if it is running in verbose mode this information will be available to that client. |
| Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, 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 |
| Constructor Detail |
protected JobClass()
| Method Detail |
public abstract java.lang.String getJobName()
public abstract java.lang.String getJobDescription()
public java.lang.String getJobCategoryName()
public int overrideNumClients()
public int overrideThreadsPerClient()
public int overrideCollectionInterval()
public abstract ParameterList getParameterStubs()
public ParameterList getClientSideParameterStubs()
getParameterStubs method, but in
some cases the list of parameters scheduled in the configuration directory
may differ a little (e.g., to be able to handle dynamically-generated
parameters created at the time the job is scheduled).
public abstract StatTracker[] getStatTrackerStubs(java.lang.String clientID,
java.lang.String threadID,
int collectionInterval)
clientID - The client ID that should be used for the
returned stat trackers.threadID - The thread ID that should be used for the
returned stat trackers.collectionInterval - The collection interval that should be used for
the returned stat trackers.
public abstract StatTracker[] getStatTrackers()
public int getClientNumber()
public void setClientNumber(int clientNumber)
clientNumber - The client number to use for this job thread.public int getThreadNumber()
public void setThreadNumber(int threadNumber)
threadNumber - The thread number to use for this job thread.
public void validateJobInfo(int numClients,
int threadsPerClient,
int threadStartupDelay,
java.util.Date startTime,
java.util.Date stopTime,
int duration,
int collectionInterval,
ParameterList parameters)
throws InvalidValueException
numClients - The number of clients that should be used to
run the job.threadsPerClient - The number of threads that should be created on
each client to run the job.threadStartupDelay - The delay in milliseconds that should be used
when starting the client threads.startTime - The time that the job should start running.stopTime - The time that the job should stop running.duration - The maximum length of time in seconds that the
job should be allowed to run.collectionInterval - The collection interval that should be used
when gathering statistics for the job.parameters - The set of parameters provided to this job that
can be used to customize its behavior.
InvalidValueException - If the provided information is not
appropriate for running this job.public boolean providesParameterTest()
false to indicate that this is
not provided, but actual implementations may override this method to
return true and should also override the
testJobParameters method to implement the actual test.
true if this job provides a means of testing the job
parameters, or false if not.
public boolean testJobParameters(ParameterList parameters,
java.util.ArrayList outputMessages)
parameters - The job parameters to be tested.outputMessages - The lines of output that were generated as part of
the testing process. Each line of output should
be added to this list as a separate string, and
empty strings (but not null values)
are allowed to provide separation between
different messages. No formatting should be
provided for these messages, however, since they
may be displayed in either an HTML or plain text
interface.
true if the test completed successfully, or
false if not. Note that even if the test did not
complete successfully, the user will be presented with a warning
but will still be allowed to schedule the job using the provided
parameters. This is necessary because the parameters may still be
valid even if the server couldn't validate them at the time the
job was scheduled (e.g., if the server wasn't running or could not
be reached by the SLAMD server even though it could be by the
clients).public boolean isDeprecated(java.lang.StringBuffer message)
message - The buffer to which a message may be appended that
provides additional information about the deprecation.
true if this job class has been deprecated, or
false if not.
public void initializeJob(ParameterList parameters)
throws UnableToRunException
parameters - The set of parameters provided to this job that can be
used to customize its behavior.
UnableToRunException - If the job initialization could not be
completed successfully and the job is unable
to run.
public void initializeClient(java.lang.String clientID,
ParameterList parameters)
throws UnableToRunException
clientID - The ID assigned to the client running this job.parameters - The set of parameters provided to this job that can be
used to customize its behavior.
UnableToRunException - If the client initialization could not be
completed successfully and the job is unable
to run.
public abstract void initializeThread(java.lang.String clientID,
java.lang.String threadID,
int collectionInterval,
ParameterList parameters)
throws UnableToRunException
clientID - The client ID for this job thread.threadID - The thread ID for this job thread.collectionInterval - The length of time in seconds to use as the
statistics collection interval.parameters - The set of parameters provided to this job that
can be used to customize its behavior.
UnableToRunException - If the thread initialization could not be
completed successfully and the job is unable
to run.public abstract void runJob()
initialize method.
public int getActiveThreadCount()
public void finalizeThread()
public void finalizeClient()
public void finalizeJob()
public final void initializeJobThread(java.lang.String clientID,
java.lang.String threadID,
int collectionInterval,
ClientSideJob job,
int duration,
java.util.Date stopTime,
long startTimeMillis,
ParameterList parameters)
throws UnableToRunException
super.initialize(threadID, job, parameters) before any
custom code.
clientID - The client ID that will be used to identify the
client to the parent job.threadID - The thread ID that will be used to identify
this thread to the parent job.collectionInterval - The interval in seconds that should be used
when gathering statistics during job
processing.job - The parent job that is controlling this thread.duration - The length of time in seconds that the job
should be allowed to run. A value of -1
indicates an unlimited duration.stopTime - The time at which the job should stop running.
A value of null indicates no
specified stop time.startTimeMillis - The time this thread should start running in
milliseconds since January 1, 1970.parameters - The list of parameters (containing values) that
should be used to control the operation of this
job.
UnableToRunExceptionpublic final ClientSideJob getClientSideJob()
public final void setClientSideJob(ClientSideJob job)
job - The client-side job that should be associated with this job
class.public java.lang.String getJobID()
null if this thread is not associated
with any job.public final java.lang.String getClientID()
public final java.lang.String getThreadID()
public final int getCollectionInterval()
public final int getScheduledDuration()
public final long getShouldStopTime()
public final void startJob()
throws AlreadyRunningException
initialize
method.
AlreadyRunningException - If this job thread is already running.public final void stopJob(int stopReason)
stopReason - The reason that the job should stop running.public final void stopAndWait(int stopReason)
stopReason - The reason that the job should stop running.public final boolean isRunning()
true if the job is running, or false if
it is not.public final boolean stopRequested()
stopJob method). Note that
there may be other reasons that the job should stop running (for example,
if a time limit has been set and has been reached). Therefore, the
shouldStop method should be used to determine whether the job
should stop processing altogether.
true if a request has been made to stop this job, or
false if not.public final boolean shouldStop()
runJob method to
determine whether it is time to stop running.
true if the job should stop running, or
false if there is no reason for it to stop.public final boolean enableRealTimeStats()
true if the associated client has enabled real-time
statistics collection, or false if not.public final RealTimeStatReporter getStatReporter()
null if none should be used.public void destroy()
public final void indicateCompletedWithErrors()
public final void indicateStoppedDueToError()
public final void writeVerbose(java.lang.String message)
message - The message to be written.public final void logMessage(java.lang.String message)
logVerboseStatusMessage method.
message - The message to be logged.public final void run()
runJob method (which actually does the real
work for this job thread). It takes care of setting a flag used to
determine if the job is currently running or not, and will properly unset
it when the job is no longer running, even if it stopped running because of
an uncaught exception. This method may not be overridden by subclasses.
public static java.lang.String stackTraceToString(java.lang.Exception e)
e - The exception for which to retrieve the stack trace.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||