Search in sources :

Example 16 with ModuleDescriptor

use of org.folio.okapi.bean.ModuleDescriptor in project okapi by folio-org.

the class DiscoveryManager method addAndDeploy2.

private void addAndDeploy2(DeploymentDescriptor dd, ProxyContext pc, Handler<ExtendedAsyncResult<DeploymentDescriptor>> fut, final String nodeId) {
    if (moduleManager == null) {
        fut.handle(new Failure<>(INTERNAL, "no module manager (should not happen)"));
        return;
    }
    String modId = dd.getSrvcId();
    moduleManager.get(modId, gres -> {
        if (gres.failed()) {
            if (gres.getType() == NOT_FOUND) {
                fut.handle(new Failure<>(NOT_FOUND, "Module " + modId + " not found"));
            } else {
                fut.handle(new Failure<>(gres.getType(), gres.cause()));
            }
            return;
        }
        ModuleDescriptor md = gres.result();
        LaunchDescriptor modLaunchDesc = md.getLaunchDescriptor();
        if (modLaunchDesc == null) {
            fut.handle(new Failure<>(USER, "Module " + modId + " has no launchDescriptor"));
            return;
        }
        dd.setDescriptor(modLaunchDesc);
        callDeploy(nodeId, pc, dd, fut);
    });
}
Also used : ModuleDescriptor(org.folio.okapi.bean.ModuleDescriptor) LaunchDescriptor(org.folio.okapi.bean.LaunchDescriptor)

Example 17 with ModuleDescriptor

use of org.folio.okapi.bean.ModuleDescriptor in project okapi by folio-org.

the class PullManager method merge.

private void merge(String urlBase, List<ModuleDescriptor> mlLocal, ModuleDescriptor[] mlRemote, Handler<ExtendedAsyncResult<List<ModuleDescriptor>>> fut) {
    TreeMap<String, Boolean> enabled = new TreeMap<>();
    for (ModuleDescriptor md : mlLocal) {
        enabled.put(md.getId(), false);
    }
    List<ModuleDescriptor> mlAdd = new LinkedList<>();
    for (ModuleDescriptor md : mlRemote) {
        if (!"okapi".equals(md.getProduct()) && enabled.get(md.getId()) == null) {
            mlAdd.add(md);
        }
    }
    logger.info("pull: " + mlAdd.size() + " MDs to fetch");
    List<ModuleDescriptor> mlList = new LinkedList<>();
    concurrentRuns = 0;
    concurrentComplete = false;
    getFull(urlBase, mlAdd.iterator(), mlList, res -> {
        if (res.failed()) {
            fut.handle(new Failure<>(res.getType(), res.cause()));
        } else {
            logger.info("pull: local insert");
            moduleManager.createList(mlList, true, res1 -> {
                if (res1.failed()) {
                    fut.handle(new Failure<>(res1.getType(), res1.cause()));
                } else {
                    fut.handle(new Success<>(mlAdd));
                }
            });
        }
    });
}
Also used : ModuleDescriptor(org.folio.okapi.bean.ModuleDescriptor) TreeMap(java.util.TreeMap) LinkedList(java.util.LinkedList)

Example 18 with ModuleDescriptor

use of org.folio.okapi.bean.ModuleDescriptor in project okapi by folio-org.

the class TenantManager method enableAndDisableModule.

private void enableAndDisableModule(Tenant tenant, String moduleFrom, String moduleTo, ProxyContext pc, Handler<ExtendedAsyncResult<String>> fut) {
    moduleManager.getLatest(moduleTo, resTo -> {
        if (resTo.failed()) {
            fut.handle(new Failure<>(resTo.getType(), resTo.cause()));
        } else {
            ModuleDescriptor mdTo = resTo.result();
            moduleManager.get(moduleFrom, resFrom -> {
                if (resFrom.failed()) {
                    fut.handle(new Failure<>(resFrom.getType(), resFrom.cause()));
                } else {
                    ModuleDescriptor mdFrom = resFrom.result();
                    enableAndDisableModule2(tenant, mdFrom, mdTo, pc, fut);
                }
            });
        }
    });
}
Also used : ModuleDescriptor(org.folio.okapi.bean.ModuleDescriptor) TenantModuleDescriptor(org.folio.okapi.bean.TenantModuleDescriptor)

Example 19 with ModuleDescriptor

use of org.folio.okapi.bean.ModuleDescriptor in project okapi by folio-org.

the class TenantManager method ead3RealoadPerms.

/**
 * enableAndDisable helper 3: Reload permissions. When we enable a module that
 * provides the tenantPermissions interface, we may have other modules already
 * enabled, who have not got their permissions pushed. Now that we have a
 * place to push those permissions to, we do it recursively for all enabled
 * modules.
 *
 * @param tenant
 * @param moduleFrom
 * @param mdTo
 * @param permsModule
 * @param pc
 * @param fut
 */
private void ead3RealoadPerms(Tenant tenant, Iterator<String> modit, String moduleFrom, ModuleDescriptor mdTo, ModuleDescriptor permsModule, ProxyContext pc, Handler<ExtendedAsyncResult<Void>> fut) {
    if (!modit.hasNext()) {
        pc.debug("ead3RealoadPerms: No more modules to reload");
        ead4Permissions(tenant, moduleFrom, mdTo, permsModule, pc, fut);
        return;
    }
    String mdid = modit.next();
    moduleManager.get(mdid, res -> {
        if (res.failed()) {
            // not likely to happen
            pc.responseError(res.getType(), res.cause());
            return;
        }
        ModuleDescriptor md = res.result();
        pc.debug("ead3RealoadPerms: Should reload perms for " + md.getName());
        tenantPerms(tenant, md, permsModule, pc, pres -> {
            if (pres.failed()) {
                // not likely to happen
                pc.responseError(res.getType(), res.cause());
                return;
            }
            ead3RealoadPerms(tenant, modit, moduleFrom, mdTo, permsModule, pc, fut);
        });
    });
}
Also used : ModuleDescriptor(org.folio.okapi.bean.ModuleDescriptor) TenantModuleDescriptor(org.folio.okapi.bean.TenantModuleDescriptor)

Example 20 with ModuleDescriptor

use of org.folio.okapi.bean.ModuleDescriptor in project okapi by folio-org.

the class TenantManager method installCommit2.

/* phase 2 enable modules for tenant */
private void installCommit2(Tenant tenant, ProxyContext pc, TenantInstallOptions options, Map<String, ModuleDescriptor> modsAvailable, List<TenantModuleDescriptor> tml, Iterator<TenantModuleDescriptor> it, Handler<ExtendedAsyncResult<Void>> fut) {
    if (it.hasNext()) {
        TenantModuleDescriptor tm = it.next();
        ModuleDescriptor mdFrom = null;
        ModuleDescriptor mdTo = null;
        if ("enable".equals(tm.getAction())) {
            if (tm.getFrom() != null) {
                mdFrom = modsAvailable.get(tm.getFrom());
            }
            mdTo = modsAvailable.get(tm.getId());
        } else if ("disable".equals(tm.getAction())) {
            mdFrom = modsAvailable.get(tm.getId());
        }
        if (mdFrom == null && mdTo == null) {
            installCommit2(tenant, pc, options, modsAvailable, tml, it, fut);
        } else {
            ead1TenantInterface(tenant, mdFrom, mdTo, pc, res -> {
                if (res.failed()) {
                    fut.handle(new Failure<>(res.getType(), res.cause()));
                } else {
                    installCommit2(tenant, pc, options, modsAvailable, tml, it, fut);
                }
            });
        }
    } else {
        installCommit3(tenant, pc, options, modsAvailable, tml, tml.iterator(), fut);
    }
}
Also used : TenantModuleDescriptor(org.folio.okapi.bean.TenantModuleDescriptor) ModuleDescriptor(org.folio.okapi.bean.ModuleDescriptor) TenantModuleDescriptor(org.folio.okapi.bean.TenantModuleDescriptor)

Aggregations

ModuleDescriptor (org.folio.okapi.bean.ModuleDescriptor)34 TenantModuleDescriptor (org.folio.okapi.bean.TenantModuleDescriptor)24 InterfaceDescriptor (org.folio.okapi.bean.InterfaceDescriptor)7 LinkedList (java.util.LinkedList)6 DecodeException (io.vertx.core.json.DecodeException)4 HashMap (java.util.HashMap)4 Failure (org.folio.okapi.common.Failure)4 Buffer (io.vertx.core.buffer.Buffer)3 ArrayList (java.util.ArrayList)3 ModuleInstance (org.folio.okapi.bean.ModuleInstance)3 RoutingEntry (org.folio.okapi.bean.RoutingEntry)3 Tenant (org.folio.okapi.bean.Tenant)3 HttpClientRequest (io.vertx.core.http.HttpClientRequest)2 LinkedHashMap (java.util.LinkedHashMap)2 ModuleId (org.folio.okapi.common.ModuleId)2 CompList (org.folio.okapi.util.CompList)2 HttpServerRequest (io.vertx.core.http.HttpServerRequest)1 RoutingContext (io.vertx.ext.web.RoutingContext)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1