com.sun.slamd.dslogplay
Class LogPlaybackJobClass

java.lang.Object
  extended by java.lang.Thread
      extended by com.sun.slamd.job.JobClass
          extended by com.sun.slamd.dslogplay.LogPlaybackJobClass
All Implemented Interfaces:
java.lang.Runnable

public class LogPlaybackJobClass
extends JobClass

This class defines a SLAMD job that can be used to replay requests parsed from one or more Netscape / iPlanet / Sun ONE Directory Server access log files. It can be used to replay various kinds of operations either in their original order or at random.

Author:
Neil A. Wilson

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static char[] ALPHABET
          The set of characters to include in randomly-generated values.
static java.lang.String REPLAY_TYPE_RANDOM
          The replay operation type that indicates that the operations should be replayed in random order.
static java.lang.String REPLAY_TYPE_SEQUENTIAL_ONCE
          The replay operation type that indicates that the operations should be replayed once in the order they appear in the log file.
static java.lang.String REPLAY_TYPE_SEQUENTIAL_REPEATED
          The replay operation type that indicates that the operations should be replayed in the order they appear in the log file and that the sequence should repeat when the end is reached.
static java.lang.String[] REPLAY_TYPES
          The set of options that may be used to control how the operations are replayed.
static java.lang.String STAT_TRACKER_ADD_DURATION
          The display name for the stat tracker used to track the average duration for add operations.
static java.lang.String STAT_TRACKER_ADDS_REPLAYED
          The display name for the stat tracker used to count the total number of add operations replayed.
static java.lang.String STAT_TRACKER_BIND_DURATION
          The display name for the stat tracker used to track the average duration for bind operations.
static java.lang.String STAT_TRACKER_BINDS_REPLAYED
          The display name for the stat tracker used to count the total number of bind operations replayed.
static java.lang.String STAT_TRACKER_COMPARE_DURATION
          The display name for the stat tracker used to track the average duration for compare operations.
static java.lang.String STAT_TRACKER_COMPARES_REPLAYED
          The display name for the stat tracker used to count the total number of compare operations replayed.
static java.lang.String STAT_TRACKER_DELETE_DURATION
          The display name for the stat tracker used to track the average duration for delete operations.
static java.lang.String STAT_TRACKER_DELETES_REPLAYED
          The display name for the stat tracker used to count the total number of delete operations replayed.
static java.lang.String STAT_TRACKER_MODIFY_DURATION
          The display name for the stat tracker used to track the average duration for modify operations.
static java.lang.String STAT_TRACKER_MODS_REPLAYED
          The display name for the stat tracker used to count the total number of modify operations replayed.
static java.lang.String STAT_TRACKER_OPERATION_RATIOS
          The display name for the stat tracker used to track the ratio of operations replayed from the log file.
static java.lang.String STAT_TRACKER_RESULT_CODES
          The display name for the stat tracker used to track the result codes for the operations replayed.
static java.lang.String STAT_TRACKER_SEARCH_DURATION
          The display name for the stat tracker used to track the average duration for search operations.
static java.lang.String STAT_TRACKER_SEARCHES_REPLAYED
          The display name for the stat tracker used to count the total number of search operations replayed.
static java.lang.String STAT_TRACKER_TOTAL_DURATION
          The display name for the stat tracker used to track the average duration for all operations replayed.
static java.lang.String STAT_TRACKER_TOTAL_REPLAYED
          The display name for the stat tracker used to count the total number of operations of all types replayed.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
LogPlaybackJobClass()
          The default constructor used to create a new instance of the job class.
 
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 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.
 LogOperation getNextOperation()
          Retrieves the next log operation that should be replayed against the directory server.
 ParameterList getParameterStubs()
          Retrieve a parameter list that can be used to determine all of the customizable options that are available for this job.
 java.lang.String getRandomString(int length)
          Retrieves a string containing the specified number of randomly-chosen characters.
 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.
 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 this job thread by executing the specified command.
 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.
 
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, writeVerbose
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, 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_TOTAL_REPLAYED

public static final java.lang.String STAT_TRACKER_TOTAL_REPLAYED
The display name for the stat tracker used to count the total number of operations of all types replayed.

See Also:
Constant Field Values

STAT_TRACKER_ADDS_REPLAYED

public static final java.lang.String STAT_TRACKER_ADDS_REPLAYED
The display name for the stat tracker used to count the total number of add operations replayed.

See Also:
Constant Field Values

STAT_TRACKER_BINDS_REPLAYED

public static final java.lang.String STAT_TRACKER_BINDS_REPLAYED
The display name for the stat tracker used to count the total number of bind operations replayed.

See Also:
Constant Field Values

STAT_TRACKER_COMPARES_REPLAYED

public static final java.lang.String STAT_TRACKER_COMPARES_REPLAYED
The display name for the stat tracker used to count the total number of compare operations replayed.

See Also:
Constant Field Values

STAT_TRACKER_DELETES_REPLAYED

public static final java.lang.String STAT_TRACKER_DELETES_REPLAYED
The display name for the stat tracker used to count the total number of delete operations replayed.

See Also:
Constant Field Values

STAT_TRACKER_MODS_REPLAYED

public static final java.lang.String STAT_TRACKER_MODS_REPLAYED
The display name for the stat tracker used to count the total number of modify operations replayed.

See Also:
Constant Field Values

STAT_TRACKER_SEARCHES_REPLAYED

public static final java.lang.String STAT_TRACKER_SEARCHES_REPLAYED
The display name for the stat tracker used to count the total number of search operations replayed.

See Also:
Constant Field Values

STAT_TRACKER_TOTAL_DURATION

public static final java.lang.String STAT_TRACKER_TOTAL_DURATION
The display name for the stat tracker used to track the average duration for all operations replayed.

See Also:
Constant Field Values

STAT_TRACKER_ADD_DURATION

public static final java.lang.String STAT_TRACKER_ADD_DURATION
The display name for the stat tracker used to track the average duration for add operations.

See Also:
Constant Field Values

STAT_TRACKER_BIND_DURATION

public static final java.lang.String STAT_TRACKER_BIND_DURATION
The display name for the stat tracker used to track the average duration for bind operations.

See Also:
Constant Field Values

STAT_TRACKER_COMPARE_DURATION

public static final java.lang.String STAT_TRACKER_COMPARE_DURATION
The display name for the stat tracker used to track the average duration for compare operations.

See Also:
Constant Field Values

STAT_TRACKER_DELETE_DURATION

public static final java.lang.String STAT_TRACKER_DELETE_DURATION
The display name for the stat tracker used to track the average duration for delete operations.

See Also:
Constant Field Values

STAT_TRACKER_MODIFY_DURATION

public static final java.lang.String STAT_TRACKER_MODIFY_DURATION
The display name for the stat tracker used to track the average duration for modify operations.

See Also:
Constant Field Values

STAT_TRACKER_SEARCH_DURATION

public static final java.lang.String STAT_TRACKER_SEARCH_DURATION
The display name for the stat tracker used to track the average duration for search operations.

See Also:
Constant Field Values

STAT_TRACKER_OPERATION_RATIOS

public static final java.lang.String STAT_TRACKER_OPERATION_RATIOS
The display name for the stat tracker used to track the ratio of operations replayed from the log file.

See Also:
Constant Field Values

STAT_TRACKER_RESULT_CODES

public static final java.lang.String STAT_TRACKER_RESULT_CODES
The display name for the stat tracker used to track the result codes for the operations replayed.

See Also:
Constant Field Values

REPLAY_TYPE_RANDOM

public static final java.lang.String REPLAY_TYPE_RANDOM
The replay operation type that indicates that the operations should be replayed in random order.

See Also:
Constant Field Values

REPLAY_TYPE_SEQUENTIAL_ONCE

public static final java.lang.String REPLAY_TYPE_SEQUENTIAL_ONCE
The replay operation type that indicates that the operations should be replayed once in the order they appear in the log file.

See Also:
Constant Field Values

REPLAY_TYPE_SEQUENTIAL_REPEATED

public static final java.lang.String REPLAY_TYPE_SEQUENTIAL_REPEATED
The replay operation type that indicates that the operations should be replayed in the order they appear in the log file and that the sequence should repeat when the end is reached.

See Also:
Constant Field Values

REPLAY_TYPES

public static final java.lang.String[] REPLAY_TYPES
The set of options that may be used to control how the operations are replayed.


ALPHABET

public static final char[] ALPHABET
The set of characters to include in randomly-generated values.

Constructor Detail

LogPlaybackJobClass

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

Method Detail

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()
Retrieve a parameter list that can be used to determine all of the customizable options that are available for this job.

Specified by:
getParameterStubs in class JobClass
Returns:
A parameter list that can be used to determine all of 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. 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.

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). By default, this method returns 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.

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

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 a problem occurs that prevents the thread from being able to run properly.

runJob

public void runJob()
Perform the work of this job thread by executing the specified command.

Specified by:
runJob in class JobClass

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

getRandomString

public java.lang.String getRandomString(int length)
Retrieves a string containing the specified number of randomly-chosen characters.

Parameters:
length - The number of characters to include in the generated string.
Returns:
The generated string.

getNextOperation

public LogOperation getNextOperation()
Retrieves the next log operation that should be replayed against the directory server.

Returns:
The next log operation that should be replayed against the directory server, or null if there are no more operations to replay.