com.sun.slamd.scripting
Class BSFJobClass

java.lang.Object
  extended byjava.lang.Thread
      extended bycom.sun.slamd.job.JobClass
          extended bycom.sun.slamd.scripting.BSFJobClass
All Implemented Interfaces:
java.lang.Runnable

public class BSFJobClass
extends JobClass

This class implements a SLAMD job that executes a Script file to generate load. It implements the standard SLAMD job methods and adds three new methods to allow the job to be referenced from the Script file.


Field Summary
static java.lang.String ENGINE_CLASS_PARAMETER_NAME
          The name of the job parameter that defines the script file to use.
static java.lang.String FILE_PATH_PARAMETER_NAME
          The name of the job parameter that defines the script file to use.
static java.lang.String SCRIPT_ARGUMENTS_PARAMETER_NAME
          The name of the job parameter that allows the user to pass arguments to the script.
static java.lang.String SCRIPT_EXTENSION_PARAMETER_NAME
          The name of the job parameter that defines the script file to use.
static java.lang.String SCRIPT_LANGUAGE_PARAMETER_NAME
          The name of the job parameter that defines the script file to use.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
BSFJobClass()
          Creates a new instance of this job thread.
 
Method Summary
 void destroy()
          Provides a means for destroying this job thread if it does not respond to a graceful shutdown request.
 java.lang.String getArgument(java.lang.String argName)
          Retrieves the value from a specified job argument
 java.lang.String getArgument(java.lang.String argName, java.lang.String defaultValue)
          Retrieves the value from a specified job argument
 java.lang.String getJobCategoryName()
          Retrieves the name of the category in which this job class exists.
 java.lang.String getJobDescription()
          Retrieves a description of the job performed by this job thread.
 java.lang.String getJobName()
          Retrieves the name of the job performed by this job thread.
 ParameterList getParameterStubs()
          Retrieves a list of parameter "stubs" that should be used to indicate which parameters should be passed to the initialize method.
 StatTracker[] getStatTrackers()
          Retrieves the stat trackers that are maintained for this job thread.
 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.
 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 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.
 StatTracker initializeTracker(StatTracker theTracker, java.lang.String displayName)
          Initializes a StatTracker created in the Script file.
 void runJob()
          The method that does all the real work for this job.
 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.
 
Methods inherited from class com.sun.slamd.job.JobClass
enableRealTimeStats, finalizeClient, finalizeJob, finalizeThread, getActiveThreadCount, getClientID, getClientNumber, getClientSideJob, getClientSideParameterStubs, getCollectionInterval, getJobID, getScheduledDuration, getShouldStopTime, getStatReporter, getThreadID, getThreadNumber, indicateCompletedWithErrors, indicateStoppedDueToError, initializeJob, initializeJobThread, isDeprecated, isRunning, logMessage, overrideCollectionInterval, overrideNumClients, overrideThreadsPerClient, providesParameterTest, run, setClientNumber, setClientSideJob, setThreadNumber, shouldStop, stackTraceToString, startJob, stopAndWait, stopJob, stopRequested, testJobParameters, writeVerbose
 
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
 

Field Detail

SCRIPT_LANGUAGE_PARAMETER_NAME

public static final java.lang.String SCRIPT_LANGUAGE_PARAMETER_NAME
The name of the job parameter that defines the script file to use.

See Also:
Constant Field Values

SCRIPT_EXTENSION_PARAMETER_NAME

public static final java.lang.String SCRIPT_EXTENSION_PARAMETER_NAME
The name of the job parameter that defines the script file to use.

See Also:
Constant Field Values

ENGINE_CLASS_PARAMETER_NAME

public static final java.lang.String ENGINE_CLASS_PARAMETER_NAME
The name of the job parameter that defines the script file to use.

See Also:
Constant Field Values

FILE_PATH_PARAMETER_NAME

public static final java.lang.String FILE_PATH_PARAMETER_NAME
The name of the job parameter that defines the script file to use.

See Also:
Constant Field Values

SCRIPT_ARGUMENTS_PARAMETER_NAME

public static final java.lang.String SCRIPT_ARGUMENTS_PARAMETER_NAME
The name of the job parameter that allows the user to pass arguments to the script.

See Also:
Constant Field Values
Constructor Detail

BSFJobClass

public BSFJobClass()
Creates a new instance of this job thread. This constructor does not need to do anything other than invoke the constructor for the superclass.

Method Detail

destroy

public void destroy()
Provides a means for destroying this job thread if it does not respond to a graceful shutdown request. The default implementation does nothing, but an actual job class may wish to do something like close a connection to a remote server that could cause the thread to terminate.

Overrides:
destroy in class JobClass

getJobName

public java.lang.String getJobName()
Retrieves the name of the job performed by this job thread.

Specified by:
getJobName in class JobClass
Returns:
The name of the job performed by this job thread.

getJobDescription

public java.lang.String getJobDescription()
Retrieves a description of the job performed by this job thread.

Specified by:
getJobDescription in class JobClass
Returns:
A description of the job performed by this job thread.

getJobCategoryName

public java.lang.String getJobCategoryName()
Retrieves the name of the category in which this job class exists. This is used to help arrange the job classes in the administrative interface.

Overrides:
getJobCategoryName in class JobClass
Returns:
The name of the category in which this job class exists.

getParameterStubs

public ParameterList getParameterStubs()
Retrieves a list of parameter "stubs" that should be used to indicate which parameters should be passed to the initialize method. These stubs do not need to have values (although they can be given default values).

Specified by:
getParameterStubs in class JobClass
Returns:
A list of the parameter stubs that can be used to determine which parameters must/may be provided to the initialize method.

getStatTrackerStubs

public 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. The stat trackers returned by this method do not have to actually contain any statistics -- the display name and stat tracker class should be the only information that callers of this method should rely upon. Note that this list can be different from the list of statistics actually collected by the job in some cases (e.g., if the job may not return all the stat trackers it advertises in all cases, or if the job may return stat trackers that it did not advertise), but it is a possibility that only the stat trackers returned by this method will be accessible for some features in the SLAMD server.

Specified by:
getStatTrackerStubs in class JobClass
Parameters:
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.
Returns:
The set of stat trackers that will be maintained by this job class.

getStatTrackers

public StatTracker[] getStatTrackers()
Retrieves the stat trackers that are maintained for this job thread.

Specified by:
getStatTrackers in class JobClass
Returns:
The stat trackers that are maintained for this job thread.

validateJobInfo

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
Provides a means of validating the information used to schedule the job, including the scheduling information and list of parameters.

Overrides:
validateJobInfo in class JobClass
Parameters:
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.
Throws:
InvalidValueException - If the provided information is not appropriate for running this job.

initializeClient

public void initializeClient(java.lang.String clientID,
                             ParameterList parameters)
                      throws UnableToRunException
Performs initialization for this job on each client immediately before each thread is created to actually run the job. Note that if any changes are to be made to variables that should be available to the individual threads, then those variables should be declared as static.

Overrides:
initializeClient in class JobClass
Parameters:
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.
Throws:
UnableToRunException - If the client initialization could not be completed successfully and the job is unable to run.

initializeThread

public void initializeThread(java.lang.String clientID,
                             java.lang.String threadID,
                             int collectionInterval,
                             ParameterList parameters)
                      throws UnableToRunException
Initializes this job thread to be used to actually run the job on the client. The provided parameter list should be processed to customize the behavior of this job thread, and any other initialization that needs to be done in order for the job to run should be performed here as well (e.g., creating and initializing the status counters).

Specified by:
initializeThread in class JobClass
Parameters:
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.
Throws:
UnableToRunException - If the thread initialization could not be completed successfully and the job is unable to run.

runJob

public void runJob()
The method that does all the real work for this job. It performs the task associated with the job thread based on the information provided through the parameter list passed into the initialize method.

Specified by:
runJob in class JobClass

initializeTracker

public StatTracker initializeTracker(StatTracker theTracker,
                                     java.lang.String displayName)
Initializes a StatTracker created in the Script file. Adds the StatTracker to the Vector of StatTrackers that will be returned by the job in the getStatTrackers() function. Starts the tracker and enables real time statistics if necessary.

Parameters:
theTracker - The StatTracker class.
displayName - The StatTracker's display name.
Returns:
The initialized StatTracker.

getArgument

public java.lang.String getArgument(java.lang.String argName,
                                    java.lang.String defaultValue)
Retrieves the value from a specified job argument

Parameters:
argName - The name of the argument to retrieve.
defaultValue - The default value if one is not in the Hashtable.
Returns:
The argument's value as a string.

getArgument

public java.lang.String getArgument(java.lang.String argName)
Retrieves the value from a specified job argument

Parameters:
argName - The name of the argument to retrieve.
Returns:
The argument's value as a string or null.