Search in sources :

Example 16 with JobStatus

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

the class HPCRemoteCluster method cancelJob.

@Override
public JobStatus cancelJob(String jobId) throws GFacException {
    JobStatus oldStatus = getJobStatus(jobId);
    RawCommandInfo cancelCommand = jobManagerConfiguration.getCancelCommand(jobId);
    StandardOutReader reader = new StandardOutReader();
    executeCommand(cancelCommand, reader);
    throwExceptionOnError(reader, cancelCommand);
    return oldStatus;
}
Also used : JobStatus(org.apache.airavata.model.status.JobStatus) RawCommandInfo(org.apache.airavata.gfac.core.cluster.RawCommandInfo)

Example 17 with JobStatus

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

the class LSFOutputParser method main.

public static void main(String[] args) {
    String test = "Job <2477982> is submitted to queue <short>.";
    System.out.println(test.substring(test.indexOf("<") + 1, test.indexOf(">")));
    String test1 = "JOBID   USER    STAT  QUEUE      FROM_HOST   EXEC_HOST   JOB_NAME   SUBMIT_TIME\n" + "2636607 lg11w   RUN   long       ghpcc06     c11b02      *069656647 Mar  7 00:58\n" + "2636582 lg11w   RUN   long       ghpcc06     c02b01      2134490944 Mar  7 00:48";
    Map<String, JobStatus> statusMap = new HashMap<String, JobStatus>();
    statusMap.put("2477983,2134490944", new JobStatus(JobState.UNKNOWN));
    LSFOutputParser lsfOutputParser = new LSFOutputParser();
    try {
        lsfOutputParser.parseJobStatuses("cjh", statusMap, test1);
    } catch (GFacException e) {
        logger.error(e.getMessage(), e);
    }
    System.out.println(statusMap.get("2477983,2134490944"));
}
Also used : JobStatus(org.apache.airavata.model.status.JobStatus) GFacException(org.apache.airavata.gfac.core.GFacException) HashMap(java.util.HashMap)

Example 18 with JobStatus

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

the class PBSOutputParser 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()) {
        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
                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;
                try {
                    statusMap.put(jobID, new JobStatus(JobUtil.getJobState(columnList.get(9))));
                } catch (IndexOutOfBoundsException e) {
                    statusMap.put(jobID, new JobStatus(JobUtil.getJobState("U")));
                }
                found = true;
                break;
            }
        }
        if (!found)
            log.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 19 with JobStatus

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

the class SlurmOutputParser method parseJobStatuses.

public void parseJobStatuses(String userName, Map<String, JobStatus> statusMap, String rawOutput) throws GFacException {
    log.debug(rawOutput);
    String[] info = rawOutput.split("\n");
    String lastString = info[info.length - 1];
    if (lastString.contains("JOBID") || lastString.contains("PARTITION")) {
        log.info("There are no jobs with this username ... ");
        return;
    }
    // int lastStop = 0;
    for (String jobID : statusMap.keySet()) {
        String jobId = jobID.split(",")[0];
        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
                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);
                    }
                }
                try {
                    statusMap.put(jobID, new JobStatus(JobState.valueOf(columnList.get(4))));
                } catch (IndexOutOfBoundsException e) {
                    statusMap.put(jobID, new JobStatus(JobState.valueOf("U")));
                }
                found = true;
                break;
            }
        }
        if (!found) {
            log.error("Couldn't find the status of the Job with JobName: " + jobName + "Job Id: " + jobId);
        }
    }
}
Also used : JobStatus(org.apache.airavata.model.status.JobStatus) ArrayList(java.util.ArrayList)

Example 20 with JobStatus

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

the class UGEOutputParser method parseJobStatus.

public JobStatus parseJobStatus(String jobID, String rawOutput) {
    Pattern pattern = Pattern.compile("job_number:[\\s]+" + jobID);
    Matcher matcher = pattern.matcher(rawOutput);
    if (matcher.find()) {
        // fixme; return correct status.
        return new JobStatus(JobState.QUEUED);
    }
    return new JobStatus(JobState.UNKNOWN);
}
Also used : JobStatus(org.apache.airavata.model.status.JobStatus) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher)

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