Search in sources :

Example 6 with JobStatus

use of org.apache.airavata.model.status.JobStatus in project airavata by apache.

the class LSFOutputParser method parseJobStatuses.

@Override
public void parseJobStatuses(String userName, Map<String, JobStatus> statusMap, String rawOutput) throws GFacException {
    logger.debug(rawOutput);
    String[] info = rawOutput.split("\n");
    // int lastStop = 0;
    for (String jobID : statusMap.keySet()) {
        String jobName = jobID.split(",")[1];
        boolean found = false;
        for (int i = 0; i < info.length; i++) {
            if (info[i].contains(jobName.substring(0, 8))) {
                // now starts processing this line
                logger.info(info[i]);
                String correctLine = info[i];
                String[] columns = correctLine.split(" ");
                List<String> columnList = new ArrayList<String>();
                for (String s : columns) {
                    if (!"".equals(s)) {
                        columnList.add(s);
                    }
                }
                // lastStop = i + 1;
                try {
                    statusMap.put(jobID, new JobStatus(JobState.valueOf(columnList.get(2))));
                } catch (IndexOutOfBoundsException e) {
                    statusMap.put(jobID, new JobStatus(JobState.valueOf("U")));
                }
                found = true;
                break;
            }
        }
        if (!found)
            logger.error("Couldn't find the status of the Job with JobName: " + jobName + "Job Id: " + jobID.split(",")[0]);
    }
}
Also used : JobStatus(org.apache.airavata.model.status.JobStatus) ArrayList(java.util.ArrayList)

Example 7 with JobStatus

use of org.apache.airavata.model.status.JobStatus in project airavata by apache.

the class SlurmOutputParser method parseJobStatus.

public JobStatus parseJobStatus(String jobID, String rawOutput) throws GFacException {
    log.info(rawOutput);
    Pattern pattern = Pattern.compile(jobID + "(?=\\s+\\S+\\s+\\S+\\s+\\S+\\s+(?<" + STATUS + ">\\w+))");
    Matcher matcher = pattern.matcher(rawOutput);
    if (matcher.find()) {
        return new JobStatus(JobUtil.getJobState(matcher.group(STATUS)));
    }
    return null;
}
Also used : JobStatus(org.apache.airavata.model.status.JobStatus) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher)

Example 8 with JobStatus

use of org.apache.airavata.model.status.JobStatus in project airavata by apache.

the class UGEOutputParser method parseJobStatuses.

public void parseJobStatuses(String userName, Map<String, JobStatus> statusMap, String rawOutput) {
    log.debug(rawOutput);
    String[] info = rawOutput.split("\n");
    int lastStop = 0;
    for (String jobID : statusMap.keySet()) {
        for (int i = lastStop; i < info.length; i++) {
            if (jobID.split(",")[0].contains(info[i].split(" ")[0]) && !"".equals(info[i].split(" ")[0])) {
                // now starts processing this line
                log.info(info[i]);
                String correctLine = info[i];
                String[] columns = correctLine.split(" ");
                List<String> columnList = new ArrayList<String>();
                for (String s : columns) {
                    if (!"".equals(s)) {
                        columnList.add(s);
                    }
                }
                lastStop = i + 1;
                if ("E".equals(columnList.get(4))) {
                    // There is another status with the same letter E other than error status
                    // to avoid that we make a small tweek to the job status
                    columnList.set(4, "Er");
                }
                statusMap.put(jobID, new JobStatus(JobState.valueOf(columnList.get(4))));
                break;
            }
        }
    }
}
Also used : JobStatus(org.apache.airavata.model.status.JobStatus) ArrayList(java.util.ArrayList)

Example 9 with JobStatus

use of org.apache.airavata.model.status.JobStatus in project airavata by apache.

the class AuroraJobSubmissionTask method execute.

@Override
public TaskStatus execute(TaskContext taskContext) {
    // set to completed.
    TaskStatus taskStatus = new TaskStatus(TaskState.COMPLETED);
    ProcessContext processContext = taskContext.getParentProcessContext();
    JobModel jobModel = processContext.getJobModel();
    jobModel.setTaskId(taskContext.getTaskId());
    String jobIdAndName = "A" + GFacUtils.generateJobName();
    jobModel.setJobName(jobIdAndName);
    JobStatus jobStatus = new JobStatus();
    jobStatus.setJobState(JobState.SUBMITTED);
    try {
        JobKeyBean jobKey = new JobKeyBean(AuroraUtils.ENVIRONMENT, AuroraUtils.ROLE, jobIdAndName);
        IdentityBean owner = new IdentityBean(AuroraUtils.ROLE);
        GroovyMap groovyMap = GFacUtils.createGroovyMap(processContext, taskContext);
        groovyMap.add(Script.JOB_SUBMITTER_COMMAND, "sh");
        String templateFileName = GFacUtils.getTemplateFileName(ResourceJobManagerType.CLOUD);
        String script = GFacUtils.generateScript(groovyMap, templateFileName);
        Set<ProcessBean> processes = new LinkedHashSet<>();
        ProcessBean process_1 = new ProcessBean("main_process", script, false);
        processes.add(process_1);
        groovyMap.getStringValue(Script.STANDARD_OUT_FILE).ifPresent(stdout -> {
            ProcessBean stdOutProcess = new ProcessBean("stdout_copy_process", "cp .logs/main_process/0/stdout " + stdout, false);
            processes.add(stdOutProcess);
        });
        groovyMap.getStringValue(Script.STANDARD_ERROR_FILE).ifPresent(stderr -> {
            ProcessBean stdErrProcess = new ProcessBean("stderr_copy_process", "cp .logs/main_process/0/stderr " + stderr, false);
            processes.add(stdErrProcess);
        });
        ResourceBean resources = new ResourceBean(1.5, 512, 512);
        TaskConfigBean taskConfig = new TaskConfigBean("Airavata-Aurora-" + jobIdAndName, processes, resources);
        JobConfigBean jobConfig = new JobConfigBean(jobKey, owner, taskConfig, AuroraUtils.CLUSTER);
        String executorConfigJson = AuroraThriftClientUtil.getExecutorConfigJson(jobConfig);
        log.info("Executor Config for Job {} , {}", jobIdAndName, executorConfigJson);
        AuroraThriftClient client = AuroraThriftClient.getAuroraThriftClient();
        ResponseBean response = client.createJob(jobConfig);
        log.info("Response for job {}, {}", jobIdAndName, response);
        jobModel.setJobDescription(resources.toString());
        jobModel.setJobId(jobIdAndName);
        jobStatus.setReason("Successfully Submitted");
        jobModel.setJobStatuses(Arrays.asList(jobStatus));
        jobStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
        taskContext.getParentProcessContext().setJobModel(jobModel);
        GFacUtils.saveJobModel(processContext, jobModel);
        GFacUtils.saveJobStatus(processContext, jobModel);
        taskStatus.setReason("Successfully submitted job to Aurora");
    } catch (Throwable e) {
        String msg = "Error occurred while submitting Aurora job";
        log.error(msg, e);
        taskStatus.setState(TaskState.FAILED);
        taskStatus.setReason(msg);
        taskStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
        ErrorModel errorModel = new ErrorModel();
        errorModel.setActualErrorMessage(e.getMessage());
        errorModel.setUserFriendlyMessage(msg);
        taskContext.getTaskModel().setTaskErrors(Arrays.asList(errorModel));
    }
    taskContext.setTaskStatus(taskStatus);
    try {
        GFacUtils.saveAndPublishTaskStatus(taskContext);
    } catch (GFacException e) {
        log.error("Error while saving task status", e);
    }
    return taskStatus;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) JobConfigBean(org.apache.airavata.cloud.aurora.client.bean.JobConfigBean) ResourceBean(org.apache.airavata.cloud.aurora.client.bean.ResourceBean) TaskStatus(org.apache.airavata.model.status.TaskStatus) ProcessBean(org.apache.airavata.cloud.aurora.client.bean.ProcessBean) AuroraThriftClient(org.apache.airavata.cloud.aurora.client.AuroraThriftClient) ProcessContext(org.apache.airavata.gfac.core.context.ProcessContext) JobStatus(org.apache.airavata.model.status.JobStatus) GFacException(org.apache.airavata.gfac.core.GFacException) ErrorModel(org.apache.airavata.model.commons.ErrorModel) JobModel(org.apache.airavata.model.job.JobModel) ResponseBean(org.apache.airavata.cloud.aurora.client.bean.ResponseBean) GroovyMap(org.apache.airavata.gfac.core.GroovyMap) JobKeyBean(org.apache.airavata.cloud.aurora.client.bean.JobKeyBean) IdentityBean(org.apache.airavata.cloud.aurora.client.bean.IdentityBean) TaskConfigBean(org.apache.airavata.cloud.aurora.client.bean.TaskConfigBean)

Example 10 with JobStatus

use of org.apache.airavata.model.status.JobStatus in project airavata by apache.

the class AuroraJobSubmissionTask method cancel.

@Override
public JobStatus cancel(TaskContext taskcontext) throws TaskException {
    JobStatus jobStatus = new JobStatus();
    jobStatus.setJobState(JobState.ACTIVE);
    return jobStatus;
}
Also used : JobStatus(org.apache.airavata.model.status.JobStatus)

Aggregations

JobStatus (org.apache.airavata.model.status.JobStatus)20 ArrayList (java.util.ArrayList)6 GFacException (org.apache.airavata.gfac.core.GFacException)5 ProcessContext (org.apache.airavata.gfac.core.context.ProcessContext)5 JobModel (org.apache.airavata.model.job.JobModel)5 TaskStatus (org.apache.airavata.model.status.TaskStatus)5 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)4 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)4 IOException (java.io.IOException)3 ErrorModel (org.apache.airavata.model.commons.ErrorModel)3 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)3 File (java.io.File)2 URISyntaxException (java.net.URISyntaxException)2 Map (java.util.Map)2 Set (java.util.Set)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 AiravataException (org.apache.airavata.common.exception.AiravataException)2 JobSubmissionOutput (org.apache.airavata.gfac.core.cluster.JobSubmissionOutput)2 RemoteCluster (org.apache.airavata.gfac.core.cluster.RemoteCluster)2