Source:
public void should_try_next_host_on_client_timeouts() { cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(1); try { scassandras .node(1).primingClient().prime(PrimingRequest.queryBuilder() .withQuery("mock query") .withThen(then().withFixedDelay(1000L).withRows(row("result", "result1"))) .build()); scassandras .node(2).primingClient().prime(PrimingRequest.queryBuilder() .withQuery("mock query") .withThen(then().withFixedDelay(1000L).withRows(row("result", "result2"))) .build()); scassandras .node(3).primingClient().prime(PrimingRequest.queryBuilder() .withQuery("mock query") .withThen(then().withFixedDelay(1000L).withRows(row("result", "result3"))) .build()); try { query(); fail("expected a NoHostAvailableException"); } catch (NoHostAvailableException e) { assertThat(e.getErrors().keySet()).hasSize(3).containsExactly( host1.getSocketAddress(), host2.getSocketAddress(), host3.getSocketAddress()); assertThat(e.getErrors().values()).extractingResultOf("getMessage").containsExactly( String.format("[%s]: Timed out waiting for server response", host1.getSocketAddress()), String.format("[%s]: Timed out waiting for server response", host2.getSocketAddress()), String.format("[%s]: Timed out waiting for server response", host3.getSocketAddress()) ); } assertOnRequestErrorWasCalled(3); assertThat(errors.getRetries().getCount()).isEqualTo(3); assertThat(errors.getClientTimeouts().getCount()).isEqualTo(3); assertThat(errors.getRetriesOnClientTimeout().getCount()).isEqualTo(3); assertQueried(1, 1); assertQueried(2, 1); assertQueried(3, 1); } finally { cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(SocketOptions.DEFAULT_READ_TIMEOUT_MILLIS); } }

Target:
public void should_try_next_host_on_client_timeouts() { cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(1); try { scassandras .node(1).primingClient().prime(PrimingRequest.queryBuilder() .withQuery("mock query") .withThen(then().withFixedDelay(1000L).withRows(row("result", "result1"))) .build()); scassandras .node(2).primingClient().prime(PrimingRequest.queryBuilder() .withQuery("mock query") .withThen(then().withFixedDelay(1000L).withRows(row("result", "result2"))) .build()); scassandras .node(3).primingClient().prime(PrimingRequest.queryBuilder() .withQuery("mock query") .withThen(then().withFixedDelay(1000L).withRows(row("result", "result3"))) .build()); try { query(); fail("expected a NoHostAvailableException"); } catch (NoHostAvailableException e) { assertThat(e.getErrors().keySet()).hasSize(3).containsOnlyOnce( host1.getSocketAddress(), host2.getSocketAddress(), host3.getSocketAddress()); assertThat(e.getErrors().values()).extractingResultOf("getMessage").containsOnlyOnce( String.format("[%s]: Timed out waiting for server response", host1.getSocketAddress()), String.format("[%s]: Timed out waiting for server response", host2.getSocketAddress()), String.format("[%s]: Timed out waiting for server response", host3.getSocketAddress()) ); } assertOnRequestErrorWasCalled(3); assertThat(errors.getRetries().getCount()).isEqualTo(3); assertThat(errors.getClientTimeouts().getCount()).isEqualTo(3); assertThat(errors.getRetriesOnClientTimeout().getCount()).isEqualTo(3); assertQueried(1, 1); assertQueried(2, 1); assertQueried(3, 1); } finally { cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(SocketOptions.DEFAULT_READ_TIMEOUT_MILLIS); } }