com.sun.slamd.example
Class ISAuthRateJobClass

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

public class ISAuthRateJobClass
extends JobClass

This class implements a SLAMD job class for performing repeated Authentication requests against an Identity server. All of the configuration for this job class can be provided through parameters.


Field Summary
static int BUFFER_SIZE
          The size of the buffer that will be used to read the response from the HTTP server.
static java.lang.String CLOSE
           
static java.lang.String CONNECTION
           
static byte[] CONNECTION_BYTES
          The byte array containing the byte representation of "connection".
static java.lang.String CONTENT_LENGTH
           
static byte[] CONTENT_LENGTH_BYTES
          The byte array containing the byte representation of "content-length".
static java.lang.String CONTENT_TYPE
           
static java.lang.String DEFAULT_HTTP_HOST
          The address that will be used if none is specified in the URL.
static int DEFAULT_HTTP_PORT
          The port number that will be used if none is specified in the URL and SSL is not to be used.
static int DEFAULT_HTTPS_PORT
          The port number that will be used if none is specified in the URL and SSL is to be used.
static java.lang.String EOL
          The end-of-line marker to be used in all requests as dictated by RFC 2068.
static java.lang.String FAILED_AUTH
           
static java.lang.String HOST
           
static java.lang.String KEEP_ALIVE
           
static byte[] KEEP_ALIVE_BYTES
          The byte array containing the byte representation of "keep-alive".
static java.lang.String POST
           
static java.lang.String PROTOCOL_VERSION_1_0
          The string that indicates that HTTP 1.0 is to be used for the GETs.
static java.lang.String PROTOCOL_VERSION_1_1
          The string that indicates that HTTP 1.1 is to be used for the GETs.
static java.lang.String[] PROTOCOL_VERSION_STRINGS
          The values that may be specified for the protocol version.
static int RESPONSE_EXPECTATION_FAILED
          The HTTP response that will be used if the client cannot parse the response from the server.
static java.lang.String SPACE
           
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_AUTHN_ATTEMPTS
          The display name for the stat tracker that will be used to track the number of successful GETs.
static java.lang.String STAT_TRACKER_AUTHN_RESULTS
          The display name for the stat tracker that will be used to track the response codes for the pages retrieved.
static java.lang.String STAT_TRACKER_AUTHN_TIME
          The display name for the stat tracker that will be used to track the time required to perform each GET.
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 SUCCESSFUL_AUTH
           
static java.lang.String X_AUTHERRORCODE
           
static byte[] X_AUTHERRORCODE_BYTES
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ISAuthRateJobClass()
          Creates a new instance of this job class.
 
Method Summary
 int authenticate()
          Issues the request to the HTTP server and reads the response.
 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.
 java.lang.String[] getLoginInfo()
          Retrieves an array containing the login ID and password that should be used to authenticate to the directory.
 ParameterList getParameterStubs()
          Retrieve a parameter list that can be used to determine all of the customizeable options that are available for this job.
 byte[] getRequest()
           
 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.
 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 startsWithIgnoreCase(byte[] bytesToMatch, int lineStartPos, int lineEndPos)
          Compares the contents of the provided byte array with the contents of the specified portion of the buffer read from the input string.
 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, providesParameterTest, run, setClientNumber, setClientSideJob, setThreadNumber, shouldStop, stackTraceToString, startJob, stopAndWait, stopJob, stopRequested, testJobParameters, 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

CONTENT_TYPE

public static final java.lang.String CONTENT_TYPE
See Also:
Constant Field Values

CONTENT_LENGTH

public static final java.lang.String CONTENT_LENGTH
See Also:
Constant Field Values

KEEP_ALIVE

public static final java.lang.String KEEP_ALIVE
See Also:
Constant Field Values

CLOSE

public static final java.lang.String CLOSE
See Also:
Constant Field Values

CONNECTION

public static final java.lang.String CONNECTION
See Also:
Constant Field Values

HOST

public static final java.lang.String HOST
See Also:
Constant Field Values

POST

public static final java.lang.String POST
See Also:
Constant Field Values

SPACE

public static final java.lang.String SPACE
See Also:
Constant Field Values

X_AUTHERRORCODE

public static final java.lang.String X_AUTHERRORCODE
See Also:
Constant Field Values

X_AUTHERRORCODE_BYTES

public static final byte[] X_AUTHERRORCODE_BYTES

SUCCESSFUL_AUTH

public static final java.lang.String SUCCESSFUL_AUTH
See Also:
Constant Field Values

FAILED_AUTH

public static final java.lang.String FAILED_AUTH
See Also:
Constant Field Values

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

DEFAULT_HTTP_PORT

public static final int DEFAULT_HTTP_PORT
The port number that will be used if none is specified in the URL and SSL is not to be used.

See Also:
Constant Field Values

DEFAULT_HTTPS_PORT

public static final int DEFAULT_HTTPS_PORT
The port number that will be used if none is specified in the URL and SSL is to be used.

See Also:
Constant Field Values

DEFAULT_HTTP_HOST

public static final java.lang.String DEFAULT_HTTP_HOST
The address that will be used if none is specified in the URL.

See Also:
Constant Field Values

BUFFER_SIZE

public static final int BUFFER_SIZE
The size of the buffer that will be used to read the response from the HTTP server.

See Also:
Constant Field Values

EOL

public static final java.lang.String EOL
The end-of-line marker to be used in all requests as dictated by RFC 2068.

See Also:
Constant Field Values

CONNECTION_BYTES

public static final byte[] CONNECTION_BYTES
The byte array containing the byte representation of "connection".


CONTENT_LENGTH_BYTES

public static final byte[] CONTENT_LENGTH_BYTES
The byte array containing the byte representation of "content-length".


KEEP_ALIVE_BYTES

public static final byte[] KEEP_ALIVE_BYTES
The byte array containing the byte representation of "keep-alive".


RESPONSE_EXPECTATION_FAILED

public static final int RESPONSE_EXPECTATION_FAILED
The HTTP response that will be used if the client cannot parse the response from the server. Technically, this is reserved for other uses by the HTTP protocol, but the geniuses that developed the protocol did not define any response codes for client-side errors, so I'm using it for this as well.

See Also:
Constant Field Values

PROTOCOL_VERSION_1_0

public static final java.lang.String PROTOCOL_VERSION_1_0
The string that indicates that HTTP 1.0 is to be used for the GETs.

See Also:
Constant Field Values

PROTOCOL_VERSION_1_1

public static final java.lang.String PROTOCOL_VERSION_1_1
The string that indicates that HTTP 1.1 is to be used for the GETs.

See Also:
Constant Field Values

PROTOCOL_VERSION_STRINGS

public static final java.lang.String[] PROTOCOL_VERSION_STRINGS
The values that may be specified for the protocol version.


STAT_TRACKER_AUTHN_TIME

public static final java.lang.String STAT_TRACKER_AUTHN_TIME
The display name for the stat tracker that will be used to track the time required to perform each GET.

See Also:
Constant Field Values

STAT_TRACKER_AUTHN_ATTEMPTS

public static final java.lang.String STAT_TRACKER_AUTHN_ATTEMPTS
The display name for the stat tracker that will be used to track the number of successful GETs.

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_AUTHN_RESULTS

public static final java.lang.String STAT_TRACKER_AUTHN_RESULTS
The display name for the stat tracker that will be used to track the response codes for the pages retrieved.

See Also:
Constant Field Values
Constructor Detail

ISAuthRateJobClass

public ISAuthRateJobClass()
Creates a new instance of this job class.

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.

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.

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 the thread initialization could not be completed successfully and the job is unable to run.

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

authenticate

public int authenticate()
                 throws java.io.IOException
Issues the request to the HTTP server and reads the response.

Returns:
The HTTP response code returned from the server.
Throws:
java.io.IOException - If an I/O problem occurred while reading from or writing to the server.

startsWithIgnoreCase

public boolean startsWithIgnoreCase(byte[] bytesToMatch,
                                    int lineStartPos,
                                    int lineEndPos)
Compares the contents of the provided byte array with the contents of the specified portion of the buffer read from the input string.

Parameters:
bytesToMatch - The byte array containing the bytes to compare against the contents of the input buffer. This byte array should contain an encoded string whose characters are all uppercase.
lineStartPos - The position in the input buffer at which the line starts.
lineEndPos - The position in the input buffer at which the line ends.

getLoginInfo

public java.lang.String[] getLoginInfo()
Retrieves an array containing the login ID and password that should be used to authenticate to the directory.

Returns:
An array containing the login ID and password.

getRequest

public byte[] getRequest()