com.sun.slamd.example
Class LDAPLoadWithReplicaLatencyJobClass

java.lang.Object
  extended by java.lang.Thread
      extended by com.sun.slamd.job.JobClass
          extended by com.sun.slamd.example.ReplicaLatencyCheckJobClass
              extended by com.sun.slamd.example.LDAPLoadWithReplicaLatencyJobClass
All Implemented Interfaces:
java.lang.Runnable, netscape.ldap.LDAPRebind

public class LDAPLoadWithReplicaLatencyJobClass
extends ReplicaLatencyCheckJobClass
implements netscape.ldap.LDAPRebind

This class implements a SLAMD job class that has the ability to generate various kinds of load against an LDAP directory server. It can perform search, compare, add, delete, modify, and modify RDN operations. The relative frequencies of each kind of operation may be specified by the user scheduling the job for execution. It can also monitor the latency associated with replicating the changes that it makes.

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 that will make up randomly-generated strings.
static java.lang.String STAT_TRACKER_ADD_ATTEMPTS
          The name of the stat tracker that counts the number of attempted adds.
static java.lang.String STAT_TRACKER_ADD_TIME
          The name of the stat tracker that times add operations.
static java.lang.String STAT_TRACKER_CATEGORIZED_LATENCY
          The name of the stat tracker that will be used to categorize latency.
static java.lang.String STAT_TRACKER_COMPARE_ATTEMPTS
          The name of the stat tracker that counts the number of attempted compares.
static java.lang.String STAT_TRACKER_COMPARE_TIME
          The name of the stat tracker that times compare operations.
static java.lang.String STAT_TRACKER_DELETE_ATTEMPTS
          The name of the stat tracker that counts the number of attempted deletes.
static java.lang.String STAT_TRACKER_DELETE_TIME
          The name of the stat tracker that times delete operations.
static java.lang.String STAT_TRACKER_MODIFY_ATTEMPTS
          The name of the stat tracker that counts the number of attempted modifies.
static java.lang.String STAT_TRACKER_MODIFY_RDN_ATTEMPTS
          The name of the stat tracker that counts the number of attempted modify RDN operations.
static java.lang.String STAT_TRACKER_MODIFY_RDN_TIME
          The name of the stat tracker that times modify RDN operations.
static java.lang.String STAT_TRACKER_MODIFY_TIME
          The name of the stat tracker that times modify operations.
static java.lang.String STAT_TRACKER_OPERATION_ATTEMPTS
          The name of the stat tracker that counts the number of attempted operations.
static java.lang.String STAT_TRACKER_OPERATION_ATTEMPTS_BY_CATEGORY
          The name of the stat tracker that categorizes the attempted operations.
static java.lang.String STAT_TRACKER_OPERATION_TIME
          The name of the stat tracker that times attempted operations.
static java.lang.String STAT_TRACKER_REPLICATION_LATENCY
          The name of the stat tracker that will be used to track replication latency.
static java.lang.String STAT_TRACKER_RESULT_CODES
          The name of the stat tracker that categorizes the result codes received from the operations.
static java.lang.String STAT_TRACKER_SEARCH_ATTEMPTS
          The name of the stat tracker that counts the number of attempted searches.
static java.lang.String STAT_TRACKER_SEARCH_TIME
          The name of the stat tracker that times search operations.
 
Fields inherited from class com.sun.slamd.example.ReplicaLatencyCheckJobClass
latencyCategories, latencyCheckMutex, latencyTime
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
LDAPLoadWithReplicaLatencyJobClass()
          Creates a new instance of this job thread.
 
Method Summary
 void addDNToDelete(java.lang.String entryDN)
          Adds the specified DN to the list of DNs to be deleted and/or renamed.
 void destroy()
          Attempts to force this thread to exit by closing the connection to the directory server and setting it to null.
 int doAdd()
          Performs an add operation in the directory.
 int doCompare()
          Performs a compare operation in the directory.
 int doDelete()
          Performs a delete operation in the directory.
 int doModify()
          Performs a modify operation in the directory.
 int doModifyRDN()
          Performs a modify RDN (i.e., rename) operation in the directory.
 int doSearch()
          Performs a search operation in the directory.
 void finalizeClient()
          Performs any per-client finalization that should be done for this job.
 java.lang.String getDNToDelete()
          Retrieves the DN of an entry to be deleted or renamed.
 netscape.ldap.LDAPEntry getEntry()
          Retrieves a randomly-generated entry that may be added to the directory.
 java.lang.String getEntryDN()
          Retrieves the DN of an entry on which a compare or modify operation may be performed.
 java.lang.String getJobCategoryName()
          Retrieves the name of the category in which this job class exists.
 java.lang.String getJobDescription()
          Returns a description of this job that can be seen in the administrative interface.
 java.lang.String getJobName()
          Returns the user-friendly name that is to be used for this job class in the administrative interface.
 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 randomly-generated string with the specified number of characters.
 netscape.ldap.LDAPRebindAuth getRebindAuthentication(java.lang.String host, int port)
          Specifies the credentials that will be used to bind to the target server if a referral is encountered.
 java.lang.String getSearchFilter()
          Retrieves a filter that may be used to perform a search.
 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 client-level initialization for this job, including retrieving the values of all the parameters and reading the filter file (if one has been specified).
 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 establishing the connection(s) to the directory server and issuing all the appropriate queries.
 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, 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

ALPHABET

public static final char[] ALPHABET
The set of characters that will make up randomly-generated strings.


STAT_TRACKER_ADD_ATTEMPTS

public static final java.lang.String STAT_TRACKER_ADD_ATTEMPTS
The name of the stat tracker that counts the number of attempted adds.

See Also:
Constant Field Values

STAT_TRACKER_ADD_TIME

public static final java.lang.String STAT_TRACKER_ADD_TIME
The name of the stat tracker that times add operations.

See Also:
Constant Field Values

STAT_TRACKER_COMPARE_ATTEMPTS

public static final java.lang.String STAT_TRACKER_COMPARE_ATTEMPTS
The name of the stat tracker that counts the number of attempted compares.

See Also:
Constant Field Values

STAT_TRACKER_COMPARE_TIME

public static final java.lang.String STAT_TRACKER_COMPARE_TIME
The name of the stat tracker that times compare operations.

See Also:
Constant Field Values

STAT_TRACKER_DELETE_ATTEMPTS

public static final java.lang.String STAT_TRACKER_DELETE_ATTEMPTS
The name of the stat tracker that counts the number of attempted deletes.

See Also:
Constant Field Values

STAT_TRACKER_DELETE_TIME

public static final java.lang.String STAT_TRACKER_DELETE_TIME
The name of the stat tracker that times delete operations.

See Also:
Constant Field Values

STAT_TRACKER_MODIFY_ATTEMPTS

public static final java.lang.String STAT_TRACKER_MODIFY_ATTEMPTS
The name of the stat tracker that counts the number of attempted modifies.

See Also:
Constant Field Values

STAT_TRACKER_MODIFY_TIME

public static final java.lang.String STAT_TRACKER_MODIFY_TIME
The name of the stat tracker that times modify operations.

See Also:
Constant Field Values

STAT_TRACKER_MODIFY_RDN_ATTEMPTS

public static final java.lang.String STAT_TRACKER_MODIFY_RDN_ATTEMPTS
The name of the stat tracker that counts the number of attempted modify RDN operations.

See Also:
Constant Field Values

STAT_TRACKER_MODIFY_RDN_TIME

public static final java.lang.String STAT_TRACKER_MODIFY_RDN_TIME
The name of the stat tracker that times modify RDN operations.

See Also:
Constant Field Values

STAT_TRACKER_OPERATION_ATTEMPTS

public static final java.lang.String STAT_TRACKER_OPERATION_ATTEMPTS
The name of the stat tracker that counts the number of attempted operations.

See Also:
Constant Field Values

STAT_TRACKER_OPERATION_ATTEMPTS_BY_CATEGORY

public static final java.lang.String STAT_TRACKER_OPERATION_ATTEMPTS_BY_CATEGORY
The name of the stat tracker that categorizes the attempted operations.

See Also:
Constant Field Values

STAT_TRACKER_OPERATION_TIME

public static final java.lang.String STAT_TRACKER_OPERATION_TIME
The name of the stat tracker that times attempted operations.

See Also:
Constant Field Values

STAT_TRACKER_RESULT_CODES

public static final java.lang.String STAT_TRACKER_RESULT_CODES
The name of the stat tracker that categorizes the result codes received from the operations.

See Also:
Constant Field Values

STAT_TRACKER_SEARCH_ATTEMPTS

public static final java.lang.String STAT_TRACKER_SEARCH_ATTEMPTS
The name of the stat tracker that counts the number of attempted searches.

See Also:
Constant Field Values

STAT_TRACKER_SEARCH_TIME

public static final java.lang.String STAT_TRACKER_SEARCH_TIME
The name of the stat tracker that times search operations.

See Also:
Constant Field Values

STAT_TRACKER_REPLICATION_LATENCY

public static final java.lang.String STAT_TRACKER_REPLICATION_LATENCY
The name of the stat tracker that will be used to track replication latency.

See Also:
Constant Field Values

STAT_TRACKER_CATEGORIZED_LATENCY

public static final java.lang.String STAT_TRACKER_CATEGORIZED_LATENCY
The name of the stat tracker that will be used to categorize latency.

See Also:
Constant Field Values
Constructor Detail

LDAPLoadWithReplicaLatencyJobClass

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

Method Detail

getJobName

public java.lang.String getJobName()
Returns the user-friendly name that is to be used for this job class in the administrative interface.

Specified by:
getJobName in class JobClass
Returns:
The user-friendly name for this job class.

getJobDescription

public java.lang.String getJobDescription()
Returns a description of this job that can be seen in the administrative interface.

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

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

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 client-level initialization for this job, including retrieving the values of all the parameters and reading the filter file (if one has been specified).

Overrides:
initializeClient in class JobClass
Parameters:
clientID - The ID assigned to the client that will be running the job.
parameters - The list of parameters defined for this job.
Throws:
UnableToRunException - If the initialization fails for some reason.

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 establishing the connection(s) to the directory server and issuing all the appropriate queries. The job will continue until the specified number of iterations have been performed, the stop time has been reached, the maximum duration has been reached, or the SLAMD server indicates that a stop has been requested.

Specified by:
runJob in class JobClass

finalizeClient

public void finalizeClient()
Performs any per-client finalization that should be done for this job. In this case, it will clean up any entries that may still be left over from processing.

Overrides:
finalizeClient in class JobClass

destroy

public void destroy()
Attempts to force this thread to exit by closing the connection to the directory server and setting it to null.

Overrides:
destroy in class JobClass

doAdd

public int doAdd()
Performs an add operation in the directory.

Returns:
The result code of the add operation.

doCompare

public int doCompare()
Performs a compare operation in the directory.

Returns:
The result code of the compare operation.

doDelete

public int doDelete()
Performs a delete operation in the directory.

Returns:
The result code of the delete operation.

doModify

public int doModify()
Performs a modify operation in the directory.

Returns:
The result code of the modify operation.

doModifyRDN

public int doModifyRDN()
Performs a modify RDN (i.e., rename) operation in the directory.

Returns:
The result code of the modify RDN operation.

doSearch

public int doSearch()
Performs a search operation in the directory.

Returns:
The result code of the search operation.

getEntry

public netscape.ldap.LDAPEntry getEntry()
Retrieves a randomly-generated entry that may be added to the directory.

Returns:
The generated entry.

getRandomString

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

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

getEntryDN

public java.lang.String getEntryDN()
Retrieves the DN of an entry on which a compare or modify operation may be performed.

Returns:
The DN of an entry on which a compare or modify operation may be performed.

addDNToDelete

public void addDNToDelete(java.lang.String entryDN)
Adds the specified DN to the list of DNs to be deleted and/or renamed.

Parameters:
entryDN - The DN to be added to the list.

getDNToDelete

public java.lang.String getDNToDelete()
Retrieves the DN of an entry to be deleted or renamed. Delete and modify RDN operations will only be performed on entries that have been added.

Returns:
The DN of an entry that can be deleted or renamed. If there are no available DNs, then null will be returned.

getSearchFilter

public java.lang.String getSearchFilter()
Retrieves a filter that may be used to perform a search.

Returns:
The filter that may be used to perform a search.

getRebindAuthentication

public netscape.ldap.LDAPRebindAuth getRebindAuthentication(java.lang.String host,
                                                            int port)
Specifies the credentials that will be used to bind to the target server if a referral is encountered. In this case, we will always attempt the bind using the same credentials used to bind to the original target.

Specified by:
getRebindAuthentication in interface netscape.ldap.LDAPRebind
Parameters:
host - The address of the directory server targeted by the referral.
port - The port of the directory server targeted by the referral.
Returns:
The credentials that will be used to bind to the server targeted by the referral.