agave-jobs/jobs-core/src/main/java/org/iplantc/service/jobs/managers/monitors/parsers/ForkJobStatusResponseParser.java
/**
     *  The job status query to LoadLeveler was of the form {@code ps -o pid= -o user= -o stat= -o time= -o comm= -p <job_id>}.
     * 	That means the response should come back in columns with the following fields:
     *
     *  <pre>
     * PID USER  STATUS  TIME COMMAND
     * </pre>
     * We parse the status value and use it to generate the appropriate {@link ForkJobStatus} used in the response.
     *
     * @param remoteJobId           the remote job id to parse from the response
     * @param schedulerResponseText the response text from the remote scheduler
     * @return a {@link JobStatusResponse containing remote status info about the job with {@code remoteJobId}
     * @throws RemoteJobMonitorEmptyResponseException   if {@code schedulerResponseText} is blank
     * @throws RemoteJobMonitorResponseParsingException if {@code schedulerResponseText} could not be parsed
     */



PID USER  STATUS  TIME COMMAND

We parse the status value and use it to generate the appropriate  ForkJobStatus used in the response.


PID USER STATUS TIME COMMAND We parse the status value and use it to generate the appropriate ForkJobStatus used in the response .
@Override
    public JobStatusResponse parse(String remoteJobId, String schedulerResponseText) throws RemoteJobMonitorEmptyResponseException, RemoteJobMonitorResponseParsingException {
        if (StringUtils.isBlank(schedulerResponseText)) {
            return new JobStatusResponse<>(remoteJobId, ForkJobStatus.DONE, "1");
        } else {
            String[] lines = StringUtils.stripToEmpty(schedulerResponseText).split("[\\r\\n]+");
            for (String line : lines) {
                String trimmedLine = StringUtils.stripToEmpty(line);
                if (StringUtils.isBlank(trimmedLine) || StringUtils.startsWithAny(trimmedLine, new String[]{"[", "usage", "ps"})) {
                    continue;
                }
                else if (StringUtils.startsWith(trimmedLine, "ps: Invalid process id")) {
                    throw new RemoteJobMonitorResponseParsingException(schedulerResponseText);
                }
                else {
                    String[] tokens = StringUtils.split(trimmedLine);
                    String localId = StringUtils.stripToEmpty(tokens[0]);
                    if (!StringUtils.isNumeric(localId)) {
                        throw new RemoteJobMonitorResponseParsingException("Unexpected response format returned from ps: " + schedulerResponseText);
                    } else if (!StringUtils.equals(remoteJobId, localId)) {
                        continue;
                    } else {
                        return new JobStatusResponse<>(remoteJobId, ForkJobStatus.valueOfCode(tokens[2]), "-1");
                    }
                }
            }
            return new JobStatusResponse<>(remoteJobId, ForkJobStatus.DONE, "-1");
        }
    }
@ Override public JobStatusResponse parse ( String remoteJobId , String schedulerResponseText ) throws RemoteJobMonitorEmptyResponseException , RemoteJobMonitorResponseParsingException { if ( StringUtils . isBlank ( schedulerResponseText ) ) { return new JobStatusResponse < > ( remoteJobId , ForkJobStatus . DONE , "1" ) ; } else { String [ ] lines = StringUtils . stripToEmpty ( schedulerResponseText ) . split ( "[\\r\\n]+" ) ; for ( String line : lines ) { String trimmedLine = StringUtils . stripToEmpty ( line ) ; if ( StringUtils . isBlank ( trimmedLine ) || StringUtils . startsWithAny ( trimmedLine , new String [ ] { "[" , "usage" , "ps" } ) ) { continue ; } else if ( StringUtils . startsWith ( trimmedLine , "ps: Invalid process id" ) ) { throw new RemoteJobMonitorResponseParsingException ( schedulerResponseText ) ; } else { String [ ] tokens = StringUtils . split ( trimmedLine ) ; String localId = StringUtils . stripToEmpty ( tokens [ 0 ] ) ; if ( ! StringUtils . isNumeric ( localId ) ) { throw new RemoteJobMonitorResponseParsingException ( "Unexpected response format returned from ps: " + schedulerResponseText ) ; } else if ( ! StringUtils . equals ( remoteJobId , localId ) ) { continue ; } else { return new JobStatusResponse < > ( remoteJobId , ForkJobStatus . valueOfCode ( tokens [ 2 ] ) , "-1" ) ; } } } return new JobStatusResponse < > ( remoteJobId , ForkJobStatus . DONE , "-1" ) ; } }
The job status query to LoadLeveler was of the form {@code ps -o pid= -o user= -o stat= -o time= -o comm= -p <job_id>}.
The job status query to LoadLeveler was of the form { @code ps - o pid = - o user = - o stat = - o time = - o comm = - p <job_id > } .
//            throw new RemoteJobMonitorEmptyResponseException( //                    "Empty response received from job status check on the remote system. Since the job was " + //                            "successfully placed into queue, this is likely caused by a communication issue with the " + //                            "scheduler. Retrying may clear up the issue."); // bad syntax...possible on some OS, in theory // pid is invalid // response isn't a show stopper out of the box. parse for more info // ignore any non-matching job ids // TODO: didn't find a line with the pid, that should mean the process is in a terminal state.