com.sun.slamd.example
Class DSADMImportRateJobClass

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

public class DSADMImportRateJobClass
extends JobClass

This class defines a SLAMD job that has the ability to perform a "dsadm import" operation in the Sun Java System Directory Server 6 and extract statistics from the progress of the import, including the total number of entries processed, the average and recent import rates, and the hit ratio.

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 int READ_BUFFER_SIZE
          The size to use for the read buffer.
static java.lang.String STAT_TRACKER_AVERAGE_RATE
          The display name of the stat tracker used to keep track of the average import rate.
static java.lang.String STAT_TRACKER_ENTRIES_PROCESSED
          The display name of the stat tracker used to keep track of the number of entries processed.
static java.lang.String STAT_TRACKER_HIT_RATIO
          The display name of the stat tracker used to keep track of the hit ratio.
static java.lang.String STAT_TRACKER_RECENT_RATE
          The display name of the stat tracker used to keep track of the recent import rate.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
DSADMImportRateJobClass()
          The default constructor used to create a new instance of the job class.
 
Method Summary
 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 customizable options that are available for this job.
 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)
          Initializes all of the instance variables that correspond to job parameters.
 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.
 int overrideNumClients()
          Provides a means for job classes to have a level of control over the number of clients that will be used to run a job.
 int overrideThreadsPerClient()
          Provides a means for job classes to have a level of control over the number of threads per client that will be used to run a job.
 void runJob()
          Perform the work of this job thread by executing the specified command.
 
Methods inherited from class com.sun.slamd.job.JobClass
destroy, enableRealTimeStats, finalizeClient, finalizeJob, finalizeThread, getActiveThreadCount, getClientID, getClientNumber, getClientSideJob, getClientSideParameterStubs, getCollectionInterval, getJobID, getScheduledDuration, getShouldStopTime, getStatReporter, getThreadID, getThreadNumber, indicateCompletedWithErrors, indicateStoppedDueToError, initializeJob, initializeJobThread, isDeprecated, isRunning, logMessage, overrideCollectionInterval, providesParameterTest, run, setClientNumber, setClientSideJob, setThreadNumber, shouldStop, stackTraceToString, startJob, stopAndWait, stopJob, stopRequested, testJobParameters, 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

STAT_TRACKER_AVERAGE_RATE

public static final java.lang.String STAT_TRACKER_AVERAGE_RATE
The display name of the stat tracker used to keep track of the average import rate.

See Also:
Constant Field Values

STAT_TRACKER_RECENT_RATE

public static final java.lang.String STAT_TRACKER_RECENT_RATE
The display name of the stat tracker used to keep track of the recent import rate.

See Also:
Constant Field Values

STAT_TRACKER_ENTRIES_PROCESSED

public static final java.lang.String STAT_TRACKER_ENTRIES_PROCESSED
The display name of the stat tracker used to keep track of the number of entries processed.

See Also:
Constant Field Values

STAT_TRACKER_HIT_RATIO

public static final java.lang.String STAT_TRACKER_HIT_RATIO
The display name of the stat tracker used to keep track of the hit ratio.

See Also:
Constant Field Values

READ_BUFFER_SIZE

public static final int READ_BUFFER_SIZE
The size to use for the read buffer.

See Also:
Constant Field Values
Constructor Detail

DSADMImportRateJobClass

public DSADMImportRateJobClass()
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.

overrideNumClients

public int overrideNumClients()
Provides a means for job classes to have a level of control over the number of clients that will be used to run a job. If a job class implements this method and returns a value greater than 0, then that number of clients will always be used to run the job, and the form allowing the user to schedule a job will not show the "Number of Clients" field. By default, the user will be allowed to choose the number of clients.

Overrides:
overrideNumClients in class JobClass
Returns:
The number of clients that should be used to run this job, or -1 if the user should be allowed to specify the number of clients.

overrideThreadsPerClient

public int overrideThreadsPerClient()
Provides a means for job classes to have a level of control over the number of threads per client that will be used to run a job. If a job class implements this method and returns a value greater than 0, then that number of threads per client will always be used to run the job, and the form allowing the user to schedule a job will not show the "Threads per Client" field. By default, the user will be allowed to choose the number of threads per client.

Overrides:
overrideThreadsPerClient in class JobClass
Returns:
The number of threads per client that should be used to run this job, or -1 if the user should be allowed to specify the number of threads per client.

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.

initializeClient

public void initializeClient(java.lang.String clientID,
                             ParameterList parameters)
                      throws UnableToRunException
Initializes all of the instance variables that correspond to job parameters.

Overrides:
initializeClient in class JobClass
Parameters:
clientID - The client ID for the current client.
parameters - The set of parameters that have been defined for this job.
Throws:
UnableToRunException - If any part of the initialization fails.

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