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);
}
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();
}
}
Aggregations