com.sun.slamd.example
Class WeightedSearchAndModJobClass

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

public class WeightedSearchAndModJobClass
extends JobClass
implements netscape.ldap.LDAPRebind

This class defines a SLAMD job that performs a search to find one or more entries, and then performs a modification on each entry found.

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 be used to generate random values for the modifications.
static java.lang.String[] DEFAULT_ATTRS_TO_MODIFY
          The default set of attributes to include in the modification.
static java.lang.String[] NO_ATTRS
          The value to request when there are no attributes to return.
static java.lang.String SSL_KEY_PASSWORD_PROPERTY
          The system property used to specify the password for the JSSE key store.
static java.lang.String SSL_KEY_STORE_PROPERTY
          The system property used to specify the location of the JSSE key store.
static java.lang.String SSL_TRUST_PASSWORD_PROPERTY
          The system property used to specify the password for the JSSE trust store.
static java.lang.String SSL_TRUST_STORE_PROPERTY
          The system property used to specify the location of the JSSE trust store.
static java.lang.String STAT_TRACKER_MOD_TIME
          The name of the stat tracker that will be used to keep track of the time required to perform each modification.
static java.lang.String STAT_TRACKER_NUM_MODS
          The name of the stat tracker that will be used to keep track of the number of modify operations performed.
static java.lang.String STAT_TRACKER_NUM_SEARCH_1
          The name of the stat tracker that will be used to keep track of the number of search 1 operations performed.
static java.lang.String STAT_TRACKER_NUM_SEARCH_2
          The name of the stat tracker that will be used to keep track of the number of search 2 operations performed.
static java.lang.String STAT_TRACKER_NUM_SEARCH_OVERALL
          The name of the stat tracker that will be used to keep track of the number of overall search operations performed.
static java.lang.String STAT_TRACKER_SEARCH_CATEGORIES
          The name of the stat tracker that will be used to categorize the types of searches performed.
static java.lang.String STAT_TRACKER_SEARCH_TIME_1
          The name of the stat tracker that will be used to keep track of the time required to perform the search 1 operations.
static java.lang.String STAT_TRACKER_SEARCH_TIME_2
          The name of the stat tracker that will be used to keep track of the time required to perform the search 2 operations.
static java.lang.String STAT_TRACKER_SEARCH_TIME_OVERALL
          The name of the stat tracker that will be used to keep track of the overall time required to perform the search operations.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
WeightedSearchAndModJobClass()
          Creates a new instance of this job thread.
 
Method Summary
 void destroy()
          Attempts to force this thread to exit by closing the connection to the directory server and setting it to null.
 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()
          Returns the set of parameters whose value may be specified by the end user.
 java.lang.String getRandomString(int length)
          Retrieves a string of random characters of the specified length.
 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.
 StatTracker[] getStatTrackers()
          Retrieves the set of stat trackers that are maintained by this job class.
 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 class with the information that it will use when actually running the job.
 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()
          Performs the work of actually running the job.
 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, 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 be used to generate random values for the modifications.


SSL_KEY_STORE_PROPERTY

public static final java.lang.String SSL_KEY_STORE_PROPERTY
The system property used to specify the location of the JSSE key store.

See Also:
Constant Field Values

SSL_KEY_PASSWORD_PROPERTY

public static final java.lang.String SSL_KEY_PASSWORD_PROPERTY
The system property used to specify the password for the JSSE key store.

See Also:
Constant Field Values

SSL_TRUST_STORE_PROPERTY

public static final java.lang.String SSL_TRUST_STORE_PROPERTY
The system property used to specify the location of the JSSE trust store.

See Also:
Constant Field Values

SSL_TRUST_PASSWORD_PROPERTY

public static final java.lang.String SSL_TRUST_PASSWORD_PROPERTY
The system property used to specify the password for the JSSE trust store.

See Also:
Constant Field Values

STAT_TRACKER_MOD_TIME

public static final java.lang.String STAT_TRACKER_MOD_TIME
The name of the stat tracker that will be used to keep track of the time required to perform each modification.

See Also:
Constant Field Values

STAT_TRACKER_NUM_MODS

public static final java.lang.String STAT_TRACKER_NUM_MODS
The name of the stat tracker that will be used to keep track of the number of modify operations performed.

See Also:
Constant Field Values

STAT_TRACKER_NUM_SEARCH_OVERALL

public static final java.lang.String STAT_TRACKER_NUM_SEARCH_OVERALL
The name of the stat tracker that will be used to keep track of the number of overall search operations performed.

See Also:
Constant Field Values

STAT_TRACKER_NUM_SEARCH_1

public static final java.lang.String STAT_TRACKER_NUM_SEARCH_1
The name of the stat tracker that will be used to keep track of the number of search 1 operations performed.

See Also:
Constant Field Values

STAT_TRACKER_NUM_SEARCH_2

public static final java.lang.String STAT_TRACKER_NUM_SEARCH_2
The name of the stat tracker that will be used to keep track of the number of search 2 operations performed.

See Also:
Constant Field Values

STAT_TRACKER_SEARCH_TIME_OVERALL

public static final java.lang.String STAT_TRACKER_SEARCH_TIME_OVERALL
The name of the stat tracker that will be used to keep track of the overall time required to perform the search operations.

See Also:
Constant Field Values

STAT_TRACKER_SEARCH_TIME_1

public static final java.lang.String STAT_TRACKER_SEARCH_TIME_1
The name of the stat tracker that will be used to keep track of the time required to perform the search 1 operations.

See Also:
Constant Field Values

STAT_TRACKER_SEARCH_TIME_2

public static final java.lang.String STAT_TRACKER_SEARCH_TIME_2
The name of the stat tracker that will be used to keep track of the time required to perform the search 2 operations.

See Also:
Constant Field Values

STAT_TRACKER_SEARCH_CATEGORIES

public static final java.lang.String STAT_TRACKER_SEARCH_CATEGORIES
The name of the stat tracker that will be used to categorize the types of searches performed.

See Also:
Constant Field Values

DEFAULT_ATTRS_TO_MODIFY

public static final java.lang.String[] DEFAULT_ATTRS_TO_MODIFY
The default set of attributes to include in the modification.


NO_ATTRS

public static final java.lang.String[] NO_ATTRS
The value to request when there are no attributes to return.

Constructor Detail

WeightedSearchAndModJobClass

public WeightedSearchAndModJobClass()
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

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()
Returns the set of parameters whose value may be specified by the end user.

Specified by:
getParameterStubs in class JobClass
Returns:
The set of configurable parameters for this job class.

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

Specified by:
getStatTrackers in class JobClass
Returns:
The set of stat trackers for this job class.

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 initialization for this job on each client immediately before each thread is created to actually run the job.

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 class with the information that it will use when actually running the job. This will also initialize the stat trackers used by the job.

Specified by:
initializeThread in class JobClass
Parameters:
clientID - The thread ID for this thread.
threadID - The thread ID for this thread.
collectionInterval - The collection interval to use for gathering statistics while processing the job.
parameters - The st of parameters that contain the information used to customize the way this job is processed.
Throws:
UnableToRunException - If a problem occurs that prevents the thread from being able to run properly.

runJob

public void runJob()
Performs the work of actually running the job. When this method completes, the job will be done.

Specified by:
runJob 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

getRandomString

public java.lang.String getRandomString(int length)
Retrieves a string of random characters of the specified length.

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

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.