agave-jobs/jobs-core/src/main/java/org/iplantc/service/jobs/managers/monitors/parsers/CondorJobStatusResponseParser.java
/**
     * Looks up the status of the last section header in the condor log file. If no section headers
     * were found, a status of {@link CondorJobStatus#UNKNOWN} is set.
     * @param condorLogEvent  the text of a single condor event log
     * @return status found in last section header
     * @throws RemoteJobMonitorResponseParsingException if the event log data cannot be parsed
     */
Looks up the status of the last section header in the condor log file. If no section headers
were found, a status of  CondorJobStatus#UNKNOWN is set.
@param condorLogEvent  the text of a single condor event log
@return status found in last section header
@throws RemoteJobMonitorResponseParsingException if the event log data cannot be parsed
Looks up the status of the last section header in the condor log file . If no section headers were found a status of CondorJobStatus#UNKNOWN is set . @param condorLogEvent the text of a single condor event log @return status found in last section header @throws RemoteJobMonitorResponseParsingException if the event log data cannot be parsed
protected JobStatusResponse parseLogEventSection(String remoteJobId, String condorLogEvent) throws RemoteJobMonitorResponseParsingException {
        condorLogEvent = StringUtils.trimToEmpty(condorLogEvent);
        if (StringUtils.isEmpty(condorLogEvent)) {
            throw new RemoteJobMonitorResponseParsingException("Empty event log found in condor runtime log file.");
        } 
        else {
            Matcher headerMatcher = Pattern.compile(CONDOR_LOG_EVENT_HEADER_REGEX).matcher(condorLogEvent);
            if (headerMatcher.find()) {
                String strippedLogJobId = StringUtils.stripStart(headerMatcher.group("jobId"), "0");
                if (StringUtils.isEmpty(strippedLogJobId)) {
                    throw new RemoteJobMonitorResponseParsingException(
                            "No job id found in current event for Condor runtime log file.");
                } else if ( !remoteJobId.equals(strippedLogJobId)) {
                    throw new RemoteJobMonitorResponseParsingException(
                            "Mismatched job id found in current event for Condor runtime log file. " +
                                    strippedLogJobId + " != " + remoteJobId );
                } else {
                    String statusCode = headerMatcher.group("statusCode");
                    CondorLogJobStatus remoteJobStatus = CondorLogJobStatus.valueOfCode(statusCode);
                    String eventMessage = headerMatcher.group("eventMessage");
                    if (!StringUtils.isEmpty(eventMessage)) {
                        remoteJobStatus.setDescription(eventMessage);
                    }
                    Matcher matcher = Pattern.compile(CONDOR_LOG_EVENT_EXIT_CODE_REGEX).matcher(condorLogEvent);
                    String exitCode = "-1";
                    if (matcher.find()) {
                        exitCode = matcher.group("exitCode");
                    }
                    return new JobStatusResponse<>(remoteJobId, remoteJobStatus, exitCode);
                }
            } else {
                throw new RemoteJobMonitorResponseParsingException("Unexpected header format found when parsing current job " +
                        "event from Condor runtime log file: " + condorLogEvent );
            }
        }
    }
protected JobStatusResponse parseLogEventSection ( String remoteJobId , String condorLogEvent ) throws RemoteJobMonitorResponseParsingException { condorLogEvent = StringUtils . trimToEmpty ( condorLogEvent ) ; if ( StringUtils . isEmpty ( condorLogEvent ) ) { throw new RemoteJobMonitorResponseParsingException ( "Empty event log found in condor runtime log file." ) ; } else { Matcher headerMatcher = Pattern . compile ( CONDOR_LOG_EVENT_HEADER_REGEX ) . matcher ( condorLogEvent ) ; if ( headerMatcher . find ( ) ) { String strippedLogJobId = StringUtils . stripStart ( headerMatcher . group ( "jobId" ) , "0" ) ; if ( StringUtils . isEmpty ( strippedLogJobId ) ) { throw new RemoteJobMonitorResponseParsingException ( "No job id found in current event for Condor runtime log file." ) ; } else if ( ! remoteJobId . equals ( strippedLogJobId ) ) { throw new RemoteJobMonitorResponseParsingException ( "Mismatched job id found in current event for Condor runtime log file. " + strippedLogJobId + " != " + remoteJobId ) ; } else { String statusCode = headerMatcher . group ( "statusCode" ) ; CondorLogJobStatus remoteJobStatus = CondorLogJobStatus . valueOfCode ( statusCode ) ; String eventMessage = headerMatcher . group ( "eventMessage" ) ; if ( ! StringUtils . isEmpty ( eventMessage ) ) { remoteJobStatus . setDescription ( eventMessage ) ; } Matcher matcher = Pattern . compile ( CONDOR_LOG_EVENT_EXIT_CODE_REGEX ) . matcher ( condorLogEvent ) ; String exitCode = "-1" ; if ( matcher . find ( ) ) { exitCode = matcher . group ( "exitCode" ) ; } return new JobStatusResponse < > ( remoteJobId , remoteJobStatus , exitCode ) ; } } else { throw new RemoteJobMonitorResponseParsingException ( "Unexpected header format found when parsing current job " + "event from Condor runtime log file: " + condorLogEvent ) ; } } }
Looks up the status of the last section header in the condor log file.
Looks up the status of the last section header in the condor log file .
// no section headers in the log file will result in an UNKNOWN status // empty event throws blank response exception as this should never happen // a three digit value followed by a space starting the event log section indicate a job status // job id in the header will be left zero padded if the job id is less than 100. We strip rather than // parse as a Long because remote job ids are stored in the db as strings. This saves us a null check // and double conversion // condor job ids start at 1, so we don't need to worry about an job id of zero being empty and // triggering a false failure here // if the job ids don't match up, throw an exception // job ids match up, so we can parse the rest of the status line and return the interpreted response // Use the condor event log message in leu of the default description, when possible, for more // job-specific info about the job state. // if an exit code was returned, we will parse that out here. We probably don't need to do this // unless the job is in a terminal state, but we're only parsing a few lines of text and the // complete condor state machine is not entirely clear, so we err on the side of certainty over // the negligible performance savings.