public void validatePrepared(boolean expectAll) { // Prepare the statement String query = "select sansa_stark from the_known_world"; PreparedStatement statement = session.prepare(query); assertThat(cluster.manager.preparedQueries).containsValue(statement); // Ensure prepared properly based on expectation. List<PreparedStatementPreparation> preparationOne = scassandra.node(1).activityClient().retrievePreparedStatementPreparations(); List<PreparedStatementPreparation> preparationTwo = scassandra.node(2).activityClient().retrievePreparedStatementPreparations(); List<PreparedStatementPreparation> preparationThree = scassandra.node(3).activityClient().retrievePreparedStatementPreparations(); assertThat(preparationOne).hasSize(1); assertThat(preparationOne.get(0).getPreparedStatementText()).isEqualTo(query); if (expectAll) { assertThat(preparationTwo).hasSize(1); assertThat(preparationTwo.get(0).getPreparedStatementText()).isEqualTo(query); assertThat(preparationThree).hasSize(1); assertThat(preparationThree.get(0).getPreparedStatementText()).isEqualTo(query); } else { assertThat(preparationTwo).isEmpty(); assertThat(preparationThree).isEmpty(); } }
scassandra.node(1).activityClient().retrievePreparedStatementPreparations(); assertThat(cluster).host(1).comesUpWithin(60, TimeUnit.SECONDS); preparationOne = scassandra.node(1).activityClient().retrievePreparedStatementPreparations(); if (expectReprepare) {
@BeforeMethod(groups = "short") public void beforeMethod() { scassandra = ScassandraCluster.builder().withNodes(3).build(); scassandra.init(); queryOptions = new QueryOptions(); loadBalancingPolicy = new SortingLoadBalancingPolicy(); cluster = Cluster.builder() .addContactPoints(scassandra.address(2).getAddress()) .withPort(scassandra.getBinaryPort()) .withLoadBalancingPolicy(loadBalancingPolicy) .withQueryOptions(queryOptions) .withNettyOptions(nonQuietClusterCloseOptions) .build(); session = cluster.connect(); host1 = TestUtils.findHost(cluster, 1); host2 = TestUtils.findHost(cluster, 2); host3 = TestUtils.findHost(cluster, 3); // Make sure there are no prepares for (int host : Lists.newArrayList(1, 2, 3)) { assertThat(scassandra.node(host).activityClient().retrievePreparedStatementPreparations()) .hasSize(0); scassandra.node(host).activityClient().clearAllRecordedActivity(); } }
public void validatePrepared(boolean expectAll) { // Prepare the statement String query = "select sansa_stark from the_known_world"; PreparedStatement statement = session.prepare(query); assertThat(cluster.manager.preparedQueries).containsValue(statement); // Ensure prepared properly based on expectation. List<PreparedStatementPreparation> preparationOne = scassandra.node(1).activityClient().retrievePreparedStatementPreparations(); List<PreparedStatementPreparation> preparationTwo = scassandra.node(2).activityClient().retrievePreparedStatementPreparations(); List<PreparedStatementPreparation> preparationThree = scassandra.node(3).activityClient().retrievePreparedStatementPreparations(); assertThat(preparationOne).hasSize(1); assertThat(preparationOne.get(0).getPreparedStatementText()).isEqualTo(query); if (expectAll) { assertThat(preparationTwo).hasSize(1); assertThat(preparationTwo.get(0).getPreparedStatementText()).isEqualTo(query); assertThat(preparationThree).hasSize(1); assertThat(preparationThree.get(0).getPreparedStatementText()).isEqualTo(query); } else { assertThat(preparationTwo).isEmpty(); assertThat(preparationThree).isEmpty(); } }
scassandra.node(1).activityClient().retrievePreparedStatementPreparations(); assertThat(cluster).host(1).comesUpWithin(60, TimeUnit.SECONDS); preparationOne = scassandra.node(1).activityClient().retrievePreparedStatementPreparations(); if (expectReprepare) {
@BeforeMethod(groups = "short") public void beforeMethod() { scassandra = ScassandraCluster.builder().withNodes(3).build(); scassandra.init(); queryOptions = new QueryOptions(); loadBalancingPolicy = new SortingLoadBalancingPolicy(); cluster = Cluster.builder() .addContactPoints(scassandra.address(2).getAddress()) .withPort(scassandra.getBinaryPort()) .withLoadBalancingPolicy(loadBalancingPolicy) .withQueryOptions(queryOptions) .withNettyOptions(nonQuietClusterCloseOptions) .build(); session = cluster.connect(); host1 = TestUtils.findHost(cluster, 1); host2 = TestUtils.findHost(cluster, 2); host3 = TestUtils.findHost(cluster, 3); // Make sure there are no prepares for (int host : Lists.newArrayList(1, 2, 3)) { assertThat(scassandra.node(host).activityClient().retrievePreparedStatementPreparations()) .hasSize(0); scassandra.node(host).activityClient().clearAllRecordedActivity(); } }