@Override public Boolean call() throws Exception { // Whether or not host is down and reconnection attempt is in progress. return actual.getReconnectionAttemptFuture() != null && !actual.getReconnectionAttemptFuture().isDone(); } })
public HostAssert isReconnectingFromDown() { assertThat( actual.getReconnectionAttemptFuture() != null && !actual.getReconnectionAttemptFuture().isDone()) .isTrue(); return this; }
@CCMConfig(dirtiesContext = true, numberOfNodes = 2, createCluster = false) @Test(groups = "long") public void should_cancel_reconnection_attempts() throws InterruptedException { // Stop a node and cancel the reconnection attempts to it CountingReconnectionPolicy reconnectionPolicy = new CountingReconnectionPolicy(new ConstantReconnectionPolicy(reconnectionDelayMillis)); Cluster cluster = register( Cluster.builder() .addContactPoints(getContactPoints().get(0)) .withPort(ccm().getBinaryPort()) .withReconnectionPolicy(reconnectionPolicy) .build()); cluster.connect(); // Stop a node and cancel the reconnection attempts to it ccm().stop(2); Host host2 = TestUtils.findHost(cluster, 2); host2.getReconnectionAttemptFuture().cancel(false); // The reconnection count should not vary over time anymore int initialCount = reconnectionPolicy.count.get(); TimeUnit.MILLISECONDS.sleep(reconnectionDelayMillis * 2); assertThat(reconnectionPolicy.count.get()).isEqualTo(initialCount); // Restart the node, which will trigger an UP notification ccm().start(2); ccm().waitForUp(2); // The driver should now see the node as UP again assertThat(cluster).host(2).comesUpWithin(Cluster.NEW_NODE_DELAY_SECONDS * 2, SECONDS); }
&& (host.getReconnectionAttemptFuture() == null || host.getReconnectionAttemptFuture().isDone())) { logger.warn( "Periodic Reconnection Attempt hasn't started yet for {}, waiting 1 second and then checking.",
@Override public Boolean call() throws Exception { // Whether or not host is down and reconnection attempt is in progress. return actual.getReconnectionAttemptFuture() != null && !actual.getReconnectionAttemptFuture().isDone(); } })
public HostAssert isReconnectingFromDown() { assertThat( actual.getReconnectionAttemptFuture() != null && !actual.getReconnectionAttemptFuture().isDone()) .isTrue(); return this; }
assertThat(cluster).host(1).goesDownWithin(20, SECONDS); Host host1 = TestUtils.findHost(cluster, 1); host1.getReconnectionAttemptFuture().cancel(false);
Host host1 = TestUtils.findHost(cluster, 1); loadBalancingPolicy.setDistance(TestUtils.findHost(cluster, 1), HostDistance.IGNORED); ListenableFuture<?> reconnectionAttemptFuture = host1.getReconnectionAttemptFuture(); if (reconnectionAttemptFuture != null) reconnectionAttemptFuture.cancel(false);
&& (host.getReconnectionAttemptFuture() == null || host.getReconnectionAttemptFuture().isDone())) { logger.warn( "Periodic Reconnection Attempt hasn't started yet for {}, waiting 1 second and then checking.",
@CCMConfig(dirtiesContext = true, numberOfNodes = 2, createCluster = false) @Test(groups = "long") public void should_cancel_reconnection_attempts() throws InterruptedException { // Stop a node and cancel the reconnection attempts to it CountingReconnectionPolicy reconnectionPolicy = new CountingReconnectionPolicy(new ConstantReconnectionPolicy(reconnectionDelayMillis)); Cluster cluster = register( Cluster.builder() .addContactPoints(getContactPoints().get(0)) .withPort(ccm().getBinaryPort()) .withReconnectionPolicy(reconnectionPolicy) .build()); cluster.connect(); // Stop a node and cancel the reconnection attempts to it ccm().stop(2); Host host2 = TestUtils.findHost(cluster, 2); host2.getReconnectionAttemptFuture().cancel(false); // The reconnection count should not vary over time anymore int initialCount = reconnectionPolicy.count.get(); TimeUnit.MILLISECONDS.sleep(reconnectionDelayMillis * 2); assertThat(reconnectionPolicy.count.get()).isEqualTo(initialCount); // Restart the node, which will trigger an UP notification ccm().start(2); ccm().waitForUp(2); // The driver should now see the node as UP again assertThat(cluster).host(2).comesUpWithin(Cluster.NEW_NODE_DELAY_SECONDS * 2, SECONDS); }
assertThat(cluster).host(1).goesDownWithin(20, SECONDS); Host host1 = TestUtils.findHost(cluster, 1); host1.getReconnectionAttemptFuture().cancel(false);
Host host1 = TestUtils.findHost(cluster, 1); loadBalancingPolicy.setDistance(TestUtils.findHost(cluster, 1), HostDistance.IGNORED); ListenableFuture<?> reconnectionAttemptFuture = host1.getReconnectionAttemptFuture(); if (reconnectionAttemptFuture != null) reconnectionAttemptFuture.cancel(false);