use of org.folio.okapi.common.Success in project okapi by folio-org.
the class DeploymentManager method deploy2.
private void deploy2(Handler<ExtendedAsyncResult<DeploymentDescriptor>> fut, Timer.Context tim, int usePort, DeploymentDescriptor md1, String url) {
LaunchDescriptor descriptor = md1.getDescriptor();
if (descriptor == null) {
ports.free(usePort);
fut.handle(new Failure<>(USER, "No LaunchDescriptor"));
tim.close();
return;
}
HashMap<String, EnvEntry> entries = new HashMap<>();
EnvEntry[] env = descriptor.getEnv();
if (env != null) {
for (EnvEntry e : env) {
entries.put(e.getName(), e);
}
}
em.get(eres -> {
if (eres.failed()) {
ports.free(usePort);
fut.handle(new Failure<>(INTERNAL, "get env: " + eres.cause().getMessage()));
tim.close();
} else {
for (EnvEntry er : eres.result()) {
entries.put(er.getName(), er);
}
if (entries.size() > 0) {
EnvEntry[] nenv = new EnvEntry[entries.size()];
int i = 0;
for (Entry<String, EnvEntry> key : entries.entrySet()) {
nenv[i++] = key.getValue();
}
descriptor.setEnv(nenv);
}
ModuleHandle mh = ModuleHandleFactory.create(vertx, descriptor, ports, usePort);
mh.start(future -> {
if (future.succeeded()) {
DeploymentDescriptor md2 = new DeploymentDescriptor(md1.getInstId(), md1.getSrvcId(), url, md1.getDescriptor(), mh);
md2.setNodeId(md1.getNodeId() != null ? md1.getNodeId() : host);
list.put(md2.getInstId(), md2);
tim.close();
dm.add(md2, res -> fut.handle(new Success<>(md2)));
} else {
tim.close();
ports.free(usePort);
logger.warn("Deploying " + md1.getSrvcId() + " failed");
fut.handle(new Failure<>(USER, future.cause()));
}
});
}
});
}
use of org.folio.okapi.common.Success in project okapi by folio-org.
the class MongoUtil method delete.
public void delete(String id, Handler<ExtendedAsyncResult<Void>> fut) {
JsonObject jq = new JsonObject().put("_id", id);
cli.removeDocument(collection, jq, rres -> {
if (rres.failed()) {
fut.handle(new Failure<>(INTERNAL, rres.cause()));
} else if (rres.result().getRemovedCount() == 0) {
fut.handle(new Failure<>(NOT_FOUND, id));
} else {
fut.handle(new Success<>());
}
});
}
Aggregations