use of org.folio.okapi.bean.DeploymentDescriptor in project okapi by folio-org.
the class DiscoveryManager method autoDeploy2.
private void autoDeploy2(ModuleDescriptor md, ProxyContext pc, Collection<String> allNodes, List<DeploymentDescriptor> ddList, Handler<ExtendedAsyncResult<Void>> fut) {
LaunchDescriptor modLaunchDesc = md.getLaunchDescriptor();
CompList<List<Void>> futures = new CompList<>(USER);
// deploy on all nodes for now
for (String node : allNodes) {
// check if we have deploy on node
logger.info("autoDeploy " + md.getId() + " consider " + node);
DeploymentDescriptor foundDd = null;
for (DeploymentDescriptor dd : ddList) {
if (dd.getNodeId() == null || node.equals(dd.getNodeId())) {
foundDd = dd;
}
}
if (foundDd == null) {
logger.info("autoDeploy " + md.getId() + " must deploy on node " + node);
DeploymentDescriptor dd = new DeploymentDescriptor();
dd.setDescriptor(modLaunchDesc);
dd.setSrvcId(md.getId());
dd.setNodeId(node);
Future<DeploymentDescriptor> f = Future.future();
addAndDeploy(dd, pc, f::handle);
futures.add(f);
} else {
logger.info("autoDeploy " + md.getId() + " already deployed on " + node);
}
}
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, String instId, Handler<ExtendedAsyncResult<DeploymentDescriptor>> fut) {
deployments.get(srvcId, instId, resGet -> {
if (resGet.failed()) {
fut.handle(new Failure<>(resGet.getType(), resGet.cause()));
} else {
DeploymentDescriptor md = resGet.result();
String url = md.getUrl();
// check that the node is alive, but only on non-url instances
if (clusterManager != null && url == null && !clusterManager.getNodes().contains(md.getNodeId())) {
fut.handle(new Failure<>(NOT_FOUND, "gone"));
return;
}
fut.handle(new Success<>(md));
}
});
}
use of org.folio.okapi.bean.DeploymentDescriptor in project okapi by folio-org.
the class DiscoveryManager method autoUndeploy.
public void autoUndeploy(ModuleDescriptor md, ProxyContext pc, Handler<ExtendedAsyncResult<Void>> fut) {
logger.info("autoUndeploy " + md.getId());
if (md.getId().startsWith(XOkapiHeaders.OKAPI_MODULE)) {
fut.handle(new Success<>());
return;
}
deployments.get(md.getId(), res -> {
if (res.failed()) {
fut.handle(new Failure<>(res.getType(), res.cause()));
} else {
List<DeploymentDescriptor> ddList = res.result();
CompList<List<Void>> futures = new CompList<>(USER);
for (DeploymentDescriptor dd : ddList) {
if (dd.getNodeId() != null) {
Future<Void> f = Future.future();
callUndeploy(dd, pc, f::handle);
futures.add(f);
}
}
futures.all(fut);
}
});
}
use of org.folio.okapi.bean.DeploymentDescriptor in project okapi by folio-org.
the class InternalModule method createDeployment.
private void createDeployment(ProxyContext pc, String body, Handler<ExtendedAsyncResult<String>> fut) {
try {
final DeploymentDescriptor pmd = Json.decodeValue(body, DeploymentDescriptor.class);
deploymentManager.deploy(pmd, res -> {
if (res.failed()) {
fut.handle(new Failure<>(res.getType(), res.cause()));
return;
}
final String s = Json.encodePrettily(res.result());
location(pc, res.result().getInstId(), null, s, fut);
});
} catch (DecodeException ex) {
fut.handle(new Failure<>(USER, ex));
}
}
use of org.folio.okapi.bean.DeploymentDescriptor in project okapi by folio-org.
the class BeanTest method testDeploymentDescriptor2.
@Test
public void testDeploymentDescriptor2() {
int fail = 0;
final String docSampleDeployment = "{" + LS + " \"srvcId\" : \"sample-module-1\"," + LS + " \"descriptor\" : {" + LS + " \"exec\" : " + "\"java -Dport=%p -jar ../okapi-test-module/target/okapi-test-module-fat.jar\"," + LS + " \"env\" : [ {" + LS + " \"name\" : \"helloGreeting\"" + LS + " } ]" + LS + " }" + LS + "}";
try {
final DeploymentDescriptor md = Json.decodeValue(docSampleDeployment, DeploymentDescriptor.class);
String pretty = Json.encodePrettily(md);
assertEquals(docSampleDeployment, pretty);
} catch (DecodeException ex) {
ex.printStackTrace();
fail = 400;
}
assertEquals(0, fail);
}
Aggregations