Search in sources :

Example 1 with HealthDescriptor

use of org.folio.okapi.bean.HealthDescriptor in project okapi by folio-org.

the class DiscoveryManager method healthList.

private void healthList(List<DeploymentDescriptor> list, Handler<ExtendedAsyncResult<List<HealthDescriptor>>> fut) {
    List<HealthDescriptor> all = new LinkedList<>();
    CompList<List<HealthDescriptor>> futures = new CompList<>(INTERNAL);
    for (DeploymentDescriptor md : list) {
        Future<HealthDescriptor> f = Future.future();
        health(md, res -> {
            if (res.succeeded()) {
                all.add(res.result());
            }
            f.handle(res);
        });
        futures.add(f);
    }
    futures.all(all, fut);
}
Also used : DeploymentDescriptor(org.folio.okapi.bean.DeploymentDescriptor) LinkedList(java.util.LinkedList) List(java.util.List) CompList(org.folio.okapi.util.CompList) CompList(org.folio.okapi.util.CompList) HealthDescriptor(org.folio.okapi.bean.HealthDescriptor) LinkedList(java.util.LinkedList)

Example 2 with HealthDescriptor

use of org.folio.okapi.bean.HealthDescriptor in project okapi by folio-org.

the class DiscoveryManager method health.

private void health(DeploymentDescriptor md, Handler<ExtendedAsyncResult<HealthDescriptor>> fut) {
    HealthDescriptor hd = new HealthDescriptor();
    String url = md.getUrl();
    hd.setInstId(md.getInstId());
    hd.setSrvcId(md.getSrvcId());
    if (url == null || url.length() == 0) {
        hd.setHealthMessage("Unknown");
        hd.setHealthStatus(false);
        fut.handle(new Success<>(hd));
    } else {
        HttpClientRequest req = httpClient.getAbs(url, res -> {
            res.endHandler(res1 -> {
                hd.setHealthMessage("OK");
                hd.setHealthStatus(true);
                fut.handle(new Success<>(hd));
            });
            res.exceptionHandler(res1 -> {
                hd.setHealthMessage("Fail: " + res1.getMessage());
                hd.setHealthStatus(false);
                fut.handle(new Success<>(hd));
            });
        });
        req.exceptionHandler(res -> {
            hd.setHealthMessage("Fail: " + res.getMessage());
            hd.setHealthStatus(false);
            fut.handle(new Success<>(hd));
        });
        req.end();
    }
}
Also used : HttpClientRequest(io.vertx.core.http.HttpClientRequest) HealthDescriptor(org.folio.okapi.bean.HealthDescriptor)

Aggregations

HealthDescriptor (org.folio.okapi.bean.HealthDescriptor)2 HttpClientRequest (io.vertx.core.http.HttpClientRequest)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 DeploymentDescriptor (org.folio.okapi.bean.DeploymentDescriptor)1 CompList (org.folio.okapi.util.CompList)1