/** * Get the deployment ID of the verticle deployment * @return the deployment ID */ public String deploymentID() { return context.deploymentID(); }
@Override public void start() throws Exception { processArgs = context.processArgs(); conf = context.config(); // if (Thread.currentThread().getContextClassLoader() != getClass().getClassLoader()) { // throw new IllegalStateException("Wrong tccl!"); // } vertx.eventBus().send("testcounts", new JsonObject().put("deploymentID", context.deploymentID()).put("count", instanceCount.incrementAndGet())); }
@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));
@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 -> {}));
@Override public void start() throws Exception { switch (startAction) { case THROW_EXCEPTION: throw new Exception("FooBar!"); case THROW_ERROR: throw new Error("FooBar!"); default: startCalled = true; startContext = Vertx.currentContext(); } deploymentID = Vertx.currentContext().deploymentID(); config = context.config(); }
/** * Get the deployment ID of the verticle deployment * @return the deployment ID */ public String deploymentID() { return context.deploymentID(); }
@Override public void start() throws Exception { processArgs = context.processArgs(); conf = context.config(); // if (Thread.currentThread().getContextClassLoader() != getClass().getClassLoader()) { // throw new IllegalStateException("Wrong tccl!"); // } vertx.eventBus().send("testcounts", new JsonObject().put("deploymentID", context.deploymentID()).put("count", instanceCount.incrementAndGet())); }
@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 -> {}));
@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));
@Override public void start() throws Exception { switch (startAction) { case THROW_EXCEPTION: throw new Exception("FooBar!"); case THROW_ERROR: throw new Error("FooBar!"); default: startCalled = true; startContext = Vertx.currentContext(); } deploymentID = Vertx.currentContext().deploymentID(); config = context.config(); }
/** * If the context is associated with a Verticle deployment, this returns the deployment ID of that deployment. * @return the deployment ID of the deployment or null if not a Verticle deployment */ public String deploymentID() { String ret = delegate.deploymentID(); return ret; }
/** * If the context is associated with a Verticle deployment, this returns the deployment ID of that deployment. * @return the deployment ID of the deployment or null if not a Verticle deployment */ public String deploymentID() { String ret = delegate.deploymentID(); return ret; }
@Test public void testDeployWithOptionsAsEmptyString(TestContext context) { String cmd = "verticle-deploy io.vertx.ext.shell.command.base.DeployVerticleTest$SomeVerticle ''"; String result = testDeployCmd(context, cmd); context.assertNotNull(ctx.get()); context.assertEquals(result, "Deployed " + ctx.get().deploymentID()); context.assertEquals(1, ctx.get().getInstanceCount()); }
@Test public void testDeploy(TestContext context) { String cmd = "verticle-deploy io.vertx.ext.shell.command.base.DeployVerticleTest$SomeVerticle"; String result = testDeployCmd(context, cmd); context.assertNotNull(ctx.get()); context.assertEquals(result, "Deployed " + ctx.get().deploymentID()); context.assertEquals(1, ctx.get().getInstanceCount()); }
@Test public void testDeployWithOptionsAsJsonInstance(TestContext context) { String cmd = "verticle-deploy io.vertx.ext.shell.command.base.DeployVerticleTest$SomeVerticle '{\"instances\" : 8}'"; String result = testDeployCmd(context, cmd); context.assertNotNull(ctx.get()); context.assertEquals(result, "Deployed " + ctx.get().deploymentID()); context.assertEquals(8, ctx.get().getInstanceCount()); }
@Test public void testDeployWithOptionsAsEmptyJsonString(TestContext context) { String cmd = "verticle-deploy io.vertx.ext.shell.command.base.DeployVerticleTest$SomeVerticle '{}'"; String result = testDeployCmd(context, cmd); context.assertNotNull(ctx.get()); context.assertEquals(result, "Deployed " + ctx.get().deploymentID()); context.assertEquals(1, ctx.get().getInstanceCount()); }
@Test public void testDeployWithOptionsAsJsonConfig(TestContext context) { String cmd = "verticle-deploy io.vertx.ext.shell.command.base.DeployVerticleTest$SomeVerticle '{\"config\":{\"ok\":true}}'"; String result = testDeployCmd(context, cmd); context.assertNotNull(ctx.get()); context.assertEquals(result, "Deployed " + ctx.get().deploymentID()); context.assertEquals(1, ctx.get().getInstanceCount()); context.assertNotNull(ctx.get().config()); context.assertTrue(ctx.get().config().containsKey("ok")); context.assertEquals(true, ctx.get().config().getBoolean("ok")); }
@Override public void start() throws Exception { vertx.runOnContext(v -> { List<String> extraCP = Arrays.asList("blah", "wibble"); DeploymentOptions expected = new DeploymentOptions().setConfig(new JsonObject().put("foo", "bar")) .setWorker(true).setIsolationGroup("mygroup").setExtraClasspath(extraCP); Deployment dep = ((VertxInternal) vertx).getDeployment(Vertx.currentContext().deploymentID()); vertx.eventBus().publish("moduleStarted", expected.equals(dep.deploymentOptions())); }); }
@Override public void start(Future<Void> fut) { KafkaConsumer<String, String> consumer = KafkaConsumer.create(vertx, config); deployed = true; consumer.handler(record -> { if (deployed) { deployed = false; vertx.undeploy(context.deploymentID(), ctx.asyncAssertSuccess(v2 -> async.countDown())); } }); consumer.assign(new TopicPartition(topicName, 0), fut); } }, ctx.asyncAssertSuccess(v -> produceLatch.complete()));
public void consumerWithDependencies(@Observes @VertxConsumer(TEST_DEP) VertxEvent event, CoolService coolService) { assertEquals(TEST_DEP, event.getAddress()); assertNotNull(event.getReplyAddress()); assertNotNull(coolService); assertNotNull(coolService.getCacheService()); assertNotNull(coolService.getVertx().eventBus()); assertNotNull(coolService.getContext().deploymentID()); event.setReply(coolService.getId() + "_" + coolService.getCacheService().getId()); assertTrue(event.isReplied()); }