ListenableFuture<Boolean> maybeAddPool(final Host host, Connection reusedConnection) { final HostDistance distance = cluster.manager.loadBalancingPolicy().distance(host); if (distance == HostDistance.IGNORED) return Futures.immediateFuture(true);
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(); } }
loadBalancingPolicy().onUp(host); controlConnection.onUp(host);
void refreshConnectedHost(Host host) { // Deal with the control connection if it was using this host Host ccHost = controlConnection.connectedHost(); if (ccHost == null || ccHost.equals(host) && loadBalancingPolicy().distance(ccHost) != HostDistance.LOCAL) controlConnection.triggerReconnect(); for (SessionManager s : sessions) s.updateCreatedPools(host); }
private static void updateLocationInfo(Host host, String datacenter, String rack, boolean isInitialConnection, Cluster.Manager cluster) { if (MoreObjects.equal(host.getDatacenter(), datacenter) && MoreObjects.equal(host.getRack(), rack)) return; // If the dc/rack information changes for an existing node, we need to update the load balancing policy. // For that, we remove and re-add the node against the policy. Not the most elegant, and assumes // that the policy will update correctly, but in practice this should work. if (!isInitialConnection) cluster.loadBalancingPolicy().onDown(host); host.setLocationInfo(datacenter, rack); if (!isInitialConnection) cluster.loadBalancingPolicy().onAdd(host); }
public HostAssert isAtDistance(HostDistance expected) { LoadBalancingPolicy loadBalancingPolicy = cluster.manager.loadBalancingPolicy(); assertThat(loadBalancingPolicy.distance(actual)).isEqualTo(expected); return this; }
void refreshConnectedHosts() { // Deal first with the control connection: if it's connected to a node that is not LOCAL, try // reconnecting (thus letting the loadBalancingPolicy pick a better node) Host ccHost = controlConnection.connectedHost(); if (ccHost == null || loadBalancingPolicy().distance(ccHost) != HostDistance.LOCAL) controlConnection.triggerReconnect(); try { for (SessionManager s : sessions) Uninterruptibles.getUninterruptibly(s.updateCreatedPools()); } catch (ExecutionException e) { throw DriverThrowables.propagateCause(e); } }
private static void updateLocationInfo(Host host, String datacenter, String rack, Cluster.Manager cluster) { if (Objects.equal(host.getDatacenter(), datacenter) && Objects.equal(host.getRack(), rack)) return; // If the dc/rack information changes, we need to update the load balancing policy. // For that, we remove and re-add the node against the policy. Not the most elegant, and assumes // that the policy will update correctly, but in practice this should work. cluster.loadBalancingPolicy().onDown(host); host.setLocationInfo(datacenter, rack); cluster.loadBalancingPolicy().onAdd(host); }
private static void updateLocationInfo(Host host, String datacenter, String rack, boolean isInitialConnection, Cluster.Manager cluster) { if (Objects.equal(host.getDatacenter(), datacenter) && Objects.equal(host.getRack(), rack)) return; // If the dc/rack information changes for an existing node, we need to update the load balancing policy. // For that, we remove and re-add the node against the policy. Not the most elegant, and assumes // that the policy will update correctly, but in practice this should work. if (!isInitialConnection) cluster.loadBalancingPolicy().onDown(host); host.setLocationInfo(datacenter, rack); if (!isInitialConnection) cluster.loadBalancingPolicy().onAdd(host); }
loadBalancingPolicy().init(Cluster.this, contactPointHosts); for (Host.StateListener listener : listeners) listener.onRegister(Cluster.this); for (Host host : removedContactPointHosts) { loadBalancingPolicy().onRemove(host); for (Host.StateListener listener : listeners) listener.onRemove(host); loadBalancingPolicy().onDown(host); for (Host.StateListener listener : listeners) listener.onDown(host); startPeriodicReconnectionAttempt(host, true); if (!contactPointHosts.contains(host)) loadBalancingPolicy().onAdd(host);
loadBalancingPolicy().onAdd(host); if (loadBalancingPolicy().distance(host) == HostDistance.IGNORED) {
loadBalancingPolicy().close(); speculativeExecutionPolicy().close(); configuration.getPolicies().getRetryPolicy().close();
HostDistance distance = loadBalancingPolicy().distance(host); loadBalancingPolicy().onDown(host); controlConnection.onDown(host); for (SessionManager s : sessions) s.onDown(host);
ListenableFuture<Boolean> forceRenewPool(final Host host, Connection reusedConnection) { final HostDistance distance = cluster.manager.loadBalancingPolicy().distance(host); if (distance == HostDistance.IGNORED) return Futures.immediateFuture(true);
private static void updateLocationInfo( Host host, String datacenter, String rack, boolean isInitialConnection, Cluster.Manager cluster) { if (MoreObjects.equal(host.getDatacenter(), datacenter) && MoreObjects.equal(host.getRack(), rack)) return; // If the dc/rack information changes for an existing node, we need to update the load balancing // policy. // For that, we remove and re-add the node against the policy. Not the most elegant, and assumes // that the policy will update correctly, but in practice this should work. if (!isInitialConnection) cluster.loadBalancingPolicy().onDown(host); host.setLocationInfo(datacenter, rack); if (!isInitialConnection) cluster.loadBalancingPolicy().onAdd(host); }
private Iterator<Host> queryPlan() { return cluster.loadBalancingPolicy().newQueryPlan(null, Statement.DEFAULT); }
LoadBalancingPolicy loadBalancingPolicy() { return cluster.manager.loadBalancingPolicy(); }
void refreshConnectedHosts() { // Deal first with the control connection: if it's connected to a node that is not LOCAL, try // reconnecting (thus letting the loadBalancingPolicy pick a better node) Host ccHost = controlConnection.connectedHost(); if (ccHost == null || loadBalancingPolicy().distance(ccHost) != HostDistance.LOCAL) controlConnection.triggerReconnect(); try { for (SessionManager s : sessions) Uninterruptibles.getUninterruptibly(s.updateCreatedPools()); } catch (ExecutionException e) { throw DriverThrowables.propagateCause(e); } }
public HostAssert isAtDistance(HostDistance expected) { LoadBalancingPolicy loadBalancingPolicy = cluster.manager.loadBalancingPolicy(); assertThat(loadBalancingPolicy.distance(actual)).isEqualTo(expected); return this; }
void refreshConnectedHost(Host host) { // Deal with the control connection if it was using this host Host ccHost = controlConnection.connectedHost(); if (ccHost == null || ccHost.equals(host) && loadBalancingPolicy().distance(ccHost) != HostDistance.LOCAL) controlConnection.triggerReconnect(); for (SessionManager s : sessions) s.updateCreatedPools(host); }