Source:
<code>ListenableFuture<Boolean> maybeAddPool(final Host host, Connection reusedConnection) { final HostDistance distance = cluster.manager.loadBalancingPolicy().distance(host); if (distance == HostDistance.IGNORED) return Futures.immediateFuture(true); HostConnectionPool previous = pools.get(host); if (previous != null && !previous.isClosed()) return Futures.immediateFuture(true); while (true) { previous = pools.get(host); if (previous != null && !previous.isClosed()) return Futures.immediateFuture(true); final SettableFuture<Boolean> future = SettableFuture.create(); ListenableFuture<Void> newPoolInit = replacePool(host, distance, previous, reusedConnection); if (newPoolInit != null) { Futures.addCallback(newPoolInit, new FutureCallback<Void>() { @Override public void onSuccess(Void result) { logger.debug("Added connection pool for {}", host); future.set(true); } @Override public void onFailure(Throwable t) { if (t instanceof UnsupportedProtocolVersionException) { cluster.manager.logUnsupportedVersionProtocol(host, ((UnsupportedProtocolVersionException) t).getUnsupportedVersion()); cluster.manager.triggerOnDown(host, false); } else if (t instanceof ClusterNameMismatchException) { ClusterNameMismatchException e = (ClusterNameMismatchException) t; cluster.manager.logClusterNameMismatch(host, e.expectedClusterName, e.actualClusterName); cluster.manager.triggerOnDown(host, false); } else { logger.warn("Error creating pool to " + host, t); <START> cluster.manager.triggerOnDown(host, true); <END> } if (t instanceof Error) future.setException(t); else future.set(false); } }); return future; } } }</code><technical_language>I this is necessary. conviction policy's job mark node if more connections it. If active connections (for example another session, control connection) host stay up</technical_language>

Target:
ListenableFuture<Boolean> maybeAddPool(final Host host, Connection reusedConnection) { final HostDistance distance = cluster.manager.loadBalancingPolicy().distance(host); if (distance == HostDistance.IGNORED) return Futures.immediateFuture(true); HostConnectionPool previous = pools.get(host); if (previous != null && !previous.isClosed()) return Futures.immediateFuture(true); while (true) { previous = pools.get(host); if (previous != null && !previous.isClosed()) return Futures.immediateFuture(true); final SettableFuture<Boolean> future = SettableFuture.create(); ListenableFuture<Void> newPoolInit = replacePool(host, distance, previous, reusedConnection); if (newPoolInit != null) { Futures.addCallback(newPoolInit, new FutureCallback<Void>() { @Override public void onSuccess(Void result) { logger.debug("Added connection pool for {}", host); future.set(true); } @Override public void onFailure(Throwable t) { if (t instanceof UnsupportedProtocolVersionException) { cluster.manager.logUnsupportedVersionProtocol(host, ((UnsupportedProtocolVersionException) t).getUnsupportedVersion()); cluster.manager.triggerOnDown(host, false); } else if (t instanceof ClusterNameMismatchException) { ClusterNameMismatchException e = (ClusterNameMismatchException) t; cluster.manager.logClusterNameMismatch(host, e.expectedClusterName, e.actualClusterName); cluster.manager.triggerOnDown(host, false); } else { logger.warn("Error creating pool to " + host, t); } if (t instanceof Error) future.setException(t); else future.set(false); } }); return future; } } }