use of io.vertx.core.DeploymentOptions in project vert.x by eclipse.
the class BlockedThreadCheckerTest method testBlockCheckWorker.
@Test
public void testBlockCheckWorker() throws Exception {
Verticle verticle = new AbstractVerticle() {
@Override
public void start() throws InterruptedException {
Thread.sleep(2000);
testComplete();
}
};
// set warning threshold to 1s and the exception threshold as well
VertxOptions vertxOptions = new VertxOptions();
vertxOptions.setMaxWorkerExecuteTime(1000000000);
vertxOptions.setWarningExceptionTime(1000000000);
Vertx newVertx = vertx(vertxOptions);
DeploymentOptions deploymentOptions = new DeploymentOptions();
deploymentOptions.setWorker(true);
newVertx.deployVerticle(verticle, deploymentOptions);
await();
}
use of io.vertx.core.DeploymentOptions in project vert.x by eclipse.
the class NamedWorkerPoolTest method testDeployWorkerUsingNamedPool.
@Test
public void testDeployWorkerUsingNamedPool() throws Exception {
AtomicReference<Thread> thread = new AtomicReference<>();
AtomicReference<String> deployment = new AtomicReference<>();
String poolName = "vert.x-" + TestUtils.randomAlphaString(10);
vertx.deployVerticle(new AbstractVerticle() {
@Override
public void start() throws Exception {
thread.set(Thread.currentThread());
assertTrue(Context.isOnVertxThread());
assertTrue(Context.isOnWorkerThread());
assertFalse(Context.isOnEventLoopThread());
assertTrue(Thread.currentThread().getName().startsWith(poolName + "-"));
context.runOnContext(v -> {
vertx.undeploy(context.deploymentID());
});
}
}, new DeploymentOptions().setWorker(true).setWorkerPoolName(poolName), onSuccess(deployment::set));
waitUntil(() -> thread.get() != null && thread.get().getState() == Thread.State.TERMINATED);
}
use of io.vertx.core.DeploymentOptions in project vert.x by eclipse.
the class RunCommand method run.
/**
* Starts vert.x and deploy the verticle.
*/
@Override
public void run() {
if (redeploy == null || redeploy.isEmpty()) {
JsonObject conf = getConfiguration();
if (conf == null) {
conf = new JsonObject();
}
afterConfigParsed(conf);
super.run();
if (vertx == null) {
// Already logged.
ExecUtils.exitBecauseOfVertxInitializationIssue();
}
deploymentOptions = new DeploymentOptions();
configureFromSystemProperties(deploymentOptions, DEPLOYMENT_OPTIONS_PROP_PREFIX);
deploymentOptions.setConfig(conf).setWorker(worker).setHa(ha).setInstances(instances);
beforeDeployingVerticle(deploymentOptions);
deploy();
} else {
// redeploy is set, start the redeployment infrastructure (watcher).
initializeRedeployment();
}
}
use of io.vertx.core.DeploymentOptions 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.DeploymentOptions 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);
}
Aggregations