public ListenableFuture<?> triggerOnAdd(final Host host) { if (!isClosed()) { return executor.submit( new ExceptionCatchingRunnable() { @Override public void runMayThrow() throws InterruptedException, ExecutionException { onAdd(host, null); } }); } else { return MoreFutures.VOID_SUCCESS; } }
public ListenableFuture<?> triggerOnUp(final Host host) { if (!isClosed()) { return executor.submit( new ExceptionCatchingRunnable() { @Override public void runMayThrow() throws InterruptedException, ExecutionException { onUp(host, null); } }); } else { return MoreFutures.VOID_SUCCESS; } }
public ListenableFuture<?> triggerOnRemove(final Host host) { if (!isClosed()) { return executor.submit( new ExceptionCatchingRunnable() { @Override public void runMayThrow() throws InterruptedException, ExecutionException { onRemove(host); } }); } else { return MoreFutures.VOID_SUCCESS; } }
private void onRemove(Host host) throws InterruptedException, ExecutionException { if (isClosed()) return; host.setDown(); logger.debug("Removing host {}", host); loadBalancingPolicy().onRemove(host); controlConnection.onRemove(host); for (SessionManager s : sessions) s.onRemove(host); for (Host.StateListener listener : listeners) listener.onRemove(host); }
private static void checkNotClosed(Manager manager) { if (manager.isClosed()) throw new IllegalStateException("Can't use this cluster instance because it was previously closed"); }
public ListenableFuture<?> triggerOnUp(final Host host) { if (!isClosed()) { return executor.submit(new ExceptionCatchingRunnable() { @Override public void runMayThrow() throws InterruptedException, ExecutionException { onUp(host, null); } }); } else { return MoreFutures.VOID_SUCCESS; } }
public ListenableFuture<?> triggerOnRemove(final Host host) { if (!isClosed()) { return executor.submit(new ExceptionCatchingRunnable() { @Override public void runMayThrow() throws InterruptedException, ExecutionException { onRemove(host); } }); } else { return MoreFutures.VOID_SUCCESS; } }
public void signalHostDown(Host host, boolean isHostAddition) { // Don't mark the node down until we've fully initialized the controlConnection as this might mess up with // the protocol detection if (!isFullyInit || isClosed()) return; triggerOnDown(host, isHostAddition, true); }
public ListenableFuture<?> triggerOnRemove(final Host host) { if (!isClosed()) { return executor.submit(new ExceptionCatchingRunnable() { @Override public void runMayThrow() throws InterruptedException, ExecutionException { onRemove(host); } }); } else { return MoreFutures.VOID_SUCCESS; } }
public void signalHostDown(Host host, boolean isHostAddition) { // Don't mark the node down until we've fully initialized the controlConnection as this might mess up with // the protocol detection if (!isFullyInit || isClosed()) return; triggerOnDown(host, isHostAddition, true); }
public ListenableFuture<?> triggerOnAdd(final Host host) { if (!isClosed()) { return executor.submit(new ExceptionCatchingRunnable() { @Override public void runMayThrow() throws InterruptedException, ExecutionException { onAdd(host, null); } }); } else { return MoreFutures.VOID_SUCCESS; } }
public ListenableFuture<?> triggerOnUp(final Host host) { if (!isClosed()) { return executor.submit(new ExceptionCatchingRunnable() { @Override public void runMayThrow() throws InterruptedException, ExecutionException { onUp(host, null); } }); } else { return MoreFutures.VOID_SUCCESS; } }
private void onUp(final Host host, Connection reusedConnection) throws InterruptedException, ExecutionException { if (isClosed()) return;
private void onAdd(final Host host, Connection reusedConnection) throws InterruptedException, ExecutionException { if (isClosed()) return;
void startSingleReconnectionAttempt(final Host host) { if (isClosed() || host.isUp()) return;
private void onDown(final Host host, final boolean isHostAddition, boolean startReconnection) throws InterruptedException, ExecutionException { if (isClosed()) return;
private void onRemove(Host host) throws InterruptedException, ExecutionException { if (isClosed()) return; boolean locked = host.notificationsLock.tryLock(NOTIF_LOCK_TIMEOUT_SECONDS, TimeUnit.SECONDS); if (!locked) { logger.warn( "Could not acquire notifications lock within {} seconds, ignoring REMOVE notification for {}", NOTIF_LOCK_TIMEOUT_SECONDS, host); return; } try { host.setDown(); Host.statesLogger.debug("[{}] removing host", host); loadBalancingPolicy().onRemove(host); controlConnection.onRemove(host); for (SessionManager s : sessions) s.onRemove(host); for (Host.StateListener listener : listeners) listener.onRemove(host); } finally { host.notificationsLock.unlock(); } }
public ListenableFuture<?> triggerOnDown( final Host host, final boolean isHostAddition, final boolean startReconnection) { if (!isClosed()) { return executor.submit( new ExceptionCatchingRunnable() { @Override public void runMayThrow() throws InterruptedException, ExecutionException { onDown(host, isHostAddition, startReconnection); } }); } else { return MoreFutures.VOID_SUCCESS; } }
private static void checkNotClosed(Manager manager) { if (manager.errorDuringInit()) { throw new IllegalStateException( "Can't use this cluster instance because it encountered an error in its initialization", manager.getInitException()); } else if (manager.isClosed()) { throw new IllegalStateException( "Can't use this cluster instance because it was previously closed"); } }
public void signalHostDown(Host host, boolean isHostAddition) { // Don't mark the node down until we've fully initialized the controlConnection as this might // mess up with // the protocol detection if (!isFullyInit || isClosed()) return; triggerOnDown(host, isHostAddition, true); }