use of io.vertx.core.impl.VertxInternal in project vert.x by eclipse.
the class HostnameResolutionTest method testResolveFromClasspath.
@Test
public void testResolveFromClasspath() {
VertxInternal vertx = (VertxInternal) vertx(new VertxOptions().setAddressResolverOptions(new AddressResolverOptions().setHostsPath("hosts_config.txt")));
vertx.resolveAddress("server.net", onSuccess(addr -> {
assertEquals("192.168.0.15", addr.getHostAddress());
assertEquals("server.net", addr.getHostName());
testComplete();
}));
await();
}
use of io.vertx.core.impl.VertxInternal 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.core.impl.VertxInternal in project vert.x by eclipse.
the class HATest method testFailureInFailover.
@Test
public void testFailureInFailover() throws Exception {
vertx1 = startVertx();
vertx2 = startVertx();
vertx3 = startVertx();
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).failDuringFailover(true);
((VertxInternal) vertx3).failDuringFailover(true);
CountDownLatch latch2 = new CountDownLatch(1);
((VertxInternal) vertx2).failoverCompleteHandler((nodeID, haInfo, succeeded) -> {
assertFalse(succeeded);
latch2.countDown();
});
((VertxInternal) vertx3).failoverCompleteHandler((nodeID, haInfo, succeeded) -> {
assertFalse(succeeded);
latch2.countDown();
});
((VertxInternal) vertx1).simulateKill();
awaitLatch(latch2);
// Now try again - this time failover should work
assertTrue(vertx2.deploymentIDs().isEmpty());
assertTrue(vertx3.deploymentIDs().isEmpty());
((VertxInternal) vertx2).failDuringFailover(false);
CountDownLatch latch3 = new CountDownLatch(1);
((VertxInternal) vertx2).failoverCompleteHandler((nodeID, haInfo, succeeded) -> {
assertTrue(succeeded);
latch3.countDown();
});
((VertxInternal) vertx3).simulateKill();
awaitLatch(latch3);
waitUntil(() -> vertx2.deploymentIDs().size() == 1);
}
use of io.vertx.core.impl.VertxInternal in project vert.x by eclipse.
the class MetricsOptionsTest method testMetricsEnabledWithoutConfig.
@Test
public void testMetricsEnabledWithoutConfig() {
vertx.close();
vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(true)));
VertxMetrics metrics = ((VertxInternal) vertx).metricsSPI();
assertNotNull(metrics);
assertTrue(metrics instanceof DummyVertxMetrics);
}
use of io.vertx.core.impl.VertxInternal in project vert.x by eclipse.
the class FileResolverTestBase method testCacheDirDeletedOnVertxClose.
@Test
public void testCacheDirDeletedOnVertxClose() {
VertxInternal vertx2 = (VertxInternal) vertx();
File file = vertx2.resolveFile(webRoot + "/somefile.html");
assertTrue(file.exists());
File cacheDir = file.getParentFile().getParentFile();
assertTrue(cacheDir.exists());
vertx2.close(onSuccess(v -> {
assertFalse(cacheDir.exists());
testComplete();
}));
await();
}
Aggregations