use of io.vertx.core.impl.VertxInternal in project vert.x by eclipse.
the class HATest method testNoFailoverToNonHANode.
@Test
public void testNoFailoverToNonHANode() throws Exception {
vertx1 = startVertx();
// Create a non HA node
vertx2 = startVertx(null, 0, false);
CountDownLatch latch1 = new CountDownLatch(1);
vertx1.deployVerticle("java:" + HAVerticle1.class.getName(), new DeploymentOptions().setHa(true), ar -> {
assertTrue(ar.succeeded());
assertTrue(vertx1.deploymentIDs().contains(ar.result()));
latch1.countDown();
});
awaitLatch(latch1);
((VertxInternal) vertx2).failoverCompleteHandler((nodeID, haInfo, succeeded) -> {
fail("Should not failover here 2");
});
((VertxInternal) vertx1).failoverCompleteHandler((nodeID, haInfo, succeeded) -> {
fail("Should not failover here 1");
});
((VertxInternal) vertx1).simulateKill();
vertx2.close(ar -> {
vertx.setTimer(500, tid -> {
testComplete();
});
});
await();
}
use of io.vertx.core.impl.VertxInternal in project vert.x by eclipse.
the class HATest method checkDeploymentExists.
protected void checkDeploymentExists(int pos, String verticleName, DeploymentOptions options) {
VertxInternal vi = (VertxInternal) vertices[pos];
for (String deploymentID : vi.deploymentIDs()) {
Deployment dep = vi.getDeployment(deploymentID);
if (verticleName.equals(dep.verticleIdentifier()) && options.equals(dep.deploymentOptions())) {
return;
}
}
fail("Can't find deployment for verticleName: " + verticleName + " on node " + pos);
}
use of io.vertx.core.impl.VertxInternal in project vert.x by eclipse.
the class HATest method testCleanCloseNoFailover.
@Test
public void testCleanCloseNoFailover() throws Exception {
vertx1 = startVertx();
vertx2 = startVertx();
DeploymentOptions options = new DeploymentOptions().setHa(true);
JsonObject config = new JsonObject().put("foo", "bar");
options.setConfig(config);
CountDownLatch deployLatch = new CountDownLatch(1);
vertx2.deployVerticle("java:" + HAVerticle1.class.getName(), options, ar -> {
assertTrue(ar.succeeded());
deployLatch.countDown();
});
awaitLatch(deployLatch);
((VertxInternal) vertx1).failoverCompleteHandler((nodeID, haInfo, succeeded) -> {
fail("Should not be called");
});
vertx2.close(ar -> {
vertx.setTimer(500, tid -> {
testComplete();
});
});
await();
}
use of io.vertx.core.impl.VertxInternal in project vert.x by eclipse.
the class HATest method testHaGroups.
@Test
public void testHaGroups() throws Exception {
vertx1 = startVertx("group1", 1);
vertx2 = startVertx("group1", 1);
vertx3 = startVertx("group2", 1);
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.deploymentIDs().contains(ar.result()));
latch1.countDown();
});
vertx3.deployVerticle("java:" + HAVerticle2.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);
((VertxInternal) vertx1).failoverCompleteHandler((nodeID, haInfo, succeeded) -> {
fail("Should not failover here 1");
});
((VertxInternal) vertx2).failoverCompleteHandler((nodeID, haInfo, succeeded) -> {
fail("Should not failover here 2");
});
((VertxInternal) vertx4).failoverCompleteHandler((nodeID, haInfo, succeeded) -> {
assertTrue(succeeded);
latch2.countDown();
});
((VertxInternal) vertx3).simulateKill();
awaitLatch(latch2);
assertTrue(vertx4.deploymentIDs().size() == 1);
CountDownLatch latch3 = new CountDownLatch(1);
((VertxInternal) vertx2).failoverCompleteHandler((nodeID, haInfo, succeeded) -> {
assertTrue(succeeded);
latch3.countDown();
});
((VertxInternal) vertx4).failoverCompleteHandler((nodeID, haInfo, succeeded) -> {
fail("Should not failover here 4");
});
((VertxInternal) vertx1).simulateKill();
awaitLatch(latch3);
assertTrue(vertx2.deploymentIDs().size() == 1);
}
use of io.vertx.core.impl.VertxInternal in project vert.x by eclipse.
the class HostnameResolutionTest method testSearchDomainWithNdots2.
@Test
public void testSearchDomainWithNdots2() throws Exception {
Map<String, String> records = new HashMap<>();
records.put("host1.sub.foo.com", "127.0.0.1");
records.put("host2.sub.foo.com", "127.0.0.2");
records.put("host2.sub", "127.0.0.3");
dnsServer.stop();
dnsServer = FakeDNSServer.testResolveA(records);
dnsServer.start();
VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(new AddressResolverOptions().addServer(dnsServerAddress.getAddress().getHostAddress() + ":" + dnsServerAddress.getPort()).setOptResourceEnabled(false).addSearchDomain("foo.com").setNdots(2)));
CountDownLatch latch1 = new CountDownLatch(1);
vertx.resolveAddress("host1.sub", onSuccess(resolved -> {
assertEquals("127.0.0.1", resolved.getHostAddress());
latch1.countDown();
}));
awaitLatch(latch1);
// "host2.sub" is resolved with the foo.com search domain as ndots = 2
CountDownLatch latch2 = new CountDownLatch(1);
vertx.resolveAddress("host2.sub", onSuccess(resolved -> {
assertEquals("127.0.0.2", resolved.getHostAddress());
latch2.countDown();
}));
awaitLatch(latch2);
}
Aggregations