Search in sources :

Example 1 with SetEnvPaths

use of org.apache.airavata.model.appcatalog.appdeployment.SetEnvPaths in project airavata by apache.

the class LocalJobSubmissionTask method initProcessBuilder.

private void initProcessBuilder(ApplicationDeploymentDescription app, List<String> cmdList) {
    builder = new ProcessBuilder(cmdList);
    List<SetEnvPaths> setEnvironment = app.getSetEnvironment();
    if (setEnvironment != null) {
        for (SetEnvPaths envPath : setEnvironment) {
            Map<String, String> builderEnv = builder.environment();
            builderEnv.put(envPath.getName(), envPath.getValue());
        }
    }
}
Also used : SetEnvPaths(org.apache.airavata.model.appcatalog.appdeployment.SetEnvPaths)

Example 2 with SetEnvPaths

use of org.apache.airavata.model.appcatalog.appdeployment.SetEnvPaths in project airavata by apache.

the class AppDeploymentUtil method createEnvPath.

public static SetEnvPaths createEnvPath(String name, String val) {
    SetEnvPaths setEnvPaths = new SetEnvPaths();
    setEnvPaths.setName(name);
    setEnvPaths.setValue(val);
    return setEnvPaths;
}
Also used : SetEnvPaths(org.apache.airavata.model.appcatalog.appdeployment.SetEnvPaths)

Example 3 with SetEnvPaths

use of org.apache.airavata.model.appcatalog.appdeployment.SetEnvPaths in project airavata by apache.

the class ApplicationDeploymentImpl method updateApplicationDeployment.

@Override
public void updateApplicationDeployment(String deploymentId, ApplicationDeploymentDescription updatedDeployment) throws AppCatalogException {
    try {
        AppDeploymentResource deploymentResource = new AppDeploymentResource();
        AppDeploymentResource existingDep = (AppDeploymentResource) deploymentResource.get(deploymentId);
        ComputeResourceResource computeHostResource = new ComputeResourceResource();
        AppModuleResource moduleResource = new AppModuleResource();
        if (!computeHostResource.isExists(updatedDeployment.getComputeHostId())) {
            logger.error("Compute host does not exist in the system. Please create a Compute host first...");
            throw new AppCatalogException("Compute host does not exist in the system. Please create a Compute host first...");
        }
        if (!moduleResource.isExists(updatedDeployment.getAppModuleId())) {
            logger.error("Application module does not exist in the system. Please create an application module first...");
            throw new AppCatalogException("Application module does not exist in the system. Please create an application module first...");
        }
        AppModuleResource module = (AppModuleResource) moduleResource.get(updatedDeployment.getAppModuleId());
        existingDep.setAppModuleId(updatedDeployment.getAppModuleId());
        existingDep.setModuleResource(module);
        existingDep.setHostId(updatedDeployment.getComputeHostId());
        existingDep.setHostResource((ComputeResourceResource) computeHostResource.get(updatedDeployment.getComputeHostId()));
        existingDep.setAppDes(updatedDeployment.getAppDeploymentDescription());
        existingDep.setExecutablePath(updatedDeployment.getExecutablePath());
        existingDep.setDefaultQueueName(updatedDeployment.getDefaultQueueName());
        existingDep.setDefaultCPUCount(updatedDeployment.getDefaultCPUCount());
        existingDep.setDefaultNodeCount(updatedDeployment.getDefaultNodeCount());
        existingDep.setDefaultWalltime(updatedDeployment.getDefaultWalltime());
        existingDep.setEditableByUser(updatedDeployment.isEditableByUser());
        if (updatedDeployment.getParallelism() != null) {
            existingDep.setParallelism(updatedDeployment.getParallelism().toString());
        }
        existingDep.save();
        // remove existing module load commands
        ModuleLoadCmdResource cmdResource = new ModuleLoadCmdResource();
        Map<String, String> ids = new HashMap<String, String>();
        ids.put(AppCatAbstractResource.ModuleLoadCmdConstants.APP_DEPLOYMENT_ID, deploymentId);
        cmdResource.remove(ids);
        List<CommandObject> moduleLoadCmds = updatedDeployment.getModuleLoadCmds();
        if (moduleLoadCmds != null && !moduleLoadCmds.isEmpty()) {
            for (CommandObject cmd : moduleLoadCmds) {
                ids = new HashMap<String, String>();
                ids.put(AppCatAbstractResource.ModuleLoadCmdConstants.APP_DEPLOYMENT_ID, deploymentId);
                ids.put(AppCatAbstractResource.ModuleLoadCmdConstants.CMD, cmd.getCommand());
                if (cmdResource.isExists(ids)) {
                    cmdResource = (ModuleLoadCmdResource) cmdResource.get(ids);
                }
                cmdResource.setCmd(cmd.getCommand());
                cmdResource.setAppDeploymentResource(existingDep);
                cmdResource.setAppDeploymentId(deploymentId);
                cmdResource.setOrder(cmd.getCommandOrder());
                cmdResource.save();
            }
        }
        PreJobCommandResource preJobCommandResource = new PreJobCommandResource();
        ids = new HashMap<String, String>();
        ids.put(AppCatAbstractResource.PreJobCommandConstants.DEPLOYMENT_ID, deploymentId);
        preJobCommandResource.remove(ids);
        List<CommandObject> preJobCommands = updatedDeployment.getPreJobCommands();
        if (preJobCommands != null && !preJobCommands.isEmpty()) {
            for (CommandObject cmd : preJobCommands) {
                ids = new HashMap<String, String>();
                ids.put(AppCatAbstractResource.PreJobCommandConstants.DEPLOYMENT_ID, deploymentId);
                ids.put(AppCatAbstractResource.PreJobCommandConstants.COMMAND, cmd.getCommand());
                if (preJobCommandResource.isExists(ids)) {
                    preJobCommandResource = (PreJobCommandResource) preJobCommandResource.get(ids);
                }
                preJobCommandResource.setCommand(cmd.getCommand());
                preJobCommandResource.setAppDeploymentResource(existingDep);
                preJobCommandResource.setAppDeploymentId(deploymentId);
                preJobCommandResource.setOrder(cmd.getCommandOrder());
                preJobCommandResource.save();
            }
        }
        PostJobCommandResource postJobCommandResource = new PostJobCommandResource();
        ids = new HashMap<String, String>();
        ids.put(AppCatAbstractResource.PostJobCommandConstants.DEPLOYMENT_ID, deploymentId);
        postJobCommandResource.remove(ids);
        List<CommandObject> postJobCommands = updatedDeployment.getPostJobCommands();
        if (postJobCommands != null && !postJobCommands.isEmpty()) {
            for (CommandObject cmd : postJobCommands) {
                ids = new HashMap<String, String>();
                ids.put(AppCatAbstractResource.PostJobCommandConstants.DEPLOYMENT_ID, deploymentId);
                ids.put(AppCatAbstractResource.PostJobCommandConstants.COMMAND, cmd.getCommand());
                if (postJobCommandResource.isExists(ids)) {
                    postJobCommandResource = (PostJobCommandResource) postJobCommandResource.get(ids);
                }
                postJobCommandResource.setCommand(cmd.getCommand());
                postJobCommandResource.setOrder(cmd.getCommandOrder());
                postJobCommandResource.setAppDeploymentResource(existingDep);
                postJobCommandResource.setAppDeploymentId(deploymentId);
                postJobCommandResource.save();
            }
        }
        // remove existing lib prepand paths
        LibraryPrepandPathResource prepandPathResource = new LibraryPrepandPathResource();
        ids = new HashMap<String, String>();
        ids.put(AppCatAbstractResource.LibraryPrepandPathConstants.DEPLOYMENT_ID, deploymentId);
        prepandPathResource.remove(ids);
        List<SetEnvPaths> libPrependPaths = updatedDeployment.getLibPrependPaths();
        if (libPrependPaths != null && !libPrependPaths.isEmpty()) {
            for (SetEnvPaths path : libPrependPaths) {
                ids = new HashMap<String, String>();
                ids.put(AppCatAbstractResource.LibraryPrepandPathConstants.DEPLOYMENT_ID, deploymentId);
                ids.put(AppCatAbstractResource.LibraryPrepandPathConstants.NAME, path.getName());
                if (prepandPathResource.isExists(ids)) {
                    prepandPathResource = (LibraryPrepandPathResource) prepandPathResource.get(ids);
                }
                prepandPathResource.setAppDeploymentResource(existingDep);
                prepandPathResource.setName(path.getName());
                prepandPathResource.setValue(path.getValue());
                prepandPathResource.setDeploymentId(deploymentId);
                prepandPathResource.save();
            }
        }
        List<SetEnvPaths> libApendPaths = updatedDeployment.getLibAppendPaths();
        // remove lib append paths
        LibraryApendPathResource apendPathResource = new LibraryApendPathResource();
        ids = new HashMap<String, String>();
        ids.put(AppCatAbstractResource.LibraryApendPathConstants.DEPLOYMENT_ID, deploymentId);
        apendPathResource.remove(ids);
        if (libApendPaths != null && !libApendPaths.isEmpty()) {
            for (SetEnvPaths path : libApendPaths) {
                ids = new HashMap<String, String>();
                ids.put(AppCatAbstractResource.LibraryApendPathConstants.DEPLOYMENT_ID, deploymentId);
                ids.put(AppCatAbstractResource.LibraryApendPathConstants.NAME, path.getName());
                if (apendPathResource.isExists(ids)) {
                    apendPathResource = (LibraryApendPathResource) apendPathResource.get(ids);
                }
                apendPathResource.setAppDeploymentResource(existingDep);
                apendPathResource.setName(path.getName());
                apendPathResource.setValue(path.getValue());
                apendPathResource.setDeploymentId(deploymentId);
                apendPathResource.save();
            }
        }
        List<SetEnvPaths> setEnvironment = updatedDeployment.getSetEnvironment();
        // remove existing setEnvPaths
        AppEnvironmentResource environmentResource = new AppEnvironmentResource();
        ids = new HashMap<String, String>();
        ids.put(AppCatAbstractResource.AppEnvironmentConstants.DEPLOYMENT_ID, deploymentId);
        environmentResource.remove(ids);
        if (setEnvironment != null && !setEnvironment.isEmpty()) {
            for (SetEnvPaths path : setEnvironment) {
                ids = new HashMap<String, String>();
                ids.put(AppCatAbstractResource.AppEnvironmentConstants.DEPLOYMENT_ID, deploymentId);
                ids.put(AppCatAbstractResource.AppEnvironmentConstants.NAME, path.getName());
                if (environmentResource.isExists(ids)) {
                    environmentResource = (AppEnvironmentResource) environmentResource.get(ids);
                }
                environmentResource.setAppDeploymentResource(existingDep);
                environmentResource.setName(path.getName());
                environmentResource.setValue(path.getValue());
                environmentResource.setDeploymentId(deploymentId);
                environmentResource.setOrder(path.getEnvPathOrder());
                environmentResource.save();
            }
        }
    } catch (Exception e) {
        logger.error("Error while updating application deployment...", e);
        throw new AppCatalogException(e);
    }
}
Also used : HashMap(java.util.HashMap) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) CommandObject(org.apache.airavata.model.appcatalog.appdeployment.CommandObject) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) SetEnvPaths(org.apache.airavata.model.appcatalog.appdeployment.SetEnvPaths)

Example 4 with SetEnvPaths

use of org.apache.airavata.model.appcatalog.appdeployment.SetEnvPaths in project airavata by apache.

the class ApplicationDeploymentImpl method addApplicationDeployment.

@Override
public String addApplicationDeployment(ApplicationDeploymentDescription deploymentDescription, String gatewayId) throws AppCatalogException {
    try {
        AppDeploymentResource deploymentResource = new AppDeploymentResource();
        ComputeResourceResource computeHostResource = new ComputeResourceResource();
        AppModuleResource moduleResource = new AppModuleResource();
        if (!computeHostResource.isExists(deploymentDescription.getComputeHostId())) {
            logger.error("Compute host does not exist in the system. Please create a Compute host first...");
            throw new AppCatalogException("Compute host does not exist in the system. Please create a Compute host first...");
        }
        if (!moduleResource.isExists(deploymentDescription.getAppModuleId())) {
            logger.error("Application module does not exist in the system. Please create an application module first...");
            throw new AppCatalogException("Application module does not exist in the system. Please create an application module first...");
        }
        AppModuleResource module = (AppModuleResource) moduleResource.get(deploymentDescription.getAppModuleId());
        ComputeResourceResource hostResource = (ComputeResourceResource) computeHostResource.get(deploymentDescription.getComputeHostId());
        deploymentResource.setDeploymentId(hostResource.getHostName() + "_" + deploymentDescription.getAppModuleId());
        deploymentResource.setAppModuleId(deploymentDescription.getAppModuleId());
        deploymentResource.setModuleResource(module);
        deploymentResource.setHostId(deploymentDescription.getComputeHostId());
        deploymentResource.setHostResource(hostResource);
        deploymentResource.setAppDes(deploymentDescription.getAppDeploymentDescription());
        deploymentResource.setExecutablePath(deploymentDescription.getExecutablePath());
        deploymentResource.setGatewayId(gatewayId);
        deploymentResource.setDefaultQueueName(deploymentDescription.getDefaultQueueName());
        deploymentResource.setDefaultCPUCount(deploymentDescription.getDefaultCPUCount());
        deploymentResource.setDefaultNodeCount(deploymentDescription.getDefaultNodeCount());
        deploymentResource.setDefaultWalltime(deploymentDescription.getDefaultWalltime());
        deploymentResource.setEditableByUser(deploymentDescription.isEditableByUser());
        ApplicationParallelismType parallelism = deploymentDescription.getParallelism();
        if (parallelism != null) {
            deploymentResource.setParallelism(parallelism.toString());
        }
        deploymentResource.save();
        deploymentDescription.setAppDeploymentId(deploymentResource.getDeploymentId());
        List<CommandObject> moduleLoadCmds = deploymentDescription.getModuleLoadCmds();
        if (moduleLoadCmds != null && !moduleLoadCmds.isEmpty()) {
            for (CommandObject cmd : moduleLoadCmds) {
                ModuleLoadCmdResource cmdResource = new ModuleLoadCmdResource();
                cmdResource.setAppDeploymentId(deploymentDescription.getAppDeploymentId());
                cmdResource.setOrder(cmd.getCommandOrder());
                cmdResource.setCmd(cmd.getCommand());
                cmdResource.save();
            }
        }
        List<CommandObject> preJobCommands = deploymentDescription.getPreJobCommands();
        if (preJobCommands != null && !preJobCommands.isEmpty()) {
            for (CommandObject cmd : preJobCommands) {
                PreJobCommandResource cmdResource = new PreJobCommandResource();
                cmdResource.setAppDeploymentId(deploymentDescription.getAppDeploymentId());
                cmdResource.setCommand(cmd.getCommand());
                cmdResource.setOrder(cmd.getCommandOrder());
                cmdResource.save();
            }
        }
        List<CommandObject> postJobCommands = deploymentDescription.getPostJobCommands();
        if (postJobCommands != null && !postJobCommands.isEmpty()) {
            for (CommandObject cmd : postJobCommands) {
                PostJobCommandResource cmdResource = new PostJobCommandResource();
                cmdResource.setAppDeploymentId(deploymentDescription.getAppDeploymentId());
                cmdResource.setCommand(cmd.getCommand());
                cmdResource.setOrder(cmd.getCommandOrder());
                cmdResource.save();
            }
        }
        List<SetEnvPaths> libPrependPaths = deploymentDescription.getLibPrependPaths();
        if (libPrependPaths != null && !libPrependPaths.isEmpty()) {
            for (SetEnvPaths path : libPrependPaths) {
                LibraryPrepandPathResource prepandPathResource = new LibraryPrepandPathResource();
                prepandPathResource.setAppDeploymentResource(deploymentResource);
                prepandPathResource.setName(path.getName());
                prepandPathResource.setValue(path.getValue());
                prepandPathResource.setDeploymentId(deploymentResource.getDeploymentId());
                prepandPathResource.save();
            }
        }
        List<SetEnvPaths> libApendPaths = deploymentDescription.getLibAppendPaths();
        if (libApendPaths != null && !libApendPaths.isEmpty()) {
            for (SetEnvPaths path : libApendPaths) {
                LibraryApendPathResource apendPathResource = new LibraryApendPathResource();
                apendPathResource.setAppDeploymentResource(deploymentResource);
                apendPathResource.setName(path.getName());
                apendPathResource.setValue(path.getValue());
                apendPathResource.setDeploymentId(deploymentResource.getDeploymentId());
                apendPathResource.save();
            }
        }
        List<SetEnvPaths> setEnvironment = deploymentDescription.getSetEnvironment();
        if (setEnvironment != null && !setEnvironment.isEmpty()) {
            for (SetEnvPaths path : setEnvironment) {
                AppEnvironmentResource environmentResource = new AppEnvironmentResource();
                environmentResource.setAppDeploymentResource(deploymentResource);
                environmentResource.setName(path.getName());
                environmentResource.setValue(path.getValue());
                environmentResource.setDeploymentId(deploymentResource.getDeploymentId());
                environmentResource.setOrder(path.getEnvPathOrder());
                environmentResource.save();
            }
        }
        return deploymentResource.getDeploymentId();
    } catch (Exception e) {
        logger.error("Error while saving application deployment...", e);
        throw new AppCatalogException(e);
    }
}
Also used : ApplicationParallelismType(org.apache.airavata.model.parallelism.ApplicationParallelismType) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) CommandObject(org.apache.airavata.model.appcatalog.appdeployment.CommandObject) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) SetEnvPaths(org.apache.airavata.model.appcatalog.appdeployment.SetEnvPaths)

Example 5 with SetEnvPaths

use of org.apache.airavata.model.appcatalog.appdeployment.SetEnvPaths in project airavata by apache.

the class AppCatalogThriftConversion method getSetEnvPath.

public static SetEnvPaths getSetEnvPath(AppCatalogResource resource) {
    SetEnvPaths envPaths = new SetEnvPaths();
    if (resource instanceof LibraryPrepandPathResource) {
        envPaths.setName(((LibraryPrepandPathResource) resource).getName());
        envPaths.setValue(((LibraryPrepandPathResource) resource).getValue());
        return envPaths;
    } else if (resource instanceof LibraryApendPathResource) {
        envPaths.setName(((LibraryApendPathResource) resource).getName());
        envPaths.setValue(((LibraryApendPathResource) resource).getValue());
        return envPaths;
    } else if (resource instanceof AppEnvironmentResource) {
        AppEnvironmentResource environmentResource = (AppEnvironmentResource) resource;
        envPaths.setName(environmentResource.getName());
        envPaths.setValue(environmentResource.getValue());
        if (environmentResource.getOrder() != null) {
            envPaths.setEnvPathOrder(environmentResource.getOrder());
        }
        return envPaths;
    } else {
        return null;
    }
}
Also used : SetEnvPaths(org.apache.airavata.model.appcatalog.appdeployment.SetEnvPaths)

Aggregations

SetEnvPaths (org.apache.airavata.model.appcatalog.appdeployment.SetEnvPaths)7 CommandObject (org.apache.airavata.model.appcatalog.appdeployment.CommandObject)3 HashMap (java.util.HashMap)2 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)2 ArrayList (java.util.ArrayList)1 ApplicationDeploymentDescription (org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription)1 ApplicationModule (org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule)1 ComputeResourceDescription (org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription)1 ApplicationParallelismType (org.apache.airavata.model.parallelism.ApplicationParallelismType)1 Test (org.junit.Test)1