currentClient.disableListener(); currentClient.closeConnections(CLOSE); TestUtils.waitForDown(TestUtils.IP_PREFIX + "1", cluster); currentClient.enableListener(); TestUtils.waitForUp(TestUtils.IP_PREFIX + "1", cluster);
currentClient.disableListener(); currentClient.closeConnection(CLOSE, ((InetSocketAddress) core0.channel.localAddress())); currentClient.closeConnection(CLOSE, ((InetSocketAddress) core2.channel.localAddress())); Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS); currentClient.enableListener();
public CurrentClient build() { return new CurrentClient(this.host, this.port, this.socketTimeout); } }
/** * 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(4); HostConnectionPool pool = createPool(cluster, 8, 8); currentClient.enableListener();
public boolean disableListener() { return disableListener(0); }
@BeforeMethod(groups = {"short", "long"}) @AfterMethod(groups = {"short", "long"}) public void resetClients() { activityClient.clearAllRecordedActivity(); primingClient.clearAllPrimes(); currentClient.enableListener(); }
scassandra.node(1).currentClient().closeConnection(CLOSE, controlSocket);
public ClosedConnectionReport closeConnections(CloseType closeType, String ip) { return closeConnectionsByUrl(closeType, "/" + ip); }
public ConnectionReport getConnection(String host, int port) { return getConnectionsByUrl("/" + host + "/" + port); }
public ConnectionReport getConnection(InetSocketAddress address) { return getConnection(address.getAddress().getHostAddress(), address.getPort()); }
ScassandraRunner(String binaryListenAddress, int binaryPort, String adminListenAddress, int adminPort, long startupTimeout) { this.binaryPort = binaryPort; this.adminPort = adminPort; this.serverStubRunner = new ServerStubRunner(binaryListenAddress, binaryPort, adminListenAddress, adminPort, startupTimeout); this.primingClient = PrimingClient.builder().withHost(adminListenAddress).withPort(adminPort).build(); this.activityClient = ActivityClient.builder().withHost(adminListenAddress).withPort(adminPort).build(); this.currentClient = CurrentClient.builder().withHost(adminListenAddress).withPort(adminPort).build(); this.versionUrl = "http://" + binaryListenAddress + ":" + adminPort + "/version"; }
/** * 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); }
/** * 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(); HostConnectionPool pool = createPool(cluster, 8, 8);
@BeforeMethod(groups = {"short", "long"}) @AfterMethod(groups = {"short", "long"}) public void resetClients() { activityClient.clearAllRecordedActivity(); primingClient.clearAllPrimes(); currentClient.enableListener(); }
scassandra.node(1).currentClient().closeConnection(CLOSE, controlSocket);
public ClosedConnectionReport closeConnections(CloseType closeType) { return closeConnectionsByUrl(closeType, ""); }
public ConnectionReport getConnections() { return getConnectionsByUrl(""); }
currentClient.disableListener(); currentClient.closeConnections(CLOSE); currentClient.enableListener();