Search in sources :

Example 16 with ProcessModel

use of org.apache.airavata.model.process.ProcessModel in project airavata by apache.

the class ExperimentModelUtil method cloneProcessFromExperiment.

public static ProcessModel cloneProcessFromExperiment(ExperimentModel experiment) {
    ProcessModel processModel = new ProcessModel();
    processModel.setCreationTime(experiment.getCreationTime());
    processModel.setExperimentId(experiment.getExperimentId());
    processModel.setApplicationInterfaceId(experiment.getExecutionId());
    processModel.setEnableEmailNotification(experiment.isEnableEmailNotification());
    List<String> emailAddresses = experiment.getEmailAddresses();
    if (emailAddresses != null && !emailAddresses.isEmpty()) {
        processModel.setEmailAddresses(emailAddresses);
    }
    List<InputDataObjectType> experimentInputs = experiment.getExperimentInputs();
    if (experimentInputs != null) {
        processModel.setProcessInputs(experimentInputs);
    }
    List<OutputDataObjectType> experimentOutputs = experiment.getExperimentOutputs();
    if (experimentOutputs != null) {
        processModel.setProcessOutputs(experimentOutputs);
    }
    UserConfigurationDataModel configData = experiment.getUserConfigurationData();
    if (configData != null) {
        processModel.setStorageResourceId(configData.getStorageId());
        processModel.setExperimentDataDir(configData.getExperimentDataDir());
        processModel.setGenerateCert(configData.isGenerateCert());
        processModel.setUserDn(configData.getUserDN());
        ComputationalResourceSchedulingModel scheduling = configData.getComputationalResourceScheduling();
        if (scheduling != null) {
            processModel.setProcessResourceSchedule(scheduling);
            processModel.setComputeResourceId(scheduling.getResourceHostId());
        }
        processModel.setUseUserCRPref(configData.isUseUserCRPref());
    }
    processModel.setUserName(experiment.getUserName());
    return processModel;
}
Also used : ProcessModel(org.apache.airavata.model.process.ProcessModel) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) UserConfigurationDataModel(org.apache.airavata.model.experiment.UserConfigurationDataModel) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)

Example 17 with ProcessModel

use of org.apache.airavata.model.process.ProcessModel in project airavata by apache.

the class GFacEngineImpl method populateProcessContext.

@Override
public ProcessContext populateProcessContext(String processId, String gatewayId, String tokenId) throws GFacException, CredentialStoreException {
    // NOTE: Process context gives precedence to data come with process Computer resources;
    ProcessContext processContext = null;
    ProcessContext.ProcessContextBuilder builder = new ProcessContext.ProcessContextBuilder(processId, gatewayId, tokenId);
    try {
        AppCatalog appCatalog = Factory.getDefaultAppCatalog();
        ExperimentCatalog expCatalog = Factory.getDefaultExpCatalog();
        ProcessModel processModel = (ProcessModel) expCatalog.get(ExperimentCatalogModelType.PROCESS, processId);
        builder.setAppCatalog(appCatalog).setExperimentCatalog(expCatalog).setCuratorClient(Factory.getCuratorClient()).setStatusPublisher(Factory.getStatusPublisher()).setProcessModel(processModel).setGatewayResourceProfile(appCatalog.getGatewayProfile().getGatewayProfile(gatewayId)).setGatewayComputeResourcePreference(appCatalog.getGatewayProfile().getComputeResourcePreference(gatewayId, processModel.getComputeResourceId())).setGatewayStorageResourcePreference(appCatalog.getGatewayProfile().getStoragePreference(gatewayId, processModel.getStorageResourceId()));
        processContext = builder.build();
        /* check point */
        checkpoint(processContext);
        if (processModel.isUseUserCRPref()) {
            setUserResourceProfile(gatewayId, processContext);
            setUserComputeResourcePreference(gatewayId, processContext);
        }
        String scratchLocation = processContext.getScratchLocation();
        String workingDirectory = scratchLocation + File.separator + processId + File.separator;
        StorageResourceDescription storageResource = appCatalog.getStorageResource().getStorageResource(processModel.getStorageResourceId());
        if (storageResource != null) {
            processContext.setStorageResource(storageResource);
        } else {
            // we need to fail the process which will fail the experiment
            processContext.setProcessStatus(new ProcessStatus(ProcessState.FAILED));
            GFacUtils.saveAndPublishProcessStatus(processContext);
            throw new GFacException("expId: " + processModel.getExperimentId() + ", processId: " + processId + ":- Couldn't find storage resource for storage resource id :" + processModel.getStorageResourceId());
        }
        /*            StorageResourceDescription storageResource = appCatalog.getStorageResource().getStorageResource(processModel.getStorageResourceId());
            if (storageResource != null){
                processContext.setStorageResource(storageResource);
            }*/
        processContext.setComputeResourceDescription(appCatalog.getComputeResource().getComputeResource(processContext.getComputeResourceId()));
        processContext.setApplicationDeploymentDescription(appCatalog.getApplicationDeployment().getApplicationDeployement(processModel.getApplicationDeploymentId()));
        ApplicationInterfaceDescription applicationInterface = appCatalog.getApplicationInterface().getApplicationInterface(processModel.getApplicationInterfaceId());
        processContext.setApplicationInterfaceDescription(applicationInterface);
        List<OutputDataObjectType> applicationOutputs = applicationInterface.getApplicationOutputs();
        if (applicationOutputs != null && !applicationOutputs.isEmpty()) {
            for (OutputDataObjectType outputDataObjectType : applicationOutputs) {
                if (outputDataObjectType.getType().equals(DataType.STDOUT)) {
                    if (outputDataObjectType.getValue() == null || outputDataObjectType.getValue().equals("")) {
                        outputDataObjectType.setValue(workingDirectory + applicationInterface.getApplicationName() + ".stdout");
                        processContext.setStdoutLocation(workingDirectory + applicationInterface.getApplicationName() + ".stdout");
                    } else {
                        processContext.setStdoutLocation(outputDataObjectType.getValue());
                    }
                }
                if (outputDataObjectType.getType().equals(DataType.STDERR)) {
                    if (outputDataObjectType.getValue() == null || outputDataObjectType.getValue().equals("")) {
                        String stderrLocation = workingDirectory + applicationInterface.getApplicationName() + ".stderr";
                        outputDataObjectType.setValue(stderrLocation);
                        processContext.setStderrLocation(stderrLocation);
                    } else {
                        processContext.setStderrLocation(outputDataObjectType.getValue());
                    }
                }
            }
        }
        expCatalog.update(ExperimentCatalogModelType.PROCESS, processModel, processId);
        processModel.setProcessOutputs(applicationOutputs);
        if (processContext.getJobSubmissionProtocol() == JobSubmissionProtocol.UNICORE) {
            // process monitor mode set in getResourceJobManager method, but unicore doesn't have resource job manager.
            // hence we set process monitor mode here.
            processContext.setMonitorMode(MonitorMode.FORK);
        } else {
            processContext.setResourceJobManager(getResourceJobManager(processContext));
            processContext.setJobSubmissionRemoteCluster(Factory.getJobSubmissionRemoteCluster(processContext));
            processContext.setDataMovementRemoteCluster(Factory.getDataMovementRemoteCluster(processContext));
        }
        String inputPath = ServerSettings.getLocalDataLocation();
        if (inputPath != null) {
            processContext.setLocalWorkingDir((inputPath.endsWith("/") ? inputPath : inputPath + "/") + processContext.getProcessId());
        }
        List<Object> jobModels = expCatalog.get(ExperimentCatalogModelType.JOB, "processId", processId);
        if (jobModels != null && !jobModels.isEmpty()) {
            if (jobModels.size() > 1) {
                log.warn("Process has more than one job model, take first one");
            }
            processContext.setJobModel(((JobModel) jobModels.get(0)));
        }
        return processContext;
    } catch (AppCatalogException e) {
        String msg = "App catalog access exception ";
        saveErrorModel(processContext, e, msg);
        updateProcessFailure(processContext, msg);
        throw new GFacException(msg, e);
    } catch (RegistryException e) {
        String msg = "Registry access exception";
        saveErrorModel(processContext, e, msg);
        updateProcessFailure(processContext, msg);
        throw new GFacException(msg, e);
    } catch (AiravataException e) {
        String msg = "Remote cluster initialization error";
        saveErrorModel(processContext, e, msg);
        updateProcessFailure(processContext, msg);
        throw new GFacException(msg, e);
    }
}
Also used : ProcessModel(org.apache.airavata.model.process.ProcessModel) ExperimentCatalog(org.apache.airavata.registry.cpi.ExperimentCatalog) ProcessStatus(org.apache.airavata.model.status.ProcessStatus) AppCatalog(org.apache.airavata.registry.cpi.AppCatalog) RegistryException(org.apache.airavata.registry.cpi.RegistryException) ProcessContext(org.apache.airavata.gfac.core.context.ProcessContext) AppCatalogException(org.apache.airavata.registry.cpi.AppCatalogException) StorageResourceDescription(org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription) GFacException(org.apache.airavata.gfac.core.GFacException) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) ApplicationInterfaceDescription(org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription) JobModel(org.apache.airavata.model.job.JobModel) AiravataException(org.apache.airavata.common.exception.AiravataException)

Example 18 with ProcessModel

use of org.apache.airavata.model.process.ProcessModel in project airavata by apache.

the class GFacUtils method saveProcessOutput.

public static void saveProcessOutput(ProcessContext processContext, String outputName, String outputVal) throws GFacException {
    try {
        ExperimentCatalog experimentCatalog = processContext.getExperimentCatalog();
        String processId = processContext.getProcessId();
        List<OutputDataObjectType> processOutputs = (List<OutputDataObjectType>) experimentCatalog.get(ExperimentCatalogModelType.PROCESS_OUTPUT, processId);
        if (processOutputs != null && !processOutputs.isEmpty()) {
            for (OutputDataObjectType processOutput : processOutputs) {
                if (processOutput.getName().equals(outputName)) {
                    processOutput.setValue(outputVal);
                }
            }
        }
        ProcessModel processModel = processContext.getProcessModel();
        processModel.setProcessOutputs(processOutputs);
        experimentCatalog.update(ExperimentCatalogModelType.PROCESS, processModel, processId);
    } catch (RegistryException e) {
        String msg = "expId: " + processContext.getExperimentId() + " processId: " + processContext.getProcessId() + " : - Error while updating experiment outputs";
        throw new GFacException(msg, e);
    }
}
Also used : ProcessModel(org.apache.airavata.model.process.ProcessModel) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) NodeList(org.w3c.dom.NodeList)

Example 19 with ProcessModel

use of org.apache.airavata.model.process.ProcessModel in project airavata by apache.

the class GFacUtils method setMailAddresses.

private static void setMailAddresses(ProcessContext processContext, GroovyMap groovyMap) throws GFacException, AppCatalogException, ApplicationSettingsException {
    ProcessModel processModel = processContext.getProcessModel();
    String emailIds = null;
    if (isEmailBasedJobMonitor(processContext)) {
        emailIds = ServerSettings.getEmailBasedMonitorAddress();
    }
    if (ServerSettings.getSetting(ServerSettings.JOB_NOTIFICATION_ENABLE).equalsIgnoreCase("true")) {
        String userJobNotifEmailIds = ServerSettings.getSetting(ServerSettings.JOB_NOTIFICATION_EMAILIDS);
        if (userJobNotifEmailIds != null && !userJobNotifEmailIds.isEmpty()) {
            if (emailIds != null && !emailIds.isEmpty()) {
                emailIds += ("," + userJobNotifEmailIds);
            } else {
                emailIds = userJobNotifEmailIds;
            }
        }
        if (processModel.isEnableEmailNotification()) {
            List<String> emailList = processModel.getEmailAddresses();
            String elist = GFacUtils.listToCsv(emailList, ',');
            if (elist != null && !elist.isEmpty()) {
                if (emailIds != null && !emailIds.isEmpty()) {
                    emailIds = emailIds + "," + elist;
                } else {
                    emailIds = elist;
                }
            }
        }
    }
    if (emailIds != null && !emailIds.isEmpty()) {
        log.info("Email list: " + emailIds);
        groovyMap.add(Script.MAIL_ADDRESS, emailIds);
    }
}
Also used : ProcessModel(org.apache.airavata.model.process.ProcessModel)

Aggregations

ProcessModel (org.apache.airavata.model.process.ProcessModel)19 TException (org.apache.thrift.TException)7 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)6 JobModel (org.apache.airavata.model.job.JobModel)5 AiravataException (org.apache.airavata.common.exception.AiravataException)4 ComputationalResourceSchedulingModel (org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)4 URISyntaxException (java.net.URISyntaxException)3 ApplicationDeploymentDescription (org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription)3 InputDataObjectType (org.apache.airavata.model.application.io.InputDataObjectType)3 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)3 ErrorModel (org.apache.airavata.model.commons.ErrorModel)3 AppCatalog (org.apache.airavata.registry.cpi.AppCatalog)3 java.util (java.util)2 ComputeResourcePreference (org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference)2 DataType (org.apache.airavata.model.application.io.DataType)2 LaunchValidationException (org.apache.airavata.model.error.LaunchValidationException)2 ExperimentModel (org.apache.airavata.model.experiment.ExperimentModel)2 org.apache.airavata.model.messaging.event (org.apache.airavata.model.messaging.event)2 OrchestratorException (org.apache.airavata.orchestrator.core.exception.OrchestratorException)2 RegistryServiceException (org.apache.airavata.registry.api.exception.RegistryServiceException)2