Search in sources :

Example 26 with ApplicationDeploymentDescription

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

the class DocumentCreatorNew method createTrestlesAmberDocs.

public String createTrestlesAmberDocs() throws InvalidRequestException, AiravataClientException, AiravataSystemException, TException, AppCatalogException {
    ComputeResourceDescription host = DocumentCreatorUtils.createComputeResourceDescription(trestleshpcHostAddress, null, null);
    host.addToIpAddresses(trestleshpcHostAddress);
    host.addToHostAliases(trestleshpcHostAddress);
    host.setComputeResourceId(client.registerComputeResource(authzToken, host));
    SSHJobSubmission sshJobSubmission = new SSHJobSubmission();
    ResourceJobManager resourceJobManager = DocumentCreatorUtils.createResourceJobManager(ResourceJobManagerType.PBS, "/opt/torque/bin/", null, null);
    sshJobSubmission.setResourceJobManager(resourceJobManager);
    sshJobSubmission.setSecurityProtocol(SecurityProtocol.GSI);
    sshJobSubmission.setSshPort(22);
    client.addSSHJobSubmissionDetails(authzToken, host.getComputeResourceId(), 1, sshJobSubmission);
    SCPDataMovement scpDataMovement = new SCPDataMovement();
    scpDataMovement.setSecurityProtocol(SecurityProtocol.GSI);
    scpDataMovement.setSshPort(22);
    client.addSCPDataMovementDetails(authzToken, host.getComputeResourceId(), 1, scpDataMovement);
    ApplicationModule amodule = DocumentCreatorUtils.createApplicationModule("Amber", "12.0", null);
    amodule.setAppModuleId(client.registerApplicationModule(authzToken, DEFAULT_GATEWAY, amodule));
    ApplicationInterfaceDescription application = new ApplicationInterfaceDescription();
    application.setApplicationName("AmberTrestles");
    application.addToApplicationModules(amodule.getAppModuleId());
    application.addToApplicationInputs(DocumentCreatorUtils.createAppInput("AMBER_HEAT_RST", "AMBER_HEAT_RST", null, null, DataType.URI));
    application.addToApplicationInputs(DocumentCreatorUtils.createAppInput("AMBER_PROD_IN", "AMBER_PROD_IN", null, null, DataType.URI));
    application.addToApplicationInputs(DocumentCreatorUtils.createAppInput("AMBER_PRMTOP", "AMBER_PRMTOP", null, null, DataType.URI));
    application.addToApplicationOutputs(DocumentCreatorUtils.createAppOutput("AMBER_Prod.info", null, DataType.URI));
    application.addToApplicationOutputs(DocumentCreatorUtils.createAppOutput("AMBER_Prod.mdcrd", null, DataType.URI));
    application.addToApplicationOutputs(DocumentCreatorUtils.createAppOutput("AMBER_Prod.out", null, DataType.URI));
    application.addToApplicationOutputs(DocumentCreatorUtils.createAppOutput("AMBER_Prod.rst", null, DataType.URI));
    application.setApplicationInterfaceId(client.registerApplicationInterface(authzToken, DEFAULT_GATEWAY, application));
    ApplicationDeploymentDescription deployment = DocumentCreatorUtils.createApplicationDeployment(host.getComputeResourceId(), amodule.getAppModuleId(), "/home/ogce/production/app_wrappers/amber_wrapper.sh", ApplicationParallelismType.SERIAL, "AmberStampede");
    deployment.setAppDeploymentId(client.registerApplicationDeployment(authzToken, DEFAULT_GATEWAY, deployment));
    client.addGatewayComputeResourcePreference(authzToken, getGatewayResourceProfile().getGatewayID(), host.getComputeResourceId(), DocumentCreatorUtils.createComputeResourcePreference(host.getComputeResourceId(), "/oasis/scratch/trestles/ogce/temp_project/", "sds128", false, null, null, null));
    return host.getComputeResourceId() + "," + application.getApplicationInterfaceId();
}
Also used : ApplicationDeploymentDescription(org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription) ComputeResourceDescription(org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription) ResourceJobManager(org.apache.airavata.model.appcatalog.computeresource.ResourceJobManager) ApplicationInterfaceDescription(org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription) SSHJobSubmission(org.apache.airavata.model.appcatalog.computeresource.SSHJobSubmission) ApplicationModule(org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule)

Example 27 with ApplicationDeploymentDescription

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

the class OrchestratorServerHandler method getAppDeploymentForModule.

private ApplicationDeploymentDescription getAppDeploymentForModule(ProcessModel processModel, String selectedModuleId) throws AppCatalogException, ClassNotFoundException, ApplicationSettingsException, InstantiationException, IllegalAccessException {
    Map<String, String> moduleIdFilter = new HashMap<String, String>();
    moduleIdFilter.put(AppCatAbstractResource.ApplicationDeploymentConstants.APP_MODULE_ID, selectedModuleId);
    if (processModel.getProcessResourceSchedule() != null && processModel.getProcessResourceSchedule().getResourceHostId() != null) {
        moduleIdFilter.put(AppCatAbstractResource.ApplicationDeploymentConstants.COMPUTE_HOST_ID, processModel.getProcessResourceSchedule().getResourceHostId());
    }
    List<ApplicationDeploymentDescription> applicationDeployements = appCatalog.getApplicationDeployment().getApplicationDeployements(moduleIdFilter);
    Map<ComputeResourceDescription, ApplicationDeploymentDescription> deploymentMap = new HashMap<ComputeResourceDescription, ApplicationDeploymentDescription>();
    ComputeResource computeResource = appCatalog.getComputeResource();
    for (ApplicationDeploymentDescription deploymentDescription : applicationDeployements) {
        deploymentMap.put(computeResource.getComputeResource(deploymentDescription.getComputeHostId()), deploymentDescription);
    }
    List<ComputeResourceDescription> computeHostList = Arrays.asList(deploymentMap.keySet().toArray(new ComputeResourceDescription[] {}));
    Class<? extends HostScheduler> aClass = Class.forName(ServerSettings.getHostScheduler()).asSubclass(HostScheduler.class);
    HostScheduler hostScheduler = aClass.newInstance();
    ComputeResourceDescription ComputeResourceDescription = hostScheduler.schedule(computeHostList);
    return deploymentMap.get(ComputeResourceDescription);
}
Also used : ApplicationDeploymentDescription(org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription) HostScheduler(org.apache.airavata.gfac.core.scheduler.HostScheduler) ComputeResourceDescription(org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription)

Example 28 with ApplicationDeploymentDescription

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

the class OrchestratorServerHandler method launchProcess.

@Override
public boolean launchProcess(String processId, String airavataCredStoreToken, String gatewayId) throws TException {
    try {
        ProcessModel processModel = (ProcessModel) experimentCatalog.get(ExperimentCatalogModelType.PROCESS, processId);
        String applicationId = processModel.getApplicationInterfaceId();
        if (applicationId == null) {
            log.error(processId, "Application interface id shouldn't be null.");
            throw new OrchestratorException("Error executing the job, application interface id shouldn't be null.");
        }
        // set application deployment id to process model
        ApplicationDeploymentDescription applicationDeploymentDescription = getAppDeployment(processModel, applicationId);
        processModel.setApplicationDeploymentId(applicationDeploymentDescription.getAppDeploymentId());
        // set compute resource id to process model, default we set the same in the user preferred compute host id
        processModel.setComputeResourceId(processModel.getProcessResourceSchedule().getResourceHostId());
        experimentCatalog.update(ExperimentCatalogModelType.PROCESS, processModel, processModel.getProcessId());
        return orchestrator.launchProcess(processModel, airavataCredStoreToken);
    } catch (Exception e) {
        log.error(processId, "Error while launching process ", e);
        throw new TException(e);
    }
}
Also used : TException(org.apache.thrift.TException) ProcessModel(org.apache.airavata.model.process.ProcessModel) ApplicationDeploymentDescription(org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription) OrchestratorException(org.apache.airavata.orchestrator.core.exception.OrchestratorException) OrchestratorException(org.apache.airavata.orchestrator.core.exception.OrchestratorException) AiravataException(org.apache.airavata.common.exception.AiravataException) LaunchValidationException(org.apache.airavata.model.error.LaunchValidationException) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException)

Example 29 with ApplicationDeploymentDescription

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

the class AppCatalogThriftConversion method getApplicationDeploymentDescription.

public static ApplicationDeploymentDescription getApplicationDeploymentDescription(AppDeploymentResource resource) throws AppCatalogException {
    ApplicationDeploymentDescription description = new ApplicationDeploymentDescription();
    description.setAppDeploymentId(resource.getDeploymentId());
    description.setAppModuleId(resource.getAppModuleId());
    description.setComputeHostId(resource.getHostId());
    description.setExecutablePath(resource.getExecutablePath());
    if (resource.getParallelism() != null) {
        description.setParallelism(ApplicationParallelismType.valueOf(resource.getParallelism()));
    }
    description.setAppDeploymentDescription(resource.getAppDes());
    description.setDefaultQueueName(resource.getDefaultQueueName());
    description.setDefaultCPUCount(resource.getDefaultCPUCount());
    description.setDefaultNodeCount(resource.getDefaultNodeCount());
    description.setDefaultWalltime(resource.getDefaultWalltime());
    description.setEditableByUser(resource.isEditableByUser());
    ModuleLoadCmdResource cmdResource = new ModuleLoadCmdResource();
    List<AppCatalogResource> moduleLoadCmds = cmdResource.get(AppCatAbstractResource.ModuleLoadCmdConstants.APP_DEPLOYMENT_ID, resource.getDeploymentId());
    if (moduleLoadCmds != null && !moduleLoadCmds.isEmpty()) {
        for (AppCatalogResource moduleLoadCmd : moduleLoadCmds) {
            description.addToModuleLoadCmds(getCommandObject(((ModuleLoadCmdResource) moduleLoadCmd).getCmd(), ((ModuleLoadCmdResource) moduleLoadCmd).getOrder()));
        }
    }
    LibraryPrepandPathResource prepandPathResource = new LibraryPrepandPathResource();
    List<AppCatalogResource> libPrepandPaths = prepandPathResource.get(AppCatAbstractResource.LibraryPrepandPathConstants.DEPLOYMENT_ID, resource.getDeploymentId());
    if (libPrepandPaths != null && !libPrepandPaths.isEmpty()) {
        description.setLibPrependPaths(getLibPrepandPaths(libPrepandPaths));
    }
    LibraryApendPathResource apendPathResource = new LibraryApendPathResource();
    List<AppCatalogResource> libApendPaths = apendPathResource.get(AppCatAbstractResource.LibraryPrepandPathConstants.DEPLOYMENT_ID, resource.getDeploymentId());
    if (libApendPaths != null && !libApendPaths.isEmpty()) {
        description.setLibAppendPaths(getLibApendPaths(libApendPaths));
    }
    AppEnvironmentResource appEnvironmentResource = new AppEnvironmentResource();
    List<AppCatalogResource> appEnvList = appEnvironmentResource.get(AppCatAbstractResource.LibraryPrepandPathConstants.DEPLOYMENT_ID, resource.getDeploymentId());
    if (appEnvList != null && !appEnvList.isEmpty()) {
        description.setSetEnvironment(getAppEnvPaths(appEnvList));
    }
    PreJobCommandResource preJobCommandResource = new PreJobCommandResource();
    List<AppCatalogResource> preJobCommands = preJobCommandResource.get(AppCatAbstractResource.PreJobCommandConstants.DEPLOYMENT_ID, resource.getDeploymentId());
    if (preJobCommands != null && !preJobCommands.isEmpty()) {
        for (AppCatalogResource prejobCommand : preJobCommands) {
            description.addToPreJobCommands(getCommandObject(((PreJobCommandResource) prejobCommand).getCommand(), ((PreJobCommandResource) prejobCommand).getOrder()));
        }
    }
    PostJobCommandResource postJobCommandResource = new PostJobCommandResource();
    List<AppCatalogResource> postJobCommands = postJobCommandResource.get(AppCatAbstractResource.PostJobCommandConstants.DEPLOYMENT_ID, resource.getDeploymentId());
    if (postJobCommands != null && !postJobCommands.isEmpty()) {
        for (AppCatalogResource postjobCommand : postJobCommands) {
            description.addToPostJobCommands(getCommandObject(((PostJobCommandResource) postjobCommand).getCommand(), ((PostJobCommandResource) postjobCommand).getOrder()));
        }
    }
    return description;
}
Also used : ApplicationDeploymentDescription(org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription)

Example 30 with ApplicationDeploymentDescription

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

the class ApplicationProcessor method generateJobSpecificAppElements.

public static void generateJobSpecificAppElements(JobDefinitionType value, JobExecutionContext context) {
    String userName = getUserNameFromContext(context);
    // if (userName.equalsIgnoreCase("admin")){
    // userName = "CN=zdv575, O=Ultrascan Gateway, C=DE";
    // }
    ApplicationDeploymentDescription appDep = context.getApplicationContext().getApplicationDeploymentDescription();
    String appname = context.getApplicationContext().getApplicationInterfaceDescription().getApplicationName();
    ApplicationParallelismType parallelism = appDep.getParallelism();
    ApplicationType appType = JSDLUtils.getOrCreateApplication(value);
    appType.setApplicationName(appname);
    // if (appDep.getSetEnvironment().size() > 0) {
    // createApplicationEnvironment(value, appDep.getSetEnvironment(), parallelism);
    // }
    // 
    String stdout = context.getStandardOutput();
    String stderr = context.getStandardError();
    if (stdout != null) {
        stdout = stdout.substring(stdout.lastIndexOf('/') + 1);
    }
    if (stderr != null) {
        stderr = stderr.substring(stderr.lastIndexOf('/') + 1);
    }
    stdout = (stdout == null || stdout.equals("")) ? "stdout" : stdout;
    stderr = (stdout == null || stderr.equals("")) ? "stderr" : stderr;
    if (appDep.getExecutablePath() != null) {
        FileNameType fNameType = FileNameType.Factory.newInstance();
        fNameType.setStringValue(appDep.getExecutablePath());
        if (isParallelJob(context)) {
            JSDLUtils.getOrCreateSPMDApplication(value).setExecutable(fNameType);
            if (parallelism.equals(ApplicationParallelismType.OPENMP_MPI)) {
                JSDLUtils.getSPMDApplication(value).setSPMDVariation(SPMDVariations.OpenMPI.value());
            } else if (parallelism.equals(ApplicationParallelismType.MPI)) {
                JSDLUtils.getSPMDApplication(value).setSPMDVariation(SPMDVariations.MPI.value());
            }
            // setting number of processes
            try {
                String np = getInputAsString(context, BESConstants.NUMBER_OF_PROCESSES);
                if ((np != null) && (Integer.parseInt(np) > 0)) {
                    NumberOfProcessesType num = NumberOfProcessesType.Factory.newInstance();
                    num.setStringValue(np);
                    JSDLUtils.getSPMDApplication(value).setNumberOfProcesses(num);
                }
            } catch (RuntimeException np) {
            // do nothing
            }
            try {
                // setting processes per host
                String pphost = getInputAsString(context, BESConstants.PROCESSES_PER_HOST);
                if ((pphost != null) && (Integer.parseInt(pphost) > 0)) {
                    ProcessesPerHostType pph = ProcessesPerHostType.Factory.newInstance();
                    pph.setStringValue(String.valueOf(pphost));
                    JSDLUtils.getSPMDApplication(value).setProcessesPerHost(pph);
                }
            } catch (RuntimeException np) {
            // do nothing
            }
            int totalThreadCount = context.getTaskData().getTaskScheduling().getNumberOfThreads();
            // we take it as threads per processes
            if (totalThreadCount > 0) {
                ThreadsPerProcessType tpp = ThreadsPerProcessType.Factory.newInstance();
                tpp.setStringValue(String.valueOf(totalThreadCount));
                JSDLUtils.getSPMDApplication(value).setThreadsPerProcess(tpp);
            }
            if (userName != null) {
                UserNameType userNameType = UserNameType.Factory.newInstance();
                userNameType.setStringValue(userName);
                JSDLUtils.getSPMDApplication(value).setUserName(userNameType);
            }
            if (stdout != null) {
                FileNameType fName = FileNameType.Factory.newInstance();
                fName.setStringValue(stdout);
                JSDLUtils.getOrCreateSPMDApplication(value).setOutput(fName);
            }
            if (stderr != null) {
                FileNameType fName = FileNameType.Factory.newInstance();
                fName.setStringValue(stderr);
                JSDLUtils.getOrCreateSPMDApplication(value).setError(fName);
            }
        } else {
            JSDLUtils.getOrCreatePOSIXApplication(value).setExecutable(fNameType);
            if (userName != null) {
                UserNameType userNameType = UserNameType.Factory.newInstance();
                userNameType.setStringValue(userName);
                JSDLUtils.getOrCreatePOSIXApplication(value).setUserName(userNameType);
            }
            if (stdout != null) {
                FileNameType fName = FileNameType.Factory.newInstance();
                fName.setStringValue(stdout);
                JSDLUtils.getOrCreatePOSIXApplication(value).setOutput(fName);
            }
            if (stderr != null) {
                FileNameType fName = FileNameType.Factory.newInstance();
                fName.setStringValue(stderr);
                JSDLUtils.getOrCreatePOSIXApplication(value).setError(fName);
            }
        }
    }
}
Also used : ApplicationType(org.ggf.schemas.jsdl.x2005.x11.jsdl.ApplicationType) ApplicationDeploymentDescription(org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription) FileNameType(org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.FileNameType) UserNameType(org.ggf.schemas.jsdl.x2005.x11.jsdlPosix.UserNameType) ThreadsPerProcessType(org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.ThreadsPerProcessType) NumberOfProcessesType(org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.NumberOfProcessesType) ApplicationParallelismType(org.apache.airavata.model.appcatalog.appdeployment.ApplicationParallelismType) ProcessesPerHostType(org.ogf.schemas.jsdl.x2007.x02.jsdlSpmd.ProcessesPerHostType)

Aggregations

ApplicationDeploymentDescription (org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription)34 ApplicationModule (org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule)13 ApplicationInterfaceDescription (org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription)13 ComputeResourceDescription (org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription)13 ResourceJobManager (org.apache.airavata.model.appcatalog.computeresource.ResourceJobManager)11 SSHJobSubmission (org.apache.airavata.model.appcatalog.computeresource.SSHJobSubmission)10 RegistryServiceException (org.apache.airavata.registry.api.exception.RegistryServiceException)5 TException (org.apache.thrift.TException)4 ArrayList (java.util.ArrayList)3 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)3 ApplicationParallelismType (org.apache.airavata.model.parallelism.ApplicationParallelismType)3 AiravataException (org.apache.airavata.common.exception.AiravataException)2 CommandObject (org.apache.airavata.model.appcatalog.appdeployment.CommandObject)2 JobManagerCommand (org.apache.airavata.model.appcatalog.computeresource.JobManagerCommand)2 ComputeResourcePreference (org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference)2 InputDataObjectType (org.apache.airavata.model.application.io.InputDataObjectType)2 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)2 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)2 Writable (groovy.lang.Writable)1 GStringTemplateEngine (groovy.text.GStringTemplateEngine)1