@BeforeClass(groups = {"short", "long"}) public void beforeTestClass() { scassandra = TestUtils.createScassandraServer(); scassandra.start(); primingClient = scassandra.primingClient(); activityClient = scassandra.activityClient(); currentClient = scassandra.currentClient(); hostAddress = new InetSocketAddress(ip, scassandra.getBinaryPort()); }
.contains("Query error") .contains(ip) .contains(Integer.toString(scassandra.getBinaryPort())) .contains(query) .contains(expectedException.getName());
protected Cluster.Builder createClusterBuilder() { return Cluster.builder() .withPort(scassandra.getBinaryPort()) .addContactPoints(hostAddress.getAddress()) .withPort(scassandra.getBinaryPort()) .withPoolingOptions( new PoolingOptions() .setCoreConnectionsPerHost(HostDistance.LOCAL, 1) .setMaxConnectionsPerHost(HostDistance.LOCAL, 1) .setHeartbeatIntervalSeconds(0)); }
@Test(groups = "short") public void should_log_timed_out_queries() throws Exception { // given error.setLevel(DEBUG); queryLogger = builder().build(); cluster.register(queryLogger); cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(1); String query = "SELECT foo FROM bar"; primingClient.prime( queryBuilder().withQuery(query).withThen(then().withFixedDelay(100L)).build()); // when try { session.execute(query); fail("Should have thrown OperationTimedOutException"); } catch (OperationTimedOutException e) { // ok } // then String line = errorAppender.waitAndGet(5000); assertThat(line) .contains("Query error") .contains(ip) .contains(Integer.toString(scassandra.getBinaryPort())) .contains(query) .contains("Timed out waiting for server response"); }
Cluster.builder() .addContactPoints(hostAddress.getAddress()) .withPort(scassandra.getBinaryPort()) .withPoolingOptions(new PoolingOptions().setHeartbeatIntervalSeconds(3)) .build();
Cluster.builder() .addContactPoints(hostAddress.getAddress()) .withPort(scassandra.getBinaryPort()) .withPoolingOptions( new PoolingOptions()
Cluster.builder() .addContactPoints(hostAddress.getAddress()) .withPort(scassandra.getBinaryPort()) .withPoolingOptions(new PoolingOptions().setHeartbeatIntervalSeconds(0)) .build();
int port = scassandra.getBinaryPort(); .withPort(scassandra.getBinaryPort()) .addContactPoints( ipOfNode(1),
Cluster.builder() .addContactPoint(TestUtils.ipOfNode(1)) .withPort(scassandra.getBinaryPort()) .withPoolingOptions( new PoolingOptions()
Cluster.builder() .addContactPoints(hostAddress.getAddress()) .withPort(scassandra.getBinaryPort()) .withPoolingOptions( new PoolingOptions()
@BeforeClass(groups = {"short", "long"}) public void beforeTestClass() { scassandra = TestUtils.createScassandraServer(); scassandra.start(); primingClient = scassandra.primingClient(); activityClient = scassandra.activityClient(); currentClient = scassandra.currentClient(); hostAddress = new InetSocketAddress(ip, scassandra.getBinaryPort()); }
.contains("Query error") .contains(ip) .contains(Integer.toString(scassandra.getBinaryPort())) .contains(query) .contains(expectedException.getName());
protected Cluster.Builder createClusterBuilder() { return Cluster.builder() .withPort(scassandra.getBinaryPort()) .addContactPoints(hostAddress.getAddress()) .withPort(scassandra.getBinaryPort()) .withPoolingOptions( new PoolingOptions() .setCoreConnectionsPerHost(HostDistance.LOCAL, 1) .setMaxConnectionsPerHost(HostDistance.LOCAL, 1) .setHeartbeatIntervalSeconds(0)); }
@Test(groups = "short") public void should_log_timed_out_queries() throws Exception { // given error.setLevel(DEBUG); queryLogger = builder().build(); cluster.register(queryLogger); cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(1); String query = "SELECT foo FROM bar"; primingClient.prime( queryBuilder().withQuery(query).withThen(then().withFixedDelay(100L)).build()); // when try { session.execute(query); fail("Should have thrown OperationTimedOutException"); } catch (OperationTimedOutException e) { // ok } // then String line = errorAppender.waitAndGet(5000); assertThat(line) .contains("Query error") .contains(ip) .contains(Integer.toString(scassandra.getBinaryPort())) .contains(query) .contains("Timed out waiting for server response"); }
Cluster.builder() .addContactPoints(hostAddress.getAddress()) .withPort(scassandra.getBinaryPort()) .withPoolingOptions(new PoolingOptions().setHeartbeatIntervalSeconds(3)) .build();
Cluster.builder() .addContactPoints(hostAddress.getAddress()) .withPort(scassandra.getBinaryPort()) .withPoolingOptions( new PoolingOptions()
Cluster.builder() .addContactPoints(hostAddress.getAddress()) .withPort(scassandra.getBinaryPort()) .withPoolingOptions(new PoolingOptions().setHeartbeatIntervalSeconds(0)) .build();
Cluster.builder() .addContactPoint(TestUtils.ipOfNode(1)) .withPort(scassandra.getBinaryPort()) .withPoolingOptions( new PoolingOptions()
int port = scassandra.getBinaryPort(); .withPort(scassandra.getBinaryPort()) .addContactPoints( ipOfNode(1),
Cluster.builder() .addContactPoints(hostAddress.getAddress()) .withPort(scassandra.getBinaryPort()) .withPoolingOptions( new PoolingOptions()