List of usage examples for io.vertx.core Future future
future
From source file:se.liquidbytes.jel.JelStarter.java
License:Apache License
/** * Startup application verticles/*from w w w .ja v a 2 s .c o m*/ */ private static void startServer() { logger.info("Starting JEL-server..." + (Settings.isDebug() ? " AND RUNNING IN DEBUG-MODE!" : "")); VertxOptions options = new VertxOptions(); if (Settings.isDebug()) { options.setBlockedThreadCheckInterval(1000 * 60 * 60); // Disable errors about event-loop being blocked when stuck on breakpoints. This will clutter the console otherwise. } vertx = Vertx.vertx(options); Future<Void> future = Future.future(); future.setHandler(res -> { if (res.failed()) { shutdownServer(); // If any of the vertices failed to deploy, shut down the application. } else { logger.debug("Done deploying main verticles."); } }); // Start up verticles in turn. If one fails ignore the rest. deployDatabaseVerticle(future, (Future<Void> event1) -> { deployMainJelVerticle(future, (Future<Void> event2) -> { deployWebserverVerticle(future, null); }); }); }
From source file:se.liquidbytes.jel.system.impl.JelServiceImpl.java
License:Apache License
/** * Method for stopping service, must be called upon during application shutdown. *///from w w w . j a va 2s . c o m @Override public void stop() { if (JelService.deviceManager() != null) { JelService.deviceManager().stop(); } JelService.vertx().setTimer(500, h -> { if (JelService.adapterManager() != null) { Future<Void> future = Future.future(); future.setHandler(res -> { if (JelService.pluginManager() != null) { JelService.pluginManager().stop(); } }); JelService.adapterManager().stop(future); } }); }
From source file:studio.lysid.scales.deploy.LauncherVerticle.java
License:Open Source License
public static Future<Void> startVerticle(Vertx vertx, Verticle verticle) { Future<Void> startFuture = Future.future(); int instancesToStart = verticle.deploymentOptions.getInstances(); if (instancesToStart == 0) { startFuture.complete();//from w w w.j a v a 2s . c o m } else { logger.info("Starting verticle [{0}] with {1} instance(s)...", verticle.shortName, instancesToStart); if (verticle.implementation == null) { /* TODO For initializing projects only */ startFuture.complete(); logger.info("Verticle [{0}] not yet implemented, skipping.", verticle.shortName); } else { logger.info("Deploying verticle class [{0}]", verticle.implementation.getName()); vertx.deployVerticle(verticle.implementation.getName(), verticle.deploymentOptions, ar -> { if (ar.succeeded()) { logger.info("Verticle [{0}] started successfully.", verticle.shortName); startFuture.complete(); } else { startFuture.fail(ar.cause()); } }); } } return startFuture; }