mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noël Rouvignac
08.32.2016 b98fbe1abd393fd3a57df11ccd543be87df15c1d
OPENDJ-1019 modrate/searchrate should validate bind parameters before launching perf test

For all *rate tools, abort the run if the tool cannot connect to the server (wrong bind options, server unreachable, etc.)

PerformanceRunner.java:
Added validateCanConnectToServer()
1 files modified
14 ■■■■ changed files
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/PerformanceRunner.java 14 ●●●● patch | view | raw | blame | history
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/PerformanceRunner.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS.
 *      Portions Copyright 2011-2016 ForgeRock AS.
 */
package com.forgerock.opendj.ldap.tools;
@@ -882,12 +882,14 @@
    final int run(final ConnectionFactory connectionFactory) {
        final List<Connection> connections = new ArrayList<>();
        Connection connection = null;
        try {
            validateCanConnectToServer(connectionFactory);
            isWarmingUp = warmUpDuration > 0;
            for (int i = 0; i < numConnections; i++) {
                Connection connection = null;
                if (keepConnectionsOpen.isPresent() || noRebindArgument.isPresent()) {
                    connection = connectionFactory.getConnectionAsync().getOrThrow();
                    connection = connectionFactory.getConnection();
                    connection.addConnectionEventListener(this);
                    connections.add(connection);
                }
@@ -930,6 +932,12 @@
        return 0;
    }
    private void validateCanConnectToServer(ConnectionFactory connectionFactory) throws LdapException {
        try (Connection c = connectionFactory.getConnection()) {
            // detects wrong bind parameters, server unreachable (server down, network problem?), etc.
        }
    }
    void setBindRequest(final BindRequest request) {
        this.bindRequest = request;
    }