You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sh...@apache.org on 2015/06/16 21:37:42 UTC
[3/7] airavata git commit: Removed gsi related code
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/LSFOutputParser.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/LSFOutputParser.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/LSFOutputParser.java
new file mode 100644
index 0000000..b16aa9b
--- /dev/null
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/LSFOutputParser.java
@@ -0,0 +1,133 @@
+/*
+ *
+ * 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.impl.job;
+
+import org.apache.airavata.gfac.core.JobDescriptor;
+import org.apache.airavata.gfac.core.cluster.OutputParser;
+import org.apache.airavata.gfac.core.SSHApiException;
+import org.apache.airavata.model.status.JobState;
+import org.apache.airavata.model.status.JobStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class LSFOutputParser implements OutputParser {
+ private final static Logger logger = LoggerFactory.getLogger(LSFOutputParser.class);
+
+ @Override
+ public void parseSingleJob(JobDescriptor jobDescriptor, String rawOutput) throws SSHApiException {
+ logger.debug(rawOutput);
+ //todo we need to implement this but we are not using it airavata runtime
+ // if someone is using the gsissh as a tool this will be useful to get a descriptive information about a single job
+ }
+
+ @Override
+ public String parseJobSubmission(String rawOutput) throws SSHApiException {
+ logger.debug(rawOutput);
+ return rawOutput.substring(rawOutput.indexOf("<")+1,rawOutput.indexOf(">"));
+ }
+
+ @Override
+ public JobStatus parseJobStatus(String jobID, String rawOutput) throws SSHApiException {
+ boolean jobFount = false;
+ logger.debug(rawOutput);
+ //todo this is not used anymore
+ return null;
+ }
+
+ @Override
+ public void parseJobStatuses(String userName, Map<String, JobStatus> statusMap, String rawOutput) throws SSHApiException {
+ logger.debug(rawOutput);
+
+ String[] info = rawOutput.split("\n");
+// int lastStop = 0;
+ for (String jobID : statusMap.keySet()) {
+ String jobName = jobID.split(",")[1];
+ boolean found = false;
+ for (int i = 0; i < info.length; i++) {
+ if (info[i].contains(jobName.substring(0,8))) {
+ // now starts processing this line
+ logger.info(info[i]);
+ String correctLine = info[i];
+ String[] columns = correctLine.split(" ");
+ List<String> columnList = new ArrayList<String>();
+ for (String s : columns) {
+ if (!"".equals(s)) {
+ columnList.add(s);
+ }
+ }
+// lastStop = i + 1;
+ try {
+ statusMap.put(jobID, new JobStatus(JobState.valueOf(columnList.get(2))));
+ }catch(IndexOutOfBoundsException e) {
+ statusMap.put(jobID, new JobStatus(JobState.valueOf("U")));
+ }
+ found = true;
+ break;
+ }
+ }
+ if(!found)
+ logger.error("Couldn't find the status of the Job with JobName: " + jobName + "Job Id: " + jobID.split(",")[0]);
+ }
+ }
+
+ @Override
+ public String parseJobId(String jobName, String rawOutput) throws SSHApiException {
+ String regJobId = "jobId";
+ Pattern pattern = Pattern.compile("(?=(?<" + regJobId + ">\\d+)\\s+\\w+\\s+" + jobName + ")"); // regex - look ahead and match
+ if (rawOutput != null) {
+ Matcher matcher = pattern.matcher(rawOutput);
+ if (matcher.find()) {
+ return matcher.group(regJobId);
+ } else {
+ logger.error("No match is found for JobName");
+ return null;
+ }
+ } else {
+ logger.error("Error: RawOutput shouldn't be null");
+ return null;
+ }
+ }
+
+ public static void main(String[] args) {
+ String test = "Job <2477982> is submitted to queue <short>.";
+ System.out.println(test.substring(test.indexOf("<")+1, test.indexOf(">")));
+ String test1 = "JOBID USER STAT QUEUE FROM_HOST EXEC_HOST JOB_NAME SUBMIT_TIME\n" +
+ "2636607 lg11w RUN long ghpcc06 c11b02 *069656647 Mar 7 00:58\n" +
+ "2636582 lg11w RUN long ghpcc06 c02b01 2134490944 Mar 7 00:48";
+ Map<String, JobStatus> statusMap = new HashMap<String, JobStatus>();
+ statusMap.put("2477983,2134490944", new JobStatus(JobState.UNKNOWN));
+ LSFOutputParser lsfOutputParser = new LSFOutputParser();
+ try {
+ lsfOutputParser.parseJobStatuses("cjh", statusMap, test1);
+ } catch (SSHApiException e) {
+ logger.error(e.getMessage(), e);
+ }
+ System.out.println(statusMap.get("2477983,2134490944"));
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/PBSJobConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/PBSJobConfiguration.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/PBSJobConfiguration.java
new file mode 100644
index 0000000..d709514
--- /dev/null
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/PBSJobConfiguration.java
@@ -0,0 +1,121 @@
+/*
+ *
+ * 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.impl.job;
+
+import org.apache.airavata.gfac.core.JobManagerConfiguration;
+import org.apache.airavata.gfac.core.cluster.OutputParser;
+import org.apache.airavata.gfac.core.cluster.RawCommandInfo;
+import org.apache.commons.io.FilenameUtils;
+
+import java.io.File;
+
+public class PBSJobConfiguration implements JobManagerConfiguration {
+
+ private String jobDescriptionTemplateName;
+
+ private String scriptExtension;
+
+ private String installedPath;
+
+ private OutputParser parser;
+
+ public PBSJobConfiguration() {
+ // this can be used to construct and use setter methods to set all the params in order
+ }
+
+ public PBSJobConfiguration(String jobDescriptionTemplateName,
+ String scriptExtension, String installedPath, OutputParser parser) {
+ this.jobDescriptionTemplateName = jobDescriptionTemplateName;
+ this.scriptExtension = scriptExtension;
+ this.parser = parser;
+ if (installedPath.endsWith("/")) {
+ this.installedPath = installedPath;
+ } else {
+ this.installedPath = installedPath + "/";
+ }
+ }
+
+ public RawCommandInfo getCancelCommand(String jobID) {
+ return new RawCommandInfo(this.installedPath + "qdel " + jobID);
+ }
+
+ public String getJobDescriptionTemplateName() {
+ return jobDescriptionTemplateName;
+ }
+
+ public void setJobDescriptionTemplateName(String jobDescriptionTemplateName) {
+ this.jobDescriptionTemplateName = jobDescriptionTemplateName;
+ }
+
+ public RawCommandInfo getMonitorCommand(String jobID) {
+ return new RawCommandInfo(this.installedPath + "qstat -f " + jobID);
+ }
+
+ public String getScriptExtension() {
+ return scriptExtension;
+ }
+
+ public RawCommandInfo getSubmitCommand(String workingDirectory, String pbsFilePath) {
+ return new RawCommandInfo(this.installedPath + "qsub " +
+ workingDirectory + File.separator + FilenameUtils.getName(pbsFilePath));
+ }
+
+ public String getInstalledPath() {
+ return installedPath;
+ }
+
+ public void setInstalledPath(String installedPath) {
+ this.installedPath = installedPath;
+ }
+
+ public OutputParser getParser() {
+ return parser;
+ }
+
+ public void setParser(OutputParser parser) {
+ this.parser = parser;
+ }
+
+ public RawCommandInfo getUserBasedMonitorCommand(String userName) {
+ return new RawCommandInfo(this.installedPath + "qstat -u " + userName);
+ }
+
+ @Override
+ public RawCommandInfo getJobIdMonitorCommand(String jobName, String userName) {
+ // For PBS there is no option to get jobDetails by JobName, so we search with userName
+ return new RawCommandInfo(this.installedPath + "qstat -u " + userName + " -f | grep \"Job_Name = " + jobName + "\" -B1");
+ }
+
+ @Override
+ public String getBaseCancelCommand() {
+ return "qdel";
+ }
+
+ @Override
+ public String getBaseMonitorCommand() {
+ return "qstat";
+ }
+
+ @Override
+ public String getBaseSubmitCommand() {
+ return "qsub ";
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/PBSOutputParser.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/PBSOutputParser.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/PBSOutputParser.java
new file mode 100644
index 0000000..38d98f9
--- /dev/null
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/PBSOutputParser.java
@@ -0,0 +1,219 @@
+/*
+ *
+ * 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.impl.job;
+
+import org.apache.airavata.gfac.core.JobDescriptor;
+import org.apache.airavata.gfac.core.cluster.OutputParser;
+import org.apache.airavata.gfac.core.SSHApiException;
+import org.apache.airavata.model.status.JobState;
+import org.apache.airavata.model.status.JobStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class PBSOutputParser implements OutputParser {
+ private static final Logger log = LoggerFactory.getLogger(PBSOutputParser.class);
+
+ public void parseSingleJob(JobDescriptor jobDescriptor, String rawOutput) {
+ log.debug(rawOutput);
+ String[] info = rawOutput.split("\n");
+ String[] line;
+ for (int i = 0; i < info.length; i++) {
+ if (info[i].contains("=")) {
+ line = info[i].split("=", 2);
+ } else {
+ line = info[i].split(":", 2);
+ }
+ if (line.length >= 2) {
+ String header = line[0].trim();
+ log.debug("Header = " + header);
+ String value = line[1].trim();
+ log.debug("value = " + value);
+
+ if (header.equals("Variable_List")) {
+ while (info[i + 1].startsWith("\t")) {
+ value += info[i + 1];
+ i++;
+ }
+ value = value.replaceAll("\t", "");
+ jobDescriptor.setVariableList(value);
+ } else if ("Job Id".equals(header)) {
+ jobDescriptor.setJobID(value);
+ } else if ("Job_Name".equals(header)) {
+ jobDescriptor.setJobName(value);
+ } else if ("Account_Name".equals(header)) {
+ jobDescriptor.setAcountString(value);
+ } else if ("job_state".equals(header)) {
+ jobDescriptor.setStatus(value);
+ } else if ("Job_Owner".equals(header)) {
+ jobDescriptor.setOwner(value);
+ } else if ("resources_used.cput".equals(header)) {
+ jobDescriptor.setUsedCPUTime(value);
+ } else if ("resources_used.mem".equals(header)) {
+ jobDescriptor.setUsedMemory(value);
+ } else if ("resources_used.walltime".equals(header)) {
+ jobDescriptor.setEllapsedTime(value);
+ } else if ("job_state".equals(header)) {
+ jobDescriptor.setStatus(value);
+ } else if ("queue".equals(header))
+ jobDescriptor.setQueueName(value);
+ else if ("ctime".equals(header)) {
+ jobDescriptor.setCTime(value);
+ } else if ("qtime".equals(header)) {
+ jobDescriptor.setQTime(value);
+ } else if ("mtime".equals(header)) {
+ jobDescriptor.setMTime(value);
+ } else if ("start_time".equals(header)) {
+ jobDescriptor.setSTime(value);
+ } else if ("comp_time".equals(header)) {
+ jobDescriptor.setCompTime(value);
+ } else if ("exec_host".equals(header)) {
+ jobDescriptor.setExecuteNode(value);
+ } else if ("Output_Path".equals(header)) {
+ if (info[i + 1].contains("=") || info[i + 1].contains(":"))
+ jobDescriptor.setStandardOutFile(value);
+ else {
+ jobDescriptor.setStandardOutFile(value + info[i + 1].trim());
+ i++;
+ }
+ } else if ("Error_Path".equals(header)) {
+ if (info[i + 1].contains("=") || info[i + 1].contains(":"))
+ jobDescriptor.setStandardErrorFile(value);
+ else {
+ String st = info[i + 1].trim();
+ jobDescriptor.setStandardErrorFile(value + st);
+ i++;
+ }
+
+ } else if ("submit_args".equals(header)) {
+ while (i + 1 < info.length) {
+ if (info[i + 1].startsWith("\t")) {
+ value += info[i + 1];
+ i++;
+ } else
+ break;
+ }
+ value = value.replaceAll("\t", "");
+ jobDescriptor.setSubmitArgs(value);
+ }
+ }
+ }
+ }
+
+ public String parseJobSubmission(String rawOutput) {
+ log.debug(rawOutput);
+ return rawOutput; //In PBS stdout is going to be directly the jobID
+ }
+
+ public JobStatus parseJobStatus(String jobID, String rawOutput) {
+ boolean jobFount = false;
+ log.debug(rawOutput);
+ String[] info = rawOutput.split("\n");
+ String[] line = null;
+ int index = 0;
+ for (String anInfo : info) {
+ index++;
+ if (anInfo.contains("Job Id:")) {
+ if (anInfo.contains(jobID)) {
+ jobFount = true;
+ break;
+ }
+ }
+ }
+ if (jobFount) {
+ for (int i=index;i<info.length;i++) {
+ String anInfo = info[i];
+ if (anInfo.contains("=")) {
+ line = anInfo.split("=", 2);
+ if (line.length != 0) {
+ if (line[0].contains("job_state")) {
+ return new JobStatus(JobState.valueOf(line[1].replaceAll(" ", "")));
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public void parseJobStatuses(String userName, Map<String, JobStatus> statusMap, String rawOutput) {
+ log.debug(rawOutput);
+ String[] info = rawOutput.split("\n");
+// int lastStop = 0;
+ for (String jobID : statusMap.keySet()) {
+ String jobName = jobID.split(",")[1];
+ boolean found = false;
+ for (int i = 0; i < info.length; i++) {
+ if (info[i].contains(jobName.substring(0,8))) {
+ // now starts processing this line
+ log.info(info[i]);
+ String correctLine = info[i];
+ String[] columns = correctLine.split(" ");
+ List<String> columnList = new ArrayList<String>();
+ for (String s : columns) {
+ if (!"".equals(s)) {
+ columnList.add(s);
+ }
+ }
+// lastStop = i + 1;
+ try {
+ statusMap.put(jobID, new JobStatus(JobState.valueOf(columnList.get(9))));
+ }catch(IndexOutOfBoundsException e) {
+ statusMap.put(jobID, new JobStatus(JobState.valueOf("U")));
+ }
+ found = true;
+ break;
+ }
+ }
+ if(!found)
+ log.error("Couldn't find the status of the Job with JobName: " + jobName + "Job Id: " + jobID.split(",")[0]);
+ }
+ }
+
+ @Override
+ public String parseJobId(String jobName, String rawOutput) throws SSHApiException {
+ /* output will look like
+ Job Id: 2080802.gordon-fe2.local
+ Job_Name = A312402627
+ */
+ String regJobId = "jobId";
+ Pattern pattern = Pattern.compile("(?<" + regJobId + ">[^\\s]*)\\s*.* " + jobName);
+ if (rawOutput != null) {
+ Matcher matcher = pattern.matcher(rawOutput);
+ if (matcher.find()) {
+ return matcher.group(regJobId);
+ } else {
+ log.error("No match is found for JobName");
+ return null;
+ }
+ } else {
+ log.error("Error: RawOutput shouldn't be null");
+ return null;
+ }
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/SlurmJobConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/SlurmJobConfiguration.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/SlurmJobConfiguration.java
new file mode 100644
index 0000000..354db8a
--- /dev/null
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/SlurmJobConfiguration.java
@@ -0,0 +1,119 @@
+/*
+ *
+ * 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.impl.job;
+
+import org.apache.airavata.gfac.core.JobManagerConfiguration;
+import org.apache.airavata.gfac.core.cluster.OutputParser;
+import org.apache.airavata.gfac.core.cluster.RawCommandInfo;
+import org.apache.commons.io.FilenameUtils;
+
+import java.io.File;
+
+public class SlurmJobConfiguration implements JobManagerConfiguration {
+
+ private String jobDescriptionTemplateName;
+
+ private String scriptExtension;
+
+ private String installedPath;
+
+ private OutputParser parser;
+
+ public SlurmJobConfiguration(){
+ // this can be used to construct and use setter methods to set all the params in order
+ }
+ public SlurmJobConfiguration(String jobDescriptionTemplateName,
+ String scriptExtension,String installedPath,OutputParser parser) {
+ this.jobDescriptionTemplateName = jobDescriptionTemplateName;
+ this.scriptExtension = scriptExtension;
+ this.parser = parser;
+ if (installedPath.endsWith("/")) {
+ this.installedPath = installedPath;
+ } else {
+ this.installedPath = installedPath + "/";
+ }
+ }
+
+ public RawCommandInfo getCancelCommand(String jobID) {
+ return new RawCommandInfo(this.installedPath + "scancel " + jobID);
+ }
+
+ public String getJobDescriptionTemplateName() {
+ return jobDescriptionTemplateName;
+ }
+
+ public void setJobDescriptionTemplateName(String jobDescriptionTemplateName) {
+ this.jobDescriptionTemplateName = jobDescriptionTemplateName;
+ }
+
+ public RawCommandInfo getMonitorCommand(String jobID) {
+ return new RawCommandInfo(this.installedPath + "squeue -j " + jobID);
+ }
+
+ public String getScriptExtension() {
+ return scriptExtension;
+ }
+
+ public RawCommandInfo getSubmitCommand(String workingDirectory,String pbsFilePath) {
+ return new RawCommandInfo(this.installedPath + "sbatch " +
+ workingDirectory + File.separator + FilenameUtils.getName(pbsFilePath));
+ }
+
+ public String getInstalledPath() {
+ return installedPath;
+ }
+
+ public void setInstalledPath(String installedPath) {
+ this.installedPath = installedPath;
+ }
+
+ public OutputParser getParser() {
+ return parser;
+ }
+
+ public void setParser(OutputParser parser) {
+ this.parser = parser;
+ }
+
+ public RawCommandInfo getUserBasedMonitorCommand(String userName) {
+ return new RawCommandInfo(this.installedPath + "squeue -u " + userName);
+ }
+
+ @Override
+ public RawCommandInfo getJobIdMonitorCommand(String jobName, String userName) {
+ return new RawCommandInfo(this.installedPath + "squeue -n " + jobName + " -u " + userName);
+ }
+
+ @Override
+ public String getBaseCancelCommand() {
+ return "scancel";
+ }
+
+ @Override
+ public String getBaseMonitorCommand() {
+ return "squeue";
+ }
+
+ @Override
+ public String getBaseSubmitCommand() {
+ return "sbatch";
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/SlurmOutputParser.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/SlurmOutputParser.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/SlurmOutputParser.java
new file mode 100644
index 0000000..1974843
--- /dev/null
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/SlurmOutputParser.java
@@ -0,0 +1,193 @@
+/*
+ *
+ * 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.impl.job;
+
+import org.apache.airavata.gfac.core.JobDescriptor;
+import org.apache.airavata.gfac.core.cluster.OutputParser;
+import org.apache.airavata.gfac.core.SSHApiException;
+import org.apache.airavata.model.status.JobState;
+import org.apache.airavata.model.status.JobStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class SlurmOutputParser implements OutputParser {
+ private static final Logger log = LoggerFactory.getLogger(SlurmOutputParser.class);
+ public static final int JOB_NAME_OUTPUT_LENGTH = 8;
+ public static final String STATUS = "status";
+
+ public void parseSingleJob(JobDescriptor descriptor, String rawOutput) throws SSHApiException {
+ log.info(rawOutput);
+ String[] info = rawOutput.split("\n");
+ String lastString = info[info.length - 1];
+ if (lastString.contains("JOB ID")) {
+ // because there's no state
+ descriptor.setStatus("U");
+ } else {
+ int column = 0;
+ System.out.println(lastString);
+ for (String each : lastString.split(" ")) {
+ if (each.trim().isEmpty()) {
+ continue;
+ } else {
+ switch (column) {
+ case 0:
+ descriptor.setJobID(each);
+ column++;
+ break;
+ case 1:
+ descriptor.setPartition(each);
+ column++;
+ break;
+ case 2:
+ descriptor.setJobName(each);
+ column++;
+ break;
+ case 3:
+ descriptor.setUserName(each);
+ column++;
+ break;
+ case 4:
+ descriptor.setStatus(each);
+ column++;
+ break;
+ case 5:
+ descriptor.setUsedCPUTime(each);
+ column++;
+ break;
+ case 6:
+ try {
+ int nodes = Integer.parseInt(each);
+ descriptor.setNodes(nodes);
+ }catch (Exception e){
+ log.error("Node count read from command output is not an integer !!!");
+ }
+ column++;
+ break;
+ case 7:
+ descriptor.setNodeList(each);
+ column++;
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ /**
+ * This can be used to parseSingleJob the outpu of sbatch and extrac the jobID from the content
+ *
+ * @param rawOutput
+ * @return
+ */
+ public String parseJobSubmission(String rawOutput) throws SSHApiException {
+ // FIXME : use regex to match correct jobId;
+ log.info(rawOutput);
+ String[] info = rawOutput.split("\n");
+ for (String anInfo : info) {
+ if (anInfo.contains("Submitted batch job")) {
+ String[] split = anInfo.split("Submitted batch job");
+ return split[1].trim();
+ }
+ }
+ return "";
+// throw new SSHApiException(rawOutput); //todo//To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public JobStatus parseJobStatus(String jobID, String rawOutput) throws SSHApiException {
+ log.info(rawOutput);
+ Pattern pattern = Pattern.compile(jobID + "(?=\\s+\\S+\\s+\\S+\\s+\\S+\\s+(?<" + STATUS + ">\\w+))");
+ Matcher matcher = pattern.matcher(rawOutput);
+ if (matcher.find()) {
+ return new JobStatus(JobState.valueOf(matcher.group(STATUS)));
+ }
+ return null;
+ }
+
+ public void parseJobStatuses(String userName, Map<String, JobStatus> statusMap, String rawOutput) throws SSHApiException {
+ log.debug(rawOutput);
+ String[] info = rawOutput.split("\n");
+ String lastString = info[info.length - 1];
+ if (lastString.contains("JOBID") || lastString.contains("PARTITION")) {
+ log.info("There are no jobs with this username ... ");
+ return;
+ }
+// int lastStop = 0;
+ for (String jobID : statusMap.keySet()) {
+ String jobId = jobID.split(",")[0];
+ String jobName = jobID.split(",")[1];
+ boolean found = false;
+ for (int i = 0; i < info.length; i++) {
+ if (info[i].contains(jobName.substring(0, 8))) {
+ // now starts processing this line
+ log.info(info[i]);
+ String correctLine = info[i];
+ String[] columns = correctLine.split(" ");
+ List<String> columnList = new ArrayList<String>();
+ for (String s : columns) {
+ if (!"".equals(s)) {
+ columnList.add(s);
+ }
+ }
+ try {
+ statusMap.put(jobID, new JobStatus(JobState.valueOf(columnList.get(4))));
+ } catch (IndexOutOfBoundsException e) {
+ statusMap.put(jobID, new JobStatus(JobState.valueOf("U")));
+ }
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ log.error("Couldn't find the status of the Job with JobName: " + jobName + "Job Id: " + jobId);
+ }
+ }
+ }
+
+ @Override
+ public String parseJobId(String jobName, String rawOutput) throws SSHApiException {
+ String regJobId = "jobId";
+ if (jobName == null) {
+ return null;
+ } else if(jobName.length() > JOB_NAME_OUTPUT_LENGTH) {
+ jobName = jobName.substring(0, JOB_NAME_OUTPUT_LENGTH);
+ }
+ Pattern pattern = Pattern.compile("(?=(?<" + regJobId + ">\\d+)\\s+\\w+\\s+" + jobName + ")"); // regex - look ahead and match
+ if (rawOutput != null) {
+ Matcher matcher = pattern.matcher(rawOutput);
+ if (matcher.find()) {
+ return matcher.group(regJobId);
+ } else {
+ log.error("No match is found for JobName");
+ return null;
+ }
+ } else {
+ log.error("Error: RawOutput shouldn't be null");
+ return null;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/UGEJobConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/UGEJobConfiguration.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/UGEJobConfiguration.java
new file mode 100644
index 0000000..f9c60cb
--- /dev/null
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/UGEJobConfiguration.java
@@ -0,0 +1,121 @@
+/*
+ *
+ * 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.impl.job;
+
+import org.apache.airavata.gfac.core.JobManagerConfiguration;
+import org.apache.airavata.gfac.core.cluster.OutputParser;
+import org.apache.airavata.gfac.core.cluster.RawCommandInfo;
+import org.apache.commons.io.FilenameUtils;
+
+import java.io.File;
+
+public class UGEJobConfiguration implements JobManagerConfiguration {
+
+ private String jobDescriptionTemplateName;
+
+ private String scriptExtension;
+
+ private String installedPath;
+
+ private OutputParser parser;
+
+ public UGEJobConfiguration() {
+ // this can be used to construct and use setter methods to set all the params in order
+ }
+
+ public UGEJobConfiguration(String jobDescriptionTemplateName,
+ String scriptExtension, String installedPath, OutputParser parser) {
+ this.jobDescriptionTemplateName = jobDescriptionTemplateName;
+ this.scriptExtension = scriptExtension;
+ this.parser = parser;
+ if (installedPath.endsWith("/")) {
+ this.installedPath = installedPath;
+ } else {
+ this.installedPath = installedPath + "/";
+ }
+ }
+
+ public RawCommandInfo getCancelCommand(String jobID) {
+ return new RawCommandInfo(this.installedPath + "qdel " + jobID);
+ }
+
+ public String getJobDescriptionTemplateName() {
+ return jobDescriptionTemplateName;
+ }
+
+ public void setJobDescriptionTemplateName(String jobDescriptionTemplateName) {
+ this.jobDescriptionTemplateName = jobDescriptionTemplateName;
+ }
+
+ public RawCommandInfo getMonitorCommand(String jobID) {
+ return new RawCommandInfo(this.installedPath + "qstat -j " + jobID);
+ }
+
+ public String getScriptExtension() {
+ return scriptExtension;
+ }
+
+ public RawCommandInfo getSubmitCommand(String workingDirectory, String pbsFilePath) {
+ return new RawCommandInfo(this.installedPath + "qsub " +
+ workingDirectory + File.separator + FilenameUtils.getName(pbsFilePath));
+ }
+
+ public String getInstalledPath() {
+ return installedPath;
+ }
+
+ public void setInstalledPath(String installedPath) {
+ this.installedPath = installedPath;
+ }
+
+ public OutputParser getParser() {
+ return parser;
+ }
+
+ public void setParser(OutputParser parser) {
+ this.parser = parser;
+ }
+
+ public RawCommandInfo getUserBasedMonitorCommand(String userName) {
+ return new RawCommandInfo(this.installedPath + "qstat -u " + userName);
+ }
+
+ @Override
+ public RawCommandInfo getJobIdMonitorCommand(String jobName, String userName) {
+ // For PBS there is no option to get jobDetails by JobName, so we search with userName
+ return new RawCommandInfo(this.installedPath + "qstat -u " + userName);
+ }
+
+ @Override
+ public String getBaseCancelCommand() {
+ return "qdel";
+ }
+
+ @Override
+ public String getBaseMonitorCommand() {
+ return "qstat";
+ }
+
+ @Override
+ public String getBaseSubmitCommand() {
+ return "qsub ";
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/UGEOutputParser.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/UGEOutputParser.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/UGEOutputParser.java
new file mode 100644
index 0000000..0ece2d9
--- /dev/null
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/UGEOutputParser.java
@@ -0,0 +1,191 @@
+/*
+ *
+ * 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.impl.job;
+
+import org.apache.airavata.gfac.core.JobDescriptor;
+import org.apache.airavata.gfac.core.cluster.OutputParser;
+import org.apache.airavata.gfac.core.SSHApiException;
+import org.apache.airavata.model.status.JobState;
+import org.apache.airavata.model.status.JobStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class UGEOutputParser implements OutputParser {
+ private static final Logger log = LoggerFactory.getLogger(PBSOutputParser.class);
+ public static final String JOB_ID = "jobId";
+
+ public void parseSingleJob(JobDescriptor jobDescriptor, String rawOutput) {
+ log.debug(rawOutput);
+ String[] info = rawOutput.split("\n");
+ String[] line;
+ for (int i = 0; i < info.length; i++) {
+ if (info[i].contains("=")) {
+ line = info[i].split("=", 2);
+ } else {
+ line = info[i].split(":", 2);
+ }
+ if (line.length >= 2) {
+ String header = line[0].trim();
+ log.debug("Header = " + header);
+ String value = line[1].trim();
+ log.debug("value = " + value);
+
+ if (header.equals("Variable_List")) {
+ while (info[i + 1].startsWith("\t")) {
+ value += info[i + 1];
+ i++;
+ }
+ value = value.replaceAll("\t", "");
+ jobDescriptor.setVariableList(value);
+ } else if ("Job Id".equals(header)) {
+ jobDescriptor.setJobID(value);
+ } else if ("Job_Name".equals(header)) {
+ jobDescriptor.setJobName(value);
+ } else if ("Account_Name".equals(header)) {
+ jobDescriptor.setAcountString(value);
+ } else if ("job_state".equals(header)) {
+ jobDescriptor.setStatus(value);
+ } else if ("Job_Owner".equals(header)) {
+ jobDescriptor.setOwner(value);
+ } else if ("resources_used.cput".equals(header)) {
+ jobDescriptor.setUsedCPUTime(value);
+ } else if ("resources_used.mem".equals(header)) {
+ jobDescriptor.setUsedMemory(value);
+ } else if ("resources_used.walltime".equals(header)) {
+ jobDescriptor.setEllapsedTime(value);
+ } else if ("job_state".equals(header)) {
+ jobDescriptor.setStatus(value);
+ } else if ("queue".equals(header))
+ jobDescriptor.setQueueName(value);
+ else if ("ctime".equals(header)) {
+ jobDescriptor.setCTime(value);
+ } else if ("qtime".equals(header)) {
+ jobDescriptor.setQTime(value);
+ } else if ("mtime".equals(header)) {
+ jobDescriptor.setMTime(value);
+ } else if ("start_time".equals(header)) {
+ jobDescriptor.setSTime(value);
+ } else if ("comp_time".equals(header)) {
+ jobDescriptor.setCompTime(value);
+ } else if ("exec_host".equals(header)) {
+ jobDescriptor.setExecuteNode(value);
+ } else if ("Output_Path".equals(header)) {
+ if (info[i + 1].contains("=") || info[i + 1].contains(":"))
+ jobDescriptor.setStandardOutFile(value);
+ else {
+ jobDescriptor.setStandardOutFile(value + info[i + 1].trim());
+ i++;
+ }
+ } else if ("Error_Path".equals(header)) {
+ if (info[i + 1].contains("=") || info[i + 1].contains(":"))
+ jobDescriptor.setStandardErrorFile(value);
+ else {
+ String st = info[i + 1].trim();
+ jobDescriptor.setStandardErrorFile(value + st);
+ i++;
+ }
+
+ } else if ("submit_args".equals(header)) {
+ while (i + 1 < info.length) {
+ if (info[i + 1].startsWith("\t")) {
+ value += info[i + 1];
+ i++;
+ } else
+ break;
+ }
+ value = value.replaceAll("\t", "");
+ jobDescriptor.setSubmitArgs(value);
+ }
+ }
+ }
+ }
+
+ public String parseJobSubmission(String rawOutput) {
+ log.debug(rawOutput);
+ if (rawOutput != null && !rawOutput.isEmpty()) {
+ String[] info = rawOutput.split("\n");
+ String lastLine = info[info.length - 1];
+ return lastLine.split(" ")[2]; // In PBS stdout is going to be directly the jobID
+ } else {
+ return "";
+ }
+ }
+
+ public JobStatus parseJobStatus(String jobID, String rawOutput) {
+ Pattern pattern = Pattern.compile("job_number:[\\s]+" + jobID);
+ Matcher matcher = pattern.matcher(rawOutput);
+ if (matcher.find()) {
+ return new JobStatus(JobState.QUEUED); // fixme; return correct status.
+ }
+ return new JobStatus(JobState.UNKNOWN);
+ }
+
+ public void parseJobStatuses(String userName, Map<String, JobStatus> statusMap, String rawOutput) {
+ log.debug(rawOutput);
+ String[] info = rawOutput.split("\n");
+ int lastStop = 0;
+ for (String jobID : statusMap.keySet()) {
+ for(int i=lastStop;i<info.length;i++){
+ if(jobID.split(",")[0].contains(info[i].split(" ")[0]) && !"".equals(info[i].split(" ")[0])){
+ // now starts processing this line
+ log.info(info[i]);
+ String correctLine = info[i];
+ String[] columns = correctLine.split(" ");
+ List<String> columnList = new ArrayList<String>();
+ for (String s : columns) {
+ if (!"".equals(s)) {
+ columnList.add(s);
+ }
+ }
+ lastStop = i+1;
+ if ("E".equals(columnList.get(4))) {
+ // There is another status with the same letter E other than error status
+ // to avoid that we make a small tweek to the job status
+ columnList.set(4, "Er");
+ }
+ statusMap.put(jobID, new JobStatus(JobState.valueOf(columnList.get(4))));
+ break;
+ }
+ }
+ }
+ }
+
+ @Override
+ public String parseJobId(String jobName, String rawOutput) throws SSHApiException {
+ if (jobName.length() > 10) {
+ jobName = jobName.substring(0, 10);
+ }
+ Pattern pattern = Pattern.compile("(?<" + JOB_ID + ">\\S+)\\s+\\S+\\s+(" + jobName + ")");
+ Matcher matcher = pattern.matcher(rawOutput);
+ if (matcher.find()) {
+ return matcher.group(JOB_ID);
+ }
+ return null;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/HPCMonitorID.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/HPCMonitorID.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/HPCMonitorID.java
deleted file mode 100644
index 69119d2..0000000
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/HPCMonitorID.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package org.apache.airavata.gfac.monitor;/*
- *
- * 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.
- *
-*/
-
-import org.apache.airavata.gfac.core.GFacException;
-import org.apache.airavata.gfac.core.SecurityContext;
-import org.apache.airavata.gfac.core.authentication.AuthenticationInfo;
-import org.apache.airavata.gfac.core.cluster.ServerInfo;
-import org.apache.airavata.gfac.core.context.JobExecutionContext;
-import org.apache.airavata.gfac.core.monitor.MonitorID;
-import org.apache.airavata.gfac.gsi.ssh.impl.authentication.MyProxyAuthenticationInfo;
-import org.apache.airavata.gfac.gsissh.security.GSISecurityContext;
-import org.apache.airavata.gfac.ssh.security.SSHSecurityContext;
-import org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.sql.Timestamp;
-import java.util.Date;
-
-public class HPCMonitorID extends MonitorID {
- private final static Logger logger = LoggerFactory.getLogger(HPCMonitorID.class);
-
-
- private AuthenticationInfo authenticationInfo = null;
-
- public HPCMonitorID(ComputeResourceDescription computeResourceDescription, String jobID, String taskID, String workflowNodeID,
- String experimentID, String userName,String jobName) {
- super(computeResourceDescription, jobID, taskID, workflowNodeID, experimentID, userName,jobName);
- setComputeResourceDescription(computeResourceDescription);
- setJobStartedTime(new Timestamp((new Date()).getTime()));
- setUserName(userName);
- setJobID(jobID);
- setTaskID(taskID);
- setExperimentID(experimentID);
- setWorkflowNodeID(workflowNodeID);
- }
-
- public HPCMonitorID(AuthenticationInfo authenticationInfo, JobExecutionContext jobExecutionContext) {
- super(jobExecutionContext);
- this.authenticationInfo = authenticationInfo;
- if (this.authenticationInfo != null) {
- try {
- String hostAddress = jobExecutionContext.getHostName();
- SecurityContext securityContext = jobExecutionContext.getSecurityContext(hostAddress);
- ServerInfo serverInfo = null;
- if (securityContext != null) {
- if (securityContext instanceof GSISecurityContext){
- serverInfo = (((GSISecurityContext) securityContext).getRemoteCluster()).getServerInfo();
- if (serverInfo.getUserName() != null) {
- setUserName(serverInfo.getUserName());
- }
- }
- if (securityContext instanceof SSHSecurityContext){
- serverInfo = (((SSHSecurityContext) securityContext).getRemoteCluster()).getServerInfo();
- if (serverInfo.getUserName() != null) {
- setUserName(serverInfo.getUserName());
- }
- }
- }
- } catch (GFacException e) {
- logger.error("Error while getting security context", e);
- }
- }
- }
-
- public HPCMonitorID(ComputeResourceDescription computeResourceDescription, String jobID, String taskID, String workflowNodeID, String experimentID, String userName, AuthenticationInfo authenticationInfo) {
- setComputeResourceDescription(computeResourceDescription);
- setJobStartedTime(new Timestamp((new Date()).getTime()));
- this.authenticationInfo = authenticationInfo;
- // if we give myproxyauthenticationInfo, so we try to use myproxy user as the user
- if (this.authenticationInfo != null) {
- if (this.authenticationInfo instanceof MyProxyAuthenticationInfo) {
- setUserName(((MyProxyAuthenticationInfo) this.authenticationInfo).getUserName());
- }
- }
- setJobID(jobID);
- setTaskID(taskID);
- setExperimentID(experimentID);
- setWorkflowNodeID(workflowNodeID);
- }
-
- public AuthenticationInfo getAuthenticationInfo() {
- return authenticationInfo;
- }
-
- public void setAuthenticationInfo(AuthenticationInfo authenticationInfo) {
- this.authenticationInfo = authenticationInfo;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/HostMonitorData.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/HostMonitorData.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/HostMonitorData.java
deleted file mode 100644
index f29e3e6..0000000
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/HostMonitorData.java
+++ /dev/null
@@ -1,88 +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;
-
-import org.apache.airavata.gfac.core.context.JobExecutionContext;
-import org.apache.airavata.gfac.core.monitor.MonitorID;
-import org.apache.airavata.gfac.monitor.exception.AiravataMonitorException;
-import org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription;
-import org.apache.airavata.model.appcatalog.computeresource.DataMovementProtocol;
-import org.apache.airavata.model.appcatalog.computeresource.JobSubmissionProtocol;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class HostMonitorData {
-// private HostDescription host;
- private ComputeResourceDescription computeResourceDescription;
- private JobSubmissionProtocol jobSubmissionProtocol;
- private DataMovementProtocol dataMovementProtocol;
-
- private List<MonitorID> monitorIDs;
-
- public HostMonitorData(JobExecutionContext jobExecutionContext) {
- this.computeResourceDescription = jobExecutionContext.getApplicationContext().getComputeResourceDescription();
- this.jobSubmissionProtocol = jobExecutionContext.getPreferredJobSubmissionProtocol();
- this.dataMovementProtocol = jobExecutionContext.getPreferredDataMovementProtocol();
- this.monitorIDs = new ArrayList<MonitorID>();
- }
-
- public HostMonitorData(JobExecutionContext jobExecutionContext, List<MonitorID> monitorIDs) {
- this.computeResourceDescription = jobExecutionContext.getApplicationContext().getComputeResourceDescription();
- this.jobSubmissionProtocol = jobExecutionContext.getPreferredJobSubmissionProtocol();
- this.dataMovementProtocol = jobExecutionContext.getPreferredDataMovementProtocol();
- this.monitorIDs = monitorIDs;
- }
-
- public ComputeResourceDescription getComputeResourceDescription() {
- return computeResourceDescription;
- }
-
- public void setComputeResourceDescription(ComputeResourceDescription computeResourceDescription) {
- this.computeResourceDescription = computeResourceDescription;
- }
-
- public List<MonitorID> getMonitorIDs() {
- return monitorIDs;
- }
-
- public void setMonitorIDs(List<MonitorID> monitorIDs) {
- this.monitorIDs = monitorIDs;
- }
-
- /**
- * this method get called by CommonUtils and it will check the right place before adding
- * so there will not be a mismatch between this.host and monitorID.host
- * @param monitorID
- * @throws org.apache.airavata.gfac.monitor.exception.AiravataMonitorException
- */
- public void addMonitorIDForHost(MonitorID monitorID)throws AiravataMonitorException {
- monitorIDs.add(monitorID);
- }
-
- public JobSubmissionProtocol getJobSubmissionProtocol() {
- return jobSubmissionProtocol;
- }
-
- public DataMovementProtocol getDataMovementProtocol() {
- return dataMovementProtocol;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/UserMonitorData.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/UserMonitorData.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/UserMonitorData.java
deleted file mode 100644
index 022d17c..0000000
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/UserMonitorData.java
+++ /dev/null
@@ -1,76 +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;
-
-import org.apache.airavata.gfac.monitor.exception.AiravataMonitorException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This is the datastructure to keep the user centric job data, rather keeping
- * the individual jobs we keep the jobs based on the each user
- */
-public class UserMonitorData {
- private final static Logger logger = LoggerFactory.getLogger(UserMonitorData.class);
-
- private String userName;
-
- private List<HostMonitorData> hostMonitorData;
-
-
- public UserMonitorData(String userName) {
- this.userName = userName;
- hostMonitorData = new ArrayList<HostMonitorData>();
- }
-
- public UserMonitorData(String userName, List<HostMonitorData> hostMonitorDataList) {
- this.hostMonitorData = hostMonitorDataList;
- this.userName = userName;
- }
-
- public List<HostMonitorData> getHostMonitorData() {
- return hostMonitorData;
- }
-
- public void setHostMonitorData(List<HostMonitorData> hostMonitorData) {
- this.hostMonitorData = hostMonitorData;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- /*
- This method will add element to the MonitorID list, user should not
- duplicate it, we do not check it because its going to be used by airavata
- so we have to use carefully and this method will add a host if its a new host
- */
- public void addHostMonitorData(HostMonitorData hostMonitorData) throws AiravataMonitorException {
- this.hostMonitorData.add(hostMonitorData);
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/command/ExperimentCancelRequest.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/command/ExperimentCancelRequest.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/command/ExperimentCancelRequest.java
deleted file mode 100644
index f19decf..0000000
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/command/ExperimentCancelRequest.java
+++ /dev/null
@@ -1,38 +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.command;
-
-public class ExperimentCancelRequest {
- private String experimentId;
-
- public ExperimentCancelRequest(String experimentId) {
- this.experimentId = experimentId;
- }
-
- public String getExperimentId() {
- return experimentId;
- }
-
- public void setExperimentId(String experimentId) {
- this.experimentId = experimentId;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/command/TaskCancelRequest.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/command/TaskCancelRequest.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/command/TaskCancelRequest.java
deleted file mode 100644
index b45e01c..0000000
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/command/TaskCancelRequest.java
+++ /dev/null
@@ -1,52 +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.command;
-
-public class TaskCancelRequest {
- private String experimentId;
- private String nodeId;
- private String taskId;
-
- public TaskCancelRequest(String experimentId, String nodeId, String taskId) {
- this.experimentId = experimentId;
- this.setNodeId(nodeId);
- this.taskId = taskId;
- }
- public String getExperimentId() {
- return experimentId;
- }
- public void setExperimentId(String experimentId) {
- this.experimentId = experimentId;
- }
- public String getTaskId() {
- return taskId;
- }
- public void setTaskId(String taskId) {
- this.taskId = taskId;
- }
- public String getNodeId() {
- return nodeId;
- }
- public void setNodeId(String nodeId) {
- this.nodeId = nodeId;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/core/AiravataAbstractMonitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/core/AiravataAbstractMonitor.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/core/AiravataAbstractMonitor.java
deleted file mode 100644
index 72ffad6..0000000
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/core/AiravataAbstractMonitor.java
+++ /dev/null
@@ -1,37 +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.core;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This is the abstract Monitor which needs to be used by
- * any Monitoring implementation which expect nto consume
- * to store the status to registry. Because they have to
- * use the LocalEventPublisher to publish the monitoring statuses
- * to the Event Bus. All the Monitor statuses publish to the eventbus
- * will be saved to the Registry.
- */
-public abstract class AiravataAbstractMonitor implements Monitor {
- private final static Logger logger = LoggerFactory.getLogger(AiravataAbstractMonitor.class);
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/core/MessageParser.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/core/MessageParser.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/core/MessageParser.java
deleted file mode 100644
index aada526..0000000
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/core/MessageParser.java
+++ /dev/null
@@ -1,43 +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.core;
-
-import org.apache.airavata.gfac.monitor.exception.AiravataMonitorException;
-import org.apache.airavata.model.experiment.JobState;
-
-/**
- * This is an interface to implement messageparser, it could be
- * pull based or push based still monitor has to parse the content of
- * the message it gets from remote monitoring system and finalize
- * them to internal job state, Ex: JSON parser for AMQP and Qstat reader
- * for pull based monitor.
- */
-public interface MessageParser {
- /**
- * This method is to implement how to parse the incoming message
- * and implement a logic to finalize the status of the job,
- * we have to makesure the correct message is given to the messageparser
- * parse method, it will not do any filtering
- * @param message content of the message
- * @return
- */
- JobState parseMessage(String message)throws AiravataMonitorException;
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/core/Monitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/core/Monitor.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/core/Monitor.java
deleted file mode 100644
index 614d606..0000000
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/core/Monitor.java
+++ /dev/null
@@ -1,30 +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.core;
-
-
-/**
- * This is the primary interface for Monitors,
- * This can be used to implement different methods of monitoring
- */
-public interface Monitor {
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/core/PullMonitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/core/PullMonitor.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/core/PullMonitor.java
deleted file mode 100644
index efdf89c..0000000
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/core/PullMonitor.java
+++ /dev/null
@@ -1,64 +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.core;
-
-import org.apache.airavata.gfac.monitor.exception.AiravataMonitorException;
-
-/**
- * PullMonitors can implement this interface
- * Since the pull and push based monitoring required different
- * operations, PullMonitor will be useful.
- * This will allow users to program Pull monitors separately
- */
-public abstract class PullMonitor extends AiravataAbstractMonitor {
-
- private int pollingFrequence;
- /**
- * This method will can invoke when PullMonitor needs to start
- * and it has to invoke in the frequency specified below,
- * @return if the start process is successful return true else false
- */
- public abstract boolean startPulling() throws AiravataMonitorException;
-
- /**
- * This is the method to stop the polling process
- * @return if the stopping process is successful return true else false
- */
- public abstract boolean stopPulling()throws AiravataMonitorException;
-
- /**
- * this method can be used to set the polling frequencey or otherwise
- * can implement a polling mechanism, and implement how to do
- * @param frequence
- */
- public void setPollingFrequence(int frequence){
- this.pollingFrequence = frequence;
- }
-
- /**
- * this method can be used to get the polling frequencey or otherwise
- * can implement a polling mechanism, and implement how to do
- * @return
- */
- public int getPollingFrequence(){
- return this.pollingFrequence;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/core/PushMonitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/core/PushMonitor.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/core/PushMonitor.java
deleted file mode 100644
index 1b6a228..0000000
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/core/PushMonitor.java
+++ /dev/null
@@ -1,60 +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.core;
-
-import org.apache.airavata.gfac.core.monitor.MonitorID;
-import org.apache.airavata.gfac.monitor.exception.AiravataMonitorException;
-
-/**
- * PushMonitors can implement this interface
- * Since the pull and push based monitoring required different
- * operations, PullMonitor will be useful.
- * This interface will allow users to program Push monitors separately
- */
-public abstract class PushMonitor extends AiravataAbstractMonitor {
- /**
- * This method can be invoked to register a listener with the
- * remote monitoring system, ideally inside this method users will be
- * writing some client listener code for the remote monitoring system,
- * this will be a simple wrapper around any client for the remote Monitor.
- * @param monitorID
- * @return
- */
- public abstract boolean registerListener(MonitorID monitorID)throws AiravataMonitorException;
-
- /**
- * This method can be invoked to unregister a listener with the
- * remote monitoring system, ideally inside this method users will be
- * writing some client listener code for the remote monitoring system,
- * this will be a simple wrapper around any client for the remote Monitor.
- * @param monitorID
- * @return
- */
- public abstract boolean unRegisterListener(MonitorID monitorID)throws AiravataMonitorException;
-
- /**
- * This can be used to stop the registration thread
- * @return
- * @throws org.apache.airavata.gfac.monitor.exception.AiravataMonitorException
- */
- public abstract boolean stopRegister()throws AiravataMonitorException;
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/EmailBasedMonitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/EmailBasedMonitor.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/EmailBasedMonitor.java
index 782a454..5ef0e88 100644
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/EmailBasedMonitor.java
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/EmailBasedMonitor.java
@@ -28,6 +28,8 @@ import org.apache.airavata.gfac.core.GFacException;
import org.apache.airavata.gfac.core.GFacUtils;
import org.apache.airavata.gfac.core.context.JobExecutionContext;
import org.apache.airavata.gfac.core.GFacThreadPoolExecutor;
+import org.apache.airavata.gfac.core.context.ProcessContext;
+import org.apache.airavata.gfac.core.monitor.JobMonitor;
import org.apache.airavata.gfac.core.monitor.JobStatusResult;
import org.apache.airavata.gfac.core.monitor.EmailParser;
import org.apache.airavata.gfac.impl.OutHandlerWorker;
@@ -42,6 +44,8 @@ import org.apache.airavata.model.experiment.CorrectiveAction;
import org.apache.airavata.model.experiment.ErrorCategory;
import org.apache.airavata.model.experiment.JobState;
import org.apache.airavata.model.experiment.JobStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.mail.Address;
import javax.mail.Flags;
@@ -60,8 +64,8 @@ import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
-public class EmailBasedMonitor implements Runnable{
- private static final AiravataLogger log = AiravataLoggerFactory.getLogger(EmailBasedMonitor.class);
+public class EmailBasedMonitor implements JobMonitor, Runnable{
+ private static final Logger log = LoggerFactory.getLogger(EmailBasedMonitor.class);
public static final int COMPARISON = 6; // after and equal
public static final String IMAPS = "imaps";
@@ -350,4 +354,14 @@ public class EmailBasedMonitor implements Runnable{
public void setDate(Date date) {
this.monitorStartDate = date;
}
+
+ @Override
+ public void monitor(String jobId, ProcessContext processContext) {
+
+ }
+
+ @Override
+ public void stopMonitor(String jobId) {
+
+ }
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/EmailMonitorFactory.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/EmailMonitorFactory.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/EmailMonitorFactory.java
deleted file mode 100644
index 870cfa4..0000000
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/email/EmailMonitorFactory.java
+++ /dev/null
@@ -1,47 +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;
-
-import org.apache.airavata.common.exception.AiravataException;
-import org.apache.airavata.model.appcatalog.computeresource.ResourceJobManagerType;
-
-import java.util.Calendar;
-import java.util.Date;
-
-public class EmailMonitorFactory {
-
- private static EmailBasedMonitor emailBasedMonitor;
- private static Date startMonitorDate = Calendar.getInstance().getTime();
-
- public static EmailBasedMonitor getEmailBasedMonitor(ResourceJobManagerType resourceJobManagerType) throws AiravataException {
- if (emailBasedMonitor == null) {
- synchronized (EmailMonitorFactory.class){
- if (emailBasedMonitor == null) {
- emailBasedMonitor = new EmailBasedMonitor(resourceJobManagerType);
- emailBasedMonitor.setDate(startMonitorDate);
- new Thread(emailBasedMonitor).start();
- }
- }
- }
- return emailBasedMonitor;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/handlers/GridPullMonitorHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/handlers/GridPullMonitorHandler.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/handlers/GridPullMonitorHandler.java
deleted file mode 100644
index a7e5b90..0000000
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/monitor/handlers/GridPullMonitorHandler.java
+++ /dev/null
@@ -1,139 +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.handlers;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.logger.AiravataLogger;
-import org.apache.airavata.common.logger.AiravataLoggerFactory;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.gfac.core.authentication.AuthenticationInfo;
-import org.apache.airavata.gfac.core.context.JobExecutionContext;
-import org.apache.airavata.gfac.core.handler.GFacHandlerException;
-import org.apache.airavata.gfac.core.handler.ThreadedHandler;
-import org.apache.airavata.gfac.core.monitor.MonitorID;
-import org.apache.airavata.gfac.gsi.ssh.impl.authentication.MyProxyAuthenticationInfo;
-import org.apache.airavata.gfac.monitor.HPCMonitorID;
-import org.apache.airavata.gfac.monitor.exception.AiravataMonitorException;
-import org.apache.airavata.gfac.monitor.impl.pull.qstat.HPCPullMonitor;
-import org.apache.airavata.gfac.monitor.util.CommonUtils;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.Watcher;
-
-import java.util.Properties;
-
-/**
- * this handler is responsible for monitoring jobs in a pull mode
- * and currently this support multiple pull monitoring in grid resource and uses
- * commands like qstat,squeue and this supports sun grid enging monitoring too
- * which is a slight variation of qstat monitoring.
- */
-public class GridPullMonitorHandler extends ThreadedHandler implements Watcher{
- private final static AiravataLogger logger = AiravataLoggerFactory.getLogger(GridPullMonitorHandler.class);
-
- private HPCPullMonitor hpcPullMonitor;
-
- private AuthenticationInfo authenticationInfo;
-
- public void initProperties(Properties properties) throws GFacHandlerException {
- String myProxyUser = null;
- try {
- myProxyUser = ServerSettings.getSetting("myproxy.username");
- String myProxyPass = ServerSettings.getSetting("myproxy.password");
- String certPath = ServerSettings.getSetting("trusted.cert.location");
- String myProxyServer = ServerSettings.getSetting("myproxy.server");
- setAuthenticationInfo(new MyProxyAuthenticationInfo(myProxyUser, myProxyPass, myProxyServer,
- 7512, 17280000, certPath));
- hpcPullMonitor = new HPCPullMonitor(null,getAuthenticationInfo()); // we use our own credentials for monitoring, not from the store
- } catch (ApplicationSettingsException e) {
- logger.error("Error while reading server properties", e);
- throw new GFacHandlerException("Error while reading server properties", e);
- }
- }
-
- public void run() {
- hpcPullMonitor.run();
- }
-
- public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
- super.invoke(jobExecutionContext);
- hpcPullMonitor.setGfac(jobExecutionContext.getGfac());
- hpcPullMonitor.setPublisher(jobExecutionContext.getLocalEventPublisher());
- MonitorID monitorID = new HPCMonitorID(getAuthenticationInfo(), jobExecutionContext);
- try {
- /* ZooKeeper zk = jobExecutionContext.getZk();
- try {
- String experimentEntry = GFacUtils.findExperimentEntry(jobExecutionContext.getExperimentID(), zk);
- String path = experimentEntry + File.separator + "operation";
- Stat exists = zk.exists(path, this);
- if (exists != null) {
- zk.getData(path, this, exists); // watching the operations node
- }
- } catch (KeeperException e) {
- logger.error(e.getMessage(), e);
- } catch (InterruptedException e) {
- logger.error(e.getMessage(), e);
- }*/
- CommonUtils.addMonitortoQueue(hpcPullMonitor.getQueue(), monitorID, jobExecutionContext);
- CommonUtils.increaseZkJobCount(monitorID); // update change job count to zookeeper
- } catch (AiravataMonitorException e) {
- logger.errorId(monitorID.getJobID(), "Error adding job {} monitorID object to the queue with experiment {}",
- monitorID.getJobID(), monitorID.getExperimentID());
- }
- }
-
- @Override
- public void recover(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
- // TODO: Auto generated method body.
- }
-
- public AuthenticationInfo getAuthenticationInfo() {
- return authenticationInfo;
- }
-
- public HPCPullMonitor getHpcPullMonitor() {
- return hpcPullMonitor;
- }
-
- public void setAuthenticationInfo(AuthenticationInfo authenticationInfo) {
- this.authenticationInfo = authenticationInfo;
- }
-
- public void setHpcPullMonitor(HPCPullMonitor hpcPullMonitor) {
- this.hpcPullMonitor = hpcPullMonitor;
- }
-
-
- public void process(WatchedEvent watchedEvent) {
- logger.info(watchedEvent.getPath());
- if(Event.EventType.NodeDataChanged.equals(watchedEvent.getType())){
- // node data is changed, this means node is cancelled.
- logger.info("Experiment is cancelled with this path:"+watchedEvent.getPath());
-
- String[] split = watchedEvent.getPath().split("/");
- for(String element:split) {
- if (element.contains("+")) {
- logger.info("Adding experimentID+TaskID to be removed from monitoring:"+element);
- hpcPullMonitor.getCancelJobList().add(element);
- }
- }
- }
- }
-}