public boolean disableListener() { return disableListener(0); }
/** * Ensures that if a connection on a host is lost but other connections remain intact in the Pool * that the host is not marked down. * * @jira_ticket JAVA-544 * @test_category connection:connection_pool * @since 2.0.11 */ @Test(groups = "short") public void should_keep_host_up_when_one_connection_lost() throws Exception { Cluster cluster = createClusterBuilder().build(); try { HostConnectionPool pool = createPool(cluster, 2, 2); Connection core0 = pool.connections.get(0); Connection core1 = pool.connections.get(1); // Drop a connection and ensure the host stays up. currentClient.disableListener(); currentClient.closeConnection(CLOSE, ((InetSocketAddress) core0.channel.localAddress())); Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS); // connection 0 should be down, while connection 1 and the Host should remain up. assertThat(core0.isClosed()).isTrue(); assertThat(core1.isClosed()).isFalse(); assertThat(pool.connections).doesNotContain(core0); assertThat(cluster).host(1).hasState(Host.State.UP); assertThat(cluster).hasOpenControlConnection(); } finally { cluster.close(); } }
currentClient.disableListener(); currentClient.closeConnections(CLOSE); TestUtils.waitForDown(TestUtils.IP_PREFIX + "1", cluster);
currentClient.disableListener(); currentClient.closeConnection(CLOSE, ((InetSocketAddress) core0.channel.localAddress())); currentClient.closeConnection(CLOSE, ((InetSocketAddress) core2.channel.localAddress()));
currentClient.disableListener(4); HostConnectionPool pool = createPool(cluster, 8, 8);
currentClient.disableListener();
currentClient.disableListener(); currentClient.closeConnections(CLOSE);
currentClient.disableListener(); HostConnectionPool pool = createPool(cluster, 8, 8);
/** * Ensures that if all connections fail to a host on pool init that the host is marked down. * * @jira_ticket JAVA-544 * @test_category connection:connection_pool * @since 2.0.11 */ @Test(groups = "short") public void should_mark_host_down_if_all_connections_fail_on_init() { // Prevent any connections on node 2. scassandra.node(2).currentClient().disableListener(); createCluster(8, 8); // Node 2 should be in a down state while node 1 stays up. assertThat(cluster).host(2).goesDownWithin(10, SECONDS); assertThat(cluster).host(1).isUp(); // Node 2 should come up as soon as it is able to reconnect. scassandra.node(2).currentClient().enableListener(); assertThat(cluster).host(2).comesUpWithin(2, SECONDS); }
currentClient.disableListener(); HostConnectionPool pool = createPool(cluster, 8, 8);
/** * Ensures that if a connection on a host is lost but other connections remain intact in the Pool * that the host is not marked down. * * @jira_ticket JAVA-544 * @test_category connection:connection_pool * @since 2.0.11 */ @Test(groups = "short") public void should_keep_host_up_when_one_connection_lost() throws Exception { Cluster cluster = createClusterBuilder().build(); try { HostConnectionPool pool = createPool(cluster, 2, 2); Connection core0 = pool.connections.get(0); Connection core1 = pool.connections.get(1); // Drop a connection and ensure the host stays up. currentClient.disableListener(); currentClient.closeConnection(CLOSE, ((InetSocketAddress) core0.channel.localAddress())); Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS); // connection 0 should be down, while connection 1 and the Host should remain up. assertThat(core0.isClosed()).isTrue(); assertThat(core1.isClosed()).isFalse(); assertThat(pool.connections).doesNotContain(core0); assertThat(cluster).host(1).hasState(Host.State.UP); assertThat(cluster).hasOpenControlConnection(); } finally { cluster.close(); } }
currentClient.disableListener(); currentClient.closeConnections(CLOSE); TestUtils.waitForDown(TestUtils.IP_PREFIX + "1", cluster);
currentClient.disableListener(); currentClient.closeConnection(CLOSE, ((InetSocketAddress) core0.channel.localAddress())); currentClient.closeConnection(CLOSE, ((InetSocketAddress) core2.channel.localAddress()));
currentClient.disableListener();
currentClient.disableListener(4); HostConnectionPool pool = createPool(cluster, 8, 8);
currentClient.disableListener(); currentClient.closeConnections(CLOSE);
currentClient.disableListener(); HostConnectionPool pool = createPool(cluster, 8, 8);
/** * Ensures that if all connections fail to a host on pool init that the host is marked down. * * @jira_ticket JAVA-544 * @test_category connection:connection_pool * @since 2.0.11 */ @Test(groups = "short") public void should_mark_host_down_if_all_connections_fail_on_init() { // Prevent any connections on node 2. scassandra.node(2).currentClient().disableListener(); createCluster(8, 8); // Node 2 should be in a down state while node 1 stays up. assertThat(cluster).host(2).goesDownWithin(10, SECONDS); assertThat(cluster).host(1).isUp(); // Node 2 should come up as soon as it is able to reconnect. scassandra.node(2).currentClient().enableListener(); assertThat(cluster).host(2).comesUpWithin(2, SECONDS); }
currentClient.disableListener(); HostConnectionPool pool = createPool(cluster, 8, 8);