agave-jobs/jobs-core/src/main/java/org/iplantc/service/jobs/managers/monitors/parsers/SGEJobStatusResponseParser.java
/**
     * Parses a single status line from the remote server response. This should be the line containing the actual
     * status info for the PBS job, trimmed of any headers, debug info, etc.
     *
     * @param remoteJobId the remote job id to parse from the response
     * @param statusLine  the qstat job status line
     * @return a {@link JobStatusResponse} containing remote status info about the job with {@code remoteJobId}
     * @throws RemoteJobMonitorResponseParsingException if unable to parse the job status
     */
Parses a single status line from the remote server response. This should be the line containing the actual
status info for the PBS job, trimmed of any headers, debug info, etc.

@param remoteJobId the remote job id to parse from the response
@param statusLine  the qstat job status line
@return a  JobStatusResponse containing remote status info about the job with  remoteJobId
@throws RemoteJobMonitorResponseParsingException if unable to parse the job status
Parses a single status line from the remote server response . This should be the line containing the actual status info for the PBS job trimmed of any headers debug info etc . @param remoteJobId the remote job id to parse from the response @param statusLine the qstat job status line @return a JobStatusResponse containing remote status info about the job with remoteJobId @throws RemoteJobMonitorResponseParsingException if unable to parse the job status
protected JobStatusResponse<SGEJobStatus> parseXMLResponse(String remoteJobId, String statusLine) throws RemoteJobMonitorResponseParsingException {
        try (InputStream in = new ByteArrayInputStream(statusLine.getBytes())) {
            SAXParserFactory factory = SAXParserFactory.newInstance();
            SAXParser saxParser = factory.newSAXParser();
			SGEHandler handler = new SGEHandler();
			saxParser.parse(in, handler);
			SGEJobInfo info = handler.sgeJobInfo;
			SGEJob sgeJob = null;
			for (SGEJob job: info.queueInfo) {
				if (job.getJB_job_number().equals(remoteJobId)) {
					sgeJob = job;
					break;
				}
			}
			if (sgeJob == null) {
				throw new RemoteJobMonitorResponseParsingException(
						"Unable to obtain job status in the response from the scheduler.");
			}
			String exitCode = "0";
			SGEJobStatus remoteJobStatus = SGEJobStatus.valueOfCode(sgeJob.state);
			return new JobStatusResponse<>(sgeJob.JB_job_number, remoteJobStatus, exitCode );
        } catch (SAXException|ParserConfigurationException|IOException e) {
			throw new RemoteJobMonitorResponseParsingException("Unexpected fields in the response from the scheduler: " + statusLine);
		}
    }
protected JobStatusResponse < SGEJobStatus > parseXMLResponse ( String remoteJobId , String statusLine ) throws RemoteJobMonitorResponseParsingException { try ( InputStream in = new ByteArrayInputStream ( statusLine . getBytes ( ) ) ) { SAXParserFactory factory = SAXParserFactory . newInstance ( ) ; SAXParser saxParser = factory . newSAXParser ( ) ; SGEHandler handler = new SGEHandler ( ) ; saxParser . parse ( in , handler ) ; SGEJobInfo info = handler . sgeJobInfo ; SGEJob sgeJob = null ; for ( SGEJob job : info . queueInfo ) { if ( job . getJB_job_number ( ) . equals ( remoteJobId ) ) { sgeJob = job ; break ; } } if ( sgeJob == null ) { throw new RemoteJobMonitorResponseParsingException ( "Unable to obtain job status in the response from the scheduler." ) ; } String exitCode = "0" ; SGEJobStatus remoteJobStatus = SGEJobStatus . valueOfCode ( sgeJob . state ) ; return new JobStatusResponse < > ( sgeJob . JB_job_number , remoteJobStatus , exitCode ) ; } catch ( SAXException | ParserConfigurationException | IOException e ) { throw new RemoteJobMonitorResponseParsingException ( "Unexpected fields in the response from the scheduler: " + statusLine ) ; } }
Parses a single status line from the remote server response.
Parses a single status line from the remote server response .