Example usage for io.vertx.core Vertx deploymentIDs

List of usage examples for io.vertx.core Vertx deploymentIDs

Introduction

In this page you can find the example usage for io.vertx.core Vertx deploymentIDs.

Prototype

Set<String> deploymentIDs();

Source Link

Document

Return a Set of deployment IDs for the currently deployed deploymentIDs.

Usage

From source file:com.foreks.vertx.launcher.ClusteredVertxFactory.java

License:Apache License

public void beforeLeaveUndeploy(Vertx vertx) {
    Observable.fromIterable(vertx.deploymentIDs()).flatMapCompletable(id -> Completable.fromSingle(s -> {
        vertx.undeploy(id, s::onSuccess);
    })).doOnComplete(latch::countDown).subscribe();
    try {/*from   w  ww  . ja va 2  s . c o  m*/
        latch.await(30000, TimeUnit.MILLISECONDS);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:io.flowly.core.verticles.VerticleUtils.java

License:Open Source License

private static void undeployVerticles(Iterator<String> deployementIds, Vertx vertx,
        Future<Void> undeployedFuture) {
    // Ensure that vertx platform has the deployment ids.
    // The list specified by the caller might be stale.
    List<String> actualDeploymentIds = new ArrayList<>();
    Set<String> vertxDeploymentIds = vertx.deploymentIDs();

    while (deployementIds.hasNext()) {
        String deploymentId = deployementIds.next();
        if (vertxDeploymentIds.contains(deploymentId)) {
            actualDeploymentIds.add(deploymentId);
        }//from   w w w  .j  a  v  a  2  s  . co m
    }

    if (actualDeploymentIds.isEmpty()) {
        undeployedFuture.complete();
    } else {
        AtomicInteger counter = new AtomicInteger(0);

        for (String deploymentId : actualDeploymentIds) {
            vertx.undeploy(deploymentId, d -> {
                if (d.succeeded()) {
                    if (counter.incrementAndGet() == actualDeploymentIds.size()) {
                        undeployedFuture.complete();
                    }
                } else if (!undeployedFuture.failed()) {
                    undeployedFuture.fail(d.cause());
                }
            });
        }
    }
}