closeVertices(vertx1, vertx2, vertx3);
}
@Test
public void testHaGroups() throws Exception {
Vertx vertx1 = startVertx("group1", 1);
Vertx vertx2 = startVertx("group1", 1);
Vertx vertx3 = startVertx("group2", 1);
Vertx vertx4 = startVertx("group2", 1);
CountDownLatch latch1 = new CountDownLatch(2);
vertx1.deployVerticle("java:" + HAVerticle1.class.getName(), new DeploymentOptions().setHa(true), ar -> {
assertTrue(ar.succeeded());
assertTrue(vertx1.deployments().contains(ar.result()));
latch1.countDown();
});
vertx3.deployVerticle("java:" + HAVerticle2.class.getName(), new DeploymentOptions().setHa(true), ar -> {
assertTrue(ar.succeeded());
assertTrue(vertx3.deployments().contains(ar.result()));
latch1.countDown();
});
awaitLatch(latch1);
CountDownLatch latch2 = new CountDownLatch(1);
((VertxInternal)vertx1).failoverCompleteHandler(succeeded -> {
fail("Should not failover here");
});
((VertxInternal)vertx2).failoverCompleteHandler(succeeded -> {
fail("Should not failover here");
});
((VertxInternal)vertx4).failoverCompleteHandler(succeeded -> {
assertTrue(succeeded);
latch2.countDown();
});
((VertxInternal)vertx3).simulateKill();
awaitLatch(latch2);
assertTrue(vertx4.deployments().size() == 1);
CountDownLatch latch3 = new CountDownLatch(1);
((VertxInternal)vertx2).failoverCompleteHandler(succeeded -> {
assertTrue(succeeded);
latch3.countDown();
});