agave-jobs/jobs-core/src/main/java/org/iplantc/service/jobs/managers/monitors/parsers/LSFJobStatusResponseParser.java
/**
	 * The job status query to LSF was of the form {@code bjobs -w -noheader <job_id>}. That means the response should
	 * come back in a tabbed column with the following fields
	 *
	 * <pre>
	 * $ bjobs -w -noheader 114
	 * 114     testuser RUN   normal     fc0b07ca1fb9 fc0b07ca1fb9 test_job   May  9 02:59
	 * </pre>
	 *
	 * We parse the status value and use it to generate the appropriate {@link LSFJobStatus} 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
	 */
The job status query to LSF was of the form  bjobs -w -noheader . That means the response should
come back in a tabbed column with the following fields


$ bjobs -w -noheader 114
114     testuser RUN   normal     fc0b07ca1fb9 fc0b07ca1fb9 test_job   May  9 02:59


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


The job status query to LSF was of the form bjobs - w - noheader . That means the response should come back in a tabbed column with the following fields $ bjobs - w - noheader 114 114 testuser RUN normal fc0b07ca1fb9 fc0b07ca1fb9 test_job May 9 02 : 59 We parse the status value and use it to generate the appropriate LSFJobStatus used in the response .
@Override
	public JobStatusResponse parse(String remoteJobId, String schedulerResponseText) throws RemoteJobMonitorEmptyResponseException, RemoteJobMonitorResponseParsingException {
		if (StringUtils.isBlank(schedulerResponseText)) {
			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.");
		} else if (schedulerResponseText.toLowerCase().contains("qstat: unknown job id")) {
			throw new RemoteJobMonitorEmptyResponseException(
					"Error response from job status check on the remote system. This is likely due to the job " +
							"completing and being purged from the qstat job cache. Calling tracejob with sufficient " +
							"permissions or examining the job logs should provide more information about the job.");
		}
		else if (schedulerResponseText.toLowerCase().contains("job id")
				|| schedulerResponseText.toLowerCase().contains("error")
				|| schedulerResponseText.toLowerCase().contains("not ")) {
			throw new RemoteJobMonitorResponseParsingException("Unable to obtain job status in the response from the scheduler: " + schedulerResponseText);
		} else {
			String[] lines = StringUtils.stripToEmpty(schedulerResponseText).split("[\\r\\n]+");
			for (String line: lines) {
				if (line.startsWith(remoteJobId)) {
					try {
						return parseLine(remoteJobId, line);
					} catch (RemoteJobMonitorResponseParsingException e) {
						throw new RemoteJobMonitorResponseParsingException(e.getMessage() + ": " + schedulerResponseText, e);
					}
				}
			}
			throw new RemoteJobMonitorResponseParsingException("Unable to obtain job status in the response from the scheduler");
		}
	}
@ Override public JobStatusResponse parse ( String remoteJobId , String schedulerResponseText ) throws RemoteJobMonitorEmptyResponseException , RemoteJobMonitorResponseParsingException { if ( StringUtils . isBlank ( schedulerResponseText ) ) { 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." ) ; } else if ( schedulerResponseText . toLowerCase ( ) . contains ( "qstat: unknown job id" ) ) { throw new RemoteJobMonitorEmptyResponseException ( "Error response from job status check on the remote system. This is likely due to the job " + "completing and being purged from the qstat job cache. Calling tracejob with sufficient " + "permissions or examining the job logs should provide more information about the job." ) ; } else if ( schedulerResponseText . toLowerCase ( ) . contains ( "job id" ) || schedulerResponseText . toLowerCase ( ) . contains ( "error" ) || schedulerResponseText . toLowerCase ( ) . contains ( "not " ) ) { throw new RemoteJobMonitorResponseParsingException ( "Unable to obtain job status in the response from the scheduler: " + schedulerResponseText ) ; } else { String [ ] lines = StringUtils . stripToEmpty ( schedulerResponseText ) . split ( "[\\r\\n]+" ) ; for ( String line : lines ) { if ( line . startsWith ( remoteJobId ) ) { try { return parseLine ( remoteJobId , line ) ; } catch ( RemoteJobMonitorResponseParsingException e ) { throw new RemoteJobMonitorResponseParsingException ( e . getMessage ( ) + ": " + schedulerResponseText , e ) ; } } } throw new RemoteJobMonitorResponseParsingException ( "Unable to obtain job status in the response from the scheduler" ) ; } }
The job status query to LSF was of the form {@code bjobs -w -noheader <job_id>}.
The job status query to LSF was of the form { @code bjobs - w - noheader <job_id > } .
// iterate over each line, finding the one starting with the job id // PBS status lines start with the job id // parse the line with the status info in it