| | |
| | | @Override |
| | | public void run() { |
| | | Promise<?, LdapException> promise; |
| | | Connection connection; |
| | | Connection connectionToUse; |
| | | final double targetTimeMs = 1000.0 / (targetThroughput / (double) (numThreads * numConnections)); |
| | | double sleepTimeMs = 0; |
| | | |
| | | while (!stopRequested && !localStopRequested |
| | | && (maxIterations <= 0 || count < maxIterations)) { |
| | | try { |
| | | connection = getConnectionToUse(); |
| | | connectionToUse = getConnectionToUse(); |
| | | } catch (final InterruptedException e) { |
| | | // Ignore and check stop requested |
| | | continue; |
| | |
| | | } |
| | | |
| | | long startTimeNs = System.nanoTime(); |
| | | promise = performOperation(connection, dataSources.get(), startTimeNs); |
| | | promise = performOperation(connectionToUse, dataSources.get(), startTimeNs); |
| | | statsThread.incrementOperationCount(); |
| | | try { |
| | | promise.getOrThrow(); |
| | |
| | | } |
| | | // Ignore. Handled by result handler |
| | | } finally { |
| | | if (this.connection == null) { |
| | | connection.close(); |
| | | if (connection == null) { |
| | | connectionToUse.close(); |
| | | } |
| | | } |
| | | |