String property = props.getProperty("constantDelayMs"); long constantDelayMs = property != null ? new Long(property) : 0l; reconnectionPolicy = new ConstantReconnectionPolicy(constantDelayMs); break;
private Cluster.Builder constant() { return Cluster.builder().withReconnectionPolicy(new ConstantReconnectionPolicy(10 * 1000)); }
new ConstantReconnectionPolicy(-1); fail(); } catch (IllegalArgumentException e) { new ConstantReconnectionPolicy(10 * 1000).newSchedule(); assertTrue(schedule.nextDelayMs() == 10000); assertTrue(schedule.nextDelayMs() == 10000);
new CountingReconnectionPolicy(new ConstantReconnectionPolicy(100)); Cluster cluster = Cluster.builder()
ReconnectionPolicy reconnectionPolicy = new ConstantReconnectionPolicy(60 * 1000);
@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); }
.withReconnectionPolicy(new ConstantReconnectionPolicy(10000)) .build();
@Override public Cluster.Builder createClusterBuilder() { channelMonitor = register(new SocketChannelMonitor()); PoolingOptions poolingOptions = new PoolingOptions().setConnectionsPerHost(HostDistance.LOCAL, 8, 8); return Cluster.builder() .withPoolingOptions(poolingOptions) .withNettyOptions(channelMonitor.nettyOptions()) .withReconnectionPolicy(new ConstantReconnectionPolicy(1000)); }
.withReconnectionPolicy(new ConstantReconnectionPolicy(1000)) .build();
.setConnectTimeoutMillis(readTimeout) .setReadTimeoutMillis(reconnectInterval)) .withReconnectionPolicy(new ConstantReconnectionPolicy(1000)) .build(); List<MockRequest> allRequests = newArrayList();
.setConnectTimeoutMillis(readTimeout) .setReadTimeoutMillis(reconnectInterval)) .withReconnectionPolicy(new ConstantReconnectionPolicy(1000)) .build(); try {
private void createCluster(int core, int max) { PoolingOptions poolingOptions = new PoolingOptions().setConnectionsPerHost(LOCAL, core, max); SocketOptions socketOptions = new SocketOptions().setReadTimeoutMillis(1000); cluster = Cluster.builder() .addContactPoints(scassandra.address(1).getAddress()) .withPort(scassandra.getBinaryPort()) .withQueryOptions(nonDebouncingQueryOptions()) .withPoolingOptions(poolingOptions) .withSocketOptions(socketOptions) .withReconnectionPolicy(new ConstantReconnectionPolicy(1000)) .build(); cluster.connect(); }
.setConnectTimeoutMillis(readTimeout) .setReadTimeoutMillis(reconnectInterval)) .withReconnectionPolicy(new ConstantReconnectionPolicy(1000)) .build(); try {
.setConnectTimeoutMillis(readTimeout) .setReadTimeoutMillis(reconnectInterval)) .withReconnectionPolicy(new ConstantReconnectionPolicy(1000)) .build(); try {
new CountingReconnectionPolicy(new ConstantReconnectionPolicy(reconnectionDelayMillis)); CountingAuthProvider authProvider = new CountingAuthProvider("cassandra", "cassandra"); Cluster cluster =
.setConnectTimeoutMillis(readTimeout) .setReadTimeoutMillis(reconnectInterval)) .withReconnectionPolicy(new ConstantReconnectionPolicy(1000)) .build(); try {
@CCMConfig(dirtiesContext = true, numberOfNodes = 2, createCluster = false) @Test(groups = "long") public void should_reconnect_after_full_connectivity_loss() throws InterruptedException { Cluster cluster = register( Cluster.builder() .addContactPoints(getContactPoints().get(0)) .withPort(ccm().getBinaryPort()) .withReconnectionPolicy(new ConstantReconnectionPolicy(reconnectionDelayMillis)) .build()); cluster.connect(); assertThat(cluster).usesControlHost(1); // Stop all nodes. We won't get notifications anymore, so the only mechanism to // reconnect is the background reconnection attempts. ccm().stop(2); ccm().stop(1); ccm().waitForDown(2); ccm().start(2); ccm().waitForUp(2); assertThat(cluster).host(2).comesUpWithin(Cluster.NEW_NODE_DELAY_SECONDS * 2, SECONDS); // Give the control connection a few moments to reconnect TimeUnit.MILLISECONDS.sleep(reconnectionDelayMillis * 2); assertThat(cluster).usesControlHost(2); }
.addContactPoints(getContactPoints().get(0)) .withPort(ccm().getBinaryPort()) .withReconnectionPolicy(new ConstantReconnectionPolicy(5000)) .withLoadBalancingPolicy(loadBalancingPolicy) .withSocketOptions(socketOptions)
.withPort(ccm().getBinaryPort()) .withLoadBalancingPolicy(loadBalancingPolicy) .withReconnectionPolicy(new ConstantReconnectionPolicy(reconnectionDelayMillis)) .build()); cluster.connect();
.withPoolingOptions(poolingOptions) .withLoadBalancingPolicy(loadBalancingPolicy) .withReconnectionPolicy(new ConstantReconnectionPolicy(1000)) .withQueryOptions(TestUtils.nonDebouncingQueryOptions()) .build());