void replace(final Connection connection) { connections.remove(connection); connection.closeAsync(); session .blockingExecutor() .submit( new Runnable() { @Override public void run() { addConnectionIfUnderMaximum(); } }); }
private List<CloseFuture> discardAvailableConnections() { List<CloseFuture> futures = new ArrayList<CloseFuture>(connections.size()); for (Connection connection : connections) { CloseFuture future = connection.closeAsync(); future.addListener( new Runnable() { public void run() { open.decrementAndGet(); } }, MoreExecutors.sameThreadExecutor()); futures.add(future); } return futures; }
private void close(final Connection connection) { connection.closeAsync(); }