com.sun.slamd.loadvariance
Class LoadVarianceJobClass

java.lang.Object
  extended byjava.lang.Thread
      extended bycom.sun.slamd.job.JobClass
          extended bycom.sun.slamd.loadvariance.LoadVarianceJobClass
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
LoadVarianceTestJobClass

public abstract class LoadVarianceJobClass
extends JobClass

This class defines a SLAMD job that varies the load that it generates over time based on input read from a file that controls the number of threads that should be active at any given time. It works by creating and starting all threads at the beginning of the job but making them remain inactive until they are needed.


Field Summary
static int DEFAULT_IDLE_SLEEP_DURATION
          The default length of time in milliseconds that an idle thread should sleep between checks to determine whether it is time to start running.
static java.lang.String PARAM_LOAD_DEFINITION
          The name of the parameter that will be used to specify the URL to the file containing the load definition.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
LoadVarianceJobClass()
          The default constructor used to create a new instance of the search thread.
 
Method Summary
abstract  void doProcessing()
          Performs the actual processing for this job.
abstract  void doShutdown()
          Performs any processing that should be done at the very end of execution after all actual processing has completed.
abstract  void doStartup()
          Performs any processing that should be done at the very beginning of execution before any actual processing is performed.
 int getIdleSleepDuration()
          Retrieves the length of time in milliseconds that each thread will sleep while it is idle before checking to determine whether it is time to start running.
 Parameter getVariableLoadParameterStub()
          Retrieves the parameter that is used to specify the URL to the data file containing the variable load definition.
 void initializeVariableLoad(ParameterList parameters)
          Initializes the logic that will be used to generate load for this thread.
 boolean loopVarianceDefinition()
          Indicates whether the job should loop back through the load variance definition when the end is reached.
 void runJob()
          Performs the processing associated with this job.
 void setIdleSleepDuration(int idleSleepDuration)
          Specifies the length of time in milliseconds that each thread should sleep while it is idle before checking to determine whether it is time to start running.
 void setLoopVarianceDefinition(boolean loopVarianceDefinition)
          Specifies whether the job should loop back through the load variance definition when the end is reached.
 boolean shouldPauseOrStop()
          Indicates whether this thread should temporarily pause its execution or stop altogether.
 void validateLoadDefinition(int threadsPerClient, java.util.Date startTime, java.util.Date stopTime, int duration, ParameterList parameters)
          Validates the information in the load definition file both for its syntax and for plausibility when used with the other provided information.
 
Methods inherited from class com.sun.slamd.job.JobClass
destroy, enableRealTimeStats, finalizeClient, finalizeJob, finalizeThread, getActiveThreadCount, getClientID, getClientNumber, getClientSideJob, getClientSideParameterStubs, getCollectionInterval, getJobCategoryName, getJobDescription, getJobID, getJobName, getParameterStubs, getScheduledDuration, getShouldStopTime, getStatReporter, getStatTrackers, getStatTrackerStubs, getThreadID, getThreadNumber, indicateCompletedWithErrors, indicateStoppedDueToError, initializeClient, initializeJob, initializeJobThread, initializeThread, isDeprecated, isRunning, logMessage, overrideCollectionInterval, overrideNumClients, overrideThreadsPerClient, providesParameterTest, run, setClientNumber, setClientSideJob, setThreadNumber, shouldStop, stackTraceToString, startJob, stopAndWait, stopJob, stopRequested, testJobParameters, validateJobInfo, 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

DEFAULT_IDLE_SLEEP_DURATION

public static final int DEFAULT_IDLE_SLEEP_DURATION
The default length of time in milliseconds that an idle thread should sleep between checks to determine whether it is time to start running.

See Also:
Constant Field Values

PARAM_LOAD_DEFINITION

public static final java.lang.String PARAM_LOAD_DEFINITION
The name of the parameter that will be used to specify the URL to the file containing the load definition.

See Also:
Constant Field Values
Constructor Detail

LoadVarianceJobClass

public LoadVarianceJobClass()
The default constructor used to create a new instance of the search thread. The only thing it should do is to invoke the superclass constructor. All other initialization should be performed in the initialize method.

Method Detail

getVariableLoadParameterStub

public final Parameter getVariableLoadParameterStub()
Retrieves the parameter that is used to specify the URL to the data file containing the variable load definition.

Returns:
The parameter that is used to specify the URL to the data file containing the variable load definition.

validateLoadDefinition

public final void validateLoadDefinition(int threadsPerClient,
                                         java.util.Date startTime,
                                         java.util.Date stopTime,
                                         int duration,
                                         ParameterList parameters)
                                  throws InvalidValueException
Validates the information in the load definition file both for its syntax and for plausibility when used with the other provided information.

Parameters:
threadsPerClient - The number of threads per client that have been scheduled for this job.
startTime - The time that this job should start running.
stopTime - The time that this job should stop running.
duration - The maximum length of time in seconds that the job should be allowed to run.
parameters - The set of parameters associated with this job, including the load definition URL parameter.
Throws:
InvalidValueException

initializeVariableLoad

public final void initializeVariableLoad(ParameterList parameters)
                                  throws UnableToRunException
Initializes the logic that will be used to generate load for this thread. This should be called by the initializeClient method, as it uses static variables to determine the logic to use for all threads. The runJob method will be used to apply this definition on a per-thread basis.

Parameters:
parameters - The parameter list containing the parameters for this job, including the load definition URL parameter.
Throws:
UnableToRunException - If a problem occurs while parsing the load definition file that would keep this job from running properly.

getIdleSleepDuration

public int getIdleSleepDuration()
Retrieves the length of time in milliseconds that each thread will sleep while it is idle before checking to determine whether it is time to start running.

Returns:
The length of time in milliseconds that each thread should sleep while it is idle before checking to determine if it is time to start running.

setIdleSleepDuration

public void setIdleSleepDuration(int idleSleepDuration)
Specifies the length of time in milliseconds that each thread should sleep while it is idle before checking to determine whether it is time to start running. Note that this method should always be called after the call to initializeVariableLoad or it will be overridden.

Parameters:
idleSleepDuration - The length of time in milliseconds that each thread should sleep while it is idle before checking to determine whether it is time to start running.

loopVarianceDefinition

public boolean loopVarianceDefinition()
Indicates whether the job should loop back through the load variance definition when the end is reached. If not, then only those threads that were active at the end of the load variance definition will continue to be used for the remainder of the job.

Returns:
true if the job should loop back through the load variance definition when the end is reached, or false if not.

setLoopVarianceDefinition

public void setLoopVarianceDefinition(boolean loopVarianceDefinition)
Specifies whether the job should loop back through the load variance definition when the end is reached.

Parameters:
loopVarianceDefinition - Indicates whether the job should loop back through the load variance definition when the end is reached.

runJob

public final void runJob()
Performs the processing associated with this job. In the generic case, it completes the initialization and then enters a loop that waits until an indication is received that the thread should start processing. If it is notified to temporarily stop, then it will do so and wait for either a permanent stop request or notification that it should start again. Once a permanent stop request is received, then this method will perform finalization and exit.

Specified by:
runJob in class JobClass

shouldPauseOrStop

public final boolean shouldPauseOrStop()
Indicates whether this thread should temporarily pause its execution or stop altogether. This method should be periodically called by the doProcessing method, and if it returns true then doProcessing should exit.


doStartup

public abstract void doStartup()
Performs any processing that should be done at the very beginning of execution before any actual processing is performed. This should include starting all stat trackers for the job.


doShutdown

public abstract void doShutdown()
Performs any processing that should be done at the very end of execution after all actual processing has completed. This should include stopping all stat trackers for the job.


doProcessing

public abstract void doProcessing()
Performs the actual processing for this job. It should periodically call the shouldPauseOrStop method and if it returns true then this method should exit.