Package com.unboundid.ldap.sdk.examples
Class ModRate
- java.lang.Object
-
- com.unboundid.util.CommandLineTool
-
- com.unboundid.util.LDAPCommandLineTool
-
- com.unboundid.ldap.sdk.examples.ModRate
-
- All Implemented Interfaces:
java.io.Serializable
@ThreadSafety(level=NOT_THREADSAFE) public final class ModRate extends LDAPCommandLineTool implements java.io.Serializable
This class provides a tool that can be used to perform repeated modifications in an LDAP directory server using multiple threads. It can help provide an estimate of the modify performance that a directory server is able to achieve. The target entry DN may be a value pattern as described in theValuePattern
class. This makes it possible to modify a range of entries rather than repeatedly updating the same entry.
Some of the APIs demonstrated by this example include:- Argument Parsing (from the
com.unboundid.util.args
package) - LDAP Command-Line Tool (from the
com.unboundid.util
package) - LDAP Communication (from the
com.unboundid.ldap.sdk
package) - Value Patterns (from the
com.unboundid.util
package)
All of the necessary information is provided using command line arguments. Supported arguments include those allowed by theLDAPCommandLineTool
class, as well as the following additional arguments:- "-b {entryDN}" or "--targetDN {baseDN}" -- specifies the DN of the entry to be modified. This must be provided. It may be a simple DN, or it may be a value pattern to express a range of entry DNs.
- "-A {name}" or "--attribute {name}" -- specifies the name of the attribute to modify. Multiple attributes may be modified by providing multiple instances of this argument. At least one attribute must be provided.
- "--valuePattern {pattern}" -- specifies the pattern to use to generate the value to use for each modification. If this argument is provided, then neither the "--valueLength" nor "--characterSet" arguments may be given.
- "-l {num}" or "--valueLength {num}" -- specifies the length in bytes to use for the values of the target attributes. If this is not provided, then a default length of 10 bytes will be used.
- "-C {chars}" or "--characterSet {chars}" -- specifies the set of characters that will be used to generate the values to use for the target attributes. It should only include ASCII characters. Values will be generated from randomly-selected characters from this set. If this is not provided, then a default set of lowercase alphabetic characters will be used.
- "-t {num}" or "--numThreads {num}" -- specifies the number of concurrent threads to use when performing the modifications. If this is not provided, then a default of one thread will be used.
- "-i {sec}" or "--intervalDuration {sec}" -- specifies the length of time in seconds between lines out output. If this is not provided, then a default interval duration of five seconds will be used.
- "-I {num}" or "--numIntervals {num}" -- specifies the maximum number of intervals for which to run. If this is not provided, then it will run forever.
- "--iterationsBeforeReconnect {num}" -- specifies the number of modify iterations that should be performed on a connection before that connection is closed and replaced with a newly-established (and authenticated, if appropriate) connection.
- "-r {modifies-per-second}" or "--ratePerSecond {modifies-per-second}" -- specifies the target number of modifies to perform per second. It is still necessary to specify a sufficient number of threads for achieving this rate. If this option is not provided, then the tool will run at the maximum rate for the specified number of threads.
- "--variableRateData {path}" -- specifies the path to a file containing information needed to allow the tool to vary the target rate over time. If this option is not provided, then the tool will either use a fixed target rate as specified by the "--ratePerSecond" argument, or it will run at the maximum rate.
- "--generateSampleRateFile {path}" -- specifies the path to a file to which sample data will be written illustrating and describing the format of the file expected to be used in conjunction with the "--variableRateData" argument.
- "--warmUpIntervals {num}" -- specifies the number of intervals to complete before beginning overall statistics collection.
- "--timestampFormat {format}" -- specifies the format to use for timestamps included before each output line. The format may be one of "none" (for no timestamps), "with-date" (to include both the date and the time), or "without-date" (to include only time time).
- "-Y {authzID}" or "--proxyAs {authzID}" -- Use the proxied authorization v2 control to request that the operation be processed using an alternate authorization identity. In this case, the bind DN should be that of a user that has permission to use this control. The authorization identity may be a value pattern.
- "--suppressErrorResultCodes" -- Indicates that information about the result codes for failed operations should not be displayed.
- "-c" or "--csv" -- Generate output in CSV format rather than a display-friendly format.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ModRate(java.io.OutputStream outStream, java.io.OutputStream errStream)
Creates a new instance of this tool.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addNonLDAPArguments(ArgumentParser parser)
Adds the arguments used by this program that aren't already provided by the genericLDAPCommandLineTool
framework.boolean
defaultsToInteractiveMode()
Indicates whether this tool defaults to launching in interactive mode if the tool is invoked without any command-line arguments.protected boolean
defaultToPromptForBindPassword()
Indicates whether this tool should default to interactively prompting for the bind password if a password is required but no argument was provided to indicate how to get the password.ResultCode
doToolProcessing()
Performs the actual processing for this tool.LDAPConnectionOptions
getConnectionOptions()
Retrieves the connection options that should be used for connections created for use with this tool.java.util.LinkedHashMap<java.lang.String[],java.lang.String>
getExampleUsages()
Retrieves a set of information that may be used to generate example usage information.java.lang.String
getToolDescription()
Retrieves the description for this tool.java.lang.String
getToolName()
Retrieves the name for this tool.java.lang.String
getToolVersion()
Retrieves the version string for this tool.protected boolean
includeAlternateLongIdentifiers()
Indicates whether the LDAP-specific arguments should include alternate versions of all long identifiers that consist of multiple words so that they are available in both camelCase and dash-separated versions.protected boolean
logToolInvocationByDefault()
Indicates whether to log messages about the launch and completion of this tool into the invocation log of Ping Identity server products that may include it.static void
main(java.lang.String[] args)
Parse the provided command line arguments and make the appropriate set of changes.static ResultCode
main(java.lang.String[] args, java.io.OutputStream outStream, java.io.OutputStream errStream)
Parse the provided command line arguments and make the appropriate set of changes.void
stopRunning()
Requests that this tool stop running.boolean
supportsInteractiveMode()
Indicates whether this tool should provide support for an interactive mode, in which the tool offers a mode in which the arguments can be provided in a text-driven menu rather than requiring them to be given on the command line.protected boolean
supportsMultipleServers()
Indicates whether this tool supports creating connections to multiple servers.protected boolean
supportsOutputFile()
Indicates whether this tool should provide arguments for redirecting output to a file.boolean
supportsPropertiesFile()
Indicates whether this tool supports the use of a properties file for specifying default values for arguments that aren't specified on the command line.-
Methods inherited from class com.unboundid.util.LDAPCommandLineTool
addToolArguments, anyLDAPArgumentsProvided, createBindRequest, createServerSet, createSSLUtil, createSSLUtil, doExtendedArgumentValidation, doExtendedNonLDAPArgumentValidation, getBindControls, getConnection, getConnectionPool, getConnectionPool, getSuppressedShortIdentifiers, getUnauthenticatedConnection, supportsAuthentication, supportsSASLHelp, supportsSSLDebugging
-
Methods inherited from class com.unboundid.util.CommandLineTool
addEnableSSLDebuggingArgument, createArgumentParser, doShutdownHookProcessing, err, getAdditionalDescriptionParagraphs, getErr, getMaxTrailingArguments, getMinTrailingArguments, getOriginalErr, getOriginalOut, getOut, getPasswordFileReader, getToolCompletionMessage, getTrailingArgumentsPlaceholder, out, registerShutdownHook, requestToolArgumentsInteractively, runTool, wrapErr, wrapOut
-
-
-
-
Constructor Detail
-
ModRate
public ModRate(java.io.OutputStream outStream, java.io.OutputStream errStream)
Creates a new instance of this tool.- Parameters:
outStream
- The output stream to which standard out should be written. It may benull
if output should be suppressed.errStream
- The output stream to which standard error should be written. It may benull
if error messages should be suppressed.
-
-
Method Detail
-
main
public static void main(java.lang.String[] args)
Parse the provided command line arguments and make the appropriate set of changes.- Parameters:
args
- The command line arguments provided to this program.
-
main
public static ResultCode main(java.lang.String[] args, java.io.OutputStream outStream, java.io.OutputStream errStream)
Parse the provided command line arguments and make the appropriate set of changes.- Parameters:
args
- The command line arguments provided to this program.outStream
- The output stream to which standard out should be written. It may benull
if output should be suppressed.errStream
- The output stream to which standard error should be written. It may benull
if error messages should be suppressed.- Returns:
- A result code indicating whether the processing was successful.
-
getToolName
public java.lang.String getToolName()
Retrieves the name for this tool.- Specified by:
getToolName
in classCommandLineTool
- Returns:
- The name for this tool.
-
getToolDescription
public java.lang.String getToolDescription()
Retrieves the description for this tool.- Specified by:
getToolDescription
in classCommandLineTool
- Returns:
- The description for this tool.
-
getToolVersion
public java.lang.String getToolVersion()
Retrieves the version string for this tool.- Overrides:
getToolVersion
in classCommandLineTool
- Returns:
- The version string for this tool.
-
supportsInteractiveMode
public boolean supportsInteractiveMode()
Indicates whether this tool should provide support for an interactive mode, in which the tool offers a mode in which the arguments can be provided in a text-driven menu rather than requiring them to be given on the command line. If interactive mode is supported, it may be invoked using the "--interactive" argument. Alternately, if interactive mode is supported anddefaultsToInteractiveMode()
returnstrue
, then interactive mode may be invoked by simply launching the tool without any arguments.- Overrides:
supportsInteractiveMode
in classCommandLineTool
- Returns:
true
if this tool supports interactive mode, orfalse
if not.
-
defaultsToInteractiveMode
public boolean defaultsToInteractiveMode()
Indicates whether this tool defaults to launching in interactive mode if the tool is invoked without any command-line arguments. This will only be used ifsupportsInteractiveMode()
returnstrue
.- Overrides:
defaultsToInteractiveMode
in classCommandLineTool
- Returns:
true
if this tool defaults to using interactive mode if launched without any command-line arguments, orfalse
if not.
-
supportsOutputFile
protected boolean supportsOutputFile()
Indicates whether this tool should provide arguments for redirecting output to a file. If this method returnstrue
, then the tool will offer an "--outputFile" argument that will specify the path to a file to which all standard output and standard error content will be written, and it will also offer a "--teeToStandardOut" argument that can only be used if the "--outputFile" argument is present and will cause all output to be written to both the specified output file and to standard output.- Overrides:
supportsOutputFile
in classCommandLineTool
- Returns:
true
if this tool should provide arguments for redirecting output to a file, orfalse
if not.
-
defaultToPromptForBindPassword
protected boolean defaultToPromptForBindPassword()
Indicates whether this tool should default to interactively prompting for the bind password if a password is required but no argument was provided to indicate how to get the password.- Overrides:
defaultToPromptForBindPassword
in classLDAPCommandLineTool
- Returns:
true
if this tool should default to interactively prompting for the bind password, orfalse
if not.
-
supportsPropertiesFile
public boolean supportsPropertiesFile()
Indicates whether this tool supports the use of a properties file for specifying default values for arguments that aren't specified on the command line.- Overrides:
supportsPropertiesFile
in classCommandLineTool
- Returns:
true
if this tool supports the use of a properties file for specifying default values for arguments that aren't specified on the command line, orfalse
if not.
-
includeAlternateLongIdentifiers
protected boolean includeAlternateLongIdentifiers()
Indicates whether the LDAP-specific arguments should include alternate versions of all long identifiers that consist of multiple words so that they are available in both camelCase and dash-separated versions.- Overrides:
includeAlternateLongIdentifiers
in classLDAPCommandLineTool
- Returns:
true
if this tool should provide multiple versions of long identifiers for LDAP-specific arguments, orfalse
if not.
-
logToolInvocationByDefault
protected boolean logToolInvocationByDefault()
Indicates whether to log messages about the launch and completion of this tool into the invocation log of Ping Identity server products that may include it. This method is not needed for tools that are not expected to be part of the Ping Identity server products suite. Further, this value may be overridden by settings in the server's tool-invocation-logging.properties file.
This method should generally returntrue
for tools that may alter the server configuration, data, or other state information, andfalse
for tools that do not make any changes.- Overrides:
logToolInvocationByDefault
in classCommandLineTool
- Returns:
true
if Ping Identity server products should include messages about the launch and completion of this tool in tool invocation log files by default, orfalse
if not.
-
addNonLDAPArguments
public void addNonLDAPArguments(ArgumentParser parser) throws ArgumentException
Adds the arguments used by this program that aren't already provided by the genericLDAPCommandLineTool
framework.- Specified by:
addNonLDAPArguments
in classLDAPCommandLineTool
- Parameters:
parser
- The argument parser to which the arguments should be added.- Throws:
ArgumentException
- If a problem occurs while adding the arguments.
-
supportsMultipleServers
protected boolean supportsMultipleServers()
Indicates whether this tool supports creating connections to multiple servers. If it is to support multiple servers, then the "--hostname" and "--port" arguments will be allowed to be provided multiple times, and will be required to be provided the same number of times. The same type of communication security and bind credentials will be used for all servers.- Overrides:
supportsMultipleServers
in classLDAPCommandLineTool
- Returns:
true
if this tool supports creating connections to multiple servers, orfalse
if not.
-
getConnectionOptions
public LDAPConnectionOptions getConnectionOptions()
Retrieves the connection options that should be used for connections created for use with this tool.- Overrides:
getConnectionOptions
in classLDAPCommandLineTool
- Returns:
- The connection options that should be used for connections created for use with this tool.
-
doToolProcessing
public ResultCode doToolProcessing()
Performs the actual processing for this tool. In this case, it gets a connection to the directory server and uses it to perform the requested modifications.- Specified by:
doToolProcessing
in classCommandLineTool
- Returns:
- The result code for the processing that was performed.
-
stopRunning
public void stopRunning()
Requests that this tool stop running. This method will attempt to wait for all threads to complete before returning control to the caller.
-
getExampleUsages
public java.util.LinkedHashMap<java.lang.String[],java.lang.String> getExampleUsages()
Retrieves a set of information that may be used to generate example usage information. Each element in the returned map should consist of a map between an example set of arguments and a string that describes the behavior of the tool when invoked with that set of arguments.- Overrides:
getExampleUsages
in classCommandLineTool
- Returns:
- A set of information that may be used to generate example usage
information. It may be
null
or empty if no example usage information is available.
-
-