- Improved usage information for searchrate and modrate
- maxIteration is now for the entire run
- Better error handling with the --argument option
| | |
| | | client disconnected |
| | | INFO_CANCELED_BY_CLIENT_ERROR=The operation was canceled because the \ |
| | | client connection failed |
| | | INFO_SEARCHRATE_TOOL_DESCRIPTION=This utility can be used to measure \ |
| | | search throughput and response time of a directory service using \ |
| | | user-defined searches |
| | | INFO_SEARCHRATE_TOOL_DESCRIPTION_BASEDN=Base DN format string. |
| | | INFO_MODRATE_TOOL_DESCRIPTION=This utility can be used to measure \ |
| | | modify throughput and response time of a directory service using \ |
| | | user-defined modifications |
| | | INFO_MODRATE_TOOL_DESCRIPTION_TARGETDN=Target entry DN format string |
| | | |
| | | |
| | |
| | | // indent the description five characters and try our best to wrap |
| | | // at or |
| | | // before column 79 so it will be friendly to 80-column displays. |
| | | final LocalizableMessage description = a.getDescription(); |
| | | final int descMaxLength = MAX_LENGTH - indentLength - 1; |
| | | if (description.length() <= descMaxLength) |
| | | { |
| | | buffer.append(INDENT); |
| | | buffer.append(description); |
| | | buffer.append(EOL); |
| | | } |
| | | else |
| | | { |
| | | String s = description.toString(); |
| | | while (s.length() > descMaxLength) |
| | | { |
| | | int spacePos = s.lastIndexOf(' ', descMaxLength); |
| | | if (spacePos > 0) |
| | | { |
| | | buffer.append(INDENT); |
| | | buffer.append(s.substring(0, spacePos).trim()); |
| | | s = s.substring(spacePos + 1).trim(); |
| | | buffer.append(EOL); |
| | | } |
| | | else |
| | | { |
| | | // There are no spaces in the first 74 columns. See if there |
| | | // is one |
| | | // after that point. If so, then break there. If not, then |
| | | // don't |
| | | // break at all. |
| | | spacePos = s.indexOf(' '); |
| | | if (spacePos > 0) |
| | | { |
| | | buffer.append(INDENT); |
| | | buffer.append(s.substring(0, spacePos).trim()); |
| | | s = s.substring(spacePos + 1).trim(); |
| | | buffer.append(EOL); |
| | | } |
| | | else |
| | | { |
| | | buffer.append(INDENT); |
| | | buffer.append(s); |
| | | s = ""; |
| | | buffer.append(EOL); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (s.length() > 0) |
| | | { |
| | | buffer.append(INDENT); |
| | | buffer.append(s); |
| | | buffer.append(EOL); |
| | | } |
| | | } |
| | | buffer.append( |
| | | Utils.wrapText(a.getDescription(), MAX_LENGTH, indentLength)); |
| | | buffer.append(EOL); |
| | | |
| | | if (a.needsValue() && (a.getDefaultValue() != null) |
| | | && (a.getDefaultValue().length() > 0)) |
| | |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | import org.opends.sdk.LocalizableMessage; |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | return lines.get(next++); |
| | | } |
| | | |
| | | public static LocalizableMessage getUsage() |
| | | { |
| | | return LocalizableMessage.raw( |
| | | "\"inc({filename})\" Consecutive, incremental line from file"); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | return next++; |
| | | } |
| | | |
| | | public static LocalizableMessage getUsage() |
| | | { |
| | | return LocalizableMessage.raw( |
| | | "\"inc({min},{max})\" Consecutive, incremental number"); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | return lines.get(random.nextInt(lines.size())); |
| | | } |
| | | |
| | | public static LocalizableMessage getUsage() |
| | | { |
| | | return LocalizableMessage.raw( |
| | | "\"rand({filename})\" Random line from file"); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | return random.nextInt(range) + offset; |
| | | } |
| | | |
| | | public static LocalizableMessage getUsage() |
| | | { |
| | | return LocalizableMessage.raw( |
| | | "\"rand({min},{max})\" Random number"); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | return new String(str); |
| | | } |
| | | |
| | | public static LocalizableMessage getUsage() |
| | | { |
| | | return LocalizableMessage.raw( |
| | | "\"randStr({length},<charSet>)\" Random string of specified " + |
| | | "length and optionally from characters in " + |
| | | "the charSet string. A range of character " + |
| | | "can be specified with [start-end] charSet notation. " + |
| | | "If no charSet is specified, the default charSet of " + |
| | | "[A-Z][a-z][0-9] will be used"); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | * @param sources |
| | | * The list of source definitions to parse. |
| | | * @return The array of parsed data sources. |
| | | * @throws IOException |
| | | * If an exception occurs while reading a file. |
| | | * @throws ArgumentException |
| | | * If an exception occurs while parsing. |
| | | */ |
| | | public static DataSource[] parse(final List<String> sources) |
| | | throws IOException |
| | | throws ArgumentException |
| | | { |
| | | Validator.ensureNotNull(sources); |
| | | final DataSource[] dataSources = new DataSource[sources.size()]; |
| | |
| | | final int lparenPos = dataSourceDef.indexOf("("); |
| | | final int commaPos = dataSourceDef.indexOf(","); |
| | | final int rparenPos = dataSourceDef.indexOf(")"); |
| | | |
| | | if (commaPos < 0) |
| | | { |
| | | // This is a file name |
| | | dataSources[i] = new DataSource(new RandomLineFileDataSource(0, |
| | | dataSourceDef.substring(lparenPos + 1, rparenPos))); |
| | | try |
| | | { |
| | | // This is a file name |
| | | dataSources[i] = new DataSource(new RandomLineFileDataSource(0, |
| | | dataSourceDef.substring(lparenPos + 1, rparenPos))); |
| | | } |
| | | catch(IOException ioe) |
| | | { |
| | | throw new ArgumentException(LocalizableMessage.raw( |
| | | "Error opening file %s: %s", |
| | | dataSourceDef.substring(lparenPos + 1, rparenPos), |
| | | ioe.getMessage()), ioe); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | throw new ArgumentException(LocalizableMessage.raw( |
| | | "Error parsing value generator: %s", e.getMessage()), e); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // This range of integers |
| | | final int low = Integer.parseInt(dataSourceDef.substring( |
| | | lparenPos + 1, commaPos)); |
| | | final int high = Integer.parseInt(dataSourceDef.substring( |
| | | commaPos + 1, rparenPos)); |
| | | dataSources[i] = new DataSource(new RandomNumberDataSource(Thread |
| | | .currentThread().getId(), low, high)); |
| | | try |
| | | { |
| | | // This range of integers |
| | | final int low = Integer.parseInt(dataSourceDef.substring( |
| | | lparenPos + 1, commaPos)); |
| | | final int high = Integer.parseInt(dataSourceDef.substring( |
| | | commaPos + 1, rparenPos)); |
| | | dataSources[i] = new DataSource(new RandomNumberDataSource(Thread |
| | | .currentThread().getId(), low, high)); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | throw new ArgumentException(LocalizableMessage.raw( |
| | | "Error parsing value generator: %s", e.getMessage()), e); |
| | | } |
| | | } |
| | | |
| | | } |
| | | else if (dataSourceDef.startsWith("randstr(") |
| | | && dataSourceDef.endsWith(")")) |
| | |
| | | final int rparenPos = dataSourceDef.indexOf(")"); |
| | | int length; |
| | | String charSet; |
| | | if (commaPos < 0) |
| | | try |
| | | { |
| | | length = Integer.parseInt(dataSourceDef.substring(lparenPos + 1, |
| | | rparenPos)); |
| | | charSet = "[A-Z][a-z][0-9]"; |
| | | if (commaPos < 0) |
| | | { |
| | | length = Integer.parseInt(dataSourceDef.substring(lparenPos + 1, |
| | | rparenPos)); |
| | | charSet = "[A-Z][a-z][0-9]"; |
| | | } |
| | | else |
| | | { |
| | | // length and charSet |
| | | length = Integer.parseInt(dataSourceDef.substring(lparenPos + 1, |
| | | commaPos)); |
| | | charSet = dataSourceDef.substring(commaPos + 1, rparenPos); |
| | | } |
| | | dataSources[i] = new DataSource(new RandomStringDataSource(0, length, |
| | | charSet)); |
| | | } |
| | | else |
| | | catch(Exception e) |
| | | { |
| | | // length and charSet |
| | | length = Integer.parseInt(dataSourceDef.substring(lparenPos + 1, |
| | | commaPos)); |
| | | charSet = dataSourceDef.substring(commaPos + 1, rparenPos); |
| | | throw new ArgumentException(LocalizableMessage.raw( |
| | | "Error parsing value generator: %s", e.getMessage()), e); |
| | | } |
| | | dataSources[i] = new DataSource(new RandomStringDataSource(0, length, |
| | | charSet)); |
| | | |
| | | } |
| | | else if (dataSourceDef.startsWith("inc(") && dataSourceDef.endsWith(")")) |
| | | { |
| | |
| | | final int rparenPos = dataSourceDef.indexOf(")"); |
| | | if (commaPos < 0) |
| | | { |
| | | // This is a file name |
| | | dataSources[i] = new DataSource(new IncrementLineFileDataSource( |
| | | dataSourceDef.substring(lparenPos + 1, rparenPos))); |
| | | try |
| | | { |
| | | // This is a file name |
| | | dataSources[i] = new DataSource(new IncrementLineFileDataSource( |
| | | dataSourceDef.substring(lparenPos + 1, rparenPos))); |
| | | } |
| | | catch(IOException ioe) |
| | | { |
| | | throw new ArgumentException(LocalizableMessage.raw( |
| | | "Error opening file %s: %s", |
| | | dataSourceDef.substring(lparenPos + 1, rparenPos), |
| | | ioe.getMessage()), ioe); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | throw new ArgumentException(LocalizableMessage.raw( |
| | | "Error parsing value generator: %s", e.getMessage()), e); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | final int low = Integer.parseInt(dataSourceDef.substring( |
| | | lparenPos + 1, commaPos)); |
| | | final int high = Integer.parseInt(dataSourceDef.substring( |
| | | commaPos + 1, rparenPos)); |
| | | dataSources[i] = new DataSource(new IncrementNumberDataSource(low, |
| | | high)); |
| | | try |
| | | { |
| | | final int low = Integer.parseInt(dataSourceDef.substring( |
| | | lparenPos + 1, commaPos)); |
| | | final int high = Integer.parseInt(dataSourceDef.substring( |
| | | commaPos + 1, rparenPos)); |
| | | dataSources[i] = new DataSource(new IncrementNumberDataSource(low, |
| | | high)); |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | throw new ArgumentException(LocalizableMessage.raw( |
| | | "Error parsing value generator: %s", e.getMessage()), e); |
| | | } |
| | | } |
| | | } |
| | | else |
| | |
| | | } |
| | | |
| | | |
| | | public static LocalizableMessage getUsage() |
| | | { |
| | | StringBuilder builder = new StringBuilder(); |
| | | builder.append(IncrementLineFileDataSource.getUsage()); |
| | | builder.append(StaticUtils.EOL); |
| | | builder.append(IncrementNumberDataSource.getUsage()); |
| | | builder.append(StaticUtils.EOL); |
| | | builder.append(RandomLineFileDataSource.getUsage()); |
| | | builder.append(StaticUtils.EOL); |
| | | builder.append(RandomNumberDataSource.getUsage()); |
| | | builder.append(StaticUtils.EOL); |
| | | builder.append(RandomStringDataSource.getUsage()); |
| | | return LocalizableMessage.raw(builder.toString()); |
| | | } |
| | | |
| | | |
| | | |
| | | private final IDataSource impl; |
| | | |
| | |
| | | { |
| | | // Create the command-line argument parser for use with this |
| | | // program. |
| | | final LocalizableMessage toolDescription = LocalizableMessage |
| | | .raw("This utility can be used to " + "measure modify performance"); |
| | | // TODO: correct usage |
| | | final LocalizableMessage toolDescription = |
| | | INFO_MODRATE_TOOL_DESCRIPTION.get(); |
| | | final ArgumentParser argParser = new ArgumentParser( |
| | | ModRate.class.getName(), toolDescription, false, true, 1, 0, |
| | | "[modifyString ...]"); |
| | | "[(attribute:value format string) ...]"); |
| | | ArgumentParserConnectionFactory connectionFactory; |
| | | ModifyPerformanceRunner runner; |
| | | |
| | |
| | | argParser.addArgument(noPropertiesFileArgument); |
| | | argParser.setNoPropertiesFileArgument(noPropertiesFileArgument); |
| | | |
| | | baseDN = new StringArgument("baseDN", OPTION_SHORT_BASEDN, |
| | | OPTION_LONG_BASEDN, true, false, true, INFO_BASEDN_PLACEHOLDER.get(), |
| | | null, null, INFO_SEARCH_DESCRIPTION_BASEDN.get()); |
| | | baseDN = new StringArgument("targetDN", OPTION_SHORT_BASEDN, |
| | | OPTION_LONG_TARGETDN, true, false, true, INFO_TARGETDN_PLACEHOLDER.get(), |
| | | null, null, INFO_MODRATE_TOOL_DESCRIPTION_TARGETDN.get()); |
| | | baseDN.setPropertyName(OPTION_LONG_BASEDN); |
| | | argParser.addArgument(baseDN); |
| | | |
| | |
| | | import java.util.concurrent.atomic.AtomicLong; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | import org.opends.sdk.*; |
| | | import org.opends.sdk.responses.ExtendedResult; |
| | | import org.opends.sdk.responses.Result; |
| | |
| | | numThreadsArgument = new IntegerArgument("numThreads", 't', "numThreads", |
| | | false, false, true, LocalizableMessage.raw("{numThreads}"), 1, null, |
| | | true, 1, false, 0, LocalizableMessage |
| | | .raw("number of search threads per connection")); |
| | | .raw("Number of worker threads per connection")); |
| | | numThreadsArgument.setPropertyName("numThreads"); |
| | | argParser.addArgument(numThreadsArgument); |
| | | |
| | | numConnectionsArgument = new IntegerArgument("numConnections", 'c', |
| | | "numConnections", false, false, true, LocalizableMessage |
| | | .raw("{numConnections}"), 1, null, true, 1, false, 0, |
| | | LocalizableMessage.raw("number of connections")); |
| | | LocalizableMessage.raw("Number of connections")); |
| | | numThreadsArgument.setPropertyName("numConnections"); |
| | | argParser.addArgument(numConnectionsArgument); |
| | | |
| | | maxIterationsArgument = new IntegerArgument("maxIterations", 'm', |
| | | "maxIterations", false, false, true, LocalizableMessage |
| | | .raw("{maxIterations}"), 0, null, LocalizableMessage |
| | | .raw("max searches per thread, 0 for unlimited")); |
| | | .raw("Max iterations, 0 for unlimited")); |
| | | numThreadsArgument.setPropertyName("maxIterations"); |
| | | argParser.addArgument(maxIterationsArgument); |
| | | |
| | |
| | | argParser.addArgument(percentilesArgument); |
| | | |
| | | keepConnectionsOpen = new BooleanArgument("keepConnectionsOpen", 'f', |
| | | "keepConnectionsOpen", LocalizableMessage.raw("keep connections open")); |
| | | "keepConnectionsOpen", LocalizableMessage.raw("Keep connections open")); |
| | | keepConnectionsOpen.setPropertyName("keepConnectionsOpen"); |
| | | argParser.addArgument(keepConnectionsOpen); |
| | | |
| | | noRebindArgument = new BooleanArgument("noRebind", 'F', "noRebind", |
| | | LocalizableMessage.raw("keep connections open and don't rebind")); |
| | | LocalizableMessage.raw("Keep connections open and don't rebind")); |
| | | keepConnectionsOpen.setPropertyName("noRebind"); |
| | | argParser.addArgument(noRebindArgument); |
| | | |
| | | asyncArgument = new BooleanArgument("asynchronous", 'A', "asynchronous", |
| | | LocalizableMessage.raw("asynch, don't wait for results")); |
| | | LocalizableMessage.raw("Use asynchronous mode and don't " + |
| | | "wait for results before sending the next request")); |
| | | keepConnectionsOpen.setPropertyName("asynchronous"); |
| | | argParser.addArgument(asyncArgument); |
| | | |
| | | arguments = new StringArgument("arguments", 'g', "arguments", false, true, |
| | | true, LocalizableMessage.raw("{arguments}"), null, null, |
| | | LocalizableMessage |
| | | .raw("arguments for variables in the filter and/or base DN")); |
| | | arguments.setPropertyName("arguments"); |
| | | arguments = new StringArgument("argument", 'g', "argument", false, true, |
| | | true, LocalizableMessage.raw("{generator function or static string}"), |
| | | null, null, |
| | | LocalizableMessage.raw("Argument used to evaluate the Java " + |
| | | "style format strings in program parameters (ie. Base DN, " + |
| | | "Search Filter). The set of all arguments provided form the " + |
| | | "the argument list in order. Besides static string " + |
| | | "arguments, they can be generated per iteration with the " + |
| | | "following functions: " + StaticUtils.EOL + |
| | | DataSource.getUsage())); |
| | | argParser.addArgument(arguments); |
| | | } |
| | | |
| | |
| | | { |
| | | numConnections = numConnectionsArgument.getIntValue(); |
| | | numThreads = numThreadsArgument.getIntValue(); |
| | | maxIterations = maxIterationsArgument.getIntValue(); |
| | | maxIterations = maxIterationsArgument.getIntValue() / |
| | | numConnections / numThreads; |
| | | statsInterval = statsIntervalArgument.getIntValue() * 1000; |
| | | targetThroughput = targetThroughputArgument.getIntValue(); |
| | | |
| | |
| | | + " must be used when using --" + asyncArgument.getLongIdentifier())); |
| | | } |
| | | |
| | | try |
| | | { |
| | | dataSourcePrototypes = DataSource.parse(arguments.getValues()); |
| | | } |
| | | catch (final IOException ioe) |
| | | { |
| | | throw new ArgumentException(LocalizableMessage |
| | | .raw("Error occured while parsing arguments: " + ioe.toString())); |
| | | } |
| | | dataSourcePrototypes = DataSource.parse(arguments.getValues()); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | // Create the command-line argument parser for use with this |
| | | // program. |
| | | final LocalizableMessage toolDescription = LocalizableMessage |
| | | .raw("This utility can be used to " + "measure search performance"); |
| | | // TODO: correct usage |
| | | final LocalizableMessage toolDescription = |
| | | INFO_SEARCHRATE_TOOL_DESCRIPTION.get(); |
| | | final ArgumentParser argParser = new ArgumentParser(SearchRate.class |
| | | .getName(), toolDescription, false, true, 1, 0, |
| | | "[filter] [attributes ...]"); |
| | | "[filter format string] [attributes ...]"); |
| | | |
| | | ArgumentParserConnectionFactory connectionFactory; |
| | | SearchPerformanceRunner runner; |
| | |
| | | |
| | | baseDN = new StringArgument("baseDN", OPTION_SHORT_BASEDN, |
| | | OPTION_LONG_BASEDN, true, false, true, INFO_BASEDN_PLACEHOLDER.get(), |
| | | null, null, INFO_SEARCH_DESCRIPTION_BASEDN.get()); |
| | | null, null, INFO_SEARCHRATE_TOOL_DESCRIPTION_BASEDN.get()); |
| | | baseDN.setPropertyName(OPTION_LONG_BASEDN); |
| | | argParser.addArgument(baseDN); |
| | | |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | */ |
| | | package com.sun.opends.sdk.tools; |
| | | |
| | |
| | | static final String OPTION_LONG_DONT_WRAP = "dontWrap"; |
| | | |
| | | /** |
| | | * The value for the long option targetDN. |
| | | */ |
| | | static final String OPTION_LONG_TARGETDN = "targetDN"; |
| | | |
| | | /** |
| | | * Long form of email notification upon completion option. |
| | | */ |
| | | static final String OPTION_LONG_COMPLETION_NOTIFICATION_EMAIL = "completionNotify"; |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | */ |
| | | package com.sun.opends.sdk.tools; |
| | | |
| | |
| | | // It's an end-of-line character, so append it as-is. |
| | | buffer.append(line); |
| | | } |
| | | else if (line.length() < width) |
| | | else if (line.length() <= width) |
| | | { |
| | | // The line fits in the specified width, so append it as-is. |
| | | buffer.append(padding); |