com.sun.slamd.example
Class SQLModRateJobClass

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

public class SQLModRateJobClass
extends JobClass

This class implements a SLAMD job that can be used to measure the update performance of an SQL database. It should work with any database for which a JDBC driver exists.


Field Summary
static char[] ALPHABET
          The characters that are available for use in the randomly-generated values.
static java.lang.String STAT_TRACKER_EXCEPTIONS_CAUGHT
          The display name of the stat tracker that counts exceptions caught while processing queries.
static java.lang.String STAT_TRACKER_UPDATE_DURATION
          The display name of the stat tracker that tracks the average length of time required to process an update.
static java.lang.String STAT_TRACKER_UPDATES_COMPLETED
          The display name of the stat tracker that tracks the rate at which updates are able to be processed.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SQLModRateJobClass()
          Creates a new instance of this SQL SearchRate job.
 
Method Summary
 void destroy()
          Try to force the thread to exit by closing the connection to the database and setting it to null.
 java.lang.String getJobCategoryName()
          Retrieves the name of the category in which this job class should be classified.
 java.lang.String getJobDescription()
          Retrieves a description for this job.
 java.lang.String getJobName()
          Retrieves the display name for this job.
 java.lang.String getMatchValue()
          Retrieves a value to use to match the row(s) to update.
 ParameterList getParameterStubs()
          Retrieves a parameter list that can be used to determine all the customizeable options that are available for this job.
 java.lang.String getRandomValue(int valueLength)
          Generates a string of randomly chosen alphabetic characters.
 StatTracker[] getStatTrackers()
          Retrieves the set of stat trackers that have been maintained by this job.
 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 one-time client initialization for this job, including assinging the values of the parameters to instance variables.
 void initializeThread(java.lang.String clientID, java.lang.String threadID, int collectionInterval, ParameterList parameters)
          Performs one-time client initialization for this job, including assinging the values of the parameters to instance variables.
 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 runJob()
          Perform the work of actually querying the database.
 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.
 
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, run, setClientNumber, setClientSideJob, setThreadNumber, shouldStop, stackTraceToString, startJob, stopAndWait, stopJob, stopRequested, 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

STAT_TRACKER_EXCEPTIONS_CAUGHT

public static final java.lang.String STAT_TRACKER_EXCEPTIONS_CAUGHT
The display name of the stat tracker that counts exceptions caught while processing queries.

See Also:
Constant Field Values

STAT_TRACKER_UPDATES_COMPLETED

public static final java.lang.String STAT_TRACKER_UPDATES_COMPLETED
The display name of the stat tracker that tracks the rate at which updates are able to be processed.

See Also:
Constant Field Values

STAT_TRACKER_UPDATE_DURATION

public static final java.lang.String STAT_TRACKER_UPDATE_DURATION
The display name of the stat tracker that tracks the average length of time required to process an update.

See Also:
Constant Field Values

ALPHABET

public static final char[] ALPHABET
The characters that are available for use in the randomly-generated values.

Constructor Detail

SQLModRateJobClass

public SQLModRateJobClass()
Creates a new instance of this SQL SearchRate job.

Method Detail

getJobName

public java.lang.String getJobName()
Retrieves the display name for this job.

Specified by:
getJobName in class JobClass
Returns:
The display name for this job.

getJobDescription

public java.lang.String getJobDescription()
Retrieves a description for this job.

Specified by:
getJobDescription in class JobClass
Returns:
A description for this job.

getJobCategoryName

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

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

getParameterStubs

public ParameterList getParameterStubs()
Retrieves a parameter list that can be used to determine all the customizeable options that are available for this job.

Specified by:
getParameterStubs in class JobClass
Returns:
A parameter list that can be used to determine all the customizable options that are available for this job.

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.

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 set of stat trackers that have been maintained by this job.

Specified by:
getStatTrackers in class JobClass
Returns:
The set of stat trackers that have been maintained by this job.

providesParameterTest

public 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).

Overrides:
providesParameterTest in class JobClass
Returns:
true if this job provides a means of testing the job parameters, or false if not.

testJobParameters

public 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. This method will be executed by the SLAMD server system itself and not by any of the clients.

Overrides:
testJobParameters in class JobClass
Parameters:
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.
Returns:
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).

initializeClient

public void initializeClient(java.lang.String clientID,
                             ParameterList parameters)
Performs one-time client initialization for this job, including assinging the values of the parameters to instance variables.

Overrides:
initializeClient in class JobClass
Parameters:
clientID - The client ID for the current client.
parameters - The set of parameters that have been defined for this job.

initializeThread

public void initializeThread(java.lang.String clientID,
                             java.lang.String threadID,
                             int collectionInterval,
                             ParameterList parameters)
Performs one-time client initialization for this job, including assinging the values of the parameters to instance variables.

Specified by:
initializeThread in class JobClass
Parameters:
clientID - The client ID for the current client.
threadID - The thread ID for the current thread.
collectionInterval - The length of time in seconds to use as the statistics collection interval.
parameters - The set of parameters that have been defined for this job.

runJob

public void runJob()
Perform the work of actually querying the database.

Specified by:
runJob in class JobClass

destroy

public void destroy()
Try to force the thread to exit by closing the connection to the database and setting it to null.

Overrides:
destroy in class JobClass

getRandomValue

public java.lang.String getRandomValue(int valueLength)
Generates a string of randomly chosen alphabetic characters.

Parameters:
valueLength - The number of characters to include in the value.
Returns:
The string of randomly chosen alphabetic characters.

getMatchValue

public java.lang.String getMatchValue()
Retrieves a value to use to match the row(s) to update.

Returns:
A value to use to match the row(s) to update.