Repository: airavata Updated Branches: refs/heads/master 1454330eb -> c497353c3
hacky way to handle SIU Little Dog EMail issue Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/c497353c Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/c497353c Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/c497353c Branch: refs/heads/master Commit: c497353c3333a7e9214a84d9050fe050cce98fbb Parents: 1454330 Author: scnakandala <[email protected]> Authored: Wed May 31 12:34:43 2017 -0400 Committer: scnakandala <[email protected]> Committed: Wed May 31 12:34:43 2017 -0400 ---------------------------------------------------------------------- .../monitor/email/parser/LDSIUEmailParser.java | 107 ------------------- .../monitor/email/parser/UGEEmailParser.java | 4 + .../compute_resource_model.thrift | 1 - 3 files changed, 4 insertions(+), 108 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/c497353c/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/parser/LDSIUEmailParser.java ---------------------------------------------------------------------- diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/parser/LDSIUEmailParser.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/parser/LDSIUEmailParser.java deleted file mode 100644 index 6edbc64..0000000 --- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/parser/LDSIUEmailParser.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.airavata.gfac.monitor.email.parser; - -import org.apache.airavata.common.exception.AiravataException; -import org.apache.airavata.gfac.core.monitor.EmailParser; -import org.apache.airavata.gfac.core.monitor.JobStatusResult; -import org.apache.airavata.model.status.JobState; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.mail.Message; -import javax.mail.MessagingException; -import java.io.IOException; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class LDSIUEmailParser implements EmailParser { - - private static final Logger log = LoggerFactory.getLogger(LDSIUEmailParser.class); - private static final String REGEX = "[\\w]*[ ]*(?<"+ JOBID + ">[\\d]*)[ ]*\\((?<" + JOBNAME - + ">[a-zA-Z0-9]*)\\)[ ]*(?<" + STATUS + ">[a-zA-Z\\s]*)"; - public static final String STARTED = "Started"; - public static final String COMPLETE = "Complete"; - public static final String FAILED = "Set in error state"; - public static final String KILLED = "Killed"; - private static final String REGEX_EXIT_STATUS = "Exit Status[ ]*=[ ]*(?<" + EXIT_STATUS + ">[\\d]+)"; - public static final String ABORTED = "Aborted"; - - - @Override - public JobStatusResult parseEmail(Message message) throws MessagingException, AiravataException { - JobStatusResult jobStatusResult = new JobStatusResult(); - - parseContent(message, jobStatusResult); - return jobStatusResult; - } - - private void parseContent(Message message, JobStatusResult jobStatusResult) throws MessagingException, AiravataException { - String subject = message.getSubject(); - Pattern pattern = Pattern.compile(REGEX); - Matcher matcher = pattern.matcher(subject); - try { - if (matcher.find()) { - jobStatusResult.setJobId(matcher.group(JOBID)); - jobStatusResult.setJobName(matcher.group(JOBNAME)); - String content = (String) message.getContent(); - jobStatusResult.setState(getJobState(matcher.group(STATUS), content)); - } else { - log.error("[EJM]: No matched found for subject => \n" + subject); - } - } catch (IOException e) { - throw new AiravataException("[EJM]: Error while reading content of the email message"); - } - } - - private JobState getJobState(String status, String content) { - switch (status) { - case STARTED: - return JobState.ACTIVE; - case COMPLETE: - int exitStatus = getExitStatus(content); - if (exitStatus == 0) { - return JobState.COMPLETE; - } else { - log.info("[EJM]: Job returns with Exit Status = " + exitStatus + " , Marked as Failed"); - return JobState.FAILED; - } - case FAILED: - return JobState.FAILED; - case ABORTED: - return JobState.CANCELED; - default: - return JobState.UNKNOWN; - - } - } - - private int getExitStatus(String content) { - Pattern statusPattern = Pattern.compile(REGEX_EXIT_STATUS); - Matcher statusMatcher = statusPattern.matcher(content); - if (statusMatcher.find()) { - String group = statusMatcher.group(EXIT_STATUS); - if (group != null && !group.trim().isEmpty()) { - return Integer.valueOf(group.trim()); - } - } - return -1; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/c497353c/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/parser/UGEEmailParser.java ---------------------------------------------------------------------- diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/parser/UGEEmailParser.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/parser/UGEEmailParser.java index c1b930d..d5fdf06 100644 --- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/parser/UGEEmailParser.java +++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/parser/UGEEmailParser.java @@ -55,6 +55,10 @@ public class UGEEmailParser implements EmailParser { private void parseContent(Message message, JobStatusResult jobStatusResult) throws MessagingException, AiravataException { String subject = message.getSubject(); + + //FIXME - HACK to handle Little Dog email issue from SIU + subject = subject.replace("Set in error state", "Failed"); + Pattern pattern = Pattern.compile(REGEX); Matcher matcher = pattern.matcher(subject); try { http://git-wip-us.apache.org/repos/asf/airavata/blob/c497353c/thrift-interface-descriptions/data-models/resource-catalog-models/compute_resource_model.thrift ---------------------------------------------------------------------- diff --git a/thrift-interface-descriptions/data-models/resource-catalog-models/compute_resource_model.thrift b/thrift-interface-descriptions/data-models/resource-catalog-models/compute_resource_model.thrift index 8f02227..87f2ff3 100644 --- a/thrift-interface-descriptions/data-models/resource-catalog-models/compute_resource_model.thrift +++ b/thrift-interface-descriptions/data-models/resource-catalog-models/compute_resource_model.thrift @@ -53,7 +53,6 @@ enum ResourceJobManagerType { SLURM, LSF, UGE, - LD_SIU, CLOUD, AIRAVATA_CUSTOM }
