@Override public void onDown(Host host) { childPolicy.onDown(host); }
@Override public void onDown(Host host) { childPolicy.onDown(host); }
@Override public void onDown(Host host) { if (predicate.apply(host)) childPolicy.onDown(host); }
@Override public void onDown(Host host) { childPolicy.onDown(host); latencyTracker.resetHost(host); }
public void onDown(Host host) { delegate.onDown(host); }
@Override public void onDown(Host host) { delegate.onDown(host); liveHosts.remove(host); chosenHosts.remove(host); updateChosenHosts(); }
host.setDown(); loadBalancingPolicy().onDown(host); controlConnection.onDown(host); for (SessionManager s : sessions) s.onDown(host);
@Test(groups = "unit") public void should_not_delegate_to_wrapped_policy_when_predicate_is_false() { Predicate<Host> predicate = Predicates.alwaysFalse(); HostFilterPolicy policy = new HostFilterPolicy(wrappedPolicy, predicate); policy.onAdd(host1); verify(wrappedPolicy, never()).onAdd(host1); policy.onDown(host1); verify(wrappedPolicy, never()).onDown(host1); policy.onUp(host1); verify(wrappedPolicy, never()).onUp(host1); policy.onRemove(host1); verify(wrappedPolicy, never()).onRemove(host1); assertThat(policy.distance(host1)).isSameAs(HostDistance.IGNORED); }
@Test(groups = "unit") public void should_delegate_to_wrapped_policy_when_predicate_is_true() { Predicate<Host> predicate = Predicates.alwaysTrue(); HostFilterPolicy policy = new HostFilterPolicy(wrappedPolicy, predicate); policy.onAdd(host1); verify(wrappedPolicy).onAdd(host1); policy.onDown(host1); verify(wrappedPolicy).onDown(host1); policy.onUp(host1); verify(wrappedPolicy).onUp(host1); policy.onRemove(host1); verify(wrappedPolicy).onRemove(host1); assertThat(policy.distance(host1)).isSameAs(HostDistance.LOCAL); policy.close(); verify(wrappedPolicy).close(); }
@Override public void onDown(Host host) { childPolicy.onDown(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); }
loadBalancingPolicy().onDown(host); for (Host.StateListener listener : listeners) listener.onDown(host); startPeriodicReconnectionAttempt(host, true);
@Override public void onDown(Host host) { if (predicate.apply(host)) childPolicy.onDown(host); }
@Override public void onDown(Host host) { childPolicy.onDown(host); latencyTracker.resetHost(host); }
@Override public void onDown(Host host) { childPolicy.onDown(host); latencyTracker.resetHost(host); }
@Override public void onDown(Host host) { myChildPolicy.onDown(host); markAsDown(host); }
@Override public void onDown(Host host) { delegate.onDown(host); liveHosts.remove(host); chosenHosts.remove(host); updateChosenHosts(); }
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); }