void makeUnavailable(final Function<Host, Boolean> reconnect) { isAvailable = false; // only do a connection re-attempt if one is not already in progress if (retryInProgress.compareAndSet(Boolean.FALSE, Boolean.TRUE)) { retryThread = this.cluster .executor() .scheduleAtFixedRate( () -> { logger.debug("Trying to reconnect to dead host at {}", this); if (reconnect.apply(this)) reconnected(); }, cluster.connectionPoolSettings().reconnectInterval, cluster.connectionPoolSettings().reconnectInterval, TimeUnit.MILLISECONDS); } }
Host(final InetSocketAddress address, final Cluster cluster) { this.cluster = cluster; this.address = address; this.hostUri = makeUriFromAddress(address, cluster.connectionPoolSettings().enableSsl); hostLabel = String.format("Host{address=%s, hostUri=%s}", address, hostUri); }