use of io.vertx.test.verticles.HAVerticle1 in project vert.x by eclipse.
the class HATest method testCloseRemovesFromCluster.
@Test
public void testCloseRemovesFromCluster() throws Exception {
vertx1 = startVertx();
vertx2 = startVertx();
vertx3 = startVertx();
CountDownLatch latch1 = new CountDownLatch(1);
vertx3.deployVerticle("java:" + HAVerticle1.class.getName(), new DeploymentOptions().setHa(true), ar -> {
assertTrue(ar.succeeded());
assertTrue(vertx3.deploymentIDs().contains(ar.result()));
latch1.countDown();
});
awaitLatch(latch1);
CountDownLatch latch2 = new CountDownLatch(1);
// Close vertx2 - this should not then participate in failover
vertx2.close(ar -> {
((VertxInternal) vertx1).failoverCompleteHandler((nodeID, haInfo, succeeded) -> {
assertTrue(succeeded);
latch2.countDown();
});
((VertxInternal) vertx3).simulateKill();
});
awaitLatch(latch2);
assertTrue(vertx1.deploymentIDs().size() == 1);
String depID = vertx1.deploymentIDs().iterator().next();
assertTrue(((VertxInternal) vertx1).getDeployment(depID).verticleIdentifier().equals("java:" + HAVerticle1.class.getName()));
}
use of io.vertx.test.verticles.HAVerticle1 in project vert.x by eclipse.
the class HATest method testNonHADeployments.
@Test
public void testNonHADeployments() throws Exception {
vertx1 = startVertx();
vertx2 = startVertx();
// Deploy an HA and a non HA deployment
CountDownLatch latch1 = new CountDownLatch(2);
vertx2.deployVerticle("java:" + HAVerticle1.class.getName(), new DeploymentOptions().setHa(true), ar -> {
assertTrue(ar.succeeded());
assertTrue(vertx2.deploymentIDs().contains(ar.result()));
latch1.countDown();
});
vertx2.deployVerticle("java:" + HAVerticle2.class.getName(), new DeploymentOptions().setHa(false), ar -> {
assertTrue(ar.succeeded());
assertTrue(vertx2.deploymentIDs().contains(ar.result()));
latch1.countDown();
});
awaitLatch(latch1);
CountDownLatch latch2 = new CountDownLatch(1);
((VertxInternal) vertx1).failoverCompleteHandler((nodeID, haInfo, succeeded) -> {
assertTrue(succeeded);
latch2.countDown();
});
((VertxInternal) vertx2).simulateKill();
awaitLatch(latch2);
assertTrue(vertx1.deploymentIDs().size() == 1);
String depID = vertx1.deploymentIDs().iterator().next();
assertTrue(((VertxInternal) vertx1).getDeployment(depID).verticleIdentifier().equals("java:" + HAVerticle1.class.getName()));
}
Aggregations