com.sun.slamd.example
Class WeightedSearchRateJobClass

java.lang.Object
  extended byjava.lang.Thread
      extended bycom.sun.slamd.job.JobClass
          extended bycom.sun.slamd.example.WeightedSearchRateJobClass
All Implemented Interfaces:
netscape.ldap.LDAPRebind, java.lang.Runnable

public class WeightedSearchRateJobClass
extends JobClass
implements netscape.ldap.LDAPRebind

This class implements a SLAMD job class for performing repeated searches against an LDAP directory server. It provides the ability to use two different filters and specify a weight that will be used to determine whether to issue the first or second filter. All of the configuration for this job thread can be provided through parameters.


Field Summary
static java.lang.String SEARCH_SCOPE_BASEOBJECT
          The string that indicates a baseObject search scope.
static java.lang.String SEARCH_SCOPE_ONELEVEL
          The string that indicates a oneLevel search scope.
static java.lang.String[] SEARCH_SCOPE_STRINGS
          The values that may be specified for the search scope.
static java.lang.String SEARCH_SCOPE_WHOLESUBTREE
          The string that indicates a wholeSubtree search scope.
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_EXCEPTIONS_CAUGHT
          The display name for the stat tracker that will be used to track the number of exceptions caught.
static java.lang.String STAT_TRACKER_OVERALL_SEARCH_COMPLETED
          The display name for the stat tracker that will be used to track overall number of searches that have been performed.
static java.lang.String STAT_TRACKER_SEARCH_1_COMPLETED
          The display name for the stat tracker that will be used to track the number of the first type of search that have been performed.
static java.lang.String STAT_TRACKER_SEARCH_1_TIME
          The display name for the stat tracker that will be used to track the time required to run each instance of the first search.
static java.lang.String STAT_TRACKER_SEARCH_2_COMPLETED
          The display name for the stat tracker that will be used to track the number of the second type of search that have been performed.
static java.lang.String STAT_TRACKER_SEARCH_2_TIME
          The display name for the stat tracker that will be used to track the time required to run each instance of the second search.
static java.lang.String STAT_TRACKER_SEARCH_FREQUENCY
          The display name for the stat tracker that will be used to track the frequency of each type of search.
static java.lang.String STAT_TRACKER_SEARCH_OVERALL_TIME
          The display name for the stat tracker that will be used to track the time required to run each search.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
WeightedSearchRateJobClass()
          The default constructor used to create a new instance of the search 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()
          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.
 ParameterList getParameterStubs()
          Retrieve a parameter list that can be used to determine all of the customizeable options that are available for this job.
 java.lang.String getRandomFilter1()
          Retrieves a filter chosen at random from the criteria for the first filter.
 java.lang.String getRandomFilter2()
          Retrieves a filter chosen at random from the criteria for the second filter.
 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 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.
 
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

SEARCH_SCOPE_BASEOBJECT

public static final java.lang.String SEARCH_SCOPE_BASEOBJECT
The string that indicates a baseObject search scope.

See Also:
Constant Field Values

SEARCH_SCOPE_ONELEVEL

public static final java.lang.String SEARCH_SCOPE_ONELEVEL
The string that indicates a oneLevel search scope.

See Also:
Constant Field Values

SEARCH_SCOPE_WHOLESUBTREE

public static final java.lang.String SEARCH_SCOPE_WHOLESUBTREE
The string that indicates a wholeSubtree search scope.

See Also:
Constant Field Values

SEARCH_SCOPE_STRINGS

public static final java.lang.String[] SEARCH_SCOPE_STRINGS
The values that may be specified for the search scope.


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_SEARCH_1_TIME

public static final java.lang.String STAT_TRACKER_SEARCH_1_TIME
The display name for the stat tracker that will be used to track the time required to run each instance of the first search.

See Also:
Constant Field Values

STAT_TRACKER_SEARCH_2_TIME

public static final java.lang.String STAT_TRACKER_SEARCH_2_TIME
The display name for the stat tracker that will be used to track the time required to run each instance of the second search.

See Also:
Constant Field Values

STAT_TRACKER_SEARCH_OVERALL_TIME

public static final java.lang.String STAT_TRACKER_SEARCH_OVERALL_TIME
The display name for the stat tracker that will be used to track the time required to run each search.

See Also:
Constant Field Values

STAT_TRACKER_SEARCH_1_COMPLETED

public static final java.lang.String STAT_TRACKER_SEARCH_1_COMPLETED
The display name for the stat tracker that will be used to track the number of the first type of search that have been performed.

See Also:
Constant Field Values

STAT_TRACKER_SEARCH_2_COMPLETED

public static final java.lang.String STAT_TRACKER_SEARCH_2_COMPLETED
The display name for the stat tracker that will be used to track the number of the second type of search that have been performed.

See Also:
Constant Field Values

STAT_TRACKER_OVERALL_SEARCH_COMPLETED

public static final java.lang.String STAT_TRACKER_OVERALL_SEARCH_COMPLETED
The display name for the stat tracker that will be used to track overall number of searches that have been performed.

See Also:
Constant Field Values

STAT_TRACKER_EXCEPTIONS_CAUGHT

public static final java.lang.String STAT_TRACKER_EXCEPTIONS_CAUGHT
The display name for the stat tracker that will be used to track the number of exceptions caught.

See Also:
Constant Field Values

STAT_TRACKER_SEARCH_FREQUENCY

public static final java.lang.String STAT_TRACKER_SEARCH_FREQUENCY
The display name for the stat tracker that will be used to track the frequency of each type of search.

See Also:
Constant Field Values
Constructor Detail

WeightedSearchRateJobClass

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

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 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 of the customizeable 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.

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

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

getRandomFilter1

public java.lang.String getRandomFilter1()
Retrieves a filter chosen at random from the criteria for the first filter.

Returns:
A filter chosen at random from the criteria for the first filter.

getRandomFilter2

public java.lang.String getRandomFilter2()
Retrieves a filter chosen at random from the criteria for the second filter.

Returns:
A filter chosen at random from the criteria for the second filter.

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.