use of io.vertx.core.DeploymentOptions in project vert.x by eclipse.
the class HATest method testSimpleFailover.
@Test
public void testSimpleFailover() throws Exception {
startNodes(2, new VertxOptions().setHAEnabled(true));
DeploymentOptions options = new DeploymentOptions().setHa(true);
JsonObject config = new JsonObject().put("foo", "bar");
options.setConfig(config);
CountDownLatch latch = new CountDownLatch(1);
vertices[0].deployVerticle("java:" + HAVerticle1.class.getName(), options, ar -> {
assertTrue(ar.succeeded());
assertEquals(1, vertices[0].deploymentIDs().size());
assertEquals(0, vertices[1].deploymentIDs().size());
latch.countDown();
});
awaitLatch(latch);
kill(0);
waitUntil(() -> vertices[1].deploymentIDs().size() == 1);
checkDeploymentExists(1, "java:" + HAVerticle1.class.getName(), options);
}
use of io.vertx.core.DeploymentOptions in project vert.x by eclipse.
the class NamedWorkerPoolTest method testDeployUsingNamedPool.
@Test
public void testDeployUsingNamedPool() throws Exception {
AtomicReference<Thread> thread = new AtomicReference<>();
String poolName = "vert.x-" + TestUtils.randomAlphaString(10);
vertx.deployVerticle(new AbstractVerticle() {
@Override
public void start() throws Exception {
vertx.executeBlocking(fut -> {
thread.set(Thread.currentThread());
assertTrue(Context.isOnVertxThread());
assertTrue(Context.isOnWorkerThread());
assertFalse(Context.isOnEventLoopThread());
assertTrue(Thread.currentThread().getName().startsWith(poolName + "-"));
fut.complete();
}, onSuccess(v -> {
vertx.undeploy(context.deploymentID());
}));
}
}, new DeploymentOptions().setWorkerPoolName(poolName), onSuccess(v -> {
}));
waitUntil(() -> thread.get() != null && thread.get().getState() == Thread.State.TERMINATED);
}
use of io.vertx.core.DeploymentOptions in project java-chassis by ServiceComb.
the class VertxUtils method deployVerticle.
public static <T extends AbstractVerticle> void deployVerticle(Vertx vertx, Class<T> cls, int instanceCount) {
DeploymentOptions options = new DeploymentOptions().setInstances(instanceCount);
vertx.deployVerticle(cls.getName(), options);
}
use of io.vertx.core.DeploymentOptions in project java-chassis by ServiceComb.
the class VertxUtils method createClientDeployOptions.
public static <CLIENT_POOL, CLIENT_OPTIONS> DeploymentOptions createClientDeployOptions(ClientPoolManager<CLIENT_POOL> clientMgr, int instanceCount, int poolCountPerVerticle, CLIENT_OPTIONS clientOptions) {
DeploymentOptions options = new DeploymentOptions().setInstances(instanceCount);
SimpleJsonObject config = new SimpleJsonObject();
config.put(AbstractClientVerticle.CLIENT_MGR, clientMgr);
config.put(AbstractClientVerticle.POOL_COUNT, poolCountPerVerticle);
config.put(AbstractClientVerticle.CLIENT_OPTIONS, clientOptions);
options.setConfig(config);
return options;
}
use of io.vertx.core.DeploymentOptions in project java-chassis by ServiceComb.
the class HighwayTransport method init.
public boolean init() throws Exception {
HighwayCodec.setHighwayTransport(this);
DeploymentOptions deployOptions = new DeploymentOptions().setInstances(HighwayConfig.getServerThreadCount());
setListenAddressWithoutSchema(HighwayConfig.getAddress(), Collections.singletonMap(TcpConst.LOGIN, "true"));
SimpleJsonObject json = new SimpleJsonObject();
json.put(ENDPOINT_KEY, getEndpoint());
deployOptions.setConfig(json);
return VertxUtils.blockDeploy(transportVertx, HighwayServerVerticle.class, deployOptions);
}
Aggregations