use of org.apache.cassandra.distributed.impl.INodeProvisionStrategy.Strategy in project cassandra by apache.
the class TopologyChangeTest method testRestartNode.
@Test
public void testRestartNode() throws Throwable {
try (Cluster control = init(Cluster.build().withNodes(3).withNodeProvisionStrategy(strategy).withConfig(config -> config.with(GOSSIP, NETWORK, NATIVE_PROTOCOL)).start());
com.datastax.driver.core.Cluster cluster = com.datastax.driver.core.Cluster.builder().addContactPoint("127.0.0.1").build();
Session session = cluster.connect()) {
EventStateListener eventStateListener = new EventStateListener();
session.getCluster().register(eventStateListener);
control.get(3).shutdown().get();
await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> Assert.assertEquals(2, cluster.getMetadata().getAllHosts().stream().filter(h -> h.isUp()).count()));
control.get(3).startup();
await().atMost(30, TimeUnit.SECONDS).untilAsserted(() -> Assert.assertEquals(3, cluster.getMetadata().getAllHosts().stream().filter(h -> h.isUp()).count()));
// DOWN UP can also be seen if the jvm is slow and connections are closed, but make sure it at least happens once
// given the node restarts
assertThat(eventStateListener.events).containsSequence(new Event(Down, control.get(3)), new Event(Up, control.get(3)));
}
}
Aggregations