use of org.folio.okapi.bean.DeploymentDescriptor in project okapi by folio-org.
the class DeploymentManager method shutdownR.
private void shutdownR(Iterator<String> it, int count, Handler<ExtendedAsyncResult<Void>> fut) {
if (!it.hasNext()) {
if (count != 0) {
logger.info("All " + count + " modules shut down");
}
fut.handle(new Success<>());
} else {
DeploymentDescriptor md = list.get(it.next());
ModuleHandle mh = md.getModuleHandle();
logger.debug("Shutting down " + md.getSrvcId());
mh.stop(future -> shutdownR(it, count + 1, fut));
}
}
use of org.folio.okapi.bean.DeploymentDescriptor 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.DeploymentDescriptor in project okapi by folio-org.
the class DiscoveryManager method restartModules.
public void restartModules(Handler<ExtendedAsyncResult<Void>> fut) {
deploymentStore.getAll(res1 -> {
if (res1.failed()) {
fut.handle(new Failure<>(res1.getType(), res1.cause()));
} else {
CompList<List<Void>> futures = new CompList<>(INTERNAL);
for (DeploymentDescriptor dd : res1.result()) {
Future<DeploymentDescriptor> f = Future.future();
addAndDeploy1(dd, null, f::handle);
futures.add(f);
}
futures.all(fut);
}
});
}
use of org.folio.okapi.bean.DeploymentDescriptor in project okapi by folio-org.
the class DiscoveryManager method get.
public void get(String srvcId, Handler<ExtendedAsyncResult<List<DeploymentDescriptor>>> fut) {
deployments.get(srvcId, res -> {
if (res.failed()) {
fut.handle(new Failure<>(res.getType(), res.cause()));
} else {
List<DeploymentDescriptor> result = res.result();
Iterator<DeploymentDescriptor> it = result.iterator();
while (it.hasNext()) {
DeploymentDescriptor md = it.next();
String url = md.getUrl();
// but not those that have an explicit URL
if (clusterManager != null && url == null && !clusterManager.getNodes().contains(md.getNodeId())) {
it.remove();
}
}
fut.handle(new Success<>(result));
}
});
}
use of org.folio.okapi.bean.DeploymentDescriptor in project okapi by folio-org.
the class DiscoveryManager method callDeploy.
/**
* Helper to actually launch (deploy) a module on a node.
*/
private void callDeploy(String nodeId, ProxyContext pc, DeploymentDescriptor dd, Handler<ExtendedAsyncResult<DeploymentDescriptor>> fut) {
logger.debug("callDeploy starting for " + Json.encode(dd));
getNode(nodeId, noderes -> {
if (noderes.failed()) {
fut.handle(new Failure<>(noderes.getType(), noderes.cause()));
} else {
Map<String, String> headers = new HashMap<>();
if (pc != null) {
for (String s : pc.getCtx().request().headers().names()) {
if (s.startsWith("X-") || s.startsWith("x-")) {
final String v = pc.getCtx().request().headers().get(s);
headers.put(s, v);
}
}
}
OkapiClient ok = new OkapiClient(noderes.result().getUrl(), vertx, headers);
String reqdata = Json.encode(dd);
ok.post("/_/deployment/modules", reqdata, okres -> {
ok.close();
if (okres.failed()) {
fut.handle(new Failure<>(okres.getType(), okres.cause().getMessage()));
} else {
DeploymentDescriptor pmd = Json.decodeValue(okres.result(), DeploymentDescriptor.class);
fut.handle(new Success<>(pmd));
}
});
}
});
}
Aggregations