Search in sources :

Example 1 with CompList

use of org.folio.okapi.util.CompList 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);
}
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) LaunchDescriptor(org.folio.okapi.bean.LaunchDescriptor)

Example 2 with CompList

use of org.folio.okapi.util.CompList 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);
        }
    });
}
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)

Example 3 with CompList

use of org.folio.okapi.util.CompList in project okapi by folio-org.

the class EnvManager method init.

public void init(Vertx vertx, Handler<ExtendedAsyncResult<Void>> fut) {
    logger.debug("starting EnvManager");
    envMap.init(vertx, "env", res -> {
        if (res.failed()) {
            fut.handle(new Failure<>(res.getType(), res.cause()));
        } else {
            envStore.getAll(res2 -> {
                if (res2.failed()) {
                    fut.handle(new Failure<>(res2.getType(), res2.cause()));
                } else {
                    CompList<List<Void>> futures = new CompList<>(INTERNAL);
                    for (EnvEntry e : res2.result()) {
                        Future<Void> f = Future.future();
                        add1(e, f::handle);
                        futures.add(f);
                    }
                    futures.all(fut);
                }
            });
        }
    });
}
Also used : List(java.util.List) LinkedList(java.util.LinkedList) CompList(org.folio.okapi.util.CompList) CompList(org.folio.okapi.util.CompList) EnvEntry(org.folio.okapi.bean.EnvEntry)

Example 4 with CompList

use of org.folio.okapi.util.CompList 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 5 with CompList

use of org.folio.okapi.util.CompList 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);
        }
    });
}
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)

Aggregations

CompList (org.folio.okapi.util.CompList)8 LinkedList (java.util.LinkedList)6 List (java.util.List)6 DeploymentDescriptor (org.folio.okapi.bean.DeploymentDescriptor)4 ModuleDescriptor (org.folio.okapi.bean.ModuleDescriptor)2 TenantModuleDescriptor (org.folio.okapi.bean.TenantModuleDescriptor)2 ArrayList (java.util.ArrayList)1 EnvEntry (org.folio.okapi.bean.EnvEntry)1 HealthDescriptor (org.folio.okapi.bean.HealthDescriptor)1 LaunchDescriptor (org.folio.okapi.bean.LaunchDescriptor)1 PermissionList (org.folio.okapi.bean.PermissionList)1 Tenant (org.folio.okapi.bean.Tenant)1