| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package com.sun.opends.sdk.tools; |
| | |
| | | |
| | | private final class SearchStatsThread extends StatsThread |
| | | { |
| | | private long totalEntryCount; |
| | | |
| | | private final String[] extraColumn; |
| | | |
| | | |
| | |
| | | String[] getAdditionalColumns() |
| | | { |
| | | final int entryCount = entryRecentCount.getAndSet(0); |
| | | totalEntryCount += entryCount; |
| | | if (successCount > 0) |
| | | { |
| | | extraColumn[0] = String.format("%.1f", (double) entryCount |
| | |
| | | |
| | | |
| | | |
| | | private final class SearchWorkerThread extends |
| | | WorkerThread<SearchStatsHandler> |
| | | private final class SearchWorkerThread extends WorkerThread |
| | | { |
| | | private SearchRequest sr; |
| | | |
| | |
| | | |
| | | |
| | | @Override |
| | | public SearchStatsHandler getHandler(final long startTime) |
| | | { |
| | | return new SearchStatsHandler(startTime); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public FutureResult<?> performOperation( |
| | | final AsynchronousConnection connection, |
| | | final SearchStatsHandler handler, final DataSource[] dataSources) |
| | | final DataSource[] dataSources, final long startTime) |
| | | { |
| | | if (sr == null) |
| | | { |
| | |
| | | sr.setFilter(String.format(filter, data)); |
| | | sr.setName(String.format(baseDN, data)); |
| | | } |
| | | return connection.search(sr, handler); |
| | | return connection.search(sr, new SearchStatsHandler(startTime)); |
| | | } |
| | | } |
| | | |
| | |
| | | private SearchPerformanceRunner(final ArgumentParser argParser, |
| | | final ConsoleApplication app) throws ArgumentException |
| | | { |
| | | super(argParser, app); |
| | | super(argParser, app, false, false, false); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | @Override |
| | | WorkerThread<?> newWorkerThread(final AsynchronousConnection connection, |
| | | WorkerThread newWorkerThread(final AsynchronousConnection connection, |
| | | final ConnectionFactory connectionFactory) |
| | | { |
| | | return new SearchWorkerThread(connection, connectionFactory); |
| | |
| | | .getName(), toolDescription, false, true, 1, 0, |
| | | "[filter format string] [attributes ...]"); |
| | | |
| | | ArgumentParserConnectionFactory connectionFactory; |
| | | ConnectionFactoryProvider connectionFactoryProvider; |
| | | ConnectionFactory connectionFactory; |
| | | SearchPerformanceRunner runner; |
| | | |
| | | StringArgument baseDN; |
| | |
| | | { |
| | | System.setProperty("org.opends.sdk.ldap.transport.linger", "0"); |
| | | } |
| | | connectionFactory = new ArgumentParserConnectionFactory(argParser, this); |
| | | connectionFactoryProvider = |
| | | new ConnectionFactoryProvider(argParser, this); |
| | | runner = new SearchPerformanceRunner(argParser, this); |
| | | |
| | | propertiesFileArgument = new StringArgument("propertiesFilePath", null, |
| | |
| | | try |
| | | { |
| | | argParser.parseArguments(args); |
| | | connectionFactory.validate(); |
| | | connectionFactory = |
| | | connectionFactoryProvider.getAuthenticatedConnectionFactory(); |
| | | runner.validate(); |
| | | } |
| | | catch (final ArgumentException ae) |