public void run() { final CountDownLatch latch = new CountDownLatch(1); mgr.undeployAll(new Handler<AsyncResult<Void>>() { public void handle(AsyncResult<Void> res) { latch.countDown(); } }); try { if (!latch.await(30, TimeUnit.SECONDS)) { log.error("Timed out waiting to undeploy"); } } catch (InterruptedException e) { throw new IllegalStateException(e); } // Now shutdown the platform manager mgr.stop(); // Run any extra tasks Runnable task; while ((task = afterShutdownTasks.poll()) != null) { try { task.run(); } catch (Throwable t) { log.error("Failed to run after shutdown task", t); } } } });
/** * Undeploy all verticles and modules * * @return Promise of undeployment */ @Override public Promise<Void> undeployAll() { final Deferred<Void> d = when.defer(); manager.undeployAll(result -> { if (result.succeeded()) { d.resolve(result.result()); } else { d.reject(result.cause()); } }); return d.getPromise(); }