Example usage for io.vertx.core AsyncResult succeeded

List of usage examples for io.vertx.core AsyncResult succeeded

Introduction

In this page you can find the example usage for io.vertx.core AsyncResult succeeded.

Prototype

boolean succeeded();

Source Link

Document

Did it succeed?

Usage

From source file:co.runrightfast.vertx.core.impl.VertxServiceImpl.java

License:Apache License

private void initVertx() {
    if (this.vertxOptions.isClustered()) {
        final CompletableFuture<AsyncResult<Vertx>> clusteredVertxResult = new CompletableFuture<>();
        Vertx.clusteredVertx(vertxOptions, clusteredVertxResult::complete);
        while (true) {
            try {
                final AsyncResult<Vertx> result = clusteredVertxResult.get(10, TimeUnit.SECONDS);
                if (result.succeeded()) {
                    this.vertx = result.result();
                    LOG.logp(INFO, getClass().getName(), "initVertx",
                            "Vertx clustered instance has been created");
                } else {
                    throw new RuntimeException("Failed to start a clustered Vertx instance", result.cause());
                }/*from  w  ww.  j av a 2 s  .  co m*/
                break;
            } catch (final ExecutionException ex) {
                throw new RuntimeException("Failed to start a clustered Vertx instance", ex);
            } catch (final TimeoutException ex) {
                LOG.logp(INFO, getClass().getName(), "initVertx", "Waiting for Vertx to start");
            } catch (final InterruptedException ex) {
                throw new RuntimeException(ex);
            }
        }
    } else {
        this.vertx = Vertx.vertx(vertxOptions);
        LOG.logp(INFO, getClass().getName(), "initVertx", "Vertx instance has been created");
    }
}

From source file:co.runrightfast.vertx.core.impl.VertxServiceImpl.java

License:Apache License

private void deployVerticleManager() throws InterruptedException {
    final CompletableFuture<AsyncResult<String>> deployVerticleResult = new CompletableFuture<>();
    vertx.deployVerticle(verticleManager, deployVerticleResult::complete);
    while (true) {
        try {/*w  w  w  . j ava 2  s.c  om*/
            final AsyncResult<String> result = deployVerticleResult.get(10, TimeUnit.SECONDS);
            if (result.succeeded()) {
                LOG.logp(INFO, getClass().getName(), "deployVerticleManager", result.result());
            } else {
                throw new RuntimeException("Failed to deploy RunRightFastVerticleManager", result.cause());
            }
            break;
        } catch (final ExecutionException ex) {
            throw new RuntimeException("Failed to deploy RunRightFastVerticleManager", ex);
        } catch (final TimeoutException ex) {
            LOG.logp(INFO, getClass().getName(), "deployVerticleManager",
                    "Waiting for RunRightFastVerticleManager deployment to complete");
        } catch (final InterruptedException ex) {
            throw new RuntimeException(ex);
        }
    }
}

From source file:co.runrightfast.vertx.core.RunRightFastVerticle.java

License:Apache License

private <REQ extends Message, RESP extends Message> Handler<AsyncResult<Void>> messageConsumerCompletionHandler(
        final String address, final Optional<Handler<AsyncResult<Void>>> handler,
        final MessageConsumerConfig<REQ, RESP> config) {
    return (AsyncResult<Void> result) -> {
        if (result.succeeded()) {
            info.log("messageConsumerCompletionHandler.succeeded",
                    () -> messageConsumerLogInfo(address, config));
        } else {//from   w  w w.  j a va 2  s  . c o  m
            error.log("messageConsumerCompletionHandler.failed", () -> messageConsumerLogInfo(address, config),
                    result.cause());
        }
        handler.ifPresent(h -> h.handle(result));
    };
}

From source file:com.acme.rxjava.example.IrcClient.java

License:Apache License

public void connect(Handler<AsyncResult<IrcClient>> connectHandler) {
    this.delegate.connect(new Handler<AsyncResult<com.acme.example.IrcClient>>() {
        public void handle(AsyncResult<com.acme.example.IrcClient> event) {
            AsyncResult<IrcClient> f;
            if (event.succeeded()) {
                f = InternalHelper.<IrcClient>result(new IrcClient(event.result()));
            } else {
                f = InternalHelper.<IrcClient>failure(event.cause());
            }/*from   w w w  .  j  av  a  2 s.c  o  m*/
            connectHandler.handle(f);
        }
    });
}

From source file:com.atypon.wayf.verticle.WayfVerticle.java

License:Apache License

private void completeStartup(AsyncResult<HttpServer> http, Future<Void> fut) {
    if (http.succeeded()) {
        initConfigs();//  w  ww  .  ja  va2  s  .  c om

        LOG.info("SUCCESS: wayf-cloud successfully initialized");
        fut.complete();
    } else {
        LOG.debug("FAILURE: Could not start wayf-cloud due to exception", http.cause());
        fut.fail(http.cause());
    }
}

From source file:com.diabolicallabs.process.manager.rxjava.service.KnowledgeService.java

License:Apache License

public KnowledgeService getProcessService(Handler<AsyncResult<ProcessService>> handler) {
    delegate.getProcessService(/*from   ww w .  j  a  v a2s.  c  o  m*/
            new Handler<AsyncResult<com.diabolicallabs.process.manager.service.ProcessService>>() {
                public void handle(AsyncResult<com.diabolicallabs.process.manager.service.ProcessService> ar) {
                    if (ar.succeeded()) {
                        handler.handle(
                                io.vertx.core.Future.succeededFuture(ProcessService.newInstance(ar.result())));
                    } else {
                        handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
                    }
                }
            });
    return this;
}

From source file:com.diabolicallabs.process.manager.rxjava.service.KnowledgeService.java

License:Apache License

public KnowledgeService getRuleService(Handler<AsyncResult<RuleService>> handler) {
    delegate.getRuleService(new Handler<AsyncResult<com.diabolicallabs.process.manager.service.RuleService>>() {
        public void handle(AsyncResult<com.diabolicallabs.process.manager.service.RuleService> ar) {
            if (ar.succeeded()) {
                handler.handle(io.vertx.core.Future.succeededFuture(RuleService.newInstance(ar.result())));
            } else {
                handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
            }//from w  w  w .  j  a  v a  2 s  .c  o m
        }
    });
    return this;
}

From source file:com.diabolicallabs.process.manager.rxjava.service.KnowledgeService.java

License:Apache License

public KnowledgeService getTaskService(Handler<AsyncResult<TaskService>> handler) {
    delegate.getTaskService(new Handler<AsyncResult<com.diabolicallabs.process.manager.service.TaskService>>() {
        public void handle(AsyncResult<com.diabolicallabs.process.manager.service.TaskService> ar) {
            if (ar.succeeded()) {
                handler.handle(io.vertx.core.Future.succeededFuture(TaskService.newInstance(ar.result())));
            } else {
                handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
            }/*from  w w w  . ja  va2 s. c o  m*/
        }
    });
    return this;
}

From source file:com.diabolicallabs.process.manager.rxjava.service.KnowledgeServiceFactory.java

License:Apache License

public KnowledgeServiceFactory getKnowledgeService(Handler<AsyncResult<KnowledgeService>> handler) {
    delegate.getKnowledgeService(/*www. ja  v  a2 s  . c o  m*/
            new Handler<AsyncResult<com.diabolicallabs.process.manager.service.KnowledgeService>>() {
                public void handle(
                        AsyncResult<com.diabolicallabs.process.manager.service.KnowledgeService> ar) {
                    if (ar.succeeded()) {
                        handler.handle(io.vertx.core.Future
                                .succeededFuture(KnowledgeService.newInstance(ar.result())));
                    } else {
                        handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
                    }
                }
            });
    return this;
}

From source file:com.diabolicallabs.process.manager.rxjava.service.ProcessService.java

License:Apache License

public ProcessService create(String processId, Handler<AsyncResult<ProcessInstanceService>> handler) {
    delegate.create(processId,// ww w. ja  v a  2 s  .  com
            new Handler<AsyncResult<com.diabolicallabs.process.manager.service.ProcessInstanceService>>() {
                public void handle(
                        AsyncResult<com.diabolicallabs.process.manager.service.ProcessInstanceService> ar) {
                    if (ar.succeeded()) {
                        handler.handle(io.vertx.core.Future
                                .succeededFuture(ProcessInstanceService.newInstance(ar.result())));
                    } else {
                        handler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
                    }
                }
            });
    return this;
}