agave-jobs/jobs-core/src/main/java/org/iplantc/service/jobs/managers/monitors/parsers/TorqueXmlJobStatusResponseParser.java
/**
	 * Parses a single status line from the remote server response. This should be the line containing the actual
	 * status info for the Torque job, trimmed of any headers, debug info, etc.
	 *
	 * @param remoteJobId the remote job id to parse from the response
	 * @param schedulerResponseText the qstat job response
	 * @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 Torque job, trimmed of any headers, debug info, etc.

@param remoteJobId the remote job id to parse from the response
@param schedulerResponseText the qstat job response
@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 Torque job trimmed of any headers debug info etc . @param remoteJobId the remote job id to parse from the response @param schedulerResponseText the qstat job response @return a JobStatusResponse containing remote status info about the job with remoteJobId @throws RemoteJobMonitorResponseParsingException if unable to parse the job status
protected JobStatusResponse<TorqueJobStatus> parseXMLResponse(String remoteJobId, String schedulerResponseText) throws RemoteJobMonitorResponseParsingException {
		try (InputStream in = new ByteArrayInputStream(schedulerResponseText.getBytes())) {
			SAXParserFactory factory = SAXParserFactory.newInstance();
			SAXParser saxParser = factory.newSAXParser();
			TorqueXmlJobStatusResponseParser.TorqueHandler handler = new TorqueXmlJobStatusResponseParser.TorqueHandler();
			saxParser.parse(in, handler);
			TorqueXmlJobStatusResponseParser.TorqueData data = handler.getJobData();
			TorqueXmlJobStatusResponseParser.TorqueJob torqueJob = null;
			for (TorqueXmlJobStatusResponseParser.TorqueJob job: data.getJobs()) {
				if (job.id.startsWith(remoteJobId + ".")) {
					torqueJob = job;
					break;
				}
			}
			if (torqueJob == null) {
				throw new RemoteJobMonitorResponseParsingException(
						"Unable to obtain job status in the response from the scheduler.");
			}
			String exitCode = "0";
			TorqueJobStatus remoteJobStatus = TorqueJobStatus.valueOfCode(torqueJob.state);
			return new JobStatusResponse<>(torqueJob.id, remoteJobStatus, exitCode );
		} catch (SAXException| ParserConfigurationException | IOException e) {
			throw new RemoteJobMonitorResponseParsingException("Unexpected fields in the response from the scheduler: " + schedulerResponseText);
		}
	}
protected JobStatusResponse < TorqueJobStatus > parseXMLResponse ( String remoteJobId , String schedulerResponseText ) throws RemoteJobMonitorResponseParsingException { try ( InputStream in = new ByteArrayInputStream ( schedulerResponseText . getBytes ( ) ) ) { SAXParserFactory factory = SAXParserFactory . newInstance ( ) ; SAXParser saxParser = factory . newSAXParser ( ) ; TorqueXmlJobStatusResponseParser . TorqueHandler handler = new TorqueXmlJobStatusResponseParser . TorqueHandler ( ) ; saxParser . parse ( in , handler ) ; TorqueXmlJobStatusResponseParser . TorqueData data = handler . getJobData ( ) ; TorqueXmlJobStatusResponseParser . TorqueJob torqueJob = null ; for ( TorqueXmlJobStatusResponseParser . TorqueJob job : data . getJobs ( ) ) { if ( job . id . startsWith ( remoteJobId + "." ) ) { torqueJob = job ; break ; } } if ( torqueJob == null ) { throw new RemoteJobMonitorResponseParsingException ( "Unable to obtain job status in the response from the scheduler." ) ; } String exitCode = "0" ; TorqueJobStatus remoteJobStatus = TorqueJobStatus . valueOfCode ( torqueJob . state ) ; return new JobStatusResponse < > ( torqueJob . id , remoteJobStatus , exitCode ) ; } catch ( SAXException | ParserConfigurationException | IOException e ) { throw new RemoteJobMonitorResponseParsingException ( "Unexpected fields in the response from the scheduler: " + schedulerResponseText ) ; } }
Parses a single status line from the remote server response.
Parses a single status line from the remote server response .