io.vertx.core.DeploymentOptions Java Examples
The following examples show how to use
io.vertx.core.DeploymentOptions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VxmsGateway.java From vxms with Apache License 2.0 | 6 votes |
public static void main(String[] args) { DeploymentOptions options = new DeploymentOptions() .setInstances(1) .setConfig( new JsonObject() .put("kube.offline", true) .put("local", true) .put("read_name", "vxms-k8s-read") .put("read_version", "1.2-SNAPSHOT") .put("write_name", "vxms-k8s-write") .put("write_version", "1.2-SNAPSHOT") .put("name.vxms-k8s-read.version.1.2-SNAPSHOT", "localhost:7070") .put("name.vxms-k8s-write.version.1.2-SNAPSHOT", "localhost:9090")); Vertx.vertx().deployVerticle(VxmsGateway.class.getName(), options); }
Example #2
Source File: TestMetricsEndpoint.java From konduit-serving with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUp(TestContext testContext) { configuration = new InferenceConfiguration() .protocol(ServerProtocol.HTTP) .pipeline(SequencePipeline.builder() .add(new LoggingStep().log(LoggingStep.Log.KEYS_AND_VALUES).logLevel(Level.ERROR)) .add(new MetricsTestingStep()) .build()); Async async = testContext.async(); vertx = DeployKonduitServing.deploy(new VertxOptions(), new DeploymentOptions(), configuration, handler -> { if(handler.succeeded()) { inferenceDeploymentResult = handler.result(); async.complete(); } else { testContext.fail(handler.cause()); } }); }
Example #3
Source File: InferenceVerticleHttpTest.java From konduit-serving with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUp(TestContext testContext) { configuration = new InferenceConfiguration() .protocol(ServerProtocol.HTTP) .pipeline(SequencePipeline.builder() .add(new LoggingStep().log(LoggingStep.Log.KEYS_AND_VALUES).logLevel(Level.ERROR)) .add(new FailureTestingPipelineStep()) .build()); Async async = testContext.async(); vertx = DeployKonduitServing.deploy(new VertxOptions(), new DeploymentOptions(), configuration, handler -> { if(handler.succeeded()) { inferenceDeploymentResult = handler.result(); async.complete(); } else { testContext.fail(handler.cause()); } }); }
Example #4
Source File: InferenceVerticleMqttTest.java From konduit-serving with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUp(TestContext testContext) { configuration = new InferenceConfiguration() .protocol(ServerProtocol.MQTT) .pipeline(SequencePipeline.builder() .add(new LoggingStep().log(LoggingStep.Log.KEYS_AND_VALUES).logLevel(Level.ERROR)) .build()); Async async = testContext.async(); vertx = DeployKonduitServing.deploy(new VertxOptions(), new DeploymentOptions(), configuration, handler -> { if(handler.succeeded()) { inferenceDeploymentResult = handler.result(); async.complete(); } else { testContext.fail(handler.cause()); } }); }
Example #5
Source File: InitVerticle.java From apiman with Apache License 2.0 | 6 votes |
private void deploy(String canonicalName, VerticleType verticleType, @SuppressWarnings("rawtypes") List<Future> deployList) { log.info("Will deploy {0} of type {1}", apimanConfig.getVerticleCount(verticleType), verticleType); if (apimanConfig.getVerticleCount(verticleType) <= 0) { return; } DeploymentOptions deploymentOptions = new DeploymentOptions(base) .setInstances(apimanConfig.getVerticleCount(verticleType)); // Future for this deployment. Future<String> future = Future.future(); // Do deployment vertx.deployVerticle(canonicalName, deploymentOptions, future.completer()); // Set the future associated with the deployment so #all can wait for it. deployList.add(future); }
Example #6
Source File: StringSerializerIntegrationTest.java From vertx-kafka-service with Apache License 2.0 | 6 votes |
@Test public void test(TestContext testContext) throws Exception { JsonObject config = makeDefaultConfig(); config.put(KafkaProducerProperties.ADDRESS, ADDRESS); config.put(KafkaProducerProperties.DEFAULT_TOPIC, TOPIC); final DeploymentOptions deploymentOptions = new DeploymentOptions(); deploymentOptions.setConfig(config); deploy(testContext, deploymentOptions); final Async async = testContext.async(); try { final KafkaProducerService kafkaProducerService = KafkaProducerService.createProxy(vertx, ADDRESS); kafkaProducerService.sendString(new StringKafkaMessage(MESSAGE), (Handler<AsyncResult<Void>>) message -> { if (message.failed()) { testContext.assertTrue(message.cause().getMessage().equals("Failed to update metadata after 5 ms.")); async.complete(); } else { testContext.fail(); } }); } catch (Exception e) { testContext.fail(e); } }
Example #7
Source File: ShellExamples.java From vertx-shell with Apache License 2.0 | 6 votes |
public void deployHttpServiceWithMongo(Vertx vertx) throws Exception { vertx.deployVerticle("maven:{maven-groupId}:{maven-artifactId}:{maven-version}", new DeploymentOptions().setConfig(new JsonObject(). put("httpOptions", new JsonObject(). put("host", "localhost"). put("port", 8080). put("ssl", true). put("keyPairOptions", new JsonObject(). put("path", "src/test/resources/server-keystore.jks"). put("password", "wibble")). put("authOptions", new JsonObject(). put("provider", "mongo"). put("config", new JsonObject(). put("connection_string", "mongodb://localhost:27018")))) ) ); }
Example #8
Source File: RESTJerseyPOSTFileClientTests.java From vxms with Apache License 2.0 | 6 votes |
@Before public void startVerticles() throws InterruptedException { CountDownLatch latch2 = new CountDownLatch(1); DeploymentOptions options = new DeploymentOptions().setInstances(1); options.setConfig(new JsonObject().put("clustered", false).put("host", HOST)); getVertx() .deployVerticle( new WsServiceOne(), options, asyncResult -> { // Deployment is asynchronous and this this handler will be called when it's complete // (or failed) System.out.println("start service: " + asyncResult.succeeded()); assertTrue(asyncResult.succeeded()); assertNotNull("deploymentID should not be null", asyncResult.result()); // If deployed correctly then start the tests! // latch2.countDown(); latch2.countDown(); }); awaitLatch(latch2); }
Example #9
Source File: Main.java From vertx-in-action with MIT License | 6 votes |
public static void main(String[] args) { Vertx vertx = Vertx.vertx(); vertx.deployVerticle("chapter5.sensor.HeatSensor", new DeploymentOptions().setConfig(new JsonObject() .put("http.port", 3000))); vertx.deployVerticle("chapter5.sensor.HeatSensor", new DeploymentOptions().setConfig(new JsonObject() .put("http.port", 3001))); vertx.deployVerticle("chapter5.sensor.HeatSensor", new DeploymentOptions().setConfig(new JsonObject() .put("http.port", 3002))); vertx.deployVerticle("chapter5.snapshot.SnapshotService"); vertx.deployVerticle("chapter5.reactivex.CollectorService"); }
Example #10
Source File: VerticleDeployment.java From vertx-config with Apache License 2.0 | 6 votes |
public void configureVertx() { // Create a first instance of Vert.x Vertx vertx = Vertx.vertx(); // Create the config retriever ConfigRetriever retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions() .addStore(new ConfigStoreOptions().setType("file").setConfig(new JsonObject().put("path", "vertx.json")))); // Retrieve the configuration retriever.getConfig(json -> { JsonObject result = json.result(); // Close the vert.x instance, we don't need it anymore. vertx.close(); // Create a new Vert.x instance using the retrieve configuration VertxOptions options = new VertxOptions(result); Vertx newVertx = Vertx.vertx(options); // Deploy your verticle newVertx.deployVerticle(GreetingVerticle.class.getName(), new DeploymentOptions().setConfig(result.getJsonObject("a"))); }); }
Example #11
Source File: RESTRouteBuilderPOSTFileClientTests.java From vxms with Apache License 2.0 | 6 votes |
@Before public void startVerticles() throws InterruptedException { CountDownLatch latch2 = new CountDownLatch(1); DeploymentOptions options = new DeploymentOptions().setInstances(1); options.setConfig(new JsonObject().put("clustered", false).put("host", HOST)); getVertx() .deployVerticle( new WsServiceOne(), options, asyncResult -> { // Deployment is asynchronous and this this handler will be called when it's complete // (or failed) System.out.println("start service: " + asyncResult.succeeded()); assertTrue(asyncResult.succeeded()); assertNotNull("deploymentID should not be null", asyncResult.result()); // If deployed correctly then start the tests! // latch2.countDown(); latch2.countDown(); }); awaitLatch(latch2); }
Example #12
Source File: PullTest.java From okapi with Apache License 2.0 | 6 votes |
@Before public void setUp(TestContext context) { logger.debug("staring PullTest"); vertx = Vertx.vertx(); Async async = context.async(); DeploymentOptions opt = new DeploymentOptions() .setConfig(new JsonObject().put("port", Integer.toString(port2)) ); vertx.deployVerticle(MainVerticle.class.getName(), opt, res -> { if (res.failed()) { context.fail(res.cause()); } else { vert1 = res.result(); otherDeploy(context, async); } }); }
Example #13
Source File: MultiInstanceTransactionTest.java From vertx-stomp with Apache License 2.0 | 6 votes |
@Test public void testThatTransactionAreNotShared(TestContext context) { vertx.deployVerticle("io.vertx.ext.stomp.verticles.StompServerVerticle", new DeploymentOptions().setInstances(3), ar -> { if (ar.failed()) { context.fail(ar.cause()); } else { deploymentId = ar.result(); // Deploy the clients. vertx.deployVerticle("io.vertx.ext.stomp.verticles.ReceiverStompClient", ar2 -> { if (ar.failed()) { context.fail(ar.cause()); } else { vertx.deployVerticle("io.vertx.ext.stomp.verticles.TxSenderStompClient", ar3 -> { System.out.println("Test started"); }); } }); } }); Awaitility.await().atMost(10, TimeUnit.SECONDS).until(() -> ReceiverStompClient.FRAMES.size() == 5); }
Example #14
Source File: TestVertxMetersInitializer.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
@Test public void init() throws InterruptedException { globalRegistry.add(registry); vertxMetersInitializer.init(globalRegistry, eventBus, null); logPublisher.init(null, eventBus, null); VertxUtils .blockDeploy(SharedVertxFactory.getSharedVertx(), TestServerVerticle.class, new DeploymentOptions()); VertxUtils .blockDeploy(SharedVertxFactory.getSharedVertx(), TestClientVerticle.class, new DeploymentOptions()); globalRegistry.poll(1); List<Meter> meters = Lists.newArrayList(registry.iterator()); List<Measurement> measurements = new ArrayList<>(); for (Meter meter : meters) { meter.measure().forEach(measurements::add); } LogCollector logCollector = new LogCollector(); testLog(logCollector, meters, measurements, true); logCollector.clear(); testLog(logCollector, meters, measurements, false); logCollector.teardown(); }
Example #15
Source File: TypeScriptVerticleTest.java From vertx-lang-typescript with Apache License 2.0 | 6 votes |
private void doTest(String verticle, String message, TestContext context) throws IOException { Async async = context.async(); int port = getAvailablePort(); JsonObject config = new JsonObject().put("port", port); DeploymentOptions options = new DeploymentOptions().setConfig(config); Vertx vertx = runTestOnContext.vertx(); vertx.deployVerticle(verticle, options, context.asyncAssertSuccess(deploymentID -> { HttpClient client = vertx.createHttpClient(); // retry for 30 seconds and give the verticle a chance to launch the server makeRequest(client, port, 30, 1000, context.asyncAssertSuccess(buffer -> { context.assertEquals(message, buffer.toString()); vertx.undeploy(deploymentID, context.asyncAssertSuccess(r -> async.complete())); client.close(); })); })); }
Example #16
Source File: AuditVerticleTest.java From vertx-microservices-workshop with Apache License 2.0 | 6 votes |
@Before public void setUp(TestContext tc) { Async async = tc.async(); vertx = Vertx.vertx(); Record record = MessageSource.createRecord("portfolio-events", "portfolio", JsonObject .class); ServiceDiscovery.create(vertx, new ServiceDiscoveryOptions() .setBackendConfiguration(new JsonObject().put("backend-name", DefaultServiceDiscoveryBackend.class.getName()))) .publish(record, r -> { if (r.failed()) { r.cause().printStackTrace(); tc.fail(r.cause()); } vertx.deployVerticle(AuditVerticle.class.getName(), new DeploymentOptions().setConfig(CONFIGURATION), tc.asyncAssertSuccess(s -> async.complete())); }); }
Example #17
Source File: Main.java From vertx-in-action with MIT License | 6 votes |
public static void main(String[] args) { Vertx vertx = Vertx.vertx(); vertx.deployVerticle("chapter5.sensor.HeatSensor", new DeploymentOptions().setConfig(new JsonObject() .put("http.port", 3000))); vertx.deployVerticle("chapter5.sensor.HeatSensor", new DeploymentOptions().setConfig(new JsonObject() .put("http.port", 3001))); vertx.deployVerticle("chapter5.sensor.HeatSensor", new DeploymentOptions().setConfig(new JsonObject() .put("http.port", 3002))); vertx.deployVerticle("chapter5.snapshot.SnapshotService"); vertx.deployVerticle("chapter5.future.CollectorService"); }
Example #18
Source File: Testverticle.java From vxms with Apache License 2.0 | 5 votes |
public static void main(String[] args) { DeploymentOptions options = new DeploymentOptions() .setInstances(2) .setConfig(new JsonObject().put("host", "localhost")); Vertx.vertx().deployVerticle(Testverticle.class.getName(), options); }
Example #19
Source File: RESTJerseyClientErrorTests.java From vxms with Apache License 2.0 | 5 votes |
@Before public void startVerticles() throws InterruptedException { CountDownLatch latch2 = new CountDownLatch(1); DeploymentOptions options = new DeploymentOptions().setInstances(1); options.setConfig(new JsonObject().put("clustered", false).put("host", HOST)); // Deploy the module - the System property `vertx.modulename` will contain the name of the // module so you // don'failure have to hardecode it in your tests getVertx() .deployVerticle( new WsServiceOne(), options, asyncResult -> { // Deployment is asynchronous and this this handler will be called when it's complete // (or failed) System.out.println("start service: " + asyncResult.succeeded()); assertTrue(asyncResult.succeeded()); assertNotNull("deploymentID should not be null", asyncResult.result()); // If deployed correctly then start the tests! // latch2.countDown(); latch2.countDown(); }); client = getVertx().createHttpClient(new HttpClientOptions()); awaitLatch(latch2); }
Example #20
Source File: RESTServiceBlockingChainStringTest.java From vxms with Apache License 2.0 | 5 votes |
@Before public void startVerticles() throws InterruptedException { CountDownLatch latch2 = new CountDownLatch(1); DeploymentOptions options = new DeploymentOptions().setInstances(1); options.setConfig(new JsonObject().put("clustered", false).put("host", HOST)); // Deploy the module - the System property `vertx.modulename` will contain the name of the // module so you // don'failure have to hardecode it in your tests getVertx() .deployVerticle( new WsServiceOne(), options, asyncResult -> { // Deployment is asynchronous and this this handler will be called when it's complete // (or failed) System.out.println("start service: " + asyncResult.succeeded()); assertTrue(asyncResult.succeeded()); assertNotNull("deploymentID should not be null", asyncResult.result()); // If deployed correctly then start the tests! // latch2.countDown(); latch2.countDown(); }); client = getVertx().createHttpClient(new HttpClientOptions()); awaitLatch(latch2); }
Example #21
Source File: HealthCheckTest.java From okapi with Apache License 2.0 | 5 votes |
@Before public void setUp(TestContext context) { vertx = Vertx.vertx(); DeploymentOptions opt = new DeploymentOptions() .setConfig(new JsonObject().put("port", Integer.toString(port))); vertx.deployVerticle(MainVerticle.class.getName(), opt, context.asyncAssertSuccess()); }
Example #22
Source File: ResolveServicesByLAbelsWithPortNameTest.java From vxms with Apache License 2.0 | 5 votes |
@Before public void startVerticles() throws InterruptedException { initKubernetes(); initService(); CountDownLatch latch2 = new CountDownLatch(1); JsonObject conf = new JsonObject(); conf.put("service1.name", "myTestService").put("service1.port", "mytcp"); conf.put("service2.name", "myTestService2").put("service2.value", "v2"); DeploymentOptions options = new DeploymentOptions().setConfig(conf).setInstances(1); vertx.deployVerticle( new WsServiceOne(config), options, asyncResult -> { // Deployment is asynchronous and this this handler will be called when it's complete // (or failed) System.out.println("start service: " + asyncResult.succeeded()); assertTrue(asyncResult.succeeded()); assertNotNull("deploymentID should not be null", asyncResult.result()); // If deployed correctly then start the tests! // latch2.countDown(); latch2.countDown(); }); httpClient = vertx.createHttpClient(new HttpClientOptions()); awaitLatch(latch2); }
Example #23
Source File: ModuleTest.java From okapi with Apache License 2.0 | 5 votes |
@Before public void setUp(TestContext context) { vertx = Vertx.vertx(); httpClient = vertx.createHttpClient(); RestAssured.port = port; RestAssured.urlEncodingEnabled = false; conf.put("postgres_password", "okapi25"); conf.put("postgres_db_init", "1"); conf.put("mongo_db_init", "1"); conf.put("mode", "dev"); DeploymentOptions opt = new DeploymentOptions().setConfig(conf); vertx.deployVerticle(MainVerticle.class.getName(), opt, context.asyncAssertSuccess()); }
Example #24
Source File: ResolveServicesByNameOfflineTest.java From vxms with Apache License 2.0 | 5 votes |
@Before public void startVerticles() throws InterruptedException { initKubernetes(); // initService(); CountDownLatch latch2 = new CountDownLatch(1); JsonObject conf = new JsonObject(); conf.put("kube.offline", true); conf.put("myTestService", "http://192.168.1.1:8080"); conf.put("myTestService2", "http://192.168.1.2:9080"); DeploymentOptions options = new DeploymentOptions().setConfig(conf).setInstances(1); vertx.deployVerticle( new WsServiceOne(config), options, asyncResult -> { // Deployment is asynchronous and this this handler will be called when it's complete // (or failed) System.out.println("start service: " + asyncResult.succeeded()); assertTrue(asyncResult.succeeded()); assertNotNull("deploymentID should not be null", asyncResult.result()); // If deployed correctly then start the tests! // latch2.countDown(); latch2.countDown(); }); httpClient = vertx.createHttpClient(new HttpClientOptions()); awaitLatch(latch2); }
Example #25
Source File: RESTServiceByteExceptionFallbackTest.java From vxms with Apache License 2.0 | 5 votes |
@Before public void startVerticles() throws InterruptedException { CountDownLatch latch2 = new CountDownLatch(1); DeploymentOptions options = new DeploymentOptions().setInstances(1); options.setConfig(new JsonObject().put("clustered", false).put("host", HOST)); // Deploy the module - the System property `vertx.modulename` will contain the name of the // module so you // don'failure have to hardecode it in your tests getVertx() .deployVerticle( new WsServiceOne(), options, asyncResult -> { // Deployment is asynchronous and this this handler will be called when it's complete // (or failed) System.out.println("start service: " + asyncResult.succeeded()); System.out.println("start service: " + asyncResult.cause()); assertTrue(asyncResult.succeeded()); assertNotNull("deploymentID should not be null", asyncResult.result()); // If deployed correctly then start the tests! // latch2.countDown(); latch2.countDown(); }); awaitLatch(latch2); }
Example #26
Source File: PluginManagerVerticle.java From dfx with Apache License 2.0 | 5 votes |
public static void start(Vertx vertx) { DfxConfig config = DfxConfig.load(MainVerticle.conf); vertx.deployVerticle(new PluginManagerVerticle(config), result -> { try { vertx.deployVerticle(new WatcherVerticle(config.getWatchCycle()) , new DeploymentOptions().setWorker(true)); } catch (IOException e) { logger.error("An error happened during start process: {}", e); vertx.close(); System.exit(-1); } }); }
Example #27
Source File: WSServiceTest.java From vert.x-microservice with Apache License 2.0 | 5 votes |
@Before public void startVerticles() throws InterruptedException { CountDownLatch latch = new CountDownLatch(1); CountDownLatch latch2 = new CountDownLatch(1); DeploymentOptions options = new DeploymentOptions().setInstances(1); options.setConfig(new JsonObject().put("clustered", false).put("host", HOST)); // Deploy the module - the System property `vertx.modulename` will contain the name of the module so you // don't have to hardecode it in your tests getVertx().deployVerticle("org.jacpfx.vertx.entrypoint.ServiceEntryPoint",options, asyncResult -> { // Deployment is asynchronous and this this handler will be called when it's complete (or failed) System.out.println("start entry point: " + asyncResult.succeeded()); assertTrue(asyncResult.succeeded()); assertNotNull("deploymentID should not be null", asyncResult.result()); // If deployed correctly then start the tests! latch.countDown(); }); awaitLatch(latch); getVertx().deployVerticle(new WsServiceOne(), options, asyncResult -> { // Deployment is asynchronous and this this handler will be called when it's complete (or failed) System.out.println("start service: " + asyncResult.succeeded()); assertTrue(asyncResult.succeeded()); assertNotNull("deploymentID should not be null", asyncResult.result()); // If deployed correctly then start the tests! // latch2.countDown(); latch2.countDown(); }); client = getVertx(). createHttpClient(new HttpClientOptions()); awaitLatch(latch2); }
Example #28
Source File: RESTServiceOnFailureTest.java From vxms with Apache License 2.0 | 5 votes |
@Before public void startVerticles() throws InterruptedException { CountDownLatch latch2 = new CountDownLatch(1); DeploymentOptions options = new DeploymentOptions().setInstances(1); options.setConfig(new JsonObject().put("clustered", false).put("host", HOST)); // Deploy the module - the System property `vertx.modulename` will contain the name of the // module so you // don'failure have to hardecode it in your tests getVertx() .deployVerticle( new WsServiceOne(), options, asyncResult -> { // Deployment is asynchronous and this this handler will be called when it's complete // (or failed) System.out.println("start service: " + asyncResult.succeeded()); assertTrue(asyncResult.succeeded()); assertNotNull("deploymentID should not be null", asyncResult.result()); // If deployed correctly then start the tests! // latch2.countDown(); latch2.countDown(); }); awaitLatch(latch2); }
Example #29
Source File: RESTServiceSelfhostedTest.java From vxms with Apache License 2.0 | 5 votes |
@Before public void startVerticles() throws InterruptedException { CountDownLatch latch2 = new CountDownLatch(1); DeploymentOptions options = new DeploymentOptions().setInstances(1); options.setConfig(new JsonObject().put("clustered", false).put("host", HOST)); // Deploy the module - the System property `vertx.modulename` will contain the name of the // module so you // don'failure have to hardecode it in your tests getVertx() .deployVerticle( new WsServiceOne(), options, asyncResult -> { // Deployment is asynchronous and this this handler will be called when it's complete // (or failed) System.out.println("start service: " + asyncResult.succeeded()); assertTrue(asyncResult.succeeded()); assertNotNull("deploymentID should not be null", asyncResult.result()); // If deployed correctly then start the tests! // latch2.countDown(); latch2.countDown(); }); client = getVertx().createHttpClient(new HttpClientOptions()); awaitLatch(latch2); }
Example #30
Source File: Kue.java From vertx-kue with Apache License 2.0 | 5 votes |
private void processInternal(String type, Handler<Job> handler, boolean isWorker) { KueWorker worker = new KueWorker(type, handler, this); vertx.deployVerticle(worker, new DeploymentOptions().setWorker(isWorker), r0 -> { if (r0.succeeded()) { this.on("job_complete", msg -> { long dur = new Job(((JsonObject) msg.body()).getJsonObject("job")).getDuration(); client.incrby(RedisHelper.getKey("stats:work-time"), dur, r1 -> { if (r1.failed()) r1.cause().printStackTrace(); }); }); } }); }