You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2014/05/01 20:29:19 UTC
[1/9] Separating gfac-monitoring implementation
Repository: airavata
Updated Branches:
refs/heads/master 0eabb9372 -> 553caa087
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/NewOrchestratorTest.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/NewOrchestratorTest.java b/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/NewOrchestratorTest.java
index 59ff255..0ab5145 100644
--- a/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/NewOrchestratorTest.java
+++ b/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/NewOrchestratorTest.java
@@ -100,6 +100,8 @@ public class NewOrchestratorTest extends BaseOrchestratorTest {
Registry defaultRegistry = RegistryFactory.getDefaultRegistry();
String experimentId = (String)defaultRegistry.add(ParentDataType.EXPERIMENT, simpleExperiment);
+
+ simpleExperiment.setExperimentID(experimentId);
tasks = orchestrator.createTasks(experimentId);
for(TaskDetails details:tasks) {
orchestrator.launchExperiment(simpleExperiment,test, details);
[2/9] Separating gfac-monitoring implementation
Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/ToStorageService.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/ToStorageService.json b/modules/gfac/gfac-monitor/src/main/resources/schema/ToStorageService.json
new file mode 100644
index 0000000..644f3d1
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/ToStorageService.json
@@ -0,0 +1,25 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/ToStorageService.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Entity.json"}],
+ "properties": {
+ "LocalPath": {
+ "type": "string",
+ "description": "The path within the ComputingService that is used to access the StorageService"
+ },
+ "RemotePath": {
+ "type": "string",
+ "description": "The path in the StorageService which is associated with the LocalPath"
+ },
+ "ComputingServiceID": {
+ "type": "string",
+ "description": "The ID of the ComputingService"
+ },
+ "StorageServiceID": {
+ "type": "string",
+ "description": "The ID of the StorageService"
+ }
+ },
+ "required": ["LocalPath","RemotePath","ComputingServiceID","StorageServiceID"]
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/UserDomain.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/UserDomain.json b/modules/gfac/gfac-monitor/src/main/resources/schema/UserDomain.json
new file mode 100644
index 0000000..7acda31
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/UserDomain.json
@@ -0,0 +1,58 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/UserDomain.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Domain.json"}],
+ "properties": {
+ "Level": {
+ "type": "integer",
+ "description": "the number of hops to reach the root of the hierarchy of UserDomains"
+ },
+ "UserManagerID": {
+ "type": "array",
+ "description": "ID for the Endpoint of a Service managing users in this UserDomain",
+ "items": {
+ "type": "string"
+ }
+ },
+ "Member": {
+ "type": "array",
+ "description": "Identifiers for users in this UserDomain",
+ "items": {
+ "type": "string"
+ }
+ },
+ "PolicyID": {
+ "type": "array",
+ "description": "IDs for Policies associated with this UserDomain",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ChildDomainID": {
+ "type": "array",
+ "description": "IDs of UserDomains aggregated by this UserDomain",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ParentDomainID": {
+ "type": "string",
+ "description": "The ID of the UserDomain that this UserDomain participates in"
+ },
+ "AccessPolicyID": {
+ "type": "array",
+ "description": "IDs of AccessPolicies associated with this UserDomain",
+ "items": {
+ "type": "string"
+ }
+ },
+ "MappingPolicyID": {
+ "type": "array",
+ "description": "IDs of MappingPolicies associated with this UserDomain",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/service.properties
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/service.properties b/modules/gfac/gfac-monitor/src/main/resources/service.properties
new file mode 100644
index 0000000..391bfea
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/service.properties
@@ -0,0 +1,58 @@
+#
+#
+# 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.
+#
+#
+
+
+#
+# Class which implemented Scheduler interface. It will be used to determine a Provider
+#
+scheduler.class= org.apache.airavata.core.gfac.scheduler.impl.SchedulerImpl
+
+#
+# Data Service Plugins classes
+#
+datachain.classes= org.apache.airavata.core.gfac.extension.data.RegistryDataService
+
+#
+# Pre execution Plugins classes. For example, GridFTP Input Staging
+#
+prechain.classes= org.apache.airavata.core.gfac.extension.pre.GridFtpInputStaging
+prechain.classes= org.apache.airavata.core.gfac.extension.pre.HttpInputStaging
+
+#
+# Post execution Plugins classes. For example, GridFTP Output Staging
+#
+postchain.classes= org.apache.airavata.core.gfac.extension.post.GridFtpOutputStaging
+postchain.classes= org.apache.airavata.core.gfac.extension.post.OutputRegister
+
+#
+# SSH private key location. It will be used by SSHProvider
+#
+# ssh.key=/home/user/.ssh/id_rsa
+# ssh.keypass=
+# ssh.username=usernameAtHost
+
+#
+# MyProxy credential. It will be used by GridFTP Plugins and GramProvider.
+#
+# myproxy.server=myproxy.teragrid.org
+# myproxy.user=username
+# myproxy.pass=password
+# myproxy.life=3600
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/test/java/org/apache/airavata/job/AMQPMonitorTest.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/test/java/org/apache/airavata/job/AMQPMonitorTest.java b/modules/gfac/gfac-monitor/src/test/java/org/apache/airavata/job/AMQPMonitorTest.java
new file mode 100644
index 0000000..9e1eadd
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/test/java/org/apache/airavata/job/AMQPMonitorTest.java
@@ -0,0 +1,178 @@
+/*
+ *
+ * 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.job;
+
+import com.google.common.eventbus.EventBus;
+import com.google.common.eventbus.Subscribe;
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.gsi.ssh.api.Cluster;
+import org.apache.airavata.gsi.ssh.api.SSHApiException;
+import org.apache.airavata.gsi.ssh.api.ServerInfo;
+import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
+import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
+import org.apache.airavata.gsi.ssh.impl.PBSCluster;
+import org.apache.airavata.gsi.ssh.impl.authentication.MyProxyAuthenticationInfo;
+import org.apache.airavata.gfac.monitor.MonitorID;
+import org.apache.airavata.gfac.monitor.event.MonitorPublisher;
+import org.apache.airavata.gfac.monitor.impl.push.amqp.AMQPMonitor;
+import org.apache.airavata.gfac.monitor.state.JobStatusChangeRequest;
+import org.apache.airavata.schemas.gfac.GsisshHostType;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+
+public class AMQPMonitorTest {
+
+ private String myProxyUserName;
+ private String myProxyPassword;
+ private String certificateLocation;
+ private String pbsFilePath;
+ private String workingDirectory;
+ private HostDescription hostDescription;
+ private MonitorPublisher monitorPublisher;
+ private BlockingQueue<MonitorID> finishQueue;
+ private BlockingQueue<MonitorID> pushQueue;
+ private Thread pushThread;
+ private String proxyFilePath;
+ @Before
+ public void setUp() throws Exception {
+ System.setProperty("myproxy.username", "ogce");
+ System.setProperty("myproxy.password", "OpenGwy14");
+ System.setProperty("basedir", "/Users/lahirugunathilake/work/airavata/sandbox/gsissh");
+ System.setProperty("gsi.working.directory", "/home1/01437/ogce");
+ System.setProperty("trusted.cert.location", "/Users/lahirugunathilake/Downloads/certificates");
+ System.setProperty("proxy.file.path", "/Users/lahirugunathilake/Downloads/x509up_u503876");
+ myProxyUserName = System.getProperty("myproxy.username");
+ myProxyPassword = System.getProperty("myproxy.password");
+ workingDirectory = System.getProperty("gsi.working.directory");
+ certificateLocation = System.getProperty("trusted.cert.location");
+ proxyFilePath = System.getProperty("proxy.file.path");
+ System.setProperty("connection.name", "xsede");
+ if (myProxyUserName == null || myProxyPassword == null || workingDirectory == null) {
+ System.out.println(">>>>>> Please run tests with my proxy user name and password. " +
+ "E.g :- mvn clean install -Dmyproxy.user=xxx -Dmyproxy.password=xxx -Dgsi.working.directory=/path<<<<<<<");
+ throw new Exception("Need my proxy user name password to run tests.");
+ }
+
+ monitorPublisher = new MonitorPublisher(new EventBus());
+ pushQueue = new LinkedBlockingQueue<MonitorID>();
+ finishQueue = new LinkedBlockingQueue<MonitorID>();
+
+
+ final AMQPMonitor amqpMonitor = new
+ AMQPMonitor(monitorPublisher,
+ pushQueue, finishQueue,proxyFilePath,"xsede",
+ Arrays.asList("info1.dyn.teragrid.org,info2.dyn.teragrid.org".split(",")));
+ try {
+ (new Thread(){
+ public void run(){
+ amqpMonitor.run();
+ }
+ }).start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ hostDescription = new HostDescription(GsisshHostType.type);
+ hostDescription.getType().setHostAddress("login1.stampede.tacc.utexas.edu");
+ hostDescription.getType().setHostName("stampede-host");
+ ((GsisshHostType) hostDescription.getType()).setJobManager("slurm");
+ ((GsisshHostType) hostDescription.getType()).setInstalledPath("/usr/bin/");
+ ((GsisshHostType) hostDescription.getType()).setPort(2222);
+ ((GsisshHostType) hostDescription.getType()).setMonitorMode("push");
+ }
+
+ @Test
+ public void testAMQPMonitor() throws SSHApiException {
+ /* now have to submit a job to some machine and add that job to the queue */
+ //Create authentication
+ GSIAuthenticationInfo authenticationInfo
+ = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
+ 7512, 17280000, certificateLocation);
+
+ // Server info
+ ServerInfo serverInfo = new ServerInfo("ogce", "login1.stampede.tacc.utexas.edu",2222);
+
+
+ Cluster pbsCluster = new
+ PBSCluster(serverInfo, authenticationInfo, org.apache.airavata.gsi.ssh.util.CommonUtils.getPBSJobManager("/usr/bin/"));
+
+
+ // Execute command
+ System.out.println("Target PBS file path: " + workingDirectory);
+ // constructing the job object
+ JobDescriptor jobDescriptor = new JobDescriptor();
+ jobDescriptor.setWorkingDirectory(workingDirectory);
+ jobDescriptor.setShellName("/bin/bash");
+ jobDescriptor.setJobName("GSI_SSH_SLEEP_JOB");
+ jobDescriptor.setExecutablePath("/bin/echo");
+ jobDescriptor.setAllEnvExport(true);
+ jobDescriptor.setMailOptions("n");
+ jobDescriptor.setStandardOutFile(workingDirectory + File.separator + "application.out");
+ jobDescriptor.setStandardErrorFile(workingDirectory + File.separator + "application.err");
+ jobDescriptor.setNodes(1);
+ jobDescriptor.setProcessesPerNode(1);
+ jobDescriptor.setQueueName("normal");
+ jobDescriptor.setMaxWallTime("60");
+ jobDescriptor.setAcountString("TG-STA110014S");
+ List<String> inputs = new ArrayList<String>();
+ jobDescriptor.setOwner("ogce");
+ inputs.add("Hello World");
+ jobDescriptor.setInputValues(inputs);
+ //finished construction of job object
+ System.out.println(jobDescriptor.toXML());
+ String jobID = pbsCluster.submitBatchJob(jobDescriptor);
+ System.out.println(jobID);
+ try {
+ pushQueue.add(new MonitorID(hostDescription, jobID,null,null,null, "ogce"));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ try {
+ pushThread.join();
+ } catch (InterruptedException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ class InnerClassAMQP{
+ @Subscribe
+ private void getStatus(JobStatusChangeRequest status){
+ Assert.assertNotNull(status);
+ pushThread.interrupt();
+ }
+ }
+ monitorPublisher.registerListener(new InnerClassAMQP());
+// try {
+// pushThread.join(5000);
+// Iterator<MonitorID> iterator = pushQueue.iterator();
+// MonitorID next = iterator.next();
+// org.junit.Assert.assertNotNull(next.getStatus());
+// } catch (Exception e) {
+// e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+// }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/test/java/org/apache/airavata/job/QstatMonitorTestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/test/java/org/apache/airavata/job/QstatMonitorTestWithMyProxyAuth.java b/modules/gfac/gfac-monitor/src/test/java/org/apache/airavata/job/QstatMonitorTestWithMyProxyAuth.java
new file mode 100644
index 0000000..54562ba
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/test/java/org/apache/airavata/job/QstatMonitorTestWithMyProxyAuth.java
@@ -0,0 +1,170 @@
+/*
+ *
+ * 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.job;
+
+import com.google.common.eventbus.EventBus;
+import com.google.common.eventbus.Subscribe;
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.gsi.ssh.api.Cluster;
+import org.apache.airavata.gsi.ssh.api.SSHApiException;
+import org.apache.airavata.gsi.ssh.api.ServerInfo;
+import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
+import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
+import org.apache.airavata.gsi.ssh.impl.PBSCluster;
+import org.apache.airavata.gsi.ssh.impl.authentication.MyProxyAuthenticationInfo;
+import org.apache.airavata.gsi.ssh.util.CommonUtils;
+import org.apache.airavata.gfac.monitor.MonitorID;
+import org.apache.airavata.gfac.monitor.UserMonitorData;
+import org.apache.airavata.gfac.monitor.event.MonitorPublisher;
+import org.apache.airavata.gfac.monitor.impl.pull.qstat.HPCPullMonitor;
+import org.apache.airavata.gfac.monitor.state.JobStatusChangeRequest;
+import org.apache.airavata.schemas.gfac.GsisshHostType;
+import org.junit.Assert;
+import org.testng.annotations.Test;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+
+public class QstatMonitorTestWithMyProxyAuth {
+ private String myProxyUserName;
+ private String myProxyPassword;
+ private String certificateLocation;
+ private String pbsFilePath;
+ private String workingDirectory;
+ private HostDescription hostDescription;
+ private MonitorPublisher monitorPublisher;
+ private BlockingQueue<UserMonitorData> pullQueue;
+ private Thread monitorThread;
+
+ @org.testng.annotations.BeforeClass
+ public void setUp() throws Exception {
+ System.setProperty("myproxy.username", "ogce");
+ System.setProperty("myproxy.password", "");
+ System.setProperty("basedir", "/Users/lahirugunathilake/work/airavata/sandbox/gsissh");
+ System.setProperty("gsi.working.directory", "/home/ogce");
+ System.setProperty("trusted.cert.location", "/Users/lahirugunathilake/Downloads/certificates");
+ myProxyUserName = System.getProperty("myproxy.username");
+ myProxyPassword = System.getProperty("myproxy.password");
+ workingDirectory = System.getProperty("gsi.working.directory");
+ certificateLocation = System.getProperty("trusted.cert.location");
+ if (myProxyUserName == null || myProxyPassword == null || workingDirectory == null) {
+ System.out.println(">>>>>> Please run tests with my proxy user name and password. " +
+ "E.g :- mvn clean install -Dmyproxy.username=xxx -Dmyproxy.password=xxx -Dgsi.working.directory=/path<<<<<<<");
+ throw new Exception("Need my proxy user name password to run tests.");
+ }
+
+ monitorPublisher = new MonitorPublisher(new EventBus());
+ class InnerClassQstat {
+
+ @Subscribe
+ private void getStatus(JobStatusChangeRequest status) {
+ Assert.assertNotNull(status);
+ System.out.println(status.getState().toString());
+ monitorThread.interrupt();
+ }
+ }
+ monitorPublisher.registerListener(this);
+ pullQueue = new LinkedBlockingQueue<UserMonitorData>();
+ final HPCPullMonitor qstatMonitor = new
+ HPCPullMonitor(pullQueue, monitorPublisher);
+ try {
+ (new Thread(){
+ public void run(){
+ qstatMonitor.run();
+ }
+ }).start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ hostDescription = new HostDescription(GsisshHostType.type);
+ hostDescription.getType().setHostAddress("trestles.sdsc.edu");
+ hostDescription.getType().setHostName("gsissh-gordon");
+ ((GsisshHostType) hostDescription.getType()).setPort(22);
+ ((GsisshHostType)hostDescription.getType()).setInstalledPath("/opt/torque/bin/");
+ }
+
+ @Test
+ public void testQstatMonitor() throws SSHApiException {
+ /* now have to submit a job to some machine and add that job to the queue */
+ //Create authentication
+ GSIAuthenticationInfo authenticationInfo
+ = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
+ 7512, 17280000, certificateLocation);
+
+ // Server info
+ ServerInfo serverInfo = new ServerInfo("ogce", hostDescription.getType().getHostAddress());
+
+
+ Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getPBSJobManager("/opt/torque/bin/"));
+
+
+ // Execute command
+ System.out.println("Target PBS file path: " + workingDirectory);
+ // constructing the job object
+ JobDescriptor jobDescriptor = new JobDescriptor();
+ jobDescriptor.setWorkingDirectory(workingDirectory);
+ jobDescriptor.setShellName("/bin/bash");
+ jobDescriptor.setJobName("GSI_SSH_SLEEP_JOB");
+ jobDescriptor.setExecutablePath("/bin/echo");
+ jobDescriptor.setAllEnvExport(true);
+ jobDescriptor.setMailOptions("n");
+ jobDescriptor.setStandardOutFile(workingDirectory + File.separator + "application.out");
+ jobDescriptor.setStandardErrorFile(workingDirectory + File.separator + "application.err");
+ jobDescriptor.setNodes(1);
+ jobDescriptor.setProcessesPerNode(1);
+ jobDescriptor.setQueueName("normal");
+ jobDescriptor.setMaxWallTime("60");
+ jobDescriptor.setAcountString("sds128");
+ List<String> inputs = new ArrayList<String>();
+ jobDescriptor.setOwner("ogce");
+ inputs.add("Hello World");
+ jobDescriptor.setInputValues(inputs);
+ //finished construction of job object
+ System.out.println(jobDescriptor.toXML());
+ for (int i = 0; i < 1; i++) {
+ String jobID = pbsCluster.submitBatchJob(jobDescriptor);
+ System.out.println("Job submitted successfully, Job ID: " + jobID);
+ MonitorID monitorID = new MonitorID(hostDescription, jobID,null,null,null, "ogce");
+ monitorID.setAuthenticationInfo(authenticationInfo);
+ try {
+ org.apache.airavata.gfac.monitor.util.CommonUtils.addMonitortoQueue(pullQueue, monitorID);
+ } catch (Exception e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ }
+ try {
+
+ monitorThread.join();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Subscribe
+ public void testCaseShutDown(JobStatusChangeRequest status) {
+ Assert.assertNotNull(status.getState());
+ monitorThread.stop();
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/test/resources/PBSTemplate.xslt
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/test/resources/PBSTemplate.xslt b/modules/gfac/gfac-monitor/src/test/resources/PBSTemplate.xslt
new file mode 100644
index 0000000..e749e9c
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/test/resources/PBSTemplate.xslt
@@ -0,0 +1,73 @@
+<!--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. -->
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns="http://airavata.apache.org/gsi/ssh/2012/12">
+<xsl:output method="text" />
+<xsl:template match="/ns:JobDescriptor">
+#! /bin/sh
+# PBS batch job script built by Globus job manager
+# <xsl:choose>
+ <xsl:when test="ns:shellName">
+##PBS -S <xsl:value-of select="ns:shellName"/>
+ </xsl:when></xsl:choose>
+ <xsl:choose>
+ <xsl:when test="ns:queueName">
+#PBS -q <xsl:value-of select="ns:queueName"/>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="ns:mailOptions">
+#PBS -m <xsl:value-of select="ns:mailOptions"/>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:choose>
+<xsl:when test="ns:acountString">
+#PBS -A <xsl:value-of select="ns:acountString"/>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="ns:maxWallTime">
+#PBS -l walltime=<xsl:value-of select="ns:maxWallTime"/>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="ns:standardOutFile">
+#PBS -o <xsl:value-of select="ns:standardOutFile"/>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="ns:standardOutFile">
+#PBS -e <xsl:value-of select="ns:standardErrorFile"/>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="(ns:nodes) and (ns:processesPerNode)">
+#PBS -l nodes=<xsl:value-of select="ns:nodes"/>:ppn=<xsl:value-of select="ns:processesPerNode"/>
+<xsl:text>
</xsl:text>
+ </xsl:when>
+ </xsl:choose>
+<xsl:for-each select="ns:exports/ns:name">
+<xsl:value-of select="."/>=<xsl:value-of select="./@value"/><xsl:text>
</xsl:text>
+export<xsl:text> </xsl:text><xsl:value-of select="."/>
+<xsl:text>
</xsl:text>
+</xsl:for-each>
+<xsl:for-each select="ns:preJobCommands/ns:command">
+ <xsl:value-of select="."/><xsl:text> </xsl:text>
+ </xsl:for-each>
+cd <xsl:text> </xsl:text><xsl:value-of select="ns:workingDirectory"/><xsl:text>
</xsl:text>
+ <xsl:choose><xsl:when test="ns:jobSubmitterCommand">
+<xsl:value-of select="ns:jobSubmitterCommand"/><xsl:text> </xsl:text></xsl:when></xsl:choose><xsl:value-of select="ns:executablePath"/><xsl:text> </xsl:text>
+<xsl:for-each select="ns:inputs/ns:input">
+ <xsl:value-of select="."/><xsl:text> </xsl:text>
+ </xsl:for-each>
+<xsl:for-each select="ns:postJobCommands/ns:command">
+ <xsl:value-of select="."/><xsl:text> </xsl:text>
+</xsl:for-each>
+
+</xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/test/resources/echo.bat
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/test/resources/echo.bat b/modules/gfac/gfac-monitor/src/test/resources/echo.bat
new file mode 100644
index 0000000..c6b849b
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/test/resources/echo.bat
@@ -0,0 +1,22 @@
+::
+::
+:: 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.
+::
+::
+@echo off
+echo %1^=%2
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/test/resources/gfac-config.xml
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/test/resources/gfac-config.xml b/modules/gfac/gfac-monitor/src/test/resources/gfac-config.xml
new file mode 100644
index 0000000..da92462
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/test/resources/gfac-config.xml
@@ -0,0 +1,65 @@
+<!-- ~ 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. -->
+
+<GFac>
+ <DaemonHandlers>
+ <Handler class="org.apache.airavata.job.TestThreadedHandler">
+ </Handler>
+ </DaemonHandlers>
+ <GlobalHandlers>
+ <InHandlers>
+ <Handler class="org.apache.airavata.job.TestGlobalHandler">
+ <property name="name" value="value"/>
+ </Handler>
+ </InHandlers>
+ <OutHandlers></OutHandlers>
+ </GlobalHandlers>
+
+ <Application name="UltraScan" class="org.apache.airavata.job.TestProvider">
+ <InHandlers>
+ <Handler class="org.apache.airavata.job.TestInHandler"/>
+ </InHandlers>
+ <OutHandlers>
+ <Handler class="org.apache.airavata.job.TestOutHandler"/>
+ </OutHandlers>
+ </Application>
+
+
+ <Provider class="org.apache.airavata.job.TestProvider" host="org.apache.airavata.schemas.gfac.impl.GsisshHostTypeImpl" executionMode="async">
+ <InHandlers>
+ <Handler class="org.apache.airavata.job.TestInHandler">
+ <property name="name1" value="value1"/>
+ </Handler>
+ <!--Handler class="org.apache.airavata.gfac.handler.AdvancedSCPInputHandler">
+ <property name="privateKeyPath" value="/Users/lahirugunathilake/.ssh/id_dsa"/>
+ <property name="publicKeyPath" value="/Users/lahirugunathilake/.ssh/id_dsa.pub"/>
+ <property name="userName" value="root"/>
+ <property name="hostName" value="gw98.iu.xsede.org"/>
+ <property name="inputPath" value="/tmp"/>
+ <property name="passPhrase" value="/home/airavata/outputData"/>
+ <property name="password" value="/home/airavata/outputData"/> <either we have to set password or keys, password has higher preference>
+ </Handler-->
+ </InHandlers>
+ <OutHandlers>
+ <Handler class="org.apache.airavata.job.TestOutHandler"/>
+ <!--Handler class="org.apache.airavata.gfac.handler.AdvancedSCPOutputHandler">
+ <property name="privateKeyPath" value="/Users/lahirugunathilake/.ssh/id_dsa"/>
+ <property name="publicKeyPath" value="/Users/lahirugunathilake/.ssh/id_dsa.pub"/>
+ <property name="userName" value="root"/>
+ <property name="hostName" value="gw111.iu.xsede.org"/>
+ <property name="outputPath" value="/tmp"/>
+ <property name="passPhrase" value="/home/airavata/outputData"/>
+ <property name="password" value="/home/airavata/outputData"/> <either we have to set password or keys, password has higher preference>
+ </Handler-->
+ </OutHandlers>
+ </Provider>
+</GFac>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/test/resources/logging.properties
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/test/resources/logging.properties b/modules/gfac/gfac-monitor/src/test/resources/logging.properties
new file mode 100644
index 0000000..0584d38
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/test/resources/logging.properties
@@ -0,0 +1,42 @@
+#
+# 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.
+#
+#
+#default/fallback log4j configuration
+#
+
+# Set root logger level to WARN and its only appender to A1.
+log4j.rootLogger=INFO, A1, A2
+
+# A1 is set to be a rolling file appender with default params
+log4j.appender.A1=org.apache.log4j.RollingFileAppender
+log4j.appender.A1.File=target/seclogs.txt
+
+# A1 uses PatternLayout.
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
+
+# A2 is a console appender
+log4j.appender.A2=org.apache.log4j.ConsoleAppender
+
+# A2 uses PatternLayout.
+log4j.appender.A2.layout=org.apache.log4j.PatternLayout
+log4j.appender.A2.layout.ConversionPattern=%d [%t] %-5p %c{1} %x - %m%n
+
+log4j.logger.unicore.security=INFO
+
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/AdvancedSCPInputHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/AdvancedSCPInputHandler.java b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/AdvancedSCPInputHandler.java
index 1fa6d86..13c325d 100644
--- a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/AdvancedSCPInputHandler.java
+++ b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/AdvancedSCPInputHandler.java
@@ -73,7 +73,7 @@ public class AdvancedSCPInputHandler extends AbstractHandler{
private String inputPath;
- public void initProperties(Map<String, String> properties) throws GFacHandlerException, GFacException {
+ public void initProperties(Map<String, String> properties) throws GFacHandlerException {
password = properties.get("password");
passPhrase = properties.get("passPhrase");
privateKeyPath = properties.get("privateKeyPath");
@@ -83,8 +83,10 @@ public class AdvancedSCPInputHandler extends AbstractHandler{
inputPath = properties.get("inputPath");
}
- public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException, GFacException {
- if(jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT) == null){
+ public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
+ MessageContext inputNew = new MessageContext();
+ try{
+ if(jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT) == null){
try {
GFACSSHUtils.addSecurityContext(jobExecutionContext);
} catch (ApplicationSettingsException e) {
@@ -92,21 +94,19 @@ public class AdvancedSCPInputHandler extends AbstractHandler{
throw new GFacHandlerException("Error while creating SSHSecurityContext", e, e.getLocalizedMessage());
}
}
- ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext()
+ ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext()
.getApplicationDeploymentDescription().getType();
- AuthenticationInfo authenticationInfo = null;
- if (password != null) {
+ AuthenticationInfo authenticationInfo = null;
+ if (password != null) {
authenticationInfo = new DefaultPasswordAuthenticationInfo(this.password);
} else {
authenticationInfo = new DefaultPublicKeyFileAuthentication(this.publicKeyPath, this.privateKeyPath,
this.passPhrase);
}
- // Server info
- ServerInfo serverInfo = new ServerInfo(this.userName, this.hostName);
- Cluster pbsCluster = null;
- MessageContext inputNew = new MessageContext();
- try {
+ // Server info
+ ServerInfo serverInfo = new ServerInfo(this.userName, this.hostName);
+ Cluster pbsCluster = null;
// here doesn't matter what the job manager is because we are only doing some file handling
// not really dealing with monitoring or job submission, so we pa
pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getPBSJobManager("/opt/torque/torque-4.2.3.1/bin/"));
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/AdvancedSCPOutputHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/AdvancedSCPOutputHandler.java b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/AdvancedSCPOutputHandler.java
index a0d3272..dba3e69 100644
--- a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/AdvancedSCPOutputHandler.java
+++ b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/AdvancedSCPOutputHandler.java
@@ -38,7 +38,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
-import java.util.List;
import java.util.Map;
/**
@@ -72,7 +71,7 @@ public class AdvancedSCPOutputHandler extends AbstractHandler {
private String outputPath;
- public void initProperties(Map<String, String> properties) throws GFacHandlerException, GFacException {
+ public void initProperties(Map<String, String> properties) throws GFacHandlerException {
password = properties.get("password");
passPhrase = properties.get("passPhrase");
privateKeyPath = properties.get("privateKeyPath");
@@ -83,31 +82,32 @@ public class AdvancedSCPOutputHandler extends AbstractHandler {
}
@Override
- public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException, GFacException {
- if(jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT) == null){
- try {
- GFACSSHUtils.addSecurityContext(jobExecutionContext);
- } catch (ApplicationSettingsException e) {
- log.error(e.getMessage());
- throw new GFacHandlerException("Error while creating SSHSecurityContext", e, e.getLocalizedMessage());
+ public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
+ try {
+ if (jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT) == null) {
+ try {
+ GFACSSHUtils.addSecurityContext(jobExecutionContext);
+ } catch (ApplicationSettingsException e) {
+ log.error(e.getMessage());
+ throw new GFacHandlerException("Error while creating SSHSecurityContext", e, e.getLocalizedMessage());
+ }
}
- }
- ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext()
- .getApplicationDeploymentDescription().getType();
- String standardError = app.getStandardError();
- String standardOutput = app.getStandardOutput();
- String outputDataDirectory = app.getOutputDataDirectory();
+ ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext()
+ .getApplicationDeploymentDescription().getType();
+ String standardError = app.getStandardError();
+ String standardOutput = app.getStandardOutput();
+ String outputDataDirectory = app.getOutputDataDirectory();
+
+ AuthenticationInfo authenticationInfo = null;
+ if (password != null) {
+ authenticationInfo = new DefaultPasswordAuthenticationInfo(this.password);
+ } else {
+ authenticationInfo = new DefaultPublicKeyFileAuthentication(this.publicKeyPath, this.privateKeyPath,
+ this.passPhrase);
+ }
+ // Server info
+ ServerInfo serverInfo = new ServerInfo(this.userName, this.hostName);
- AuthenticationInfo authenticationInfo = null;
- if (password != null) {
- authenticationInfo = new DefaultPasswordAuthenticationInfo(this.password);
- } else {
- authenticationInfo = new DefaultPublicKeyFileAuthentication(this.publicKeyPath, this.privateKeyPath,
- this.passPhrase);
- }
- // Server info
- ServerInfo serverInfo = new ServerInfo(this.userName, this.hostName);
- try {
Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getPBSJobManager("/opt/torque/torque-4.2.3.1/bin/"));
outputPath = outputPath + File.separator + jobExecutionContext.getExperimentID() + "-" + jobExecutionContext.getTaskData().getTaskID()
+ File.separator;
@@ -120,7 +120,9 @@ public class AdvancedSCPOutputHandler extends AbstractHandler {
} catch (SSHApiException e) {
log.error("Error transfering files to remote host : " + hostName + " with the user: " + userName);
log.error(e.getMessage());
- throw new GFacException(e);
+ throw new GFacHandlerException(e);
+ } catch (GFacException e) {
+ throw new GFacHandlerException(e);
}
}
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/SSHDirectorySetupHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/SSHDirectorySetupHandler.java b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/SSHDirectorySetupHandler.java
index 70358f9..1f99a98 100644
--- a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/SSHDirectorySetupHandler.java
+++ b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/SSHDirectorySetupHandler.java
@@ -43,21 +43,25 @@ import org.slf4j.LoggerFactory;
public class SSHDirectorySetupHandler extends AbstractHandler{
private static final Logger log = LoggerFactory.getLogger(SSHDirectorySetupHandler.class);
- public void invoke(JobExecutionContext jobExecutionContext) throws GFacException {
- if(jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT) == null){
- try {
+ public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
+ try {
+ if (jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT) == null) {
GFACSSHUtils.addSecurityContext(jobExecutionContext);
- } catch (ApplicationSettingsException e) {
- log.error(e.getMessage());
- throw new GFacHandlerException("Error while creating SSHSecurityContext", e, e.getLocalizedMessage());
}
+ } catch (ApplicationSettingsException e) {
+ log.error(e.getMessage());
+ throw new GFacHandlerException("Error while creating SSHSecurityContext", e, e.getLocalizedMessage());
+ } catch (GFacException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
- log.info("Setup SSH job directorties");
- super.invoke(jobExecutionContext);
- makeDirectory(jobExecutionContext);
+
+ log.info("Setup SSH job directorties");
+ super.invoke(jobExecutionContext);
+ makeDirectory(jobExecutionContext);
}
- private void makeDirectory(JobExecutionContext jobExecutionContext) throws GFacException {
+ private void makeDirectory(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
+ try{
Cluster cluster = ((SSHSecurityContext) jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT)).getPbsCluster();
if (cluster == null) {
throw new GFacHandlerException("Security context is not set properly");
@@ -65,7 +69,6 @@ public class SSHDirectorySetupHandler extends AbstractHandler{
log.info("Successfully retrieved the Security Context");
}
ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType();
- try {
String workingDirectory = app.getScratchWorkingDirectory();
cluster.makeDirectory(workingDirectory);
cluster.makeDirectory(app.getScratchWorkingDirectory());
@@ -88,7 +91,7 @@ public class SSHDirectorySetupHandler extends AbstractHandler{
detail.setTransferStatus(status);
try {
registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
- GFacUtils.saveErrorDetails(e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE, jobExecutionContext.getTaskData().getTaskID());
+ GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE);
} catch (Exception e1) {
throw new GFacHandlerException("Error persisting status", e1, e1.getLocalizedMessage());
}
@@ -96,7 +99,7 @@ public class SSHDirectorySetupHandler extends AbstractHandler{
}
}
- public void initProperties(Map<String, String> properties) throws GFacHandlerException, GFacException {
+ public void initProperties(Map<String, String> properties) throws GFacHandlerException {
}
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/SSHInputHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/SSHInputHandler.java b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/SSHInputHandler.java
index 8da8253..5cc0ffb 100644
--- a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/SSHInputHandler.java
+++ b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/SSHInputHandler.java
@@ -57,23 +57,24 @@ public class SSHInputHandler extends AbstractHandler {
private static final Logger log = LoggerFactory.getLogger(SSHInputHandler.class);
- public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException, GFacException {
- if(jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT) == null){
- try {
- GFACSSHUtils.addSecurityContext(jobExecutionContext);
- } catch (ApplicationSettingsException e) {
- log.error(e.getMessage());
- throw new GFacHandlerException("Error while creating SSHSecurityContext", e, e.getLocalizedMessage());
- }
- }
- log.info("Invoking SCPInputHandler");
- super.invoke(jobExecutionContext);
-
+ public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
DataTransferDetails detail = new DataTransferDetails();
TransferStatus status = new TransferStatus();
-
MessageContext inputNew = new MessageContext();
try {
+
+ if (jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT) == null) {
+ try {
+ GFACSSHUtils.addSecurityContext(jobExecutionContext);
+ } catch (ApplicationSettingsException e) {
+ log.error(e.getMessage());
+ throw new GFacHandlerException("Error while creating SSHSecurityContext", e, e.getLocalizedMessage());
+ }
+ }
+ log.info("Invoking SCPInputHandler");
+ super.invoke(jobExecutionContext);
+
+
MessageContext input = jobExecutionContext.getInMessageContext();
Set<String> parameters = input.getParameters().keySet();
for (String paramName : parameters) {
@@ -90,8 +91,8 @@ public class SSHInputHandler extends AbstractHandler {
status.setTransferState(TransferState.UPLOAD);
detail.setTransferStatus(status);
detail.setTransferDescription("Input Data Staged: " + stageInputFiles);
- registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
- newFiles.add(stageInputFiles);
+ registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
+ newFiles.add(stageInputFiles);
}
((URIArrayType) actualParameter.getType()).setValueArray(newFiles.toArray(new String[newFiles.size()]));
}
@@ -102,11 +103,11 @@ public class SSHInputHandler extends AbstractHandler {
status.setTransferState(TransferState.FAILED);
detail.setTransferStatus(status);
try {
- GFacUtils.saveErrorDetails(e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE, jobExecutionContext.getTaskData().getTaskID());
- registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
- } catch (Exception e1) {
- throw new GFacHandlerException("Error persisting status", e1, e1.getLocalizedMessage());
- }
+ GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE);
+ registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
+ } catch (Exception e1) {
+ throw new GFacHandlerException("Error persisting status", e1, e1.getLocalizedMessage());
+ }
throw new GFacHandlerException("Error while input File Staging", e, e.getLocalizedMessage());
}
jobExecutionContext.setInMessageContext(inputNew);
@@ -134,7 +135,7 @@ public class SSHInputHandler extends AbstractHandler {
}
}
- public void initProperties(Map<String, String> properties) throws GFacHandlerException, GFacException {
+ public void initProperties(Map<String, String> properties) throws GFacHandlerException {
}
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/SSHOutputHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/SSHOutputHandler.java b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/SSHOutputHandler.java
index 42cebba..9e1cfb2 100644
--- a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/SSHOutputHandler.java
+++ b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/handler/SSHOutputHandler.java
@@ -57,7 +57,7 @@ import org.slf4j.LoggerFactory;
public class SSHOutputHandler extends AbstractHandler{
private static final Logger log = LoggerFactory.getLogger(SSHOutputHandler.class);
- public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException, GFacException {
+ public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
if (jobExecutionContext.getApplicationContext().getHostDescription().getType() instanceof GsisshHostType) { // this is because we don't have the right jobexecution context
// so attempting to get it from the registry
if (Constants.PUSH.equals(((GsisshHostType) jobExecutionContext.getApplicationContext().getHostDescription().getType()).getMonitorMode())) { // this is because we don't have the right jobexecution context
@@ -89,14 +89,20 @@ public class SSHOutputHandler extends AbstractHandler{
}
}
}
- if (jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT) == null) {
- try {
+
+ try {
+ if (jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT) == null) {
+
GFACSSHUtils.addSecurityContext(jobExecutionContext);
- } catch (ApplicationSettingsException e) {
- log.error(e.getMessage());
- throw new GFacHandlerException("Error while creating SSHSecurityContext", e, e.getLocalizedMessage());
}
+ } catch (ApplicationSettingsException e) {
+ log.error(e.getMessage());
+ throw new GFacHandlerException("Error while creating SSHSecurityContext", e, e.getLocalizedMessage());
+ } catch (GFacException e1) {
+ log.error(e1.getMessage());
+ throw new GFacHandlerException("Error while creating SSHSecurityContext", e1, e1.getLocalizedMessage());
}
+
super.invoke(jobExecutionContext);
DataTransferDetails detail = new DataTransferDetails();
TransferStatus status = new TransferStatus();
@@ -197,7 +203,7 @@ public class SSHOutputHandler extends AbstractHandler{
status.setTransferState(TransferState.FAILED);
detail.setTransferStatus(status);
registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
- GFacUtils.saveErrorDetails(e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE, jobExecutionContext.getTaskData().getTaskID());
+ GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE);
} catch (Exception e1) {
throw new GFacHandlerException("Error persisting status", e1, e1.getLocalizedMessage());
}
@@ -206,7 +212,7 @@ public class SSHOutputHandler extends AbstractHandler{
}
- public void initProperties(Map<String, String> properties) throws GFacHandlerException, GFacException {
+ public void initProperties(Map<String, String> properties) throws GFacHandlerException {
}
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/provider/impl/SSHProvider.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/provider/impl/SSHProvider.java b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/provider/impl/SSHProvider.java
index da48ae5..e972f0d 100644
--- a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/provider/impl/SSHProvider.java
+++ b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/provider/impl/SSHProvider.java
@@ -42,6 +42,7 @@ import org.apache.airavata.gfac.context.MessageContext;
import org.apache.airavata.gfac.context.security.SSHSecurityContext;
import org.apache.airavata.gfac.handler.GFacHandlerException;
import org.apache.airavata.gfac.notification.events.StartExecutionEvent;
+import org.apache.airavata.gfac.provider.AbstractProvider;
import org.apache.airavata.gfac.provider.GFacProviderException;
import org.apache.airavata.gfac.util.GFACSSHUtils;
import org.apache.airavata.gfac.utils.GFacUtils;
@@ -64,7 +65,7 @@ import sun.reflect.generics.reflectiveObjects.NotImplementedException;
/**
* Execute application using remote SSH
*/
-public class SSHProvider extends AbstractProvider{
+public class SSHProvider extends AbstractProvider {
private static final Logger log = LoggerFactory.getLogger(SSHProvider.class);
private Cluster cluster;
private String jobID = null;
@@ -92,10 +93,10 @@ public class SSHProvider extends AbstractProvider{
details.setJobID(taskID);
details.setJobDescription(remoteFile);
jobExecutionContext.setJobDetails(details);
- JobDescriptor jobDescriptor = GFacUtils.createJobDescriptor(jobExecutionContext, app, null);
+ JobDescriptor jobDescriptor = GFACSSHUtils.createJobDescriptor(jobExecutionContext, app, null);
details.setJobDescription(jobDescriptor.toXML());
- GFacUtils.saveJobStatus(details, JobState.SETUP, taskID);
+ GFacUtils.saveJobStatus(jobExecutionContext, details, JobState.SETUP);
log.info(remoteFile);
try {
File runscript = createShellScript(jobExecutionContext);
@@ -161,7 +162,7 @@ public class SSHProvider extends AbstractProvider{
log.info("Successfully retrieved the Security Context");
}
// This installed path is a mandetory field, because this could change based on the computing resource
- JobDescriptor jobDescriptor = GFacUtils.createJobDescriptor(jobExecutionContext, app, cluster);
+ JobDescriptor jobDescriptor = GFACSSHUtils.createJobDescriptor(jobExecutionContext, app, cluster);
log.info(jobDescriptor.toXML());
@@ -171,25 +172,25 @@ public class SSHProvider extends AbstractProvider{
jobExecutionContext.setJobDetails(jobDetails);
if (jobID == null) {
jobDetails.setJobID("none");
- GFacUtils.saveJobStatus(jobDetails, JobState.FAILED, taskID);
+ GFacUtils.saveJobStatus(jobExecutionContext, jobDetails, JobState.FAILED);
} else {
jobDetails.setJobID(jobID);
- GFacUtils.saveJobStatus(jobDetails, JobState.SUBMITTED, taskID);
+ GFacUtils.saveJobStatus(jobExecutionContext, jobDetails, JobState.SUBMITTED);
}
} catch (SSHApiException e) {
String error = "Error submitting the job to host " + host.getHostAddress() + " message: " + e.getMessage();
log.error(error);
jobDetails.setJobID("none");
- GFacUtils.saveJobStatus(jobDetails, JobState.FAILED, taskID);
- GFacUtils.saveErrorDetails(error, CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR, taskID);
+ GFacUtils.saveJobStatus(jobExecutionContext, jobDetails, JobState.FAILED);
+ GFacUtils.saveErrorDetails(jobExecutionContext, error, CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
throw new GFacProviderException(error, e);
} catch (Exception e) {
String error = "Error submitting the job to host " + host.getHostAddress() + " message: " + e.getMessage();
log.error(error);
jobDetails.setJobID("none");
- GFacUtils.saveJobStatus(jobDetails, JobState.FAILED, taskID);
- GFacUtils.saveErrorDetails(error, CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR, taskID);
+ GFacUtils.saveJobStatus(jobExecutionContext, jobDetails, JobState.FAILED);
+ GFacUtils.saveErrorDetails(jobExecutionContext, error, CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
throw new GFacProviderException(error, e);
}
} catch (GFacException e) {
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/util/GFACSSHUtils.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/util/GFACSSHUtils.java b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/util/GFACSSHUtils.java
index 29def62..9146bfd 100644
--- a/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/util/GFACSSHUtils.java
+++ b/modules/gfac/gfac-ssh/src/main/java/org/apache/airavata/gfac/util/GFACSSHUtils.java
@@ -22,25 +22,32 @@ package org.apache.airavata.gfac.util;
import org.apache.airavata.common.exception.ApplicationSettingsException;
import org.apache.airavata.common.utils.ServerSettings;
+import org.apache.airavata.common.utils.StringUtil;
+import org.apache.airavata.commons.gfac.type.ActualParameter;
import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.commons.gfac.type.MappingFactory;
import org.apache.airavata.gfac.Constants;
import org.apache.airavata.gfac.GFacException;
import org.apache.airavata.gfac.RequestData;
import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.context.MessageContext;
import org.apache.airavata.gfac.context.security.SSHSecurityContext;
import org.apache.airavata.gsi.ssh.api.Cluster;
import org.apache.airavata.gsi.ssh.api.SSHApiException;
import org.apache.airavata.gsi.ssh.api.ServerInfo;
import org.apache.airavata.gsi.ssh.api.authentication.AuthenticationInfo;
+import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
import org.apache.airavata.gsi.ssh.impl.PBSCluster;
import org.apache.airavata.gsi.ssh.impl.authentication.DefaultPasswordAuthenticationInfo;
import org.apache.airavata.gsi.ssh.impl.authentication.DefaultPublicKeyFileAuthentication;
import org.apache.airavata.gsi.ssh.util.CommonUtils;
+import org.apache.airavata.model.workspace.experiment.ComputationalResourceScheduling;
+import org.apache.airavata.model.workspace.experiment.TaskDetails;
import org.apache.airavata.schemas.gfac.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Properties;
+import java.util.*;
public class GFACSSHUtils {
private final static Logger logger = LoggerFactory.getLogger(GFACSSHUtils.class);
@@ -84,5 +91,90 @@ public class GFACSSHUtils {
jobExecutionContext.addSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT, sshSecurityContext);
}
}
+ public static JobDescriptor createJobDescriptor(JobExecutionContext jobExecutionContext,
+ ApplicationDeploymentDescriptionType app, Cluster cluster) {
+ JobDescriptor jobDescriptor = new JobDescriptor();
+ // this is common for any application descriptor
+ jobDescriptor.setInputDirectory(app.getInputDataDirectory());
+ jobDescriptor.setOutputDirectory(app.getOutputDataDirectory());
+ jobDescriptor.setExecutablePath(app.getExecutableLocation());
+ jobDescriptor.setStandardOutFile(app.getStandardOutput());
+ jobDescriptor.setStandardErrorFile(app.getStandardError());
+ Random random = new Random();
+ int i = random.nextInt();
+ jobDescriptor.setJobName(app.getApplicationName().getStringValue() + String.valueOf(i));
+ jobDescriptor.setWorkingDirectory(app.getStaticWorkingDirectory());
+
+
+ List<String> inputValues = new ArrayList<String>();
+ MessageContext input = jobExecutionContext.getInMessageContext();
+ Map<String, Object> inputs = input.getParameters();
+ Set<String> keys = inputs.keySet();
+ for (String paramName : keys) {
+ ActualParameter actualParameter = (ActualParameter) inputs.get(paramName);
+ if ("URIArray".equals(actualParameter.getType().getType().toString()) || "StringArray".equals(actualParameter.getType().getType().toString())
+ || "FileArray".equals(actualParameter.getType().getType().toString())) {
+ String[] values = null;
+ if (actualParameter.getType() instanceof URIArrayType) {
+ values = ((URIArrayType) actualParameter.getType()).getValueArray();
+ } else if (actualParameter.getType() instanceof StringArrayType) {
+ values = ((StringArrayType) actualParameter.getType()).getValueArray();
+ } else if (actualParameter.getType() instanceof FileArrayType) {
+ values = ((FileArrayType) actualParameter.getType()).getValueArray();
+ }
+ String value = StringUtil.createDelimiteredString(values, " ");
+ inputValues.add(value);
+ } else {
+ String paramValue = MappingFactory.toString(actualParameter);
+ inputValues.add(paramValue);
+ }
+ }
+ jobDescriptor.setInputValues(inputValues);
+
+ // this part will fill out the hpcApplicationDescriptor
+ if (app instanceof HpcApplicationDeploymentType) {
+ HpcApplicationDeploymentType applicationDeploymentType
+ = (HpcApplicationDeploymentType) app;
+ jobDescriptor.setShellName("/bin/bash");
+ jobDescriptor.setAllEnvExport(true);
+ jobDescriptor.setMailOptions("n");
+ jobDescriptor.setNodes(applicationDeploymentType.getNodeCount());
+ jobDescriptor.setProcessesPerNode(applicationDeploymentType.getProcessorsPerNode());
+ jobDescriptor.setMaxWallTime(String.valueOf(applicationDeploymentType.getMaxWallTime()));
+ jobDescriptor.setJobSubmitter(applicationDeploymentType.getJobSubmitterCommand());
+ if (applicationDeploymentType.getProjectAccount() != null) {
+ if (applicationDeploymentType.getProjectAccount().getProjectAccountNumber() != null) {
+ jobDescriptor.setAcountString(applicationDeploymentType.getProjectAccount().getProjectAccountNumber());
+ }
+ }
+ if (applicationDeploymentType.getQueue() != null) {
+ if (applicationDeploymentType.getQueue().getQueueName() != null) {
+ jobDescriptor.setQueueName(applicationDeploymentType.getQueue().getQueueName());
+ }
+ }
+ jobDescriptor.setOwner(((PBSCluster) cluster).getServerInfo().getUserName());
+ TaskDetails taskData = jobExecutionContext.getTaskData();
+ if (taskData != null && taskData.isSetTaskScheduling()) {
+ ComputationalResourceScheduling computionnalResource = taskData.getTaskScheduling();
+ if (computionnalResource.getNodeCount() > 0) {
+ jobDescriptor.setNodes(computionnalResource.getNodeCount());
+ }
+ if (computionnalResource.getComputationalProjectAccount() != null) {
+ jobDescriptor.setAcountString(computionnalResource.getComputationalProjectAccount());
+ }
+ if (computionnalResource.getQueueName() != null) {
+ jobDescriptor.setQueueName(computionnalResource.getQueueName());
+ }
+ if (computionnalResource.getTotalCPUCount() > 0) {
+ jobDescriptor.setProcessesPerNode(computionnalResource.getTotalCPUCount());
+ }
+ if (computionnalResource.getWallTimeLimit() > 0) {
+ jobDescriptor.setMaxWallTime(String.valueOf(computionnalResource.getWallTimeLimit()));
+ }
+ }
+
+ }
+ return jobDescriptor;
+ }
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/pom.xml
----------------------------------------------------------------------
diff --git a/modules/gfac/pom.xml b/modules/gfac/pom.xml
index 1d6f0d1..9e1dcc0 100644
--- a/modules/gfac/pom.xml
+++ b/modules/gfac/pom.xml
@@ -38,6 +38,7 @@
<module>gfac-gram</module>
<module>gfac-gsissh</module>
<module>gfac-bes</module>
+ <module>gfac-monitor</module>
</modules>
</profile>
</profiles>
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java b/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
index c3491be..86c0c5e 100644
--- a/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
+++ b/modules/orchestrator/airavata-orchestrator-service/src/main/java/org/apache/airavata/orchestrator/server/OrchestratorServerHandler.java
@@ -24,9 +24,6 @@ package org.apache.airavata.orchestrator.server;
import java.util.Arrays;
import java.util.List;
-import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
-import org.apache.airavata.gfac.monitor.MonitorID;
-import org.apache.airavata.gfac.monitor.MonitorManager;
import org.apache.airavata.model.workspace.experiment.Experiment;
import org.apache.airavata.model.workspace.experiment.TaskDetails;
import org.apache.airavata.model.workspace.experiment.WorkflowNodeDetails;
@@ -46,14 +43,10 @@ import org.slf4j.LoggerFactory;
public class OrchestratorServerHandler implements OrchestratorService.Iface {
private static Logger log = LoggerFactory.getLogger(OrchestratorServerHandler.class);
- private MonitorManager monitorManager = null;
-
private SimpleOrchestratorImpl orchestrator = null;
private Registry registry;
- GSIAuthenticationInfo authenticationInfo = null;
-
/**
* Query orchestrator server to fetch the CPI version
*/
@@ -90,7 +83,6 @@ public class OrchestratorServerHandler implements OrchestratorService.Iface {
//TODO: Write the Orchestrator implementaion
try {
List<TaskDetails> tasks = orchestrator.createTasks(experimentId);
- MonitorID monitorID = null;
if (tasks.size() > 1) {
log.info("There are multiple tasks for this experiment, So Orchestrator will launch multiple Jobs");
}
@@ -115,15 +107,6 @@ public class OrchestratorServerHandler implements OrchestratorService.Iface {
}
return true;
}
-
- public MonitorManager getMonitorManager() {
- return monitorManager;
- }
-
- public void setMonitorManager(MonitorManager monitorManager) {
- this.monitorManager = monitorManager;
- }
-
public boolean terminateExperiment(String experimentId) throws TException {
try {
orchestrator.cancelExperiment(experimentId);
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/context/OrchestratorContext.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/context/OrchestratorContext.java b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/context/OrchestratorContext.java
index fad5e58..eb3f463 100644
--- a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/context/OrchestratorContext.java
+++ b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/context/OrchestratorContext.java
@@ -23,7 +23,6 @@ package org.apache.airavata.orchestrator.core.context;
import java.util.ArrayList;
import java.util.List;
-import org.apache.airavata.gfac.monitor.MonitorManager;
import org.apache.airavata.orchestrator.core.OrchestratorConfiguration;
import org.apache.airavata.orchestrator.core.gfac.GFACInstance;
import org.apache.airavata.registry.api.AiravataRegistry2;
@@ -41,8 +40,6 @@ public class OrchestratorContext {
private Registry newRegistry;
- private MonitorManager monitorManager;
-
public OrchestratorContext(List<GFACInstance> gfacInstanceList) {
this.gfacInstanceList = new ArrayList<GFACInstance>();
}
@@ -81,12 +78,4 @@ public class OrchestratorContext {
public void setNewRegistry(Registry newRegistry) {
this.newRegistry = newRegistry;
}
-
- public MonitorManager getMonitorManager() {
- return monitorManager;
- }
-
- public void setMonitorManager(MonitorManager monitorManager) {
- this.monitorManager = monitorManager;
- }
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/EmbeddedGFACJobSubmitter.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/EmbeddedGFACJobSubmitter.java b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/EmbeddedGFACJobSubmitter.java
index 53b9206..2c41ef7 100644
--- a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/EmbeddedGFACJobSubmitter.java
+++ b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/impl/EmbeddedGFACJobSubmitter.java
@@ -48,9 +48,6 @@ public class EmbeddedGFACJobSubmitter implements JobSubmitter {
public void initialize(OrchestratorContext orchestratorContext) throws OrchestratorException {
this.orchestratorContext = orchestratorContext;
gfac = new GFacImpl(orchestratorContext.getNewRegistry(), null, orchestratorContext.getRegistry());
- if (orchestratorContext.getMonitorManager()!=null) {
- orchestratorContext.getMonitorManager().registerListener(gfac);
- }
}
public GFACInstance selectGFACInstance() throws OrchestratorException {
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/cpi/impl/SimpleOrchestratorImpl.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/cpi/impl/SimpleOrchestratorImpl.java b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/cpi/impl/SimpleOrchestratorImpl.java
index 6e5ff2f..91a6e47 100644
--- a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/cpi/impl/SimpleOrchestratorImpl.java
+++ b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/cpi/impl/SimpleOrchestratorImpl.java
@@ -21,49 +21,28 @@
package org.apache.airavata.orchestrator.cpi.impl;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutorService;
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.Constants;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.commons.gfac.type.HostDescription;
+
import org.apache.airavata.gfac.context.JobExecutionContext;
-import org.apache.airavata.gsi.ssh.api.authentication.AuthenticationInfo;
-import org.apache.airavata.gsi.ssh.impl.authentication.MyProxyAuthenticationInfo;
-import org.apache.airavata.gfac.monitor.AbstractActivityListener;
-import org.apache.airavata.gfac.monitor.MonitorID;
-import org.apache.airavata.gfac.monitor.MonitorManager;
-import org.apache.airavata.gfac.monitor.command.ExperimentCancelRequest;
-import org.apache.airavata.gfac.monitor.core.Monitor;
-import org.apache.airavata.gfac.monitor.core.PullMonitor;
-import org.apache.airavata.gfac.monitor.core.PushMonitor;
-import org.apache.airavata.gfac.monitor.exception.AiravataMonitorException;
-import org.apache.airavata.gfac.monitor.impl.LocalJobMonitor;
-import org.apache.airavata.gfac.monitor.impl.pull.qstat.QstatMonitor;
-import org.apache.airavata.gfac.monitor.impl.push.amqp.AMQPMonitor;
-import org.apache.airavata.gfac.monitor.state.JobStatusChangeRequest;
import org.apache.airavata.model.util.ExperimentModelUtil;
import org.apache.airavata.model.workspace.experiment.Experiment;
-import org.apache.airavata.model.workspace.experiment.JobState;
import org.apache.airavata.model.workspace.experiment.TaskDetails;
import org.apache.airavata.model.workspace.experiment.WorkflowNodeDetails;
import org.apache.airavata.orchestrator.core.exception.OrchestratorException;
import org.apache.airavata.orchestrator.core.job.JobSubmitter;
-import org.apache.airavata.orchestrator.core.utils.OrchestratorUtils;
import org.apache.airavata.orchestrator.core.validator.JobMetadataValidator;
-import org.apache.airavata.persistance.registry.jpa.model.WorkflowNodeDetail;
import org.apache.airavata.registry.cpi.ChildDataType;
import org.apache.airavata.registry.cpi.DataType;
import org.apache.airavata.registry.cpi.Registry;
-import org.apache.airavata.schemas.gfac.GsisshHostType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.eventbus.Subscribe;
-public class SimpleOrchestratorImpl extends AbstractOrchestrator implements AbstractActivityListener{
+import javax.naming.OperationNotSupportedException;
+
+public class SimpleOrchestratorImpl extends AbstractOrchestrator{
private final static Logger logger = LoggerFactory.getLogger(SimpleOrchestratorImpl.class);
private ExecutorService executor;
@@ -72,9 +51,7 @@ public class SimpleOrchestratorImpl extends AbstractOrchestrator implements Abst
private JobMetadataValidator jobMetadataValidator = null;
- private MonitorManager monitorManager = null;
- private AuthenticationInfo authenticationInfo = null;
public SimpleOrchestratorImpl() throws OrchestratorException {
try {
@@ -83,7 +60,6 @@ public class SimpleOrchestratorImpl extends AbstractOrchestrator implements Abst
Class<? extends JobSubmitter> aClass = Class.forName(submitterClass.trim()).asSubclass(JobSubmitter.class);
jobSubmitter = aClass.newInstance();
jobSubmitter.initialize(this.orchestratorContext);
- monitorManager = new MonitorManager();
String validatorClzz = this.orchestratorContext.getOrchestratorConfiguration().getValidatorClass();
if (this.orchestratorConfiguration.isEnableValidation()) {
if (validatorClzz == null) {
@@ -106,52 +82,17 @@ public class SimpleOrchestratorImpl extends AbstractOrchestrator implements Abst
public String launchExperiment(Experiment experiment, WorkflowNodeDetails workflowNode, TaskDetails task) throws OrchestratorException {
// we give higher priority to userExperimentID
//todo support multiple validators
- String jobID = null;
String experimentId = experiment.getExperimentID();
String taskId = task.getTaskID();
- String workflowNodeId = workflowNode.getNodeInstanceId();
- String userName = experiment.getUserName();
- // creating monitorID to register with monitoring queue
- // this is a special case because amqp has to be in place before submitting the job
- HostDescription hostDescription = OrchestratorUtils.getHostDescription(this, task);
-
// creating monitorID to register with monitoring queue
// this is a special case because amqp has to be in place before submitting the job
try {
- if ((hostDescription instanceof GsisshHostType) &&
- Constants.PUSH.equals(((GsisshHostType) hostDescription).getMonitorMode())) {
- MonitorID monitorID = new MonitorID(hostDescription, null, taskId, workflowNodeId, experimentId, userName);
- monitorManager.addAJobToMonitor(monitorID);
- jobSubmitter.submit(experimentId, taskId); // even this get returns we cannot use this because subscription has to be done early
- if ("none".equals(jobID)) {
- logger.error("Job submission Failed, so we remove the job from monitoring");
-
- } else {
- logger.info("Job Launched to the resource by GFAC and jobID returned : " + jobID);
- }
- } else {
- // Launching job for each task
- // if the monitoring is pull mode then we add the monitorID for each task after submitting
- // the job with the jobID, otherwise we don't need the jobID
- JobExecutionContext jobExecutionContext = jobSubmitter.submit(experimentId, taskId);
- jobExecutionContext.setTaskData(task);
- jobID = jobExecutionContext.getJobDetails().getJobID();
-
- logger.info("Job Launched to the resource by GFAC and jobID returned : " + jobID);
- MonitorID monitorID = new MonitorID(hostDescription, jobID, taskId, workflowNodeId, experimentId, userName, authenticationInfo);
- monitorID.setJobExecutionContext(jobExecutionContext);
- if ("none".equals(jobID)) {
- logger.error("Job submission Failed, so we remove the job from monitoring");
-
- } else {
- monitorManager.addAJobToMonitor(monitorID);
- }
- }
+ JobExecutionContext jobExecutionContext = jobSubmitter.submit(experimentId, taskId);
+ return jobExecutionContext.getJobDetails().getJobID();
} catch (Exception e) {
throw new OrchestratorException("Error launching the job", e);
}
- return jobID;
}
/**
@@ -182,28 +123,12 @@ public class SimpleOrchestratorImpl extends AbstractOrchestrator implements Abst
return tasks;
}
- @Override
public void cancelExperiment(String experimentID)
throws OrchestratorException {
- orchestratorContext.getMonitorManager().getMonitorPublisher().publish(new ExperimentCancelRequest(experimentID));
- }
-
- @Subscribe
- public void handlePostExperimentTask(JobStatusChangeRequest status) throws OrchestratorException {
- if(status.getState() == JobState.COMPLETE){
- MonitorID monitorID = status.getMonitorID();
- if(monitorID.getJobExecutionContext() == null){
- // this code is to handle amqp scenario where monitorID doesn't have
- // job execution context, in this case it will be created by the outputhandler
- String experimentID = monitorID.getExperimentID();
- String taskID = monitorID.getTaskID();
- JobExecutionContext jobExecutionContext = new JobExecutionContext(null, null);
- jobExecutionContext.setExperimentID(experimentID);
- jobExecutionContext.setTaskData(new TaskDetails(taskID));
- }
- jobSubmitter.runAfterJobTask(monitorID.getJobExecutionContext());
- }
+ throw new OrchestratorException(new OperationNotSupportedException());
}
+
+
public ExecutorService getExecutor() {
return executor;
}
@@ -228,83 +153,7 @@ public class SimpleOrchestratorImpl extends AbstractOrchestrator implements Abst
this.jobSubmitter = jobSubmitter;
}
- public AuthenticationInfo getAuthenticationInfo() {
- return authenticationInfo;
- }
-
- public void setAuthenticationInfo(AuthenticationInfo authenticationInfo) {
- this.authenticationInfo = authenticationInfo;
- }
-
- @Override
- public void setup(Object... configurations) {
- for (Object config : configurations) {
- if (config instanceof MonitorManager){
- orchestratorContext.setMonitorManager((MonitorManager)config);
- try {
- getJobSubmitter().initialize(orchestratorContext);
- } catch (OrchestratorException e) {
- logger.error("Error reinitializing the job submitter!!!",e);
- }
- }
- }
- }
-
public void initialize() throws OrchestratorException {
- // Filling monitorManager properties
- // we can keep a single user to do all the monitoring authentication for required machine..
- try{
- String 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));
-
- // loading Monitor configuration
- String monitors = ServerSettings.getSetting("monitors");
- if(monitors == null) {
- logger.error("No Monitor is configured, so job monitoring will not monitor any job");
- return;
- }
- List<String> monitorList = Arrays.asList(monitors.split(","));
- List<String> list = Arrays.asList(ServerSettings.getSetting("amqp.hosts").split(","));
- String proxyPath = ServerSettings.getSetting("proxy.file.path");
- String connectionName = ServerSettings.getSetting("connection.name");
-
- for (String monitorClass : monitorList) {
- Class<? extends Monitor> aClass = Class.forName(monitorClass).asSubclass(Monitor.class);
- Monitor monitor = aClass.newInstance();
- if (monitor instanceof PullMonitor) {
- if (monitor instanceof QstatMonitor) {
- monitorManager.addQstatMonitor((QstatMonitor) monitor);
- }
- } else if (monitor instanceof PushMonitor) {
- if (monitor instanceof AMQPMonitor) {
- ((AMQPMonitor) monitor).initialize(proxyPath, connectionName, list);
- monitorManager.addAMQPMonitor((AMQPMonitor) monitor);
- }
- } else if(monitor instanceof LocalJobMonitor){
- monitorManager.addLocalMonitor((LocalJobMonitor)monitor);
- } else {
- logger.error("Wrong class is given to primary Monitor");
- }
- }
- monitorManager.registerListener(this);
- // Now Monitor Manager is properly configured, now we have to start the monitoring system.
- // This will initialize all the required threads and required queues
- monitorManager.launchMonitor();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- } catch (InstantiationException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (AiravataMonitorException e) {
- e.printStackTrace();
- } catch (ApplicationSettingsException e) {
- e.printStackTrace();
- }
}
}
[9/9] git commit: Separating gfac-monitoring implementation
Posted by la...@apache.org.
Separating gfac-monitoring implementation
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/553caa08
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/553caa08
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/553caa08
Branch: refs/heads/master
Commit: 553caa0878fd8c16816583549d573b0c9257cee7
Parents: 0eabb93
Author: lahiru <la...@apache.org>
Authored: Thu May 1 14:28:39 2014 -0400
Committer: lahiru <la...@apache.org>
Committed: Thu May 1 14:28:39 2014 -0400
----------------------------------------------------------------------
.../client/samples/CreateLaunchExperiment.java | 2 +-
.../server/src/main/resources/gfac-config.xml | 5 +-
modules/distribution/server/pom.xml | 5 +
.../server/src/main/assembly/bin-assembly.xml | 1 +
.../gfac/provider/impl/BESProvider.java | 7 +-
modules/gfac/gfac-core/pom.xml | 36 --
.../org/apache/airavata/gfac/Constants.java | 2 +
.../org/apache/airavata/gfac/ExecutionMode.java | 39 +++
.../apache/airavata/gfac/GFacConfiguration.java | 21 +-
.../org/apache/airavata/gfac/Scheduler.java | 42 ++-
.../gfac/context/JobExecutionContext.java | 31 +-
.../org/apache/airavata/gfac/cpi/GFacImpl.java | 141 +++++---
.../airavata/gfac/handler/AbstractHandler.java | 3 +-
.../gfac/handler/AppDescriptorCheckHandler.java | 3 +-
.../airavata/gfac/handler/GFacHandler.java | 4 +-
.../gfac/handler/GFacHandlerException.java | 4 +
.../airavata/gfac/handler/ThreadedHandler.java | 31 ++
.../gfac/monitor/AbstractActivityListener.java | 27 --
.../AiravataExperimentStatusUpdator.java | 81 -----
.../gfac/monitor/AiravataJobStatusUpdator.java | 145 --------
.../gfac/monitor/AiravataTaskStatusUpdator.java | 113 ------
.../AiravataWorkflowNodeStatusUpdator.java | 112 ------
.../gfac/monitor/ExperimentIdentity.java | 36 --
.../airavata/gfac/monitor/HostMonitorData.java | 69 ----
.../airavata/gfac/monitor/JobIdentity.java | 39 ---
.../apache/airavata/gfac/monitor/MonitorID.java | 238 -------------
.../airavata/gfac/monitor/MonitorManager.java | 347 -------------------
.../airavata/gfac/monitor/TaskIdentity.java | 38 --
.../airavata/gfac/monitor/UserMonitorData.java | 76 ----
.../gfac/monitor/WorkflowNodeIdentity.java | 37 --
.../command/ExperimentCancelRequest.java | 38 --
.../gfac/monitor/command/TaskCancelRequest.java | 52 ---
.../monitor/core/AiravataAbstractMonitor.java | 46 ---
.../gfac/monitor/core/MessageParser.java | 43 ---
.../airavata/gfac/monitor/core/Monitor.java | 30 --
.../airavata/gfac/monitor/core/PullMonitor.java | 64 ----
.../airavata/gfac/monitor/core/PushMonitor.java | 60 ----
.../gfac/monitor/event/MonitorPublisher.java | 47 ---
.../exception/AiravataMonitorException.java | 37 --
.../gfac/monitor/impl/LocalJobMonitor.java | 59 ----
.../monitor/impl/pull/qstat/QstatMonitor.java | 262 --------------
.../impl/pull/qstat/ResourceConnection.java | 151 --------
.../monitor/impl/push/amqp/AMQPMonitor.java | 263 --------------
.../monitor/impl/push/amqp/BasicConsumer.java | 86 -----
.../impl/push/amqp/JSONMessageParser.java | 78 -----
.../impl/push/amqp/UnRegisterWorker.java | 68 ----
.../state/AbstractStateChangeRequest.java | 27 --
.../state/ExperimentStatusChangeRequest.java | 63 ----
.../monitor/state/JobStatusChangeRequest.java | 80 -----
.../gfac/monitor/state/JobStatusInfo.java | 48 ---
.../gfac/monitor/state/PublisherMessage.java | 26 --
.../monitor/state/TaskStatusChangeRequest.java | 61 ----
.../state/WorkflowNodeStatusChangeRequest.java | 63 ----
.../monitor/state/impl/AmazonJobStatusInfo.java | 39 ---
.../monitor/state/impl/GridJobStatusInfo.java | 40 ---
.../gfac/monitor/util/AMQPConnectionUtil.java | 77 ----
.../airavata/gfac/monitor/util/CommonUtils.java | 172 ---------
.../airavata/gfac/monitor/util/X509Helper.java | 161 ---------
.../listeners/GSISSHJobSubmissionListener.java | 55 ---
.../gfac/provider/AbstractProvider.java | 50 +++
.../airavata/gfac/provider/GFacProvider.java | 9 +-
.../gfac/provider/impl/AbstractProvider.java | 92 -----
.../apache/airavata/gfac/utils/GFacUtils.java | 129 ++-----
.../apache/airavata/job/AMQPMonitorTest.java | 175 ----------
.../apache/airavata/job/GFacConfigXmlTest.java | 113 ++++++
.../job/QstatMonitorTestWithMyProxyAuth.java | 167 ---------
.../apache/airavata/job/TestGlobalHandler.java | 32 ++
.../org/apache/airavata/job/TestInHandler.java | 32 ++
.../org/apache/airavata/job/TestOutHandler.java | 32 ++
.../org/apache/airavata/job/TestProvider.java | 47 +++
.../airavata/job/TestThreadedHandler.java | 39 +++
.../src/test/resources/gfac-config.xml | 101 ++----
modules/gfac/gfac-ec2/pom.xml | 4 +-
.../apache/airavata/gfac/ec2/EC2Provider.java | 12 +-
.../gfac-ec2/src/test/resources/gfac-config.xml | 64 ----
.../context/security/GSISecurityContext.java | 13 -
.../gfac/handler/GramDirectorySetupHandler.java | 10 +-
.../gfac/handler/GridFTPInputHandler.java | 6 +-
.../gfac/handler/GridFTPOutputHandler.java | 6 +-
.../gfac/provider/impl/GramProvider.java | 21 +-
.../gfac/util/GramJobSubmissionListener.java | 2 +-
modules/gfac/gfac-gsissh/pom.xml | 7 +-
.../handler/GSISSHDirectorySetupHandler.java | 29 +-
.../gfac/handler/GSISSHInputHandler.java | 47 ++-
.../gfac/handler/GSISSHOutputHandler.java | 19 +-
.../gfac/provider/impl/GSISSHProvider.java | 42 ++-
.../airavata/gfac/util/GFACGSISSHUtils.java | 94 +++++
.../gfac/handler/HDFSDataMovementHandler.java | 3 +-
.../gfac/handler/HadoopDeploymentHandler.java | 4 +-
.../gfac/provider/impl/HadoopProvider.java | 3 +-
.../src/test/resources/gfac-config.xml | 50 ---
.../handler/LocalDirectorySetupHandler.java | 3 +-
.../gfac/provider/impl/LocalProvider.java | 11 +-
.../gfac/services/impl/LocalProviderTest.java | 44 ++-
.../src/test/resources/gfac-config.xml | 63 ----
modules/gfac/gfac-monitor/pom.xml | 181 ++++++++++
.../gfac/monitor/AbstractActivityListener.java | 27 ++
.../AiravataExperimentStatusUpdator.java | 81 +++++
.../gfac/monitor/AiravataJobStatusUpdator.java | 145 ++++++++
.../gfac/monitor/AiravataTaskStatusUpdator.java | 113 ++++++
.../AiravataWorkflowNodeStatusUpdator.java | 112 ++++++
.../gfac/monitor/ExperimentIdentity.java | 36 ++
.../airavata/gfac/monitor/HostMonitorData.java | 69 ++++
.../airavata/gfac/monitor/JobIdentity.java | 39 +++
.../apache/airavata/gfac/monitor/MonitorID.java | 251 ++++++++++++++
.../airavata/gfac/monitor/TaskIdentity.java | 38 ++
.../airavata/gfac/monitor/UserMonitorData.java | 76 ++++
.../gfac/monitor/WorkflowNodeIdentity.java | 37 ++
.../command/ExperimentCancelRequest.java | 38 ++
.../gfac/monitor/command/TaskCancelRequest.java | 52 +++
.../monitor/core/AiravataAbstractMonitor.java | 46 +++
.../gfac/monitor/core/MessageParser.java | 43 +++
.../airavata/gfac/monitor/core/Monitor.java | 30 ++
.../airavata/gfac/monitor/core/PullMonitor.java | 64 ++++
.../airavata/gfac/monitor/core/PushMonitor.java | 60 ++++
.../gfac/monitor/event/MonitorPublisher.java | 47 +++
.../exception/AiravataMonitorException.java | 37 ++
.../handlers/GridPullMonitorHandler.java | 96 +++++
.../gfac/monitor/impl/LocalJobMonitor.java | 59 ++++
.../monitor/impl/pull/qstat/HPCPullMonitor.java | 284 +++++++++++++++
.../impl/pull/qstat/ResourceConnection.java | 151 ++++++++
.../monitor/impl/push/amqp/AMQPMonitor.java | 263 ++++++++++++++
.../monitor/impl/push/amqp/BasicConsumer.java | 86 +++++
.../impl/push/amqp/JSONMessageParser.java | 78 +++++
.../impl/push/amqp/UnRegisterWorker.java | 68 ++++
.../state/AbstractStateChangeRequest.java | 27 ++
.../state/ExperimentStatusChangeRequest.java | 63 ++++
.../monitor/state/JobStatusChangeRequest.java | 80 +++++
.../gfac/monitor/state/JobStatusInfo.java | 48 +++
.../gfac/monitor/state/PublisherMessage.java | 26 ++
.../monitor/state/TaskStatusChangeRequest.java | 61 ++++
.../state/WorkflowNodeStatusChangeRequest.java | 63 ++++
.../monitor/state/impl/AmazonJobStatusInfo.java | 39 +++
.../monitor/state/impl/GridJobStatusInfo.java | 40 +++
.../gfac/monitor/util/AMQPConnectionUtil.java | 77 ++++
.../airavata/gfac/monitor/util/CommonUtils.java | 172 +++++++++
.../airavata/gfac/monitor/util/X509Helper.java | 161 +++++++++
.../src/main/resources/errors.properties | 197 +++++++++++
.../src/main/resources/schema/AccessPolicy.json | 13 +
.../src/main/resources/schema/Activity.json | 31 ++
.../src/main/resources/schema/AdminDomain.json | 51 +++
.../schema/ApplicationEnvironment.json | 86 +++++
.../resources/schema/ApplicationHandle.json | 21 ++
.../src/main/resources/schema/Benchmark.json | 21 ++
.../resources/schema/ComputingActivity.json | 165 +++++++++
.../resources/schema/ComputingEndpoint.json | 44 +++
.../main/resources/schema/ComputingManager.json | 117 +++++++
.../main/resources/schema/ComputingService.json | 32 ++
.../main/resources/schema/ComputingShare.json | 182 ++++++++++
.../src/main/resources/schema/Contact.json | 32 ++
.../src/main/resources/schema/DataStore.json | 30 ++
.../src/main/resources/schema/Domain.json | 30 ++
.../src/main/resources/schema/Endpoint.json | 147 ++++++++
.../src/main/resources/schema/Entity.json | 35 ++
.../resources/schema/ExecutionEnvironment.json | 115 ++++++
.../src/main/resources/schema/Glue2.json | 246 +++++++++++++
.../src/main/resources/schema/Location.json | 47 +++
.../src/main/resources/schema/Manager.json | 28 ++
.../main/resources/schema/MappingPolicy.json | 13 +
.../src/main/resources/schema/Policy.json | 27 ++
.../src/main/resources/schema/Resource.json | 27 ++
.../src/main/resources/schema/Service.json | 75 ++++
.../src/main/resources/schema/Share.json | 45 +++
.../resources/schema/StorageAccessProtocol.json | 32 ++
.../main/resources/schema/StorageEndpoint.json | 8 +
.../main/resources/schema/StorageManager.json | 8 +
.../main/resources/schema/StorageService.json | 22 ++
.../schema/StorageServiceCapacity.json | 33 ++
.../src/main/resources/schema/StorageShare.json | 65 ++++
.../resources/schema/StorageShareCapacity.json | 33 ++
.../resources/schema/ToComputingService.json | 32 ++
.../main/resources/schema/ToStorageService.json | 25 ++
.../src/main/resources/schema/UserDomain.json | 58 ++++
.../src/main/resources/service.properties | 58 ++++
.../apache/airavata/job/AMQPMonitorTest.java | 178 ++++++++++
.../job/QstatMonitorTestWithMyProxyAuth.java | 170 +++++++++
.../src/test/resources/PBSTemplate.xslt | 73 ++++
.../gfac-monitor/src/test/resources/echo.bat | 22 ++
.../src/test/resources/gfac-config.xml | 65 ++++
.../src/test/resources/logging.properties | 42 +++
.../gfac/handler/AdvancedSCPInputHandler.java | 22 +-
.../gfac/handler/AdvancedSCPOutputHandler.java | 54 +--
.../gfac/handler/SSHDirectorySetupHandler.java | 29 +-
.../airavata/gfac/handler/SSHInputHandler.java | 43 +--
.../airavata/gfac/handler/SSHOutputHandler.java | 22 +-
.../gfac/provider/impl/SSHProvider.java | 21 +-
.../apache/airavata/gfac/util/GFACSSHUtils.java | 94 ++++-
modules/gfac/pom.xml | 1 +
.../server/OrchestratorServerHandler.java | 17 -
.../core/context/OrchestratorContext.java | 11 -
.../core/impl/EmbeddedGFACJobSubmitter.java | 3 -
.../cpi/impl/SimpleOrchestratorImpl.java | 169 +--------
.../orchestrator/core/NewOrchestratorTest.java | 2 +
193 files changed, 7501 insertions(+), 4938 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
index 89bab76..eac1350 100644
--- a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
+++ b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
@@ -61,7 +61,7 @@ public class CreateLaunchExperiment {
AiravataUtils.setExecutionAsClient();
final Airavata.Client airavata = AiravataClientFactory.createAiravataClient(THRIFT_SERVER_HOST, THRIFT_SERVER_PORT);
System.out.println("API version is " + airavata.GetAPIVersion());
-// addDescriptors();
+ addDescriptors();
// final String expId = createExperimentForSSHHost(airavata);
// final String expId = createExperimentForSSHHost(airavata);
final String expId = createExperimentForTrestles(airavata);
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/configuration/server/src/main/resources/gfac-config.xml
----------------------------------------------------------------------
diff --git a/modules/configuration/server/src/main/resources/gfac-config.xml b/modules/configuration/server/src/main/resources/gfac-config.xml
index 1651205..f44fbec 100644
--- a/modules/configuration/server/src/main/resources/gfac-config.xml
+++ b/modules/configuration/server/src/main/resources/gfac-config.xml
@@ -11,6 +11,9 @@
~ under the License. -->
<GFac>
+ <DaemonHandlers>
+ <Handler class="org.apache.airavata.gfac.monitor.handlers.GridPullMonitorHandler"/>
+ </DaemonHandlers>
<GlobalHandlers>
<InHandlers>
<Handler class="org.apache.airavata.gfac.handler.AppDescriptorCheckHandler">
@@ -54,7 +57,7 @@
<Application name="UltraScan">
<InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GramDirectorySetupHandler"/>
+ <Handler class="org.apache.airavata.gfac.handler.GfacDirectorySetupHandler"/>
<Handler class="org.apache.airavata.gfac.handler.GridFTPInputHandler"/>
</InHandlers>
<OutHandlers>
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/distribution/server/pom.xml
----------------------------------------------------------------------
diff --git a/modules/distribution/server/pom.xml b/modules/distribution/server/pom.xml
index 202db63..32880bc 100644
--- a/modules/distribution/server/pom.xml
+++ b/modules/distribution/server/pom.xml
@@ -306,6 +306,11 @@
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-gfac-hpc-monitor</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
<artifactId>airavata-gfac-local</artifactId>
<version>${project.version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/distribution/server/src/main/assembly/bin-assembly.xml
----------------------------------------------------------------------
diff --git a/modules/distribution/server/src/main/assembly/bin-assembly.xml b/modules/distribution/server/src/main/assembly/bin-assembly.xml
index b5faaa5..3435565 100644
--- a/modules/distribution/server/src/main/assembly/bin-assembly.xml
+++ b/modules/distribution/server/src/main/assembly/bin-assembly.xml
@@ -199,6 +199,7 @@
<include>org.apache.airavata:airavata-gfac-ssh:jar</include>
<include>org.apache.airavata:airavata-gfac-local:jar</include>
<include>org.apache.airavata:airavata-gfac-gsissh:jar</include>
+ <include>org.apache.airavata:airavata-gfac-hpc-monitor:jar</include>
<include>org.apache.airavata:airavata-gfac-hadoop:jar</include>
<include>org.apache.airavata:airavata-gfac-bes:jar</include>
<include>org.apache.airavata:airavata-gfac-gram:jar</include>
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/provider/impl/BESProvider.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/provider/impl/BESProvider.java b/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/provider/impl/BESProvider.java
index 2ace533..4a531a6 100644
--- a/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/provider/impl/BESProvider.java
+++ b/modules/gfac/gfac-bes/src/main/java/org/apache/airavata/gfac/provider/impl/BESProvider.java
@@ -48,6 +48,7 @@ import org.apache.airavata.gfac.context.JobExecutionContext;
import org.apache.airavata.gfac.context.security.GSISecurityContext;
import org.apache.airavata.gfac.notification.events.StatusChangeEvent;
import org.apache.airavata.gfac.notification.events.UnicoreJobIDEvent;
+import org.apache.airavata.gfac.provider.AbstractProvider;
import org.apache.airavata.gfac.provider.GFacProviderException;
import org.apache.airavata.gfac.utils.DataTransferrer;
import org.apache.airavata.gfac.utils.JSDLGenerator;
@@ -91,7 +92,7 @@ import eu.unicore.util.httpclient.DefaultClientConfiguration;
-public class BESProvider extends AbstractProvider{
+public class BESProvider extends AbstractProvider {
protected final Logger log = LoggerFactory.getLogger(this.getClass());
private DefaultClientConfiguration secProperties;
@@ -199,7 +200,7 @@ public class BESProvider extends AbstractProvider{
String jobStatusMessage = "Status of job " + jobId + "is " + jobStatus;
jobExecutionContext.getNotifier().publish(new StatusChangeEvent(jobStatusMessage));
details.setJobID(jobId);
- GFacUtils.updateJobStatus(details, jobStatus);
+ GFacUtils.updateJobStatus(jobExecutionContext, details, jobStatus);
} catch (UnknownActivityIdentifierFault e) {
throw new GFacProviderException(e.getMessage(), e.getCause());
}catch (GFacException e) {
@@ -239,7 +240,7 @@ public class BESProvider extends AbstractProvider{
jobExecutionContext.getNotifier().publish(new StatusChangeEvent(jobStatusMessage));
details.setJobID(jobId);
try {
- GFacUtils.saveJobStatus(details, jobStatus, jobExecutionContext.getTaskData().getTaskID());
+ GFacUtils.saveJobStatus(jobExecutionContext,details, jobStatus);
} catch (GFacException e) {
throw new GFacProviderException(e.getLocalizedMessage(),e);
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/pom.xml b/modules/gfac/gfac-core/pom.xml
index db8d3f5..33758e2 100644
--- a/modules/gfac/gfac-core/pom.xml
+++ b/modules/gfac/gfac-core/pom.xml
@@ -112,35 +112,15 @@
<!-- gsi-ssh api dependencies -->
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId>gsissh</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.airavata</groupId>
<artifactId>airavata-data-models</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>com.jcraft</groupId>
- <artifactId>jsch</artifactId>
- <version>0.1.50</version>
- </dependency>
- <dependency>
- <groupId>org.ogce</groupId>
- <artifactId>bcgss</artifactId>
- <version>146</version>
- </dependency>
- <dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>${xmlbeans.version}</version>
</dependency>
<!-- this is the dependency for amqp implementation -->
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- <version>2.0.0</version>
- </dependency>
</dependencies>
<build>
@@ -154,22 +134,6 @@
<failIfNoTests>false</failIfNoTests>
</configuration>
</plugin>
- <plugin>
- <groupId>org.jsonschema2pojo</groupId>
- <artifactId>jsonschema2pojo-maven-plugin</artifactId>
- <version>0.4.0</version>
- <configuration>
- <sourceDirectory>${basedir}/src/main/resources/schema</sourceDirectory>
- <targetPackage>org.apache.airavata</targetPackage>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/Constants.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/Constants.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/Constants.java
index bda40b1..b9ecdbe 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/Constants.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/Constants.java
@@ -24,6 +24,7 @@ package org.apache.airavata.gfac;
public class Constants {
public static final String XPATH_EXPR_GLOBAL_INFLOW_HANDLERS = "/GFac/GlobalHandlers/InHandlers/Handler";
public static final String XPATH_EXPR_GLOBAL_OUTFLOW_HANDLERS = "/GFac/GlobalHandlers/OutHandlers/Handler";
+ public static final String XPATH_EXPR_DAEMON_HANDLERS = "/GFac/DaemonHandlers/Handler";
public static final String XPATH_EXPR_APPLICATION_HANDLERS_START = "/GFac/Application[@name='";
public static final String XPATH_EXPR_APPLICATION_INFLOW_HANDLERS_END = "']/InHandlers/Handler";
@@ -37,6 +38,7 @@ public class Constants {
public static final String XPATH_EXPR_PROVIDER_OUTFLOW_HANDLERS_END = "']/OutHandlers/Handler";
public static final String GFAC_CONFIG_CLASS_ATTRIBUTE = "class";
+ public static final String GFAC_CONFIG_EXECUTION_MODE_ATTRIBUTE = "executionMode";
public static final String GFAC_CONFIG_APPLICATION_NAME_ATTRIBUTE = "class";
public static final String NEWLINE = System.getProperty("line.separator");
public static final String INPUT_DATA_DIR_VAR_NAME = "input";
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/ExecutionMode.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/ExecutionMode.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/ExecutionMode.java
new file mode 100644
index 0000000..63f2523
--- /dev/null
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/ExecutionMode.java
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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;
+
+
+/**
+ * These are the different modes of execution chains in gfac
+ * if the mode is SYNCHRONOUS then gfac will waits until the provider invoke mthod returns and then
+ * invoke the out handlers explicitly, otherwise gfac will not invoke out hanlders, implementation
+ * has to handler when to invoke out handlers, and default execution mode is synchronous.
+ */
+public enum ExecutionMode {
+ SYNCHRONOUS,ASYNCHRONOUS;
+
+ public static ExecutionMode fromString(String mode){
+ if("async".equals(mode) || "asynchronous".equals(mode)){
+ return ExecutionMode.ASYNCHRONOUS;
+ }
+ return ExecutionMode.SYNCHRONOUS;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/GFacConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/GFacConfiguration.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/GFacConfiguration.java
index 3ae29d6..cd716e5 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/GFacConfiguration.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/GFacConfiguration.java
@@ -38,6 +38,7 @@ import org.apache.airavata.client.api.AiravataAPI;
import org.apache.airavata.common.exception.ApplicationSettingsException;
import org.apache.airavata.common.exception.UnspecifiedApplicationSettingsException;
import org.apache.airavata.common.utils.ServerSettings;
+import org.apache.airavata.gfac.context.JobExecutionContext;
import org.apache.airavata.gfac.handler.GFacHandlerConfig;
import org.apache.airavata.gfac.provider.GFacProviderConfig;
import org.slf4j.Logger;
@@ -60,6 +61,7 @@ public class GFacConfiguration {
// the provider
private List<GFacHandlerConfig> outHandlers = new ArrayList<GFacHandlerConfig>();
+ public ExecutionMode executionMode = ExecutionMode.SYNCHRONOUS; // default execution mode is SYNCHRONOUS
public GFacConfiguration(AiravataAPI airavataAPI) {
this.airavataAPI = airavataAPI;
@@ -232,13 +234,13 @@ public class GFacConfiguration {
return gFacProviderConfigs;
}
- public static String getProviderClassName(Document doc, String expression, String attribute) throws XPathExpressionException {
+ public static String getAttributeValue(Document doc, String expression, String attribute) throws XPathExpressionException {
XPathFactory xPathFactory = XPathFactory.newInstance();
XPath xPath = xPathFactory.newXPath();
XPathExpression expr = xPath.compile(expression);
NodeList nl = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
- String className = "";
+ String className = null;
for (int i = 0; i < nl.getLength(); i++) {
className = ((Element) nl.item(i)).getAttribute(attribute);
break;
@@ -262,8 +264,21 @@ public class GFacConfiguration {
arlList.addAll(newList);
return arlList;
}
-
+ public static List<GFacHandlerConfig> getDaemonHandlers(File configFile)throws ParserConfigurationException, IOException, SAXException, XPathExpressionException{
+ DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+ handlerDoc = docBuilder.parse(configFile);
+ return getHandlerConfig(handlerDoc, Constants.XPATH_EXPR_DAEMON_HANDLERS, Constants.GFAC_CONFIG_CLASS_ATTRIBUTE);
+ }
public static Document getHandlerDoc() {
return handlerDoc;
}
+
+ public ExecutionMode getExecutionMode() {
+ return executionMode;
+ }
+
+ public void setExecutionMode(ExecutionMode executionMode) {
+ this.executionMode = executionMode;
+ }
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/Scheduler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/Scheduler.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/Scheduler.java
index 1b30240..273013b 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/Scheduler.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/Scheduler.java
@@ -64,6 +64,11 @@ public class Scheduler {
// Current implementation only support static handler sequence.
jobExecutionContext.setProvider(getProvider(jobExecutionContext));
// TODO: Selecting the provider based on application description.
+ jobExecutionContext.getGFacConfiguration().setInHandlers(jobExecutionContext.getProvider().getClass().getName(),
+ jobExecutionContext.getServiceName());
+ jobExecutionContext.getGFacConfiguration().setOutHandlers(jobExecutionContext.getProvider().getClass().getName(),
+ jobExecutionContext.getServiceName());
+ jobExecutionContext.getGFacConfiguration().setExecutionMode(getExecutionMode(jobExecutionContext));
}
/**
@@ -109,7 +114,7 @@ public class Scheduler {
// We give higher preference to applications specific provider if configured
if (provider == null) {
String hostClass = hostDescription.getType().getClass().getName();
- providerClassName = GFacConfiguration.getProviderClassName(GFacConfiguration.getHandlerDoc(), Constants.XPATH_EXPR_PROVIDER_ON_HOST + hostClass + "']", Constants.GFAC_CONFIG_CLASS_ATTRIBUTE);
+ providerClassName = GFacConfiguration.getAttributeValue(GFacConfiguration.getHandlerDoc(), Constants.XPATH_EXPR_PROVIDER_ON_HOST + hostClass + "']", Constants.GFAC_CONFIG_CLASS_ATTRIBUTE);
Class<? extends GFacProvider> aClass1 = Class.forName(providerClassName).asSubclass(GFacProvider.class);
provider = aClass1.newInstance();
//loading the provider properties
@@ -137,7 +142,42 @@ public class Scheduler {
}
return provider;
}
+ public static ExecutionMode getExecutionMode(JobExecutionContext jobExecutionContext)throws GFacException{
+ HostDescription hostDescription = jobExecutionContext.getApplicationContext().getHostDescription();
+ String applicationName = jobExecutionContext.getServiceName();
+ URL resource = Scheduler.class.getClassLoader().getResource(org.apache.airavata.common.utils.Constants.GFAC_CONFIG_XML);
+ DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = null;
+ Document handlerDoc = null;
+ try {
+ docBuilder = docBuilderFactory.newDocumentBuilder();
+ handlerDoc = docBuilder.parse(new File(resource.getPath()));
+ } catch (ParserConfigurationException e) {
+ throw new GFacException(e);
+ } catch (SAXException e) {
+ throw new GFacException(e);
+ } catch (IOException e) {
+ throw new GFacException(e);
+ }
+ GFacProviderConfig s = null;
+ String executionMode = "sync";
+ try {
+ executionMode = GFacConfiguration.getAttributeValue(handlerDoc,
+ Constants.XPATH_EXPR_APPLICATION_HANDLERS_START + applicationName + "']", Constants.GFAC_CONFIG_EXECUTION_MODE_ATTRIBUTE);
+ // This should be have a single element only.
+
+ if (executionMode == null || "".equals(executionMode)) {
+ String hostClass = hostDescription.getType().getClass().getName();
+ executionMode = GFacConfiguration.getAttributeValue(GFacConfiguration.getHandlerDoc(), Constants.XPATH_EXPR_PROVIDER_ON_HOST + hostClass + "']", Constants.GFAC_CONFIG_EXECUTION_MODE_ATTRIBUTE);
+ }
+ } catch (XPathExpressionException e) {
+ log.error("Error evaluating XPath expression"); //To change body of catch statement use File | Settings | File Templates.
+ throw new GFacException("Error evaluating XPath expression", e);
+ }
+
+ return ExecutionMode.fromString(executionMode);
+ }
public static HostDescription pickaHost(AiravataAPI api, String serviceName) throws AiravataAPIInvocationException {
List<HostDescription> registeredHosts = new ArrayList<HostDescription>();
Map<String, ApplicationDescription> applicationDescriptors = api.getApplicationManager().getApplicationDescriptors(serviceName);
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/context/JobExecutionContext.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/context/JobExecutionContext.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/context/JobExecutionContext.java
index 1f99057..2de8f48 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/context/JobExecutionContext.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/context/JobExecutionContext.java
@@ -26,13 +26,16 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.airavata.gfac.ExecutionMode;
import org.apache.airavata.gfac.GFacConfiguration;
import org.apache.airavata.gfac.GFacException;
import org.apache.airavata.gfac.SecurityContext;
import org.apache.airavata.gfac.notification.GFacNotifier;
import org.apache.airavata.gfac.provider.GFacProvider;
+import org.apache.airavata.model.workspace.experiment.Experiment;
import org.apache.airavata.model.workspace.experiment.JobDetails;
import org.apache.airavata.model.workspace.experiment.TaskDetails;
+import org.apache.airavata.model.workspace.experiment.WorkflowNodeDetails;
import org.apache.airavata.registry.cpi.Registry;
public class JobExecutionContext extends AbstractContext{
@@ -46,11 +49,15 @@ public class JobExecutionContext extends AbstractContext{
private MessageContext outMessageContext;
private GFacNotifier notifier;
-
+
+ private Experiment experiment;
+
private TaskDetails taskData;
private JobDetails jobDetails;
+ private WorkflowNodeDetails workflowNodeDetails;
+
// private ContextHeaderDocument.ContextHeader contextHeader;
// Keep track of the current path of the message. Before hitting provider its in-path.
@@ -83,6 +90,7 @@ public class JobExecutionContext extends AbstractContext{
private List<String> outputFileList;
private Registry registry;
+
/**
* Security context is used to handle authentication for input handlers and providers.
* There can be multiple security requirement for a single job so this allows you to add multiple security types
@@ -97,6 +105,7 @@ public class JobExecutionContext extends AbstractContext{
outputFileList = new ArrayList<String>();
}
+
public String getExperimentID() {
return experimentID;
}
@@ -142,10 +151,6 @@ public class JobExecutionContext extends AbstractContext{
}
public void setProvider(GFacProvider provider) {
- this.gfacConfiguration.setInHandlers(provider.getClass().getName(),
- this.getServiceName());
- this.gfacConfiguration.setOutHandlers(provider.getClass().getName(),
- this.getServiceName());
this.provider = provider;
}
@@ -253,4 +258,20 @@ public class JobExecutionContext extends AbstractContext{
public void setRegistry(Registry registry) {
this.registry = registry;
}
+
+ public Experiment getExperiment() {
+ return experiment;
+ }
+
+ public void setExperiment(Experiment experiment) {
+ this.experiment = experiment;
+ }
+
+ public WorkflowNodeDetails getWorkflowNodeDetails() {
+ return workflowNodeDetails;
+ }
+
+ public void setWorkflowNodeDetails(WorkflowNodeDetails workflowNodeDetails) {
+ this.workflowNodeDetails = workflowNodeDetails;
+ }
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/cpi/GFacImpl.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/cpi/GFacImpl.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/cpi/GFacImpl.java
index c09f45a..642d659 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/cpi/GFacImpl.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/cpi/GFacImpl.java
@@ -21,6 +21,7 @@
package org.apache.airavata.gfac.cpi;
import java.io.File;
+import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
@@ -42,39 +43,35 @@ import org.apache.airavata.gfac.context.MessageContext;
import org.apache.airavata.gfac.handler.GFacHandler;
import org.apache.airavata.gfac.handler.GFacHandlerConfig;
import org.apache.airavata.gfac.handler.GFacHandlerException;
+import org.apache.airavata.gfac.handler.ThreadedHandler;
import org.apache.airavata.gfac.notification.events.ExecutionFailEvent;
import org.apache.airavata.gfac.notification.listeners.LoggingListener;
import org.apache.airavata.gfac.notification.listeners.WorkflowTrackingListener;
import org.apache.airavata.gfac.provider.GFacProvider;
import org.apache.airavata.gfac.scheduler.HostScheduler;
import org.apache.airavata.gfac.utils.GFacUtils;
-import org.apache.airavata.gfac.monitor.AbstractActivityListener;
-import org.apache.airavata.gfac.monitor.MonitorManager;
-import org.apache.airavata.gfac.monitor.command.ExperimentCancelRequest;
-import org.apache.airavata.gfac.monitor.command.TaskCancelRequest;
import org.apache.airavata.model.workspace.experiment.DataObjectType;
+import org.apache.airavata.model.workspace.experiment.Experiment;
import org.apache.airavata.model.workspace.experiment.TaskDetails;
-import org.apache.airavata.persistance.registry.jpa.resources.AbstractResource.TaskDetailConstants;
+import org.apache.airavata.model.workspace.experiment.WorkflowNodeDetails;
import org.apache.airavata.registry.api.AiravataRegistry2;
import org.apache.airavata.registry.cpi.DataType;
import org.apache.airavata.registry.cpi.Registry;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.apache.airavata.registry.cpi.utils.Constants.FieldConstants.WorkflowNodeConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.eventbus.Subscribe;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPathExpressionException;
/**
* This is the GFac CPI class for external usage, this simply have a single method to submit a job to
* the resource, required data for the job has to be stored in registry prior to invoke this object.
*/
-public class GFacImpl implements GFac, AbstractActivityListener {
+public class GFacImpl implements GFac {
private static final Logger log = LoggerFactory.getLogger(GFacImpl.class);
public static final String ERROR_SENT = "ErrorSent";
- public static final String PBS_JOB_MANAGER = "pbs";
- public static final String SLURM_JOB_MANAGER = "slurm";
- public static final String SUN_GRID_ENGINE_JOB_MANAGER = "sge";
private Registry registry;
@@ -82,8 +79,9 @@ public class GFacImpl implements GFac, AbstractActivityListener {
private AiravataRegistry2 airavataRegistry2;
- private MonitorManager monitorManager;
+ private static List<ThreadedHandler> daemonHandlers;
+ private File gfacConfigFile;
/**
* Constructor for GFac
*
@@ -95,13 +93,59 @@ public class GFacImpl implements GFac, AbstractActivityListener {
this.registry = registry;
this.airavataAPI = airavataAPI;
this.airavataRegistry2 = airavataRegistry2;
+ daemonHandlers = new ArrayList<ThreadedHandler>();
+ startDaemonHandlers();
+ }
+
+ private void startDaemonHandlers() {
+ List<GFacHandlerConfig> daemonHandlerConfig = null;
+ URL resource = GFacImpl.class.getClassLoader().getResource(org.apache.airavata.common.utils.Constants.GFAC_CONFIG_XML);
+ gfacConfigFile = new File(resource.getPath());
+ try {
+ daemonHandlerConfig = GFacConfiguration.getDaemonHandlers(gfacConfigFile);
+ } catch (ParserConfigurationException e) {
+ log.error("Error parsing gfac-config.xml, double check the xml configuration",e);
+ } catch (IOException e) {
+ log.error("Error parsing gfac-config.xml, double check the xml configuration", e);
+ } catch (SAXException e) {
+ log.error("Error parsing gfac-config.xml, double check the xml configuration", e);
+ } catch (XPathExpressionException e) {
+ log.error("Error parsing gfac-config.xml, double check the xml configuration", e);
+ }
+
+ for(GFacHandlerConfig handlerConfig:daemonHandlerConfig){
+ String className = handlerConfig.getClassName();
+ try {
+ Class<?> aClass = Class.forName(className).asSubclass(ThreadedHandler.class);
+ ThreadedHandler threadedHandler = (ThreadedHandler) aClass.newInstance();
+ threadedHandler.initProperties(handlerConfig.getProperties());
+ daemonHandlers.add(threadedHandler);
+ }catch (ClassNotFoundException e){
+ log.error("Error initializing the handler: " + className);
+ log.error(className + " class has to implement " + ThreadedHandler.class);
+ } catch (InstantiationException e) {
+ log.error("Error initializing the handler: " + className);
+ log.error(className + " class has to implement " + ThreadedHandler.class);
+ } catch (IllegalAccessException e) {
+ log.error("Error initializing the handler: " + className);
+ log.error(className + " class has to implement " + ThreadedHandler.class);
+ } catch (GFacHandlerException e) {
+ log.error("Error initializing the handler " + className);
+ } catch (GFacException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ }
+ for(ThreadedHandler tHandler:daemonHandlers){
+ tHandler.run();
+ }
}
/**
* This can be used to submit jobs for testing purposes just by filling parameters by hand (JobExecutionContext)
*/
public GFacImpl() {
-
+ daemonHandlers = new ArrayList<ThreadedHandler>();
+ startDaemonHandlers();
}
/**
@@ -127,6 +171,7 @@ public class GFacImpl implements GFac, AbstractActivityListener {
private JobExecutionContext createJEC(String experimentID, String taskID) throws Exception {
JobExecutionContext jobExecutionContext;
TaskDetails taskData = (TaskDetails) registry.get(DataType.TASK_DETAIL, taskID);
+
// this is wear our new model and old model is mapping (so serviceName in ExperimentData and service name in ServiceDescriptor
// has to be same.
@@ -146,22 +191,32 @@ public class GFacImpl implements GFac, AbstractActivityListener {
HostDescription hostDescription = hostScheduler.schedule(registeredHosts);
ServiceDescription serviceDescription = airavataRegistry2.getServiceDescriptor(serviceName);
- String hostName;
+ String hostName;
if(taskData.getTaskScheduling().getResourceHostId() != null){
- hostName = taskData.getTaskScheduling().getResourceHostId();
+ hostName = taskData.getTaskScheduling().getResourceHostId();
}else{
- hostName = hostDescription.getType().getHostName();
+ hostName = hostDescription.getType().getHostName();
}
-
- ApplicationDescription applicationDescription = airavataRegistry2.getApplicationDescriptors(serviceName, hostName);
+
+ ApplicationDescription applicationDescription = airavataRegistry2.getApplicationDescriptors(serviceName, hostName);
URL resource = GFacImpl.class.getClassLoader().getResource(org.apache.airavata.common.utils.Constants.GFAC_CONFIG_XML);
Properties configurationProperties = ServerSettings.getProperties();
GFacConfiguration gFacConfiguration = GFacConfiguration.create(new File(resource.getPath()), airavataAPI, configurationProperties);
+
+ // start constructing jobexecutioncontext
jobExecutionContext = new JobExecutionContext(gFacConfiguration, serviceName);
- jobExecutionContext.setRegistry(registry);
+ Experiment experiment = (Experiment) registry.get(DataType.EXPERIMENT, experimentID);
+ jobExecutionContext.setExperiment(experiment);
+ jobExecutionContext.setExperimentID(experimentID);
+
jobExecutionContext.setTaskData(taskData);
+
+
+
+ jobExecutionContext.setRegistry(registry);
+
ApplicationContext applicationContext = new ApplicationContext();
applicationContext.setApplicationDeploymentDescription(applicationDescription);
applicationContext.setHostDescription(hostDescription);
@@ -177,7 +232,6 @@ public class GFacImpl implements GFac, AbstractActivityListener {
serviceDescription.getType().getOutputParametersArray())));
jobExecutionContext.setProperty(Constants.PROP_TOPIC, experimentID);
- jobExecutionContext.setExperimentID(experimentID);
return jobExecutionContext;
}
@@ -218,6 +272,9 @@ public class GFacImpl implements GFac, AbstractActivityListener {
executeProvider(provider, jobExecutionContext);
disposeProvider(provider, jobExecutionContext);
}
+ if(GFacUtils.isSynchronousMode(jobExecutionContext)){
+ invokeOutFlowHandlers(jobExecutionContext);
+ }
} catch (Exception e) {
jobExecutionContext.setProperty(ERROR_SENT, "true");
jobExecutionContext.getNotifier().publish(new ExecutionFailEvent(e.getCause()));
@@ -323,29 +380,25 @@ public class GFacImpl implements GFac, AbstractActivityListener {
}
+ public AiravataAPI getAiravataAPI() {
+ return airavataAPI;
+ }
+
+ public AiravataRegistry2 getAiravataRegistry2() {
+ return airavataRegistry2;
+ }
+
+ public static List<ThreadedHandler> getDaemonHandlers() {
+ return daemonHandlers;
+ }
+
+ public static String getErrorSent() {
+ return ERROR_SENT;
+ }
+
+ public File getGfacConfigFile() {
+ return gfacConfigFile;
+ }
- public void setup(Object... configurations) {
- for (Object configuration : configurations) {
- if (configuration instanceof MonitorManager){
- monitorManager=(MonitorManager) configuration;
- }
- }
-
- }
-
- @Subscribe
- public void experimentCancelRequested(ExperimentCancelRequest request){
- try {
- List<String> nodeIds = registry.getIds(DataType.WORKFLOW_NODE_DETAIL, WorkflowNodeConstants.EXPERIMENT_ID, request.getExperimentId());
- for (String nodeId : nodeIds) {
- List<String> taskIds = registry.getIds(DataType.TASK_DETAIL, TaskDetailConstants.NODE_INSTANCE_ID, nodeId);
- for (String taskId : taskIds) {
- monitorManager.getMonitorPublisher().publish(new TaskCancelRequest(request.getExperimentId(),nodeId, taskId));
- }
- }
- } catch (RegistryException e) {
- log.error("Error while attempting to publish task cancel requests!!!",e);
- }
- }
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/AbstractHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/AbstractHandler.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/AbstractHandler.java
index 2468273..3524cdb 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/AbstractHandler.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/AbstractHandler.java
@@ -20,7 +20,6 @@
*/
package org.apache.airavata.gfac.handler;
-import org.apache.airavata.gfac.GFacException;
import org.apache.airavata.gfac.context.JobExecutionContext;
import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory;
import org.apache.airavata.registry.cpi.Registry;
@@ -28,7 +27,7 @@ import org.apache.airavata.registry.cpi.Registry;
public abstract class AbstractHandler implements GFacHandler {
protected Registry registry = null;
- public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException, GFacException {
+ public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
registry = jobExecutionContext.getRegistry();
if(registry == null){
registry = RegistryFactory.getDefaultRegistry();
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/AppDescriptorCheckHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/AppDescriptorCheckHandler.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/AppDescriptorCheckHandler.java
index 9afa92f..7cc5a47 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/AppDescriptorCheckHandler.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/AppDescriptorCheckHandler.java
@@ -22,7 +22,6 @@ package org.apache.airavata.gfac.handler;
import org.apache.airavata.commons.gfac.type.ApplicationDescription;
import org.apache.airavata.gfac.Constants;
-import org.apache.airavata.gfac.GFacException;
import org.apache.airavata.gfac.context.JobExecutionContext;
import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
import org.slf4j.Logger;
@@ -82,7 +81,7 @@ public class AppDescriptorCheckHandler implements GFacHandler {
jobExecutionContext.getApplicationContext().setApplicationDeploymentDescription(app);
}
- public void initProperties(Map<String, String> properties) throws GFacHandlerException, GFacException {
+ public void initProperties(Map<String, String> properties) throws GFacHandlerException {
}
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GFacHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GFacHandler.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GFacHandler.java
index 3975031..8f86a48 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GFacHandler.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GFacHandler.java
@@ -28,7 +28,7 @@ import java.util.Map;
public interface GFacHandler {
- public void initProperties(Map<String, String> properties) throws GFacHandlerException,GFacException;
+ public void initProperties(Map<String, String> properties) throws GFacHandlerException;
- public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException,GFacException;
+ public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GFacHandlerException.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GFacHandlerException.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GFacHandlerException.java
index ad86479..775e515 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GFacHandlerException.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GFacHandlerException.java
@@ -43,4 +43,8 @@ public class GFacHandlerException extends GFacException {
super(message, e);
log.error(message,e);
}
+ public GFacHandlerException(Exception e) {
+ super(e);
+ log.error(e.getMessage(),e);
+ }
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/ThreadedHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/ThreadedHandler.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/ThreadedHandler.java
new file mode 100644
index 0000000..fadf120
--- /dev/null
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/handler/ThreadedHandler.java
@@ -0,0 +1,31 @@
+/*
+ *
+ * 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.handler;
+
+/**
+ * This handler can be used to run in a separate thread in handler chain or as a daemon
+ * for the gfac instance you are running. If this is configured as another
+ * handler in the execution chain this will get invoked in asynchronous mode in a separate
+ * thread for each request, so you have to make sure the thread is returning properly.
+ */
+public abstract class ThreadedHandler extends AbstractHandler implements Runnable{
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/AbstractActivityListener.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/AbstractActivityListener.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/AbstractActivityListener.java
deleted file mode 100644
index 63f89df..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/AbstractActivityListener.java
+++ /dev/null
@@ -1,27 +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;
-
-
-public interface AbstractActivityListener {
- public void setup(Object... configurations);
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/AiravataExperimentStatusUpdator.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/AiravataExperimentStatusUpdator.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/AiravataExperimentStatusUpdator.java
deleted file mode 100644
index a70b14f..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/AiravataExperimentStatusUpdator.java
+++ /dev/null
@@ -1,81 +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 com.google.common.eventbus.Subscribe;
-import org.apache.airavata.gfac.monitor.state.ExperimentStatusChangeRequest;
-import org.apache.airavata.model.workspace.experiment.Experiment;
-import org.apache.airavata.model.workspace.experiment.ExperimentState;
-import org.apache.airavata.registry.cpi.DataType;
-import org.apache.airavata.registry.cpi.Registry;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Calendar;
-
-public class AiravataExperimentStatusUpdator implements AbstractActivityListener {
- private final static Logger logger = LoggerFactory.getLogger(AiravataExperimentStatusUpdator.class);
-
- private Registry airavataRegistry;
-
- public Registry getAiravataRegistry() {
- return airavataRegistry;
- }
-
- public void setAiravataRegistry(Registry airavataRegistry) {
- this.airavataRegistry = airavataRegistry;
- }
-
- @Subscribe
- public void updateRegistry(ExperimentStatusChangeRequest experimentStatus) {
- ExperimentState state = experimentStatus.getState();
- if (state != null) {
- try {
- String experimentID = experimentStatus.getIdentity().getExperimentID();
- updateExperimentStatus(experimentID, state);
- } catch (Exception e) {
- logger.error("Error persisting data" + e.getLocalizedMessage(), e);
- }
- }
- }
-
- public void updateExperimentStatus(String experimentId, ExperimentState state) throws Exception {
- Experiment details = (Experiment)airavataRegistry.get(DataType.EXPERIMENT, experimentId);
- if(details == null) {
- details = new Experiment();
- details.setExperimentID(experimentId);
- }
- org.apache.airavata.model.workspace.experiment.ExperimentStatus status = new org.apache.airavata.model.workspace.experiment.ExperimentStatus();
- status.setExperimentState(state);
- status.setTimeOfStateChange(Calendar.getInstance().getTimeInMillis());
- details.setExperimentStatus(status);
- airavataRegistry.update(DataType.EXPERIMENT, details, experimentId);
- }
-
- @Override
- public void setup(Object... configurations) {
- for (Object configuration : configurations) {
- if (configuration instanceof Registry){
- this.airavataRegistry=(Registry)configuration;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/AiravataJobStatusUpdator.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/AiravataJobStatusUpdator.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/AiravataJobStatusUpdator.java
deleted file mode 100644
index 99c8733..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/AiravataJobStatusUpdator.java
+++ /dev/null
@@ -1,145 +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 com.google.common.eventbus.Subscribe;
-import org.apache.airavata.gfac.monitor.event.MonitorPublisher;
-import org.apache.airavata.gfac.monitor.state.JobStatusChangeRequest;
-import org.apache.airavata.gfac.monitor.state.TaskStatusChangeRequest;
-import org.apache.airavata.model.workspace.experiment.JobDetails;
-import org.apache.airavata.model.workspace.experiment.JobState;
-import org.apache.airavata.model.workspace.experiment.TaskState;
-import org.apache.airavata.registry.cpi.CompositeIdentifier;
-import org.apache.airavata.registry.cpi.DataType;
-import org.apache.airavata.registry.cpi.Registry;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Calendar;
-import java.util.concurrent.BlockingQueue;
-
-public class AiravataJobStatusUpdator implements AbstractActivityListener {
- private final static Logger logger = LoggerFactory.getLogger(AiravataJobStatusUpdator.class);
-
- private Registry airavataRegistry;
-
- private MonitorPublisher monitorPublisher;
-
- private BlockingQueue<MonitorID> jobsToMonitor;
-
- public Registry getAiravataRegistry() {
- return airavataRegistry;
- }
-
- public void setAiravataRegistry(Registry airavataRegistry) {
- this.airavataRegistry = airavataRegistry;
- }
-
- public BlockingQueue<MonitorID> getJobsToMonitor() {
- return jobsToMonitor;
- }
-
- public void setJobsToMonitor(BlockingQueue<MonitorID> jobsToMonitor) {
- this.jobsToMonitor = jobsToMonitor;
- }
-
- @Subscribe
- public void updateRegistry(JobStatusChangeRequest jobStatus) {
- /* Here we need to parse the jobStatus message and update
- the registry accordingly, for now we are just printing to standard Out
- */
- JobState state = jobStatus.getState();
- if (state != null) {
- try {
- String taskID = jobStatus.getIdentity().getTaskId();
- String jobID = jobStatus.getIdentity().getJobId();
- updateJobStatus(taskID, jobID, state);
- } catch (Exception e) {
- logger.error("Error persisting data" + e.getLocalizedMessage(), e);
- }
- logger.info("Job ID:" + jobStatus.getIdentity().getJobId() + " is "+state.toString());
- switch (state) {
- case COMPLETE: case UNKNOWN: case CANCELED:case FAILED:case SUSPENDED:
- jobsToMonitor.remove(jobStatus.getMonitorID());
- break;
- default:
- break;
- }
- }
- }
-
- @Subscribe
- public void setupTaskStatus(JobStatusChangeRequest jobStatus){
- TaskState state=TaskState.UNKNOWN;
- switch(jobStatus.getState()){
- case ACTIVE:
- state=TaskState.EXECUTING; break;
- case CANCELED:
- state=TaskState.CANCELED; break;
- case COMPLETE:
- state=TaskState.COMPLETED; break;
- case FAILED:
- state=TaskState.FAILED; break;
- case HELD: case SUSPENDED: case QUEUED:
- state=TaskState.WAITING; break;
- case SETUP:
- state=TaskState.PRE_PROCESSING; break;
- case SUBMITTED:
- state=TaskState.STARTED; break;
- case UN_SUBMITTED:
- state=TaskState.CANCELED; break;
- case CANCELING:
- state=TaskState.CANCELING; break;
- default:
- break;
- }
- logger.debug("Publishing Task Status "+state.toString());
- monitorPublisher.publish(new TaskStatusChangeRequest(jobStatus.getIdentity(),state));
- }
-
- public void updateJobStatus(String taskId, String jobID, JobState state) throws Exception {
- CompositeIdentifier ids = new CompositeIdentifier(taskId, jobID);
- JobDetails details = (JobDetails)airavataRegistry.get(DataType.JOB_DETAIL, ids);
- if(details == null) {
- details = new JobDetails();
- }
- org.apache.airavata.model.workspace.experiment.JobStatus status = new org.apache.airavata.model.workspace.experiment.JobStatus();
- status.setJobState(state);
- status.setTimeOfStateChange(Calendar.getInstance().getTimeInMillis());
- details.setJobStatus(status);
- details.setJobID(jobID);
- airavataRegistry.update(DataType.JOB_DETAIL, details, ids);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void setup(Object... configurations) {
- for (Object configuration : configurations) {
- if (configuration instanceof Registry){
- this.airavataRegistry=(Registry)configuration;
- } else if (configuration instanceof BlockingQueue<?>){
- this.jobsToMonitor=(BlockingQueue<MonitorID>) configuration;
- } else if (configuration instanceof MonitorPublisher){
- this.monitorPublisher=(MonitorPublisher) configuration;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/AiravataTaskStatusUpdator.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/AiravataTaskStatusUpdator.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/AiravataTaskStatusUpdator.java
deleted file mode 100644
index e8dd7a0..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/AiravataTaskStatusUpdator.java
+++ /dev/null
@@ -1,113 +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 com.google.common.eventbus.Subscribe;
-import org.apache.airavata.gfac.monitor.event.MonitorPublisher;
-import org.apache.airavata.gfac.monitor.state.TaskStatusChangeRequest;
-import org.apache.airavata.gfac.monitor.state.WorkflowNodeStatusChangeRequest;
-import org.apache.airavata.model.workspace.experiment.TaskDetails;
-import org.apache.airavata.model.workspace.experiment.TaskState;
-import org.apache.airavata.model.workspace.experiment.WorkflowNodeState;
-import org.apache.airavata.registry.cpi.DataType;
-import org.apache.airavata.registry.cpi.Registry;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Calendar;
-
-public class AiravataTaskStatusUpdator implements AbstractActivityListener {
- private final static Logger logger = LoggerFactory.getLogger(AiravataTaskStatusUpdator.class);
-
- private Registry airavataRegistry;
-
- private MonitorPublisher monitorPublisher;
-
- public Registry getAiravataRegistry() {
- return airavataRegistry;
- }
-
- public void setAiravataRegistry(Registry airavataRegistry) {
- this.airavataRegistry = airavataRegistry;
- }
-
- @Subscribe
- public void updateRegistry(TaskStatusChangeRequest taskStatus) {
- TaskState state = taskStatus.getState();
- if (state != null) {
- try {
- String taskID = taskStatus.getIdentity().getTaskId();
- updateTaskStatus(taskID, state);
- } catch (Exception e) {
- logger.error("Error persisting data" + e.getLocalizedMessage(), e);
- }
- }
- }
-
- @Subscribe
- public void setupWorkflowNodeStatus(TaskStatusChangeRequest taskStatus){
- WorkflowNodeState state=WorkflowNodeState.UNKNOWN;
- switch(taskStatus.getState()){
- case CANCELED:
- state=WorkflowNodeState.CANCELED; break;
- case COMPLETED:
- state=WorkflowNodeState.COMPLETED; break;
- case CONFIGURING_WORKSPACE:
- state=WorkflowNodeState.INVOKED; break;
- case FAILED:
- state=WorkflowNodeState.FAILED; break;
- case EXECUTING: case WAITING: case PRE_PROCESSING: case POST_PROCESSING: case OUTPUT_DATA_STAGING: case INPUT_DATA_STAGING:
- state=WorkflowNodeState.EXECUTING; break;
- case STARTED:
- state=WorkflowNodeState.INVOKED; break;
- case CANCELING:
- state=WorkflowNodeState.CANCELING; break;
- default:
- break;
- }
- logger.debug("Publishing Experiment Status "+state.toString());
- monitorPublisher.publish(new WorkflowNodeStatusChangeRequest(taskStatus.getIdentity(),state));
- }
-
- public void updateTaskStatus(String taskId, TaskState state) throws Exception {
- TaskDetails details = (TaskDetails)airavataRegistry.get(DataType.TASK_DETAIL, taskId);
- if(details == null) {
- details = new TaskDetails();
- details.setTaskID(taskId);
- }
- org.apache.airavata.model.workspace.experiment.TaskStatus status = new org.apache.airavata.model.workspace.experiment.TaskStatus();
- status.setExecutionState(state);
- status.setTimeOfStateChange(Calendar.getInstance().getTimeInMillis());
- details.setTaskStatus(status);
- airavataRegistry.update(DataType.TASK_DETAIL, details, taskId);
- }
-
- @Override
- public void setup(Object... configurations) {
- for (Object configuration : configurations) {
- if (configuration instanceof Registry){
- this.airavataRegistry=(Registry)configuration;
- } else if (configuration instanceof MonitorPublisher){
- this.monitorPublisher=(MonitorPublisher) configuration;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/AiravataWorkflowNodeStatusUpdator.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/AiravataWorkflowNodeStatusUpdator.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/AiravataWorkflowNodeStatusUpdator.java
deleted file mode 100644
index 2375d72..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/AiravataWorkflowNodeStatusUpdator.java
+++ /dev/null
@@ -1,112 +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 com.google.common.eventbus.Subscribe;
-import org.apache.airavata.gfac.monitor.event.MonitorPublisher;
-import org.apache.airavata.gfac.monitor.state.ExperimentStatusChangeRequest;
-import org.apache.airavata.gfac.monitor.state.WorkflowNodeStatusChangeRequest;
-import org.apache.airavata.model.workspace.experiment.ExperimentState;
-import org.apache.airavata.model.workspace.experiment.WorkflowNodeDetails;
-import org.apache.airavata.model.workspace.experiment.WorkflowNodeState;
-import org.apache.airavata.model.workspace.experiment.WorkflowNodeStatus;
-import org.apache.airavata.registry.cpi.DataType;
-import org.apache.airavata.registry.cpi.Registry;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Calendar;
-
-public class AiravataWorkflowNodeStatusUpdator implements AbstractActivityListener {
- private final static Logger logger = LoggerFactory.getLogger(AiravataWorkflowNodeStatusUpdator.class);
-
- private Registry airavataRegistry;
-
- private MonitorPublisher monitorPublisher;
-
- public Registry getAiravataRegistry() {
- return airavataRegistry;
- }
-
- public void setAiravataRegistry(Registry airavataRegistry) {
- this.airavataRegistry = airavataRegistry;
- }
-
- @Subscribe
- public void updateRegistry(WorkflowNodeStatusChangeRequest workflowNodeStatus) {
- WorkflowNodeState state = workflowNodeStatus.getState();
- if (state != null) {
- try {
- String workflowNodeID = workflowNodeStatus.getIdentity().getWorkflowNodeID();
- updateWorkflowNodeStatus(workflowNodeID, state);
- } catch (Exception e) {
- logger.error("Error persisting data" + e.getLocalizedMessage(), e);
- }
- }
- }
-
- @Subscribe
- public void setupExperimentStatus(WorkflowNodeStatusChangeRequest nodeStatus){
- ExperimentState state=ExperimentState.UNKNOWN;
- switch(nodeStatus.getState()){
- case CANCELED:
- state=ExperimentState.CANCELED; break;
- case COMPLETED:
- state=ExperimentState.COMPLETED; break;
- case INVOKED:
- state=ExperimentState.LAUNCHED; break;
- case FAILED:
- state=ExperimentState.FAILED; break;
- case EXECUTING:
- state=ExperimentState.EXECUTING; break;
- case CANCELING:
- state=ExperimentState.CANCELING; break;
- default:
- break;
- }
- logger.debug("Publishing Experiment Status "+state.toString());
- monitorPublisher.publish(new ExperimentStatusChangeRequest(nodeStatus.getIdentity(),state));
- }
-
- public void updateWorkflowNodeStatus(String workflowNodeId, WorkflowNodeState state) throws Exception {
- WorkflowNodeDetails details = (WorkflowNodeDetails)airavataRegistry.get(DataType.WORKFLOW_NODE_DETAIL, workflowNodeId);
- if(details == null) {
- details = new WorkflowNodeDetails();
- details.setNodeInstanceId(workflowNodeId);
- }
- WorkflowNodeStatus status = new WorkflowNodeStatus();
- status.setWorkflowNodeState(state);
- status.setTimeOfStateChange(Calendar.getInstance().getTimeInMillis());
- details.setWorkflowNodeStatus(status);
- airavataRegistry.update(DataType.WORKFLOW_NODE_DETAIL, details, workflowNodeId);
- }
-
- @Override
- public void setup(Object... configurations) {
- for (Object configuration : configurations) {
- if (configuration instanceof Registry){
- this.airavataRegistry=(Registry)configuration;
- } else if (configuration instanceof MonitorPublisher){
- this.monitorPublisher=(MonitorPublisher) configuration;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/ExperimentIdentity.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/ExperimentIdentity.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/ExperimentIdentity.java
deleted file mode 100644
index ba8efeb..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/ExperimentIdentity.java
+++ /dev/null
@@ -1,36 +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;
-
-public class ExperimentIdentity {
- private String experimentID;
- public ExperimentIdentity(String experimentId) {
- setExperimentID(experimentId);
- }
- public String getExperimentID() {
- return experimentID;
- }
-
- public void setExperimentID(String experimentID) {
- this.experimentID = experimentID;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/HostMonitorData.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/HostMonitorData.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/HostMonitorData.java
deleted file mode 100644
index e57087d..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/HostMonitorData.java
+++ /dev/null
@@ -1,69 +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.commons.gfac.type.HostDescription;
-import org.apache.airavata.gfac.monitor.exception.AiravataMonitorException;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class HostMonitorData {
- private HostDescription host;
-
- private List<MonitorID> monitorIDs;
-
- public HostMonitorData(HostDescription host) {
- this.host = host;
- monitorIDs = new ArrayList<MonitorID>();
- }
-
- public HostMonitorData(HostDescription host, List<MonitorID> monitorIDs) {
- this.host = host;
- this.monitorIDs = monitorIDs;
- }
-
- public HostDescription getHost() {
- return host;
- }
-
- public void setHost(HostDescription host) {
- this.host = host;
- }
-
- 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);
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/JobIdentity.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/JobIdentity.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/JobIdentity.java
deleted file mode 100644
index 84c4a55..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/JobIdentity.java
+++ /dev/null
@@ -1,39 +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;
-
-public class JobIdentity extends TaskIdentity {
- private String jobId;
-
- public JobIdentity(String experimentId, String workflowNodeId, String taskId, String jobId) {
- super(experimentId,workflowNodeId,taskId);
- setJobId(jobId);
- }
-
- public String getJobId() {
- return jobId;
- }
-
- public void setJobId(String jobId) {
- this.jobId = jobId;
- }
-}
[5/9] Separating gfac-monitoring implementation
Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-local/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-local/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java b/modules/gfac/gfac-local/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java
index a12bf5d..6a92e53 100644
--- a/modules/gfac/gfac-local/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java
+++ b/modules/gfac/gfac-local/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java
@@ -30,13 +30,13 @@ import org.apache.airavata.gfac.Constants;
import org.apache.airavata.gfac.GFacException;
import org.apache.airavata.gfac.context.JobExecutionContext;
import org.apache.airavata.gfac.notification.events.StartExecutionEvent;
+import org.apache.airavata.gfac.provider.AbstractProvider;
import org.apache.airavata.gfac.provider.GFacProviderException;
import org.apache.airavata.gfac.provider.utils.ProviderUtils;
import org.apache.airavata.gfac.utils.GFacUtils;
import org.apache.airavata.gfac.utils.InputStreamToFileWriter;
import org.apache.airavata.gfac.utils.InputUtils;
import org.apache.airavata.gfac.utils.OutputUtils;
-import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
import org.apache.airavata.model.workspace.experiment.JobDetails;
import org.apache.airavata.model.workspace.experiment.JobState;
import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
@@ -47,7 +47,7 @@ import org.slf4j.LoggerFactory;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
-public class LocalProvider extends AbstractProvider{
+public class LocalProvider extends AbstractProvider {
private static final Logger log = LoggerFactory.getLogger(LocalProvider.class);
private ProcessBuilder builder;
private List<String> cmdList;
@@ -123,13 +123,12 @@ public class LocalProvider extends AbstractProvider{
getApplicationContext().getApplicationDeploymentDescription().getType();
JobDetails jobDetails = new JobDetails();
try {
- jobId= jobExecutionContext.getTaskData().getTaskID();
+ jobId = jobExecutionContext.getTaskData().getTaskID();
jobDetails.setJobID(jobId);
jobDetails.setJobDescription(app.toString());
jobExecutionContext.setJobDetails(jobDetails);
- JobDescriptor jobDescriptor = GFacUtils.createJobDescriptor(jobExecutionContext, app, null);
- jobDetails.setJobDescription(jobDescriptor.toXML());
- GFacUtils.saveJobStatus(jobDetails, JobState.SETUP, jobExecutionContext.getTaskData().getTaskID());
+ jobDetails.setJobDescription(app.toString());
+ GFacUtils.saveJobStatus(jobExecutionContext,jobDetails, JobState.SETUP);
// running cmd
Process process = builder.start();
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-local/src/test/java/org/apache/airavata/core/gfac/services/impl/LocalProviderTest.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-local/src/test/java/org/apache/airavata/core/gfac/services/impl/LocalProviderTest.java b/modules/gfac/gfac-local/src/test/java/org/apache/airavata/core/gfac/services/impl/LocalProviderTest.java
index c33a8bc..bade5f0 100644
--- a/modules/gfac/gfac-local/src/test/java/org/apache/airavata/core/gfac/services/impl/LocalProviderTest.java
+++ b/modules/gfac/gfac-local/src/test/java/org/apache/airavata/core/gfac/services/impl/LocalProviderTest.java
@@ -26,15 +26,18 @@ import org.apache.airavata.gfac.GFacException;
import org.apache.airavata.gfac.context.ApplicationContext;
import org.apache.airavata.gfac.context.JobExecutionContext;
import org.apache.airavata.gfac.context.MessageContext;
-import org.apache.airavata.gfac.cpi.GFacImpl;
+import org.apache.airavata.gfac.handler.LocalDirectorySetupHandler;
+import org.apache.airavata.gfac.provider.GFacProviderException;
+import org.apache.airavata.gfac.provider.impl.LocalProvider;
+import org.apache.airavata.model.workspace.experiment.TaskDetails;
+import org.apache.airavata.persistance.registry.jpa.impl.LoggingRegistryImpl;
import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
import org.apache.airavata.schemas.gfac.InputParameterType;
import org.apache.airavata.schemas.gfac.OutputParameterType;
import org.apache.airavata.schemas.gfac.StringParameterType;
import org.apache.commons.lang.SystemUtils;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
import java.io.File;
import java.net.URL;
@@ -43,7 +46,7 @@ import java.util.List;
public class LocalProviderTest {
private JobExecutionContext jobExecutionContext;
- @Before
+ @BeforeTest
public void setUp() throws Exception {
URL resource = this.getClass().getClassLoader().getResource(org.apache.airavata.common.utils.Constants.GFAC_CONFIG_XML);
@@ -133,18 +136,37 @@ public class LocalProviderTest {
MessageContext outMessage = new MessageContext();
ActualParameter echo_out = new ActualParameter();
-// ((StringParameterType)echo_input.getType()).setValue("echo_output=hello");
outMessage.addParameter("echo_output", echo_out);
jobExecutionContext.setOutMessageContext(outMessage);
+ jobExecutionContext.setExperimentID("test123");
+ jobExecutionContext.setTaskData(new TaskDetails(jobExecutionContext.getExperimentID()));
+ jobExecutionContext.setRegistry(new LoggingRegistryImpl());
+
+
+ }
+
+ @Test
+ public void testLocalDirectorySetupHandler() throws GFacException {
+ LocalDirectorySetupHandler localDirectorySetupHandler = new LocalDirectorySetupHandler();
+ localDirectorySetupHandler.invoke(jobExecutionContext);
+
+ ApplicationDescription applicationDeploymentDescription = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription();
+ ApplicationDeploymentDescriptionType app = applicationDeploymentDescription.getType();
+ junit.framework.Assert.assertTrue(new File(app.getStaticWorkingDirectory()).exists());
+ junit.framework.Assert.assertTrue(new File(app.getScratchWorkingDirectory()).exists());
+ junit.framework.Assert.assertTrue(new File(app.getInputDataDirectory()).exists());
+ junit.framework.Assert.assertTrue(new File(app.getOutputDataDirectory()).exists());
}
@Test
- public void testLocalProvider() throws GFacException {
- GFacImpl gFacAPI = new GFacImpl();
- gFacAPI.submitJob(jobExecutionContext);
- MessageContext outMessageContext = jobExecutionContext.getOutMessageContext();
- Assert.assertEquals(MappingFactory.toString((ActualParameter)outMessageContext.getParameter("echo_output")), "hello");
+ public void testLocalProvider() throws GFacException,GFacProviderException{
+ LocalDirectorySetupHandler localDirectorySetupHandler = new LocalDirectorySetupHandler();
+ localDirectorySetupHandler.invoke(jobExecutionContext);
+ LocalProvider localProvider = new LocalProvider();
+ localProvider.initialize(jobExecutionContext);
+ localProvider.execute(jobExecutionContext);
+ localProvider.dispose(jobExecutionContext);
}
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-local/src/test/resources/gfac-config.xml
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-local/src/test/resources/gfac-config.xml b/modules/gfac/gfac-local/src/test/resources/gfac-config.xml
index 61dca4f..f16460f 100644
--- a/modules/gfac/gfac-local/src/test/resources/gfac-config.xml
+++ b/modules/gfac/gfac-local/src/test/resources/gfac-config.xml
@@ -24,67 +24,4 @@
<Handler class="org.apache.airavata.gfac.handler.LocalDirectorySetupHandler"/>
</InHandlers>
</Provider>
- <Provider class="org.apache.airavata.gfac.provider.impl.GramProvider" host="org.apache.airavata.schemas.gfac.impl.GlobusHostTypeImpl">
- <property name="name" value="value"/>
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GramDirectorySetupHandler">
- <property name="name" value="value"/>
- </Handler>
- <Handler class="org.apache.airavata.gfac.handler.GridFTPInputHandler"/>
- </InHandlers>
- <OutHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GridFTPOutputHandler"/>
- </OutHandlers>
- </Provider>
- <Provider class="org.apache.airavata.gfac.provider.impl.BESProvider" host="org.apache.airavata.schemas.gfac.impl.UnicoreHostTypeImpl">
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GramDirectorySetupHandler"/>
- <Handler class="org.apache.airavata.gfac.handler.GridFTPInputHandler"/>
- </InHandlers>
- <OutHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GridFTPOutputHandler"/>
- </OutHandlers>
- </Provider>
-
- <Provider class="org.apache.airavata.gfac.ec2.EC2Provider" host="org.apache.airavata.schemas.gfac.impl.Ec2HostTypeImpl">
- <InHandlers/>
- <OutHandlers/>
- </Provider>
-
- <Provider class="org.apache.airavata.gfac.provider.impl.HadoopProvider" host="org.apache.airavata.schemas.gfac.impl.HadoopHostTypeImpl">
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.HadoopDeploymentHandler"/>
- <Handler class="org.apache.airavata.gfac.handler.HDFSDataMovementHandler"/>
- </InHandlers>
- <OutHandlers/>
- </Provider>
-
- <Application name="UltraScan">
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GramDirectorySetupHandler"/>
- <Handler class="org.apache.airavata.gfac.handler.GridFTPInputHandler"/>
- </InHandlers>
- <OutHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GridFTPOutputHandler"/>
- </OutHandlers>
- </Application>
-
- <Provider class="org.apache.airavata.gfac.provider.impl.SSHProvider" host="org.apache.airavata.schemas.gfac.impl.SSHHostTypeImpl">
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.SCPDirectorySetupHandler"/>
- <Handler class="org.apache.airavata.gfac.handler.SCPInputHandler"/>
- </InHandlers>
- <OutHandlers>
- <Handler class="org.apache.airavata.gfac.handler.SCPOutputHandler"/>
- </OutHandlers>
- </Provider>
- <Provider class="org.apache.airavata.gfac.provider.impl.GSISSHProvider" host="org.apache.airavata.schemas.gfac.impl.GsisshHostTypeImpl">
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.SCPDirectorySetupHandler"/>
- <Handler class="org.apache.airavata.gfac.handler.SCPInputHandler"/>
- </InHandlers>
- <OutHandlers>
- <Handler class="org.apache.airavata.gfac.handler.SCPOutputHandler"/>
- </OutHandlers>
- </Provider>
</GFac>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/pom.xml
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/pom.xml b/modules/gfac/gfac-monitor/pom.xml
new file mode 100644
index 0000000..8991dcd
--- /dev/null
+++ b/modules/gfac/gfac-monitor/pom.xml
@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--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. -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>gfac</artifactId>
+ <version>0.12-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>airavata-gfac-hpc-monitor</artifactId>
+ <name>Airavata GFac Grid Job Monitor</name>
+ <description>The Grid related monitoring implementation</description>
+ <url>http://airavata.apache.org/</url>
+
+ <dependencies>
+ <!-- Logging -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+
+ <!-- GFAC schemas -->
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-client-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-gfac-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-workflow-execution-context</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-registry-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-registry-cpi</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-jpa-registry</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- Workflow Tracking -->
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-workflow-tracking</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- Credential Store -->
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-credential-store</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+
+ <!-- Test -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>6.1.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-server-configuration</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-client-configuration</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- Guava -->
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>12.0</version>
+ </dependency>
+ <!-- gsi-ssh api dependencies -->
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>gsissh</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-data-models</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.jcraft</groupId>
+ <artifactId>jsch</artifactId>
+ <version>0.1.50</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ogce</groupId>
+ <artifactId>bcgss</artifactId>
+ <version>146</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.xmlbeans</groupId>
+ <artifactId>xmlbeans</artifactId>
+ <version>${xmlbeans.version}</version>
+ </dependency>
+ <!-- this is the dependency for amqp implementation -->
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>false</skip>
+ <forkMode>always</forkMode>
+ <failIfNoTests>false</failIfNoTests>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.jsonschema2pojo</groupId>
+ <artifactId>jsonschema2pojo-maven-plugin</artifactId>
+ <version>0.4.0</version>
+ <configuration>
+ <sourceDirectory>${basedir}/src/main/resources/schema</sourceDirectory>
+ <targetPackage>org.apache.airavata</targetPackage>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/AbstractActivityListener.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/AbstractActivityListener.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/AbstractActivityListener.java
new file mode 100644
index 0000000..63f89df
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/AbstractActivityListener.java
@@ -0,0 +1,27 @@
+/*
+ *
+ * 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;
+
+
+public interface AbstractActivityListener {
+ public void setup(Object... configurations);
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/AiravataExperimentStatusUpdator.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/AiravataExperimentStatusUpdator.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/AiravataExperimentStatusUpdator.java
new file mode 100644
index 0000000..a70b14f
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/AiravataExperimentStatusUpdator.java
@@ -0,0 +1,81 @@
+/*
+ *
+ * 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 com.google.common.eventbus.Subscribe;
+import org.apache.airavata.gfac.monitor.state.ExperimentStatusChangeRequest;
+import org.apache.airavata.model.workspace.experiment.Experiment;
+import org.apache.airavata.model.workspace.experiment.ExperimentState;
+import org.apache.airavata.registry.cpi.DataType;
+import org.apache.airavata.registry.cpi.Registry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Calendar;
+
+public class AiravataExperimentStatusUpdator implements AbstractActivityListener {
+ private final static Logger logger = LoggerFactory.getLogger(AiravataExperimentStatusUpdator.class);
+
+ private Registry airavataRegistry;
+
+ public Registry getAiravataRegistry() {
+ return airavataRegistry;
+ }
+
+ public void setAiravataRegistry(Registry airavataRegistry) {
+ this.airavataRegistry = airavataRegistry;
+ }
+
+ @Subscribe
+ public void updateRegistry(ExperimentStatusChangeRequest experimentStatus) {
+ ExperimentState state = experimentStatus.getState();
+ if (state != null) {
+ try {
+ String experimentID = experimentStatus.getIdentity().getExperimentID();
+ updateExperimentStatus(experimentID, state);
+ } catch (Exception e) {
+ logger.error("Error persisting data" + e.getLocalizedMessage(), e);
+ }
+ }
+ }
+
+ public void updateExperimentStatus(String experimentId, ExperimentState state) throws Exception {
+ Experiment details = (Experiment)airavataRegistry.get(DataType.EXPERIMENT, experimentId);
+ if(details == null) {
+ details = new Experiment();
+ details.setExperimentID(experimentId);
+ }
+ org.apache.airavata.model.workspace.experiment.ExperimentStatus status = new org.apache.airavata.model.workspace.experiment.ExperimentStatus();
+ status.setExperimentState(state);
+ status.setTimeOfStateChange(Calendar.getInstance().getTimeInMillis());
+ details.setExperimentStatus(status);
+ airavataRegistry.update(DataType.EXPERIMENT, details, experimentId);
+ }
+
+ @Override
+ public void setup(Object... configurations) {
+ for (Object configuration : configurations) {
+ if (configuration instanceof Registry){
+ this.airavataRegistry=(Registry)configuration;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/AiravataJobStatusUpdator.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/AiravataJobStatusUpdator.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/AiravataJobStatusUpdator.java
new file mode 100644
index 0000000..99c8733
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/AiravataJobStatusUpdator.java
@@ -0,0 +1,145 @@
+/*
+ *
+ * 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 com.google.common.eventbus.Subscribe;
+import org.apache.airavata.gfac.monitor.event.MonitorPublisher;
+import org.apache.airavata.gfac.monitor.state.JobStatusChangeRequest;
+import org.apache.airavata.gfac.monitor.state.TaskStatusChangeRequest;
+import org.apache.airavata.model.workspace.experiment.JobDetails;
+import org.apache.airavata.model.workspace.experiment.JobState;
+import org.apache.airavata.model.workspace.experiment.TaskState;
+import org.apache.airavata.registry.cpi.CompositeIdentifier;
+import org.apache.airavata.registry.cpi.DataType;
+import org.apache.airavata.registry.cpi.Registry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Calendar;
+import java.util.concurrent.BlockingQueue;
+
+public class AiravataJobStatusUpdator implements AbstractActivityListener {
+ private final static Logger logger = LoggerFactory.getLogger(AiravataJobStatusUpdator.class);
+
+ private Registry airavataRegistry;
+
+ private MonitorPublisher monitorPublisher;
+
+ private BlockingQueue<MonitorID> jobsToMonitor;
+
+ public Registry getAiravataRegistry() {
+ return airavataRegistry;
+ }
+
+ public void setAiravataRegistry(Registry airavataRegistry) {
+ this.airavataRegistry = airavataRegistry;
+ }
+
+ public BlockingQueue<MonitorID> getJobsToMonitor() {
+ return jobsToMonitor;
+ }
+
+ public void setJobsToMonitor(BlockingQueue<MonitorID> jobsToMonitor) {
+ this.jobsToMonitor = jobsToMonitor;
+ }
+
+ @Subscribe
+ public void updateRegistry(JobStatusChangeRequest jobStatus) {
+ /* Here we need to parse the jobStatus message and update
+ the registry accordingly, for now we are just printing to standard Out
+ */
+ JobState state = jobStatus.getState();
+ if (state != null) {
+ try {
+ String taskID = jobStatus.getIdentity().getTaskId();
+ String jobID = jobStatus.getIdentity().getJobId();
+ updateJobStatus(taskID, jobID, state);
+ } catch (Exception e) {
+ logger.error("Error persisting data" + e.getLocalizedMessage(), e);
+ }
+ logger.info("Job ID:" + jobStatus.getIdentity().getJobId() + " is "+state.toString());
+ switch (state) {
+ case COMPLETE: case UNKNOWN: case CANCELED:case FAILED:case SUSPENDED:
+ jobsToMonitor.remove(jobStatus.getMonitorID());
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ @Subscribe
+ public void setupTaskStatus(JobStatusChangeRequest jobStatus){
+ TaskState state=TaskState.UNKNOWN;
+ switch(jobStatus.getState()){
+ case ACTIVE:
+ state=TaskState.EXECUTING; break;
+ case CANCELED:
+ state=TaskState.CANCELED; break;
+ case COMPLETE:
+ state=TaskState.COMPLETED; break;
+ case FAILED:
+ state=TaskState.FAILED; break;
+ case HELD: case SUSPENDED: case QUEUED:
+ state=TaskState.WAITING; break;
+ case SETUP:
+ state=TaskState.PRE_PROCESSING; break;
+ case SUBMITTED:
+ state=TaskState.STARTED; break;
+ case UN_SUBMITTED:
+ state=TaskState.CANCELED; break;
+ case CANCELING:
+ state=TaskState.CANCELING; break;
+ default:
+ break;
+ }
+ logger.debug("Publishing Task Status "+state.toString());
+ monitorPublisher.publish(new TaskStatusChangeRequest(jobStatus.getIdentity(),state));
+ }
+
+ public void updateJobStatus(String taskId, String jobID, JobState state) throws Exception {
+ CompositeIdentifier ids = new CompositeIdentifier(taskId, jobID);
+ JobDetails details = (JobDetails)airavataRegistry.get(DataType.JOB_DETAIL, ids);
+ if(details == null) {
+ details = new JobDetails();
+ }
+ org.apache.airavata.model.workspace.experiment.JobStatus status = new org.apache.airavata.model.workspace.experiment.JobStatus();
+ status.setJobState(state);
+ status.setTimeOfStateChange(Calendar.getInstance().getTimeInMillis());
+ details.setJobStatus(status);
+ details.setJobID(jobID);
+ airavataRegistry.update(DataType.JOB_DETAIL, details, ids);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void setup(Object... configurations) {
+ for (Object configuration : configurations) {
+ if (configuration instanceof Registry){
+ this.airavataRegistry=(Registry)configuration;
+ } else if (configuration instanceof BlockingQueue<?>){
+ this.jobsToMonitor=(BlockingQueue<MonitorID>) configuration;
+ } else if (configuration instanceof MonitorPublisher){
+ this.monitorPublisher=(MonitorPublisher) configuration;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/AiravataTaskStatusUpdator.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/AiravataTaskStatusUpdator.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/AiravataTaskStatusUpdator.java
new file mode 100644
index 0000000..e8dd7a0
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/AiravataTaskStatusUpdator.java
@@ -0,0 +1,113 @@
+/*
+ *
+ * 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 com.google.common.eventbus.Subscribe;
+import org.apache.airavata.gfac.monitor.event.MonitorPublisher;
+import org.apache.airavata.gfac.monitor.state.TaskStatusChangeRequest;
+import org.apache.airavata.gfac.monitor.state.WorkflowNodeStatusChangeRequest;
+import org.apache.airavata.model.workspace.experiment.TaskDetails;
+import org.apache.airavata.model.workspace.experiment.TaskState;
+import org.apache.airavata.model.workspace.experiment.WorkflowNodeState;
+import org.apache.airavata.registry.cpi.DataType;
+import org.apache.airavata.registry.cpi.Registry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Calendar;
+
+public class AiravataTaskStatusUpdator implements AbstractActivityListener {
+ private final static Logger logger = LoggerFactory.getLogger(AiravataTaskStatusUpdator.class);
+
+ private Registry airavataRegistry;
+
+ private MonitorPublisher monitorPublisher;
+
+ public Registry getAiravataRegistry() {
+ return airavataRegistry;
+ }
+
+ public void setAiravataRegistry(Registry airavataRegistry) {
+ this.airavataRegistry = airavataRegistry;
+ }
+
+ @Subscribe
+ public void updateRegistry(TaskStatusChangeRequest taskStatus) {
+ TaskState state = taskStatus.getState();
+ if (state != null) {
+ try {
+ String taskID = taskStatus.getIdentity().getTaskId();
+ updateTaskStatus(taskID, state);
+ } catch (Exception e) {
+ logger.error("Error persisting data" + e.getLocalizedMessage(), e);
+ }
+ }
+ }
+
+ @Subscribe
+ public void setupWorkflowNodeStatus(TaskStatusChangeRequest taskStatus){
+ WorkflowNodeState state=WorkflowNodeState.UNKNOWN;
+ switch(taskStatus.getState()){
+ case CANCELED:
+ state=WorkflowNodeState.CANCELED; break;
+ case COMPLETED:
+ state=WorkflowNodeState.COMPLETED; break;
+ case CONFIGURING_WORKSPACE:
+ state=WorkflowNodeState.INVOKED; break;
+ case FAILED:
+ state=WorkflowNodeState.FAILED; break;
+ case EXECUTING: case WAITING: case PRE_PROCESSING: case POST_PROCESSING: case OUTPUT_DATA_STAGING: case INPUT_DATA_STAGING:
+ state=WorkflowNodeState.EXECUTING; break;
+ case STARTED:
+ state=WorkflowNodeState.INVOKED; break;
+ case CANCELING:
+ state=WorkflowNodeState.CANCELING; break;
+ default:
+ break;
+ }
+ logger.debug("Publishing Experiment Status "+state.toString());
+ monitorPublisher.publish(new WorkflowNodeStatusChangeRequest(taskStatus.getIdentity(),state));
+ }
+
+ public void updateTaskStatus(String taskId, TaskState state) throws Exception {
+ TaskDetails details = (TaskDetails)airavataRegistry.get(DataType.TASK_DETAIL, taskId);
+ if(details == null) {
+ details = new TaskDetails();
+ details.setTaskID(taskId);
+ }
+ org.apache.airavata.model.workspace.experiment.TaskStatus status = new org.apache.airavata.model.workspace.experiment.TaskStatus();
+ status.setExecutionState(state);
+ status.setTimeOfStateChange(Calendar.getInstance().getTimeInMillis());
+ details.setTaskStatus(status);
+ airavataRegistry.update(DataType.TASK_DETAIL, details, taskId);
+ }
+
+ @Override
+ public void setup(Object... configurations) {
+ for (Object configuration : configurations) {
+ if (configuration instanceof Registry){
+ this.airavataRegistry=(Registry)configuration;
+ } else if (configuration instanceof MonitorPublisher){
+ this.monitorPublisher=(MonitorPublisher) configuration;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/AiravataWorkflowNodeStatusUpdator.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/AiravataWorkflowNodeStatusUpdator.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/AiravataWorkflowNodeStatusUpdator.java
new file mode 100644
index 0000000..2375d72
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/AiravataWorkflowNodeStatusUpdator.java
@@ -0,0 +1,112 @@
+/*
+ *
+ * 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 com.google.common.eventbus.Subscribe;
+import org.apache.airavata.gfac.monitor.event.MonitorPublisher;
+import org.apache.airavata.gfac.monitor.state.ExperimentStatusChangeRequest;
+import org.apache.airavata.gfac.monitor.state.WorkflowNodeStatusChangeRequest;
+import org.apache.airavata.model.workspace.experiment.ExperimentState;
+import org.apache.airavata.model.workspace.experiment.WorkflowNodeDetails;
+import org.apache.airavata.model.workspace.experiment.WorkflowNodeState;
+import org.apache.airavata.model.workspace.experiment.WorkflowNodeStatus;
+import org.apache.airavata.registry.cpi.DataType;
+import org.apache.airavata.registry.cpi.Registry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Calendar;
+
+public class AiravataWorkflowNodeStatusUpdator implements AbstractActivityListener {
+ private final static Logger logger = LoggerFactory.getLogger(AiravataWorkflowNodeStatusUpdator.class);
+
+ private Registry airavataRegistry;
+
+ private MonitorPublisher monitorPublisher;
+
+ public Registry getAiravataRegistry() {
+ return airavataRegistry;
+ }
+
+ public void setAiravataRegistry(Registry airavataRegistry) {
+ this.airavataRegistry = airavataRegistry;
+ }
+
+ @Subscribe
+ public void updateRegistry(WorkflowNodeStatusChangeRequest workflowNodeStatus) {
+ WorkflowNodeState state = workflowNodeStatus.getState();
+ if (state != null) {
+ try {
+ String workflowNodeID = workflowNodeStatus.getIdentity().getWorkflowNodeID();
+ updateWorkflowNodeStatus(workflowNodeID, state);
+ } catch (Exception e) {
+ logger.error("Error persisting data" + e.getLocalizedMessage(), e);
+ }
+ }
+ }
+
+ @Subscribe
+ public void setupExperimentStatus(WorkflowNodeStatusChangeRequest nodeStatus){
+ ExperimentState state=ExperimentState.UNKNOWN;
+ switch(nodeStatus.getState()){
+ case CANCELED:
+ state=ExperimentState.CANCELED; break;
+ case COMPLETED:
+ state=ExperimentState.COMPLETED; break;
+ case INVOKED:
+ state=ExperimentState.LAUNCHED; break;
+ case FAILED:
+ state=ExperimentState.FAILED; break;
+ case EXECUTING:
+ state=ExperimentState.EXECUTING; break;
+ case CANCELING:
+ state=ExperimentState.CANCELING; break;
+ default:
+ break;
+ }
+ logger.debug("Publishing Experiment Status "+state.toString());
+ monitorPublisher.publish(new ExperimentStatusChangeRequest(nodeStatus.getIdentity(),state));
+ }
+
+ public void updateWorkflowNodeStatus(String workflowNodeId, WorkflowNodeState state) throws Exception {
+ WorkflowNodeDetails details = (WorkflowNodeDetails)airavataRegistry.get(DataType.WORKFLOW_NODE_DETAIL, workflowNodeId);
+ if(details == null) {
+ details = new WorkflowNodeDetails();
+ details.setNodeInstanceId(workflowNodeId);
+ }
+ WorkflowNodeStatus status = new WorkflowNodeStatus();
+ status.setWorkflowNodeState(state);
+ status.setTimeOfStateChange(Calendar.getInstance().getTimeInMillis());
+ details.setWorkflowNodeStatus(status);
+ airavataRegistry.update(DataType.WORKFLOW_NODE_DETAIL, details, workflowNodeId);
+ }
+
+ @Override
+ public void setup(Object... configurations) {
+ for (Object configuration : configurations) {
+ if (configuration instanceof Registry){
+ this.airavataRegistry=(Registry)configuration;
+ } else if (configuration instanceof MonitorPublisher){
+ this.monitorPublisher=(MonitorPublisher) configuration;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/ExperimentIdentity.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/ExperimentIdentity.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/ExperimentIdentity.java
new file mode 100644
index 0000000..ba8efeb
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/ExperimentIdentity.java
@@ -0,0 +1,36 @@
+/*
+ *
+ * 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;
+
+public class ExperimentIdentity {
+ private String experimentID;
+ public ExperimentIdentity(String experimentId) {
+ setExperimentID(experimentId);
+ }
+ public String getExperimentID() {
+ return experimentID;
+ }
+
+ public void setExperimentID(String experimentID) {
+ this.experimentID = experimentID;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/HostMonitorData.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/HostMonitorData.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/HostMonitorData.java
new file mode 100644
index 0000000..e57087d
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/HostMonitorData.java
@@ -0,0 +1,69 @@
+/*
+ *
+ * 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.commons.gfac.type.HostDescription;
+import org.apache.airavata.gfac.monitor.exception.AiravataMonitorException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class HostMonitorData {
+ private HostDescription host;
+
+ private List<MonitorID> monitorIDs;
+
+ public HostMonitorData(HostDescription host) {
+ this.host = host;
+ monitorIDs = new ArrayList<MonitorID>();
+ }
+
+ public HostMonitorData(HostDescription host, List<MonitorID> monitorIDs) {
+ this.host = host;
+ this.monitorIDs = monitorIDs;
+ }
+
+ public HostDescription getHost() {
+ return host;
+ }
+
+ public void setHost(HostDescription host) {
+ this.host = host;
+ }
+
+ 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);
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/JobIdentity.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/JobIdentity.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/JobIdentity.java
new file mode 100644
index 0000000..84c4a55
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/JobIdentity.java
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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;
+
+public class JobIdentity extends TaskIdentity {
+ private String jobId;
+
+ public JobIdentity(String experimentId, String workflowNodeId, String taskId, String jobId) {
+ super(experimentId,workflowNodeId,taskId);
+ setJobId(jobId);
+ }
+
+ public String getJobId() {
+ return jobId;
+ }
+
+ public void setJobId(String jobId) {
+ this.jobId = jobId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/MonitorID.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/MonitorID.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/MonitorID.java
new file mode 100644
index 0000000..e21160a
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/MonitorID.java
@@ -0,0 +1,251 @@
+/*
+ *
+ * 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.commons.gfac.type.HostDescription;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gsi.ssh.api.authentication.AuthenticationInfo;
+import org.apache.airavata.gsi.ssh.impl.authentication.MyProxyAuthenticationInfo;
+import org.apache.airavata.model.workspace.experiment.JobState;
+import org.apache.airavata.model.workspace.experiment.WorkflowNodeDetails;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.Timestamp;
+import java.util.Date;
+import java.util.Map;
+
+/*
+This is the object which contains the data to identify a particular
+Job to start the monitoring
+*/
+public class MonitorID {
+ private final static Logger logger = LoggerFactory.getLogger(MonitorID.class);
+
+ private String userName;
+
+ private Timestamp jobStartedTime;
+
+ private Timestamp lastMonitored;
+
+ private HostDescription host;
+
+ private AuthenticationInfo authenticationInfo = null;
+
+ private Map<String, Object> parameters;
+
+ private String experimentID;
+
+ private String workflowNodeID;
+
+ private String taskID;
+
+ private String jobID;
+
+ private int failedCount = 0;
+
+ private JobState state;
+
+ private JobExecutionContext jobExecutionContext;
+
+ public MonitorID(HostDescription host, String jobID,String taskID, String workflowNodeID, String experimentID, String userName) {
+ this.host = host;
+ this.jobStartedTime = new Timestamp((new Date()).getTime());
+ this.userName = userName;
+ this.jobID = jobID;
+ this.taskID = taskID;
+ this.experimentID = experimentID;
+ this.workflowNodeID = workflowNodeID;
+ }
+
+ public MonitorID(AuthenticationInfo authenticationInfo, JobExecutionContext jobExecutionContext) {
+ this.authenticationInfo = authenticationInfo;
+ this.jobExecutionContext = jobExecutionContext;
+ host = jobExecutionContext.getApplicationContext().getHostDescription();
+ userName = jobExecutionContext.getExperiment().getUserName();
+ jobID = jobExecutionContext.getJobDetails().getJobID();
+ taskID = jobExecutionContext.getTaskData().getTaskID();
+ experimentID = jobExecutionContext.getExperiment().getExperimentID();
+ workflowNodeID = jobExecutionContext.getExperiment().getWorkflowNodeDetailsList().get(0).getNodeInstanceId();// at this point we only have one node todo: fix this
+
+ }
+
+ public MonitorID(HostDescription host, String jobID,String taskID, String workflowNodeID, String experimentID, String userName,AuthenticationInfo authenticationInfo) {
+ this.host = host;
+ this.jobStartedTime = new Timestamp((new Date()).getTime());
+ this.authenticationInfo = authenticationInfo;
+ this.userName = userName;
+ // if we give myproxyauthenticationInfo, so we try to use myproxy user as the user
+ if(this.authenticationInfo != null){
+ if(this.authenticationInfo instanceof MyProxyAuthenticationInfo){
+ this.userName = ((MyProxyAuthenticationInfo)this.authenticationInfo).getUserName();
+ }
+ }
+ this.workflowNodeID = workflowNodeID;
+ this.jobID = jobID;
+ this.taskID = taskID;
+ this.experimentID = experimentID;
+ }
+ public HostDescription getHost() {
+ return host;
+ }
+
+ public void setHost(HostDescription host) {
+ this.host = host;
+ }
+
+ public Timestamp getLastMonitored() {
+ return lastMonitored;
+ }
+
+ public void setLastMonitored(Timestamp lastMonitored) {
+ this.lastMonitored = lastMonitored;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getJobID() {
+ return jobID;
+ }
+
+ public void setJobID(String jobID) {
+ this.jobID = jobID;
+ }
+
+ public Timestamp getJobStartedTime() {
+ return jobStartedTime;
+ }
+
+ public void setJobStartedTime(Timestamp jobStartedTime) {
+ this.jobStartedTime = jobStartedTime;
+ }
+
+ public AuthenticationInfo getAuthenticationInfo() {
+ return authenticationInfo;
+ }
+
+ public void setAuthenticationInfo(AuthenticationInfo authenticationInfo) {
+ this.authenticationInfo = authenticationInfo;
+ }
+
+ public void addParameter(String key,Object value) {
+ this.parameters.put(key, value);
+ }
+
+ public Object getParameter(String key) {
+ return this.parameters.get(key);
+ }
+
+ public Map<String, Object> getParameters() {
+ return parameters;
+ }
+
+ public void setParameters(Map<String, Object> parameters) {
+ this.parameters = parameters;
+ }
+
+ 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 int getFailedCount() {
+ return failedCount;
+ }
+
+ public void setFailedCount(int failedCount) {
+ this.failedCount = failedCount;
+ }
+
+ public JobState getStatus() {
+ return state;
+ }
+
+ public void setStatus(JobState status) {
+ // this logic is going to be useful for fast finishing jobs
+ // because in some machines job state vanishes quicckly when the job is done
+ // during that case job state comes as unknown.so we handle it here.
+ if (this.state != null && status.equals(JobState.UNKNOWN)) {
+ if (getFailedCount() > 2) {
+ switch (this.state) {
+ case ACTIVE:
+ this.state = JobState.COMPLETE;
+ break;
+ case QUEUED:
+ this.state = JobState.COMPLETE;
+ break;
+ }
+ } else {
+ try {
+ // when state becomes unknown we sleep for a while
+ Thread.sleep(10000);
+ } catch (InterruptedException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ setFailedCount(getFailedCount() + 1);
+ }
+ } else {
+ // normal scenario
+ this.state = status;
+ }
+ }
+
+ public String getWorkflowNodeID() {
+ return workflowNodeID;
+ }
+
+ public void setWorkflowNodeID(String workflowNodeID) {
+ this.workflowNodeID = workflowNodeID;
+ }
+
+ public JobExecutionContext getJobExecutionContext() {
+ return jobExecutionContext;
+ }
+
+ public void setJobExecutionContext(JobExecutionContext jobExecutionContext) {
+ this.jobExecutionContext = jobExecutionContext;
+ }
+
+ // public String getWorkflowNodeID() {
+// return workflowNodeID;
+// }
+//
+// public void setWorkflowNodeID(String workflowNodeID) {
+// this.workflowNodeID = workflowNodeID;
+// }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/TaskIdentity.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/TaskIdentity.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/TaskIdentity.java
new file mode 100644
index 0000000..c6d386e
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/TaskIdentity.java
@@ -0,0 +1,38 @@
+/*
+ *
+ * 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;
+
+public class TaskIdentity extends WorkflowNodeIdentity {
+ private String taskId;
+
+ public TaskIdentity(String experimentId, String workflowNodeId, String taskId) {
+ super(experimentId,workflowNodeId);
+ setTaskId(taskId);
+ }
+ public String getTaskId() {
+ return taskId;
+ }
+
+ public void setTaskId(String taskId) {
+ this.taskId = taskId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/UserMonitorData.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/UserMonitorData.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/UserMonitorData.java
new file mode 100644
index 0000000..022d17c
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/UserMonitorData.java
@@ -0,0 +1,76 @@
+/*
+ *
+ * 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/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/WorkflowNodeIdentity.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/WorkflowNodeIdentity.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/WorkflowNodeIdentity.java
new file mode 100644
index 0000000..e569c52
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/WorkflowNodeIdentity.java
@@ -0,0 +1,37 @@
+/*
+ *
+ * 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;
+
+public class WorkflowNodeIdentity extends ExperimentIdentity {
+ private String workflowNodeID;
+ public WorkflowNodeIdentity(String experimentId, String workflowNodeId) {
+ super(experimentId);
+ setWorkflowNodeID(workflowNodeId);
+ }
+ public String getWorkflowNodeID() {
+ return workflowNodeID;
+ }
+
+ public void setWorkflowNodeID(String workflowNodeID) {
+ this.workflowNodeID = workflowNodeID;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/command/ExperimentCancelRequest.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/command/ExperimentCancelRequest.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/command/ExperimentCancelRequest.java
new file mode 100644
index 0000000..f19decf
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/command/ExperimentCancelRequest.java
@@ -0,0 +1,38 @@
+/*
+ *
+ * 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/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/command/TaskCancelRequest.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/command/TaskCancelRequest.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/command/TaskCancelRequest.java
new file mode 100644
index 0000000..b45e01c
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/command/TaskCancelRequest.java
@@ -0,0 +1,52 @@
+/*
+ *
+ * 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/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/core/AiravataAbstractMonitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/core/AiravataAbstractMonitor.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/core/AiravataAbstractMonitor.java
new file mode 100644
index 0000000..da6baf8
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/core/AiravataAbstractMonitor.java
@@ -0,0 +1,46 @@
+/*
+ *
+ * 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.event.MonitorPublisher;
+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 MonitorPublisher 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);
+ protected MonitorPublisher publisher;
+
+ public MonitorPublisher getPublisher() {
+ return publisher;
+ }
+
+ public void setPublisher(MonitorPublisher publisher) {
+ this.publisher = publisher;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/core/MessageParser.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/core/MessageParser.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/core/MessageParser.java
new file mode 100644
index 0000000..a003f55
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/core/MessageParser.java
@@ -0,0 +1,43 @@
+/*
+ *
+ * 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.workspace.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/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/core/Monitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/core/Monitor.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/core/Monitor.java
new file mode 100644
index 0000000..614d606
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/core/Monitor.java
@@ -0,0 +1,30 @@
+/*
+ *
+ * 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/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/core/PullMonitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/core/PullMonitor.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/core/PullMonitor.java
new file mode 100644
index 0000000..efdf89c
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/core/PullMonitor.java
@@ -0,0 +1,64 @@
+/*
+ *
+ * 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/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/core/PushMonitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/core/PushMonitor.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/core/PushMonitor.java
new file mode 100644
index 0000000..8e13252
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/core/PushMonitor.java
@@ -0,0 +1,60 @@
+/*
+ *
+ * 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.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/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/event/MonitorPublisher.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/event/MonitorPublisher.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/event/MonitorPublisher.java
new file mode 100644
index 0000000..52487fe
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/event/MonitorPublisher.java
@@ -0,0 +1,47 @@
+/*
+ *
+ * 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.event;
+
+import com.google.common.eventbus.EventBus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MonitorPublisher{
+ private final static Logger logger = LoggerFactory.getLogger(MonitorPublisher.class);
+ private EventBus eventBus;
+
+ public MonitorPublisher(EventBus eventBus) {
+ this.eventBus = eventBus;
+ }
+
+ public void registerListener(Object listener) {
+ eventBus.register(listener);
+ }
+
+ public void unregisterListener(Object listener) {
+ eventBus.unregister(listener);
+ }
+
+ public void publish(Object o) {
+ eventBus.post(o);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/exception/AiravataMonitorException.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/exception/AiravataMonitorException.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/exception/AiravataMonitorException.java
new file mode 100644
index 0000000..3acef66
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/exception/AiravataMonitorException.java
@@ -0,0 +1,37 @@
+/*
+ *
+ * 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.exception;
+
+public class AiravataMonitorException extends Exception {
+ private static final long serialVersionUID = -2849422320139467602L;
+
+ public AiravataMonitorException(Throwable e) {
+ super(e);
+ }
+
+ public AiravataMonitorException(String message) {
+ super(message, null);
+ }
+
+ public AiravataMonitorException(String message, Throwable e) {
+ super(message, e);
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/handlers/GridPullMonitorHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/handlers/GridPullMonitorHandler.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/handlers/GridPullMonitorHandler.java
new file mode 100644
index 0000000..b3420b8
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/handlers/GridPullMonitorHandler.java
@@ -0,0 +1,96 @@
+/*
+ *
+ * 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.utils.ServerSettings;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.handler.GFacHandlerException;
+import org.apache.airavata.gfac.handler.ThreadedHandler;
+import org.apache.airavata.gfac.monitor.MonitorID;
+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.airavata.gsi.ssh.api.authentication.AuthenticationInfo;
+import org.apache.airavata.gsi.ssh.impl.authentication.MyProxyAuthenticationInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+
+/**
+ * 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 {
+ private final static Logger logger = LoggerFactory.getLogger(GridPullMonitorHandler.class);
+
+ private HPCPullMonitor hpcPullMonitor;
+
+ private AuthenticationInfo authenticationInfo;
+
+ public void initProperties(Map<String, String> 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();
+ } catch (ApplicationSettingsException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ }
+
+ public void run() {
+ hpcPullMonitor.run();
+ }
+
+ public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException{
+ super.invoke(jobExecutionContext);
+ MonitorID monitorID = new MonitorID(authenticationInfo, jobExecutionContext);
+ try {
+ CommonUtils.addMonitortoQueue(hpcPullMonitor.getQueue(), monitorID);
+ } catch (AiravataMonitorException e) {
+ logger.error("Error adding monitorID object to the queue with experiment ", monitorID.getExperimentID());
+ }
+ }
+
+ 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;
+ }
+}
[7/9] Separating gfac-monitoring implementation
Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/JSONMessageParser.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/JSONMessageParser.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/JSONMessageParser.java
deleted file mode 100644
index 72c77d5..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/JSONMessageParser.java
+++ /dev/null
@@ -1,78 +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.impl.push.amqp;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.airavata.ComputingActivity;
-import org.apache.airavata.gfac.monitor.core.MessageParser;
-import org.apache.airavata.gfac.monitor.exception.AiravataMonitorException;
-import org.apache.airavata.model.workspace.experiment.JobState;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.List;
-
-public class JSONMessageParser implements MessageParser {
- private final static Logger logger = LoggerFactory.getLogger(JSONMessageParser.class);
-
- public JobState parseMessage(String message)throws AiravataMonitorException {
- /*todo write a json message parser here*/
- logger.debug(message);
- ObjectMapper objectMapper = new ObjectMapper();
- try {
- ComputingActivity computingActivity = objectMapper.readValue(message.getBytes(), ComputingActivity.class);
- logger.info(computingActivity.getIDFromEndpoint());
- List<String> stateList = computingActivity.getState();
- JobState jobState = null;
- for (String aState : stateList) {
- jobState = getStatusFromString(aState);
- }
- // we get the last value of the state array
- return jobState;
- } catch (IOException e) {
- throw new AiravataMonitorException(e);
- }
- }
-
-private JobState getStatusFromString(String status) {
- logger.info("parsing the job status returned : " + status);
- if(status != null){
- if("ipf:finished".equals(status)){
- return JobState.COMPLETE;
- }else if("ipf:pending".equals(status)|| "ipf:starting".equals(status)){
- return JobState.QUEUED;
- }else if("ipf:running".equals(status) || "ipf:finishing".equals(status)){
- return JobState.ACTIVE;
- }else if ("ipf:held".equals(status) || "ipf:teminating".equals(status) || "ipf:teminated".equals(status)) {
- return JobState.HELD;
- } else if ("ipf:suspending".equals(status)) {
- return JobState.SUSPENDED;
- }else if ("ipf:failed".equals(status)) {
- return JobState.FAILED;
- }else if ("ipf:unknown".equals(status)){
- return JobState.UNKNOWN;
- }
- }
- return JobState.UNKNOWN;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/UnRegisterWorker.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/UnRegisterWorker.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/UnRegisterWorker.java
deleted file mode 100644
index c6e1378..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/UnRegisterWorker.java
+++ /dev/null
@@ -1,68 +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.impl.push.amqp;
-
-import com.google.common.eventbus.Subscribe;
-import com.rabbitmq.client.Channel;
-import org.apache.airavata.gfac.monitor.MonitorID;
-import org.apache.airavata.gfac.monitor.exception.AiravataMonitorException;
-import org.apache.airavata.gfac.monitor.state.JobStatusChangeRequest;
-import org.apache.airavata.gfac.monitor.util.CommonUtils;
-import org.apache.airavata.model.workspace.experiment.JobState;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.Map;
-
-public class UnRegisterWorker{
- private final static Logger logger = LoggerFactory.getLogger(UnRegisterWorker.class);
- private Map<String, Channel> availableChannels;
-
- public UnRegisterWorker(Map<String, Channel> channels) {
- this.availableChannels = channels;
- }
-
- @Subscribe
- private boolean unRegisterListener(JobStatusChangeRequest jobStatus) throws AiravataMonitorException {
- MonitorID monitorID = jobStatus.getMonitorID();
- String channelID = CommonUtils.getChannelID(monitorID);
- if (JobState.FAILED.equals(jobStatus.getState()) || JobState.COMPLETE.equals(jobStatus.getState())){
- Channel channel = availableChannels.get(channelID);
- if (channel == null) {
- logger.error("Already Unregistered the listener");
- throw new AiravataMonitorException("Already Unregistered the listener");
- } else {
- try {
- channel.queueUnbind(channel.queueDeclare().getQueue(), "glue2.computing_activity", CommonUtils.getRoutingKey(monitorID));
- channel.close();
- channel.getConnection().close();
- availableChannels.remove(channelID);
- } catch (IOException e) {
- logger.error("Error unregistering the listener");
- throw new AiravataMonitorException("Error unregistering the listener");
- }
- }
- }
- return true;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/AbstractStateChangeRequest.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/AbstractStateChangeRequest.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/AbstractStateChangeRequest.java
deleted file mode 100644
index 10048b0..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/AbstractStateChangeRequest.java
+++ /dev/null
@@ -1,27 +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.state;
-
-
-public abstract class AbstractStateChangeRequest implements PublisherMessage {
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/ExperimentStatusChangeRequest.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/ExperimentStatusChangeRequest.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/ExperimentStatusChangeRequest.java
deleted file mode 100644
index eecf88d..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/ExperimentStatusChangeRequest.java
+++ /dev/null
@@ -1,63 +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.state;
-
-import org.apache.airavata.gfac.monitor.ExperimentIdentity;
-import org.apache.airavata.model.workspace.experiment.ExperimentState;
-
-/**
- * This is the primary job state object used in
- * through out the monitor module. This use airavata-data-model JobState enum
- * Ideally after processing each event or monitoring message from remote system
- * Each monitoring implementation has to return this object with a state and
- * the monitoring ID
- */
-public class ExperimentStatusChangeRequest extends AbstractStateChangeRequest {
- private ExperimentState state;
- private ExperimentIdentity identity;
-
- // this constructor can be used in Qstat monitor to handle errors
- public ExperimentStatusChangeRequest() {
- }
-
- public ExperimentStatusChangeRequest(ExperimentIdentity experimentIdentity, ExperimentState state) {
- this.state = state;
- setIdentity(experimentIdentity);
- }
-
- public ExperimentState getState() {
- return state;
- }
-
- public void setState(ExperimentState state) {
- this.state = state;
- }
-
- public ExperimentIdentity getIdentity() {
- return identity;
- }
-
- public void setIdentity(ExperimentIdentity identity) {
- this.identity = identity;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/JobStatusChangeRequest.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/JobStatusChangeRequest.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/JobStatusChangeRequest.java
deleted file mode 100644
index da52656..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/JobStatusChangeRequest.java
+++ /dev/null
@@ -1,80 +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.state;
-
-import org.apache.airavata.gfac.monitor.JobIdentity;
-import org.apache.airavata.gfac.monitor.MonitorID;
-import org.apache.airavata.model.workspace.experiment.JobState;
-
-/**
- * This is the primary job state object used in
- * through out the monitor module. This use airavata-data-model JobState enum
- * Ideally after processing each event or monitoring message from remote system
- * Each monitoring implementation has to return this object with a state and
- * the monitoring ID
- */
-public class JobStatusChangeRequest extends AbstractStateChangeRequest {
- private JobState state;
- private JobIdentity identity;
-
- private MonitorID monitorID;
-
- // this constructor can be used in Qstat monitor to handle errors
- public JobStatusChangeRequest() {
- }
-
- public JobStatusChangeRequest(MonitorID monitorID) {
- setIdentity(new JobIdentity(monitorID.getExperimentID(),monitorID.getWorkflowNodeID(),
- monitorID.getTaskID(),monitorID.getJobID()));
- setMonitorID(monitorID);
- this.state = monitorID.getStatus();
- }
- public JobStatusChangeRequest(MonitorID monitorID, JobIdentity jobId, JobState state) {
- setIdentity(jobId);
- setMonitorID(monitorID);
- this.state = state;
- }
-
- public JobState getState() {
- return state;
- }
-
- public void setState(JobState state) {
- this.state = state;
- }
-
- public JobIdentity getIdentity() {
- return identity;
- }
-
- public void setIdentity(JobIdentity identity) {
- this.identity = identity;
- }
-
- public MonitorID getMonitorID() {
- return monitorID;
- }
-
- public void setMonitorID(MonitorID monitorID) {
- this.monitorID = monitorID;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/JobStatusInfo.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/JobStatusInfo.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/JobStatusInfo.java
deleted file mode 100644
index 9a59b50..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/JobStatusInfo.java
+++ /dev/null
@@ -1,48 +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.state;
-
-import org.apache.airavata.gsi.ssh.impl.JobStatus;
-
-/**
- * Based on the job status monitoring we can gather
- * different informaation about the job, its not simply
- * the job status, so we need a way to implement
- * different job statusinfo object to keep job status
- */
-public interface JobStatusInfo {
-
- /**
- * This method can be used to get JobStatusInfo data and
- * decide the finalJobState
- *
- * @param jobState
- */
- void setJobStatus(JobStatus jobState);
-
- /**
- * After setting the jobState by processing jobinformation
- * this method can be used to get the JobStatus
- * @return
- */
- JobStatus getJobStatus();
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/PublisherMessage.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/PublisherMessage.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/PublisherMessage.java
deleted file mode 100644
index cbfcb5a..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/PublisherMessage.java
+++ /dev/null
@@ -1,26 +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.state;
-
-public interface PublisherMessage {
-// public String getType();
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/TaskStatusChangeRequest.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/TaskStatusChangeRequest.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/TaskStatusChangeRequest.java
deleted file mode 100644
index af20707..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/TaskStatusChangeRequest.java
+++ /dev/null
@@ -1,61 +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.state;
-
-import org.apache.airavata.gfac.monitor.TaskIdentity;
-import org.apache.airavata.model.workspace.experiment.TaskState;
-
-/**
- * This is the primary job state object used in
- * through out the monitor module. This use airavata-data-model JobState enum
- * Ideally after processing each event or monitoring message from remote system
- * Each monitoring implementation has to return this object with a state and
- * the monitoring ID
- */
-public class TaskStatusChangeRequest extends AbstractStateChangeRequest {
- private TaskState state;
- private TaskIdentity identity;
- // this constructor can be used in Qstat monitor to handle errors
- public TaskStatusChangeRequest() {
- }
-
- public TaskStatusChangeRequest(TaskIdentity taskIdentity, TaskState state) {
- this.state = state;
- setIdentity(taskIdentity);
- }
-
- public TaskState getState() {
- return state;
- }
-
- public void setState(TaskState state) {
- this.state = state;
- }
-
- public TaskIdentity getIdentity() {
- return identity;
- }
-
- public void setIdentity(TaskIdentity identity) {
- this.identity = identity;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/WorkflowNodeStatusChangeRequest.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/WorkflowNodeStatusChangeRequest.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/WorkflowNodeStatusChangeRequest.java
deleted file mode 100644
index 632f2e3..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/WorkflowNodeStatusChangeRequest.java
+++ /dev/null
@@ -1,63 +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.state;
-
-import org.apache.airavata.gfac.monitor.WorkflowNodeIdentity;
-import org.apache.airavata.model.workspace.experiment.WorkflowNodeState;
-
-/**
- * This is the primary job state object used in
- * through out the monitor module. This use airavata-data-model JobState enum
- * Ideally after processing each event or monitoring message from remote system
- * Each monitoring implementation has to return this object with a state and
- * the monitoring ID
- */
-public class WorkflowNodeStatusChangeRequest extends AbstractStateChangeRequest {
- private WorkflowNodeState state;
- private WorkflowNodeIdentity identity;
-
- // this constructor can be used in Qstat monitor to handle errors
- public WorkflowNodeStatusChangeRequest() {
- }
-
- public WorkflowNodeStatusChangeRequest(WorkflowNodeIdentity identity, WorkflowNodeState state) {
- this.state = state;
- setIdentity(identity);
- }
-
- public WorkflowNodeState getState() {
- return state;
- }
-
- public void setState(WorkflowNodeState state) {
- this.state = state;
- }
-
- public WorkflowNodeIdentity getIdentity() {
- return identity;
- }
-
- public void setIdentity(WorkflowNodeIdentity identity) {
- this.identity = identity;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/impl/AmazonJobStatusInfo.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/impl/AmazonJobStatusInfo.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/impl/AmazonJobStatusInfo.java
deleted file mode 100644
index 19b051a..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/impl/AmazonJobStatusInfo.java
+++ /dev/null
@@ -1,39 +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.state.impl;
-
-import org.apache.airavata.gfac.monitor.state.JobStatusInfo;
-import org.apache.airavata.gsi.ssh.impl.JobStatus;
-
-/**
- * This can be used to store job status information about
- * amazon jobs, this data could be very different from
- * a typical grid job
- */
-public class AmazonJobStatusInfo implements JobStatusInfo {
- public void setJobStatus(JobStatus jobState) {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public JobStatus getJobStatus() {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/impl/GridJobStatusInfo.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/impl/GridJobStatusInfo.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/impl/GridJobStatusInfo.java
deleted file mode 100644
index 4612c3c..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/state/impl/GridJobStatusInfo.java
+++ /dev/null
@@ -1,40 +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.state.impl;
-
-import org.apache.airavata.gfac.monitor.state.JobStatusInfo;
-import org.apache.airavata.gsi.ssh.impl.JobStatus;
-
-
-/**
- * This can be used to keep information about a Grid job
- * which we can get from qstat polling or from amqp based
- * monitoring in Grid machines
- */
-public class GridJobStatusInfo implements JobStatusInfo {
- public void setJobStatus(JobStatus jobState) {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public JobStatus getJobStatus() {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/util/AMQPConnectionUtil.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/util/AMQPConnectionUtil.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/util/AMQPConnectionUtil.java
deleted file mode 100644
index b69cf52..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/util/AMQPConnectionUtil.java
+++ /dev/null
@@ -1,77 +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.util;
-
-import com.rabbitmq.client.Connection;
-import com.rabbitmq.client.ConnectionFactory;
-import com.rabbitmq.client.DefaultSaslConfig;
-
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManagerFactory;
-import java.security.KeyStore;
-import java.util.Collections;
-import java.util.List;
-
-public class AMQPConnectionUtil {
- public static Connection connect(List<String>hosts,String vhost, String proxyFile) {
- Collections.shuffle(hosts);
- for (String host : hosts) {
- Connection connection = connect(host, vhost, proxyFile);
- if (host != null) {
- System.out.println("connected to " + host);
- return connection;
- }
- }
- return null;
- }
-
- public static Connection connect(String host, String vhost, String proxyFile) {
- Connection connection;
- try {
- String keyPassPhrase = "test123";
- KeyStore ks = X509Helper.keyStoreFromPEM(proxyFile, keyPassPhrase);
- KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
- kmf.init(ks, keyPassPhrase.toCharArray());
-
- KeyStore tks = X509Helper.trustKeyStoreFromCertDir();
- TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
- tmf.init(tks);
-
- SSLContext c = SSLContext.getInstance("SSLv3");
- c.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
-
- ConnectionFactory factory = new ConnectionFactory();
- factory.setHost(host);
- factory.setPort(5671);
- factory.useSslProtocol(c);
- factory.setVirtualHost(vhost);
- factory.setSaslConfig(DefaultSaslConfig.EXTERNAL);
-
- connection = factory.newConnection();
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- return connection;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/util/CommonUtils.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/util/CommonUtils.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/util/CommonUtils.java
deleted file mode 100644
index 30f1ae4..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/util/CommonUtils.java
+++ /dev/null
@@ -1,172 +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.util;
-
-import org.apache.airavata.commons.gfac.type.HostDescription;
-import org.apache.airavata.gfac.monitor.HostMonitorData;
-import org.apache.airavata.gfac.monitor.MonitorID;
-import org.apache.airavata.gfac.monitor.UserMonitorData;
-import org.apache.airavata.gfac.monitor.exception.AiravataMonitorException;
-import org.apache.airavata.schemas.gfac.GsisshHostType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.concurrent.BlockingQueue;
-
-public class CommonUtils {
- private final static Logger logger = LoggerFactory.getLogger(CommonUtils.class);
-
- public static boolean isPBSHost(HostDescription host){
- if("pbs".equals(((GsisshHostType)host.getType()).getJobManager()) ||
- "".equals(((GsisshHostType)host.getType()).getJobManager())){
- return true;
- }else{
- // default is pbs so we return true
- return false;
- }
- }
- public static boolean isSlurm(HostDescription host){
- if("slurm".equals(((GsisshHostType)host.getType()).getJobManager())){
- return true;
- }else{
- // default is pbs so we return true
- return false;
- }
- }
- public static boolean isSGE(HostDescription host){
- if("sge".equals(((GsisshHostType)host.getType()).getJobManager())){
- return true;
- }else{
- // default is pbs so we return true
- return false;
- }
- }
- public static String getChannelID(MonitorID monitorID) {
- return monitorID.getUserName() + "-" + monitorID.getHost().getType().getHostName();
- }
-
- public static String getRoutingKey(MonitorID monitorID) {
- return "*." + monitorID.getUserName() + "." + monitorID.getHost().getType().getHostAddress();
- }
-
- public static String getChannelID(String userName,String hostAddress) {
- return userName + "-" + hostAddress;
- }
-
- public static String getRoutingKey(String userName,String hostAddress) {
- return "*." + userName + "." + hostAddress;
- }
-
- public static void addMonitortoQueue(BlockingQueue<UserMonitorData> queue, MonitorID monitorID) throws AiravataMonitorException {
- Iterator<UserMonitorData> iterator = queue.iterator();
- while (iterator.hasNext()) {
- UserMonitorData next = iterator.next();
- if (next.getUserName().equals(monitorID.getUserName())) {
- // then this is the right place to update
- List<HostMonitorData> monitorIDs = next.getHostMonitorData();
- for (HostMonitorData host : monitorIDs) {
- if (host.getHost().equals(monitorID.getHost())) {
- // ok we found right place to add this monitorID
- host.addMonitorIDForHost(monitorID);
- return;
- }
- }
- // there is a userMonitor object for this user name but no Hosts for this host
- // so we have to create new Hosts
- HostMonitorData hostMonitorData = new HostMonitorData(monitorID.getHost());
- hostMonitorData.addMonitorIDForHost(monitorID);
- next.addHostMonitorData(hostMonitorData);
- return;
- }
- }
- HostMonitorData hostMonitorData = new HostMonitorData(monitorID.getHost());
- hostMonitorData.addMonitorIDForHost(monitorID);
-
- UserMonitorData userMonitorData = new UserMonitorData(monitorID.getUserName());
- userMonitorData.addHostMonitorData(hostMonitorData);
- try {
- queue.put(userMonitorData);
- } catch (InterruptedException e) {
- throw new AiravataMonitorException(e);
- }
- }
- public static boolean isTheLastJobInQueue(BlockingQueue<MonitorID> queue,MonitorID monitorID){
- Iterator<MonitorID> iterator = queue.iterator();
- while(iterator.hasNext()){
- MonitorID next = iterator.next();
- if(monitorID.getUserName().equals(next.getUserName()) && CommonUtils.isEqual(monitorID.getHost(), next.getHost())){
- return false;
- }
- }
- return true;
- }
- public static void removeMonitorFromQueue(BlockingQueue<UserMonitorData> queue,MonitorID monitorID) throws AiravataMonitorException {
- Iterator<UserMonitorData> iterator = queue.iterator();
- while(iterator.hasNext()){
- UserMonitorData next = iterator.next();
- if(next.getUserName().equals(monitorID.getUserName())){
- // then this is the right place to update
- List<HostMonitorData> hostMonitorData = next.getHostMonitorData();
- for(HostMonitorData iHostMonitorID:hostMonitorData){
- if(iHostMonitorID.getHost().equals(monitorID.getHost())) {
- List<MonitorID> monitorIDs = iHostMonitorID.getMonitorIDs();
- for(MonitorID iMonitorID:monitorIDs){
- if(iMonitorID.getJobID().equals(monitorID.getJobID())) {
- // OK we found the object, we cannot do list.remove(object) states of two objects
- // could be different, thats why we check the jobID
- monitorIDs.remove(iMonitorID);
- if(monitorIDs.size()==0) {
- hostMonitorData.remove(iHostMonitorID);
- if (hostMonitorData.size() == 0) {
- // no useful data so we have to remove the element from the queue
- queue.remove(next);
- }
- }
- return;
- }
- }
- }
- }
- }
- }
- throw new AiravataMonitorException("Cannot find the given MonitorID in the queue with userName " +
- monitorID.getUserName() + " and jobID " + monitorID.getJobID());
-
- }
-
- public static boolean isEqual(HostDescription host1,HostDescription host2) {
- if ((host1.getType() instanceof GsisshHostType) && (host2.getType() instanceof GsisshHostType)) {
- GsisshHostType hostType1 = (GsisshHostType)host1.getType();
- GsisshHostType hostType2 = (GsisshHostType)host2.getType();
- if(hostType1.getHostAddress().equals(hostType2.getHostAddress())
- && hostType1.getJobManager().equals(hostType2.getJobManager())
- && (hostType1.getPort() == hostType2.getPort())
- && hostType1.getMonitorMode().equals(hostType2.getMonitorMode())){
- return true;
- }
- } else {
- logger.error("This method is only impmlemented to handle Gsissh host types");
- }
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/util/X509Helper.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/util/X509Helper.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/util/X509Helper.java
deleted file mode 100644
index c29490a..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/util/X509Helper.java
+++ /dev/null
@@ -1,161 +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.util;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.bouncycastle.openssl.PEMReader;
-
-import java.io.*;
-import java.security.*;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.CertificateParsingException;
-import java.security.cert.X509Certificate;
-import java.security.spec.InvalidKeySpecException;
-
-public class X509Helper {
-
- static {
- // parsing of RSA key fails without this
- java.security.Security.addProvider(new BouncyCastleProvider());
- }
-
-
-
- public static KeyStore keyStoreFromPEM(String proxyFile,
- String keyPassPhrase) throws IOException,
- CertificateException,
- NoSuchAlgorithmException,
- InvalidKeySpecException,
- KeyStoreException {
- return keyStoreFromPEM(proxyFile,proxyFile,keyPassPhrase);
- }
-
- public static KeyStore keyStoreFromPEM(String certFile,
- String keyFile,
- String keyPassPhrase) throws IOException,
- CertificateException,
- NoSuchAlgorithmException,
- InvalidKeySpecException,
- KeyStoreException {
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert = (X509Certificate)cf.generateCertificate(new FileInputStream(certFile));
- //System.out.println(cert.toString());
-
- // this works for proxy files, too, since it skips over the certificate
- BufferedReader reader = new BufferedReader(new FileReader(keyFile));
- String line = null;
- StringBuilder builder = new StringBuilder();
- boolean inKey = false;
- while((line=reader.readLine()) != null) {
- if (line.contains("-----BEGIN RSA PRIVATE KEY-----")) {
- inKey = true;
- }
- if (inKey) {
- builder.append(line);
- builder.append(System.getProperty("line.separator"));
- }
- if (line.contains("-----END RSA PRIVATE KEY-----")) {
- inKey = false;
- }
- }
- String privKeyPEM = builder.toString();
- //System.out.println(privKeyPEM);
-
- // using BouncyCastle
- PEMReader pemParser = new PEMReader(new StringReader(privKeyPEM));
- Object object = pemParser.readObject();
-
- PrivateKey privKey = null;
- if(object instanceof KeyPair){
- privKey = ((KeyPair)object).getPrivate();
- }
- // PEMParser from BouncyCastle is good for reading PEM files, but I didn't want to add that dependency
- /*
- // Base64 decode the data
- byte[] encoded = javax.xml.bind.DatatypeConverter.parseBase64Binary(privKeyPEM);
-
- // PKCS8 decode the encoded RSA private key
- java.security.spec.PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encoded);
- KeyFactory kf = KeyFactory.getInstance("RSA");
- PrivateKey privKey = kf.generatePrivate(keySpec);
- //RSAPrivateKey privKey = (RSAPrivateKey)kf.generatePrivate(keySpec);
- */
- //System.out.println(privKey.toString());
-
- KeyStore keyStore = KeyStore.getInstance("PKCS12");
- keyStore.load(null,null);
-
- KeyStore.PrivateKeyEntry entry =
- new KeyStore.PrivateKeyEntry(privKey,
- new java.security.cert.Certificate[] {(java.security.cert.Certificate)cert});
- KeyStore.PasswordProtection prot = new KeyStore.PasswordProtection(keyPassPhrase.toCharArray());
- keyStore.setEntry(cert.getSubjectX500Principal().getName(), entry, prot);
-
- return keyStore;
- }
-
-
- public static KeyStore trustKeyStoreFromCertDir() throws IOException,
- KeyStoreException,
- CertificateException,
- NoSuchAlgorithmException, ApplicationSettingsException {
- return trustKeyStoreFromCertDir(ServerSettings.getSetting("trusted.cert.location"));
- }
-
- public static KeyStore trustKeyStoreFromCertDir(String certDir) throws IOException,
- KeyStoreException,
- CertificateException,
- NoSuchAlgorithmException {
- KeyStore ks = KeyStore.getInstance("JKS");
- ks.load(null,null);
-
- File dir = new File(certDir);
- for(File file : dir.listFiles()) {
- if (!file.isFile()) {
- continue;
- }
- if (!file.getName().endsWith(".0")) {
- continue;
- }
-
- try {
- //System.out.println("reading file "+file.getName());
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert = (X509Certificate) cf.generateCertificate(new FileInputStream(file));
- //System.out.println(cert.toString());
-
- KeyStore.TrustedCertificateEntry entry = new KeyStore.TrustedCertificateEntry(cert);
-
- ks.setEntry(cert.getSubjectX500Principal().getName(), entry, null);
- } catch (KeyStoreException e) {
- } catch (CertificateParsingException e) {
- continue;
- }
-
- }
-
- return ks;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/notification/listeners/GSISSHJobSubmissionListener.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/notification/listeners/GSISSHJobSubmissionListener.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/notification/listeners/GSISSHJobSubmissionListener.java
deleted file mode 100644
index 75a055c..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/notification/listeners/GSISSHJobSubmissionListener.java
+++ /dev/null
@@ -1,55 +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.notification.listeners;
-
-import org.apache.airavata.gfac.context.JobExecutionContext;
-import org.apache.airavata.gfac.notification.events.StatusChangeEvent;
-import org.apache.airavata.gsi.ssh.api.SSHApiException;
-import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
-import org.apache.airavata.gsi.ssh.impl.JobStatus;
-import org.apache.airavata.gsi.ssh.listener.JobSubmissionListener;
-
-public class GSISSHJobSubmissionListener extends JobSubmissionListener {
-
- JobExecutionContext context;
-
- public GSISSHJobSubmissionListener(JobExecutionContext context) {
- this.context = context;
- }
-
- public void statusChanged(JobDescriptor jobDescriptor) throws SSHApiException {
- this.context.getNotifier().publish(new StatusChangeEvent("Job status has changed to : " + jobDescriptor.getStatus()));
- }
-
- @Override
- public void statusChanged(JobStatus jobStatus) throws SSHApiException {
- this.context.getNotifier().publish(new StatusChangeEvent("Job status has changed to : " + jobStatus.toString()));
- }
-
- @Override
- public boolean isJobDone() throws SSHApiException {
- return getJobStatus().equals(JobStatus.C);
- }
-
- public void setContext(JobExecutionContext context) {
- this.context = context;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/provider/AbstractProvider.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/provider/AbstractProvider.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/provider/AbstractProvider.java
new file mode 100644
index 0000000..0b712b0
--- /dev/null
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/provider/AbstractProvider.java
@@ -0,0 +1,50 @@
+/*
+ *
+ * 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.provider;
+
+import java.util.List;
+
+import org.apache.airavata.gfac.GFacException;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.model.workspace.experiment.JobDetails;
+import org.apache.airavata.model.workspace.experiment.JobStatus;
+import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory;
+import org.apache.airavata.registry.cpi.Registry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class AbstractProvider implements GFacProvider{
+ private final Logger log = LoggerFactory.getLogger(this.getClass());
+
+ protected Registry registry = null;
+ protected JobDetails details; //todo we need to remove this and add methods to fill Job details, this is not a property of a provider
+ protected JobStatus status; //todo we need to remove this and add methods to fill Job details, this is not a property of a provider
+ protected JobExecutionContext jobExecutionContext;
+
+ public void initialize(JobExecutionContext jobExecutionContext) throws GFacProviderException, GFacException {
+ log.debug("Initializing " + this.getClass().getName());
+ registry = RegistryFactory.getDefaultRegistry();
+ details = new JobDetails();
+ status = new JobStatus();
+ this.jobExecutionContext=jobExecutionContext;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/provider/GFacProvider.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/provider/GFacProvider.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/provider/GFacProvider.java
index cf77fab..85d1dc5 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/provider/GFacProvider.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/provider/GFacProvider.java
@@ -25,12 +25,8 @@ import java.util.Map;
import org.apache.airavata.gfac.GFacException;
import org.apache.airavata.gfac.context.JobExecutionContext;
-import org.apache.airavata.gfac.monitor.AbstractActivityListener;
-import org.apache.airavata.gfac.monitor.command.TaskCancelRequest;
-import com.google.common.eventbus.Subscribe;
-
-public interface GFacProvider extends AbstractActivityListener{
+public interface GFacProvider{
void initProperties(Map<String,String> properties) throws GFacProviderException,GFacException;
/**
@@ -63,6 +59,5 @@ public interface GFacProvider extends AbstractActivityListener{
*/
public void cancelJob(String jobId, JobExecutionContext jobExecutionContext) throws GFacProviderException, GFacException;
- @Subscribe
- public void taskCancelRequested(TaskCancelRequest request);
+
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/AbstractProvider.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/AbstractProvider.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/AbstractProvider.java
deleted file mode 100644
index a3f8879..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/AbstractProvider.java
+++ /dev/null
@@ -1,92 +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.provider.impl;
-
-import java.util.List;
-
-import org.apache.airavata.gfac.GFacException;
-import org.apache.airavata.gfac.context.JobExecutionContext;
-import org.apache.airavata.gfac.provider.GFacProvider;
-import org.apache.airavata.gfac.provider.GFacProviderException;
-import org.apache.airavata.gfac.monitor.JobIdentity;
-import org.apache.airavata.gfac.monitor.MonitorID;
-import org.apache.airavata.gfac.monitor.command.TaskCancelRequest;
-import org.apache.airavata.gfac.monitor.event.MonitorPublisher;
-import org.apache.airavata.gfac.monitor.state.JobStatusChangeRequest;
-import org.apache.airavata.model.workspace.experiment.JobDetails;
-import org.apache.airavata.model.workspace.experiment.JobState;
-import org.apache.airavata.model.workspace.experiment.JobStatus;
-import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory;
-import org.apache.airavata.registry.cpi.DataType;
-import org.apache.airavata.registry.cpi.Registry;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.apache.airavata.registry.cpi.utils.Constants.FieldConstants.JobDetaisConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class AbstractProvider implements GFacProvider{
- private final Logger log = LoggerFactory.getLogger(this.getClass());
-
- protected Registry registry = null;
- protected JobDetails details; //todo we need to remove this and add methods to fill Job details, this is not a property of a provider
- protected JobStatus status; //todo we need to remove this and add methods to fill Job details, this is not a property of a provider
- protected JobExecutionContext jobExecutionContext;
-
- private MonitorPublisher monitorPublisher;
-
- public void initialize(JobExecutionContext jobExecutionContext) throws GFacProviderException, GFacException {
- registry = RegistryFactory.getDefaultRegistry();
- details = new JobDetails();
- status = new JobStatus();
- this.jobExecutionContext=jobExecutionContext;
- }
-
- @Override
- public void taskCancelRequested(TaskCancelRequest request) {
- try {
- List<Object> jobDetails = registry.get(DataType.JOB_DETAIL, JobDetaisConstants.TASK_ID, request.getTaskId());
- for (Object o : jobDetails) {
- JobDetails jd=(JobDetails)o;
- JobState jobState = jd.getJobStatus().getJobState();
- if (jobState!=JobState.CANCELED || jobState!=JobState.CANCELING || jobState!=JobState.COMPLETE || jobState!=JobState.FAILED){
- MonitorID monitorId = new MonitorID(null, jd.getJobID(), request.getTaskId(), request.getExperimentId(), null, null);
- monitorPublisher.publish(new JobStatusChangeRequest(monitorId, new JobIdentity(monitorId.getExperimentID(), monitorId.getWorkflowNodeID(), monitorId.getTaskID(), monitorId.getJobID()), JobState.CANCELING));
- log.debug("Canceling job "+jd.getJobID());
- cancelJob(jd.getJobID(), jobExecutionContext);
- }
- }
- } catch (RegistryException e) {
- log.error("Error retrieving job details for Task "+request.getTaskId(),e);
- } catch (Exception e) {
- log.error("Error canceling jobs!!!",e);
- }
- }
-
- @Override
- public void setup(Object... configurations) {
- for (Object configuration : configurations) {
- if (configuration instanceof MonitorPublisher){
- this.monitorPublisher=(MonitorPublisher) configuration;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/utils/GFacUtils.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/utils/GFacUtils.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/utils/GFacUtils.java
index 3058909..c8113e5 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/utils/GFacUtils.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/utils/GFacUtils.java
@@ -26,7 +26,6 @@ import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
-import java.net.URI;
import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.util.*;
@@ -35,14 +34,11 @@ import org.apache.airavata.client.api.AiravataAPI;
import org.apache.airavata.client.api.exception.AiravataAPIInvocationException;
import org.apache.airavata.common.utils.StringUtil;
import org.apache.airavata.commons.gfac.type.ActualParameter;
-import org.apache.airavata.commons.gfac.type.MappingFactory;
import org.apache.airavata.gfac.Constants;
+import org.apache.airavata.gfac.ExecutionMode;
+import org.apache.airavata.gfac.GFacConfiguration;
import org.apache.airavata.gfac.GFacException;
import org.apache.airavata.gfac.context.JobExecutionContext;
-import org.apache.airavata.gfac.context.MessageContext;
-import org.apache.airavata.gsi.ssh.api.Cluster;
-import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
-import org.apache.airavata.gsi.ssh.impl.PBSCluster;
import org.apache.airavata.model.workspace.experiment.*;
import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory;
import org.apache.airavata.registry.api.workflow.ApplicationJob;
@@ -90,6 +86,18 @@ public class GFacUtils {
}
}
+ /**
+ * this can be used to do framework opertaions specific to different modes
+ * @param jobExecutionContext
+ * @return
+ */
+ public static boolean isSynchronousMode(JobExecutionContext jobExecutionContext){
+ GFacConfiguration gFacConfiguration = jobExecutionContext.getGFacConfiguration();
+ if(ExecutionMode.ASYNCHRONOUS.equals(gFacConfiguration.getExecutionMode())){
+ return false;
+ }
+ return true;
+ }
public static String readFileToString(String file) throws FileNotFoundException, IOException {
BufferedReader instream = null;
try {
@@ -154,27 +162,27 @@ public class GFacUtils {
actualParameter = new ActualParameter(DoubleParameterType.type);
if (!"".equals(element.getValue())) {
((DoubleParameterType) actualParameter.getType()).setValue(new Double(element.getValue()));
- }
+ }
} else if ("Integer".equals(parameter.getParameterType().getName())) {
actualParameter = new ActualParameter(IntegerParameterType.type);
if (!"".equals(element.getValue())) {
((IntegerParameterType) actualParameter.getType()).setValue(new Integer(element.getValue()));
- }
+ }
} else if ("Float".equals(parameter.getParameterType().getName())) {
actualParameter = new ActualParameter(FloatParameterType.type);
if (!"".equals(element.getValue())) {
((FloatParameterType) actualParameter.getType()).setValue(new Float(element.getValue()));
- }
+ }
} else if ("Boolean".equals(parameter.getParameterType().getName())) {
actualParameter = new ActualParameter(BooleanParameterType.type);
if (!"".equals(element.getValue())) {
((BooleanParameterType) actualParameter.getType()).setValue(new Boolean(element.getValue()));
- }
+ }
} else if ("File".equals(parameter.getParameterType().getName())) {
actualParameter = new ActualParameter(FileParameterType.type);
if (!"".equals(element.getValue())) {
((FileParameterType) actualParameter.getType()).setValue(element.getValue());
- }
+ }
} else if ("URI".equals(parameter.getParameterType().getName())) {
actualParameter = new ActualParameter(URIParameterType.type);
if (!"".equals(element.getValue())) {
@@ -592,20 +600,21 @@ public class GFacUtils {
log.error("Error in persisting application job data for application job " + job.getJobId() + "!!!", e);
}
}
- public static void saveJobStatus(JobDetails details, JobState state, String taskID) throws GFacException {
+ public static void saveJobStatus(JobExecutionContext jobExecutionContext, JobDetails details, JobState state) throws GFacException {
try {
- Registry registry = RegistryFactory.getDefaultRegistry();
+ Registry registry = jobExecutionContext.getRegistry();
JobStatus status = new JobStatus();
status.setJobState(state);
details.setJobStatus(status);
- registry.add(ChildDataType.JOB_DETAIL,details, new CompositeIdentifier(taskID, details.getJobID()));
+ registry.add(ChildDataType.JOB_DETAIL,details, new CompositeIdentifier(jobExecutionContext.getTaskData().getTaskID(), details.getJobID()));
} catch (Exception e) {
throw new GFacException("Error persisting job status" + e.getLocalizedMessage(),e);
}
}
- public static void updateJobStatus(JobDetails details, JobState state) throws GFacException {
+
+ public static void updateJobStatus(JobExecutionContext jobExecutionContext,JobDetails details, JobState state) throws GFacException {
try {
- Registry registry = RegistryFactory.getDefaultRegistry();
+ Registry registry = jobExecutionContext.getRegistry();
JobStatus status = new JobStatus();
status.setJobState(state);
status.setTimeOfStateChange(Calendar.getInstance().getTimeInMillis());
@@ -615,7 +624,7 @@ public class GFacUtils {
throw new GFacException("Error persisting job status" + e.getLocalizedMessage(),e);
}
}
- public static void saveErrorDetails(String errorMessage, CorrectiveAction action, ErrorCategory errorCatogory, String id) throws GFacException {
+ public static void saveErrorDetails(JobExecutionContext jobExecutionContext, String errorMessage, CorrectiveAction action, ErrorCategory errorCatogory) throws GFacException {
try {
Registry registry = RegistryFactory.getDefaultRegistry();
ErrorDetails details = new ErrorDetails();
@@ -624,7 +633,7 @@ public class GFacUtils {
details.setActionableGroup(ActionableGroup.GATEWAYS_ADMINS);
details.setCreationTime(Calendar.getInstance().getTimeInMillis());
details.setErrorCategory(errorCatogory);
- registry.add(ChildDataType.ERROR_DETAIL, details, id);
+ registry.add(ChildDataType.ERROR_DETAIL, details, jobExecutionContext.getTaskData().getTaskID());
} catch (Exception e) {
throw new GFacException("Error persisting job status" + e.getLocalizedMessage(),e);
}
@@ -649,89 +658,5 @@ public class GFacUtils {
return stringObjectHashMap;
}
- public static JobDescriptor createJobDescriptor(JobExecutionContext jobExecutionContext,
- ApplicationDeploymentDescriptionType app, Cluster cluster) {
- JobDescriptor jobDescriptor = new JobDescriptor();
- // this is common for any application descriptor
- jobDescriptor.setInputDirectory(app.getInputDataDirectory());
- jobDescriptor.setOutputDirectory(app.getOutputDataDirectory());
- jobDescriptor.setExecutablePath(app.getExecutableLocation());
- jobDescriptor.setStandardOutFile(app.getStandardOutput());
- jobDescriptor.setStandardErrorFile(app.getStandardError());
- Random random = new Random();
- int i = random.nextInt();
- jobDescriptor.setJobName(app.getApplicationName().getStringValue() + String.valueOf(i));
- jobDescriptor.setWorkingDirectory(app.getStaticWorkingDirectory());
-
-
- List<String> inputValues = new ArrayList<String>();
- MessageContext input = jobExecutionContext.getInMessageContext();
- Map<String, Object> inputs = input.getParameters();
- Set<String> keys = inputs.keySet();
- for (String paramName : keys) {
- ActualParameter actualParameter = (ActualParameter) inputs.get(paramName);
- if ("URIArray".equals(actualParameter.getType().getType().toString()) || "StringArray".equals(actualParameter.getType().getType().toString())
- || "FileArray".equals(actualParameter.getType().getType().toString())) {
- String[] values = null;
- if (actualParameter.getType() instanceof URIArrayType) {
- values = ((URIArrayType) actualParameter.getType()).getValueArray();
- } else if (actualParameter.getType() instanceof StringArrayType) {
- values = ((StringArrayType) actualParameter.getType()).getValueArray();
- } else if (actualParameter.getType() instanceof FileArrayType) {
- values = ((FileArrayType) actualParameter.getType()).getValueArray();
- }
- String value = StringUtil.createDelimiteredString(values, " ");
- inputValues.add(value);
- } else {
- String paramValue = MappingFactory.toString(actualParameter);
- inputValues.add(paramValue);
- }
- }
- jobDescriptor.setInputValues(inputValues);
-
- // this part will fill out the hpcApplicationDescriptor
- if (app instanceof HpcApplicationDeploymentType) {
- HpcApplicationDeploymentType applicationDeploymentType
- = (HpcApplicationDeploymentType) app;
- jobDescriptor.setShellName("/bin/bash");
- jobDescriptor.setAllEnvExport(true);
- jobDescriptor.setMailOptions("n");
- jobDescriptor.setNodes(applicationDeploymentType.getNodeCount());
- jobDescriptor.setProcessesPerNode(applicationDeploymentType.getProcessorsPerNode());
- jobDescriptor.setMaxWallTime(String.valueOf(applicationDeploymentType.getMaxWallTime()));
- jobDescriptor.setJobSubmitter(applicationDeploymentType.getJobSubmitterCommand());
- if (applicationDeploymentType.getProjectAccount() != null) {
- if (applicationDeploymentType.getProjectAccount().getProjectAccountNumber() != null) {
- jobDescriptor.setAcountString(applicationDeploymentType.getProjectAccount().getProjectAccountNumber());
- }
- }
- if (applicationDeploymentType.getQueue() != null) {
- if (applicationDeploymentType.getQueue().getQueueName() != null) {
- jobDescriptor.setQueueName(applicationDeploymentType.getQueue().getQueueName());
- }
- }
- jobDescriptor.setOwner(((PBSCluster) cluster).getServerInfo().getUserName());
- TaskDetails taskData = jobExecutionContext.getTaskData();
- if (taskData != null && taskData.isSetTaskScheduling()) {
- ComputationalResourceScheduling computionnalResource = taskData.getTaskScheduling();
- if (computionnalResource.getNodeCount() > 0) {
- jobDescriptor.setNodes(computionnalResource.getNodeCount());
- }
- if (computionnalResource.getComputationalProjectAccount() != null) {
- jobDescriptor.setAcountString(computionnalResource.getComputationalProjectAccount());
- }
- if (computionnalResource.getQueueName() != null) {
- jobDescriptor.setQueueName(computionnalResource.getQueueName());
- }
- if (computionnalResource.getTotalCPUCount() > 0) {
- jobDescriptor.setProcessesPerNode(computionnalResource.getTotalCPUCount());
- }
- if (computionnalResource.getWallTimeLimit() > 0) {
- jobDescriptor.setMaxWallTime(String.valueOf(computionnalResource.getWallTimeLimit()));
- }
- }
- }
- return jobDescriptor;
- }
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/AMQPMonitorTest.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/AMQPMonitorTest.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/AMQPMonitorTest.java
deleted file mode 100644
index d61083b..0000000
--- a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/AMQPMonitorTest.java
+++ /dev/null
@@ -1,175 +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.job;
-
-import com.google.common.eventbus.EventBus;
-import com.google.common.eventbus.Subscribe;
-import org.apache.airavata.commons.gfac.type.HostDescription;
-import org.apache.airavata.gsi.ssh.api.Cluster;
-import org.apache.airavata.gsi.ssh.api.SSHApiException;
-import org.apache.airavata.gsi.ssh.api.ServerInfo;
-import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
-import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
-import org.apache.airavata.gsi.ssh.impl.PBSCluster;
-import org.apache.airavata.gsi.ssh.impl.authentication.MyProxyAuthenticationInfo;
-import org.apache.airavata.gfac.monitor.MonitorID;
-import org.apache.airavata.gfac.monitor.event.MonitorPublisher;
-import org.apache.airavata.gfac.monitor.impl.push.amqp.AMQPMonitor;
-import org.apache.airavata.gfac.monitor.state.JobStatusChangeRequest;
-import org.apache.airavata.schemas.gfac.GsisshHostType;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-
-public class AMQPMonitorTest {
-
- private String myProxyUserName;
- private String myProxyPassword;
- private String certificateLocation;
- private String pbsFilePath;
- private String workingDirectory;
- private HostDescription hostDescription;
- private MonitorPublisher monitorPublisher;
- private BlockingQueue<MonitorID> finishQueue;
- private BlockingQueue<MonitorID> pushQueue;
- private Thread pushThread;
- private String proxyFilePath;
- @Before
- public void setUp() throws Exception {
- System.setProperty("myproxy.username", "ogce");
- System.setProperty("myproxy.password", "OpenGwy14");
- System.setProperty("basedir", "/Users/lahirugunathilake/work/airavata/sandbox/gsissh");
- System.setProperty("gsi.working.directory", "/home1/01437/ogce");
- System.setProperty("trusted.cert.location", "/Users/lahirugunathilake/Downloads/certificates");
- System.setProperty("proxy.file.path", "/Users/lahirugunathilake/Downloads/x509up_u503876");
- myProxyUserName = System.getProperty("myproxy.username");
- myProxyPassword = System.getProperty("myproxy.password");
- workingDirectory = System.getProperty("gsi.working.directory");
- certificateLocation = System.getProperty("trusted.cert.location");
- proxyFilePath = System.getProperty("proxy.file.path");
- System.setProperty("connection.name", "xsede");
- if (myProxyUserName == null || myProxyPassword == null || workingDirectory == null) {
- System.out.println(">>>>>> Please run tests with my proxy user name and password. " +
- "E.g :- mvn clean install -Dmyproxy.user=xxx -Dmyproxy.password=xxx -Dgsi.working.directory=/path<<<<<<<");
- throw new Exception("Need my proxy user name password to run tests.");
- }
-
- monitorPublisher = new MonitorPublisher(new EventBus());
- pushQueue = new LinkedBlockingQueue<MonitorID>();
- finishQueue = new LinkedBlockingQueue<MonitorID>();
-
-
- AMQPMonitor amqpMonitor = new
- AMQPMonitor(monitorPublisher,
- pushQueue, finishQueue,proxyFilePath,"xsede",
- Arrays.asList("info1.dyn.teragrid.org,info2.dyn.teragrid.org".split(",")));
- try {
- pushThread = (new Thread(amqpMonitor));
- pushThread.start();
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- hostDescription = new HostDescription(GsisshHostType.type);
- hostDescription.getType().setHostAddress("login1.stampede.tacc.utexas.edu");
- hostDescription.getType().setHostName("stampede-host");
- ((GsisshHostType) hostDescription.getType()).setJobManager("slurm");
- ((GsisshHostType) hostDescription.getType()).setInstalledPath("/usr/bin/");
- ((GsisshHostType) hostDescription.getType()).setPort(2222);
- ((GsisshHostType) hostDescription.getType()).setMonitorMode("push");
- }
-
- @Test
- public void testAMQPMonitor() throws SSHApiException {
- /* now have to submit a job to some machine and add that job to the queue */
- //Create authentication
- GSIAuthenticationInfo authenticationInfo
- = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
- 7512, 17280000, certificateLocation);
-
- // Server info
- ServerInfo serverInfo = new ServerInfo("ogce", "login1.stampede.tacc.utexas.edu",2222);
-
-
- Cluster pbsCluster = new
- PBSCluster(serverInfo, authenticationInfo, org.apache.airavata.gsi.ssh.util.CommonUtils.getPBSJobManager("/usr/bin/"));
-
-
- // Execute command
- System.out.println("Target PBS file path: " + workingDirectory);
- // constructing the job object
- JobDescriptor jobDescriptor = new JobDescriptor();
- jobDescriptor.setWorkingDirectory(workingDirectory);
- jobDescriptor.setShellName("/bin/bash");
- jobDescriptor.setJobName("GSI_SSH_SLEEP_JOB");
- jobDescriptor.setExecutablePath("/bin/echo");
- jobDescriptor.setAllEnvExport(true);
- jobDescriptor.setMailOptions("n");
- jobDescriptor.setStandardOutFile(workingDirectory + File.separator + "application.out");
- jobDescriptor.setStandardErrorFile(workingDirectory + File.separator + "application.err");
- jobDescriptor.setNodes(1);
- jobDescriptor.setProcessesPerNode(1);
- jobDescriptor.setQueueName("normal");
- jobDescriptor.setMaxWallTime("60");
- jobDescriptor.setAcountString("TG-STA110014S");
- List<String> inputs = new ArrayList<String>();
- jobDescriptor.setOwner("ogce");
- inputs.add("Hello World");
- jobDescriptor.setInputValues(inputs);
- //finished construction of job object
- System.out.println(jobDescriptor.toXML());
- String jobID = pbsCluster.submitBatchJob(jobDescriptor);
- System.out.println(jobID);
- try {
- pushQueue.add(new MonitorID(hostDescription, jobID,null,null,null, "ogce"));
- } catch (Exception e) {
- e.printStackTrace();
- }
- try {
- pushThread.join();
- } catch (InterruptedException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- class InnerClassAMQP{
- @Subscribe
- private void getStatus(JobStatusChangeRequest status){
- Assert.assertNotNull(status);
- pushThread.interrupt();
- }
- }
- monitorPublisher.registerListener(new InnerClassAMQP());
-// try {
-// pushThread.join(5000);
-// Iterator<MonitorID> iterator = pushQueue.iterator();
-// MonitorID next = iterator.next();
-// org.junit.Assert.assertNotNull(next.getStatus());
-// } catch (Exception e) {
-// e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
-// }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/GFacConfigXmlTest.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/GFacConfigXmlTest.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/GFacConfigXmlTest.java
new file mode 100644
index 0000000..042db95
--- /dev/null
+++ b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/GFacConfigXmlTest.java
@@ -0,0 +1,113 @@
+/*
+ *
+ * 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.job;
+
+import junit.framework.Assert;
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.gfac.ExecutionMode;
+import org.apache.airavata.gfac.GFacConfiguration;
+import org.apache.airavata.gfac.GFacException;
+import org.apache.airavata.gfac.Scheduler;
+import org.apache.airavata.gfac.context.ApplicationContext;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.cpi.GFacImpl;
+import org.apache.airavata.schemas.gfac.GsisshHostType;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPathExpressionException;
+import java.io.IOException;
+
+public class GFacConfigXmlTest {
+
+ private GFacImpl gfac;
+ @BeforeClass
+ public void setUp() throws Exception {
+ gfac = new GFacImpl();
+ }
+
+ @Test
+ public void testGFacConfigWithHost(){
+ Assert.assertNotNull(gfac.getGfacConfigFile());
+ Assert.assertEquals(1,gfac.getDaemonHandlers().size());
+ try {
+ JobExecutionContext jec = new JobExecutionContext(GFacConfiguration.create(gfac.getGfacConfigFile(), null, null), "testService");
+ ApplicationContext applicationContext = new ApplicationContext();
+ HostDescription host = new HostDescription(GsisshHostType.type);
+ host.getType().setHostAddress("trestles.sdsc.edu");
+ host.getType().setHostName("trestles");
+ ((GsisshHostType) host.getType()).setPort(22);
+ ((GsisshHostType) host.getType()).setInstalledPath("/opt/torque/bin/");
+ applicationContext.setHostDescription(host);
+ jec.setApplicationContext(applicationContext);
+ Scheduler.schedule(jec);
+ Assert.assertEquals(ExecutionMode.ASYNCHRONOUS, jec.getGFacConfiguration().getExecutionMode());
+ Assert.assertEquals("org.apache.airavata.job.TestProvider", jec.getProvider().getClass().getName());
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } catch (IOException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } catch (SAXException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } catch (XPathExpressionException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } catch (GFacException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ }
+ @Test
+ public void testAppSpecificConfig(){
+ Assert.assertNotNull(gfac.getGfacConfigFile());
+ Assert.assertEquals(1,gfac.getDaemonHandlers().size());
+ try {
+ JobExecutionContext jec = new JobExecutionContext(GFacConfiguration.create(gfac.getGfacConfigFile(), null, null), "UltraScan");
+ ApplicationContext applicationContext = new ApplicationContext();
+ HostDescription host = new HostDescription(GsisshHostType.type);
+ host.getType().setHostAddress("trestles.sdsc.edu");
+ host.getType().setHostName("trestles");
+ ((GsisshHostType) host.getType()).setPort(22);
+ ((GsisshHostType) host.getType()).setInstalledPath("/opt/torque/bin/");
+ applicationContext.setHostDescription(host);
+ jec.setApplicationContext(applicationContext);
+ Scheduler.schedule(jec);
+ Assert.assertEquals(3, jec.getGFacConfiguration().getInHandlers().size());
+ Assert.assertEquals(1, jec.getGFacConfiguration().getInHandlers().get(0).getProperties().size());
+ Assert.assertEquals(0, jec.getGFacConfiguration().getInHandlers().get(1).getProperties().size());
+ Assert.assertEquals(1,jec.getGFacConfiguration().getInHandlers().get(2).getProperties().size());
+ Assert.assertEquals(ExecutionMode.ASYNCHRONOUS, jec.getGFacConfiguration().getExecutionMode());// todo this logic might be wrong
+ Assert.assertEquals("org.apache.airavata.job.TestProvider", jec.getProvider().getClass().getName());
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } catch (IOException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } catch (SAXException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } catch (XPathExpressionException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } catch (GFacException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ }
+
+
+}
[4/9] Separating gfac-monitoring implementation
Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/LocalJobMonitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/LocalJobMonitor.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/LocalJobMonitor.java
new file mode 100644
index 0000000..a64b484
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/LocalJobMonitor.java
@@ -0,0 +1,59 @@
+/*
+ *
+ * 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.impl;
+
+import org.apache.airavata.common.utils.ServerSettings;
+import org.apache.airavata.gfac.monitor.JobIdentity;
+import org.apache.airavata.gfac.monitor.MonitorID;
+import org.apache.airavata.gfac.monitor.core.AiravataAbstractMonitor;
+import org.apache.airavata.gfac.monitor.state.JobStatusChangeRequest;
+import org.apache.airavata.model.workspace.experiment.JobState;
+
+import java.util.concurrent.BlockingQueue;
+
+/**
+ * This monitor can be used to monitor a job which runs locally,
+ * Since its a local job job doesn't have states, once it get executed
+ * then the job starts running
+ */
+public class LocalJobMonitor extends AiravataAbstractMonitor {
+ // Though we have a qeuue here, it not going to be used in local jobs
+ BlockingQueue<MonitorID> jobQueue;
+
+ public void run() {
+ do {
+ try {
+ MonitorID take = jobQueue.take();
+ getPublisher().publish(new JobStatusChangeRequest(take, new JobIdentity(take.getExperimentID(), take.getWorkflowNodeID(), take.getTaskID(), take.getJobID()), JobState.COMPLETE));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } while (!ServerSettings.isStopAllThreads());
+ }
+
+ public BlockingQueue<MonitorID> getJobQueue() {
+ return jobQueue;
+ }
+
+ public void setJobQueue(BlockingQueue<MonitorID> jobQueue) {
+ this.jobQueue = jobQueue;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/HPCPullMonitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/HPCPullMonitor.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/HPCPullMonitor.java
new file mode 100644
index 0000000..edd6ce0
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/HPCPullMonitor.java
@@ -0,0 +1,284 @@
+/*
+ *
+ * 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.impl.pull.qstat;
+
+import com.google.common.eventbus.EventBus;
+import org.apache.airavata.common.utils.ServerSettings;
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.gfac.monitor.HostMonitorData;
+import org.apache.airavata.gfac.monitor.MonitorID;
+import org.apache.airavata.gfac.monitor.UserMonitorData;
+import org.apache.airavata.gfac.monitor.core.PullMonitor;
+import org.apache.airavata.gfac.monitor.event.MonitorPublisher;
+import org.apache.airavata.gfac.monitor.exception.AiravataMonitorException;
+import org.apache.airavata.gfac.monitor.state.JobStatusChangeRequest;
+import org.apache.airavata.gfac.monitor.util.CommonUtils;
+import org.apache.airavata.gsi.ssh.api.SSHApiException;
+import org.apache.airavata.model.workspace.experiment.JobState;
+import org.apache.airavata.schemas.gfac.GsisshHostType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.Timestamp;
+import java.util.*;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingDeque;
+
+/**
+ * This monitor is based on qstat command which can be run
+ * in grid resources and retrieve the job status.
+ */
+public class HPCPullMonitor extends PullMonitor {
+ private final static Logger logger = LoggerFactory.getLogger(HPCPullMonitor.class);
+
+ // I think this should use DelayedBlocking Queue to do the monitoring*/
+ private BlockingQueue<UserMonitorData> queue;
+
+ private boolean startPulling = false;
+
+ private Map<String, ResourceConnection> connections;
+
+ private MonitorPublisher publisher;
+
+ public HPCPullMonitor(){
+ connections = new HashMap<String, ResourceConnection>();
+ this.queue = new LinkedBlockingDeque<UserMonitorData>();
+ publisher = new MonitorPublisher(new EventBus());
+ }
+ public HPCPullMonitor(BlockingQueue<UserMonitorData> queue, MonitorPublisher publisher) {
+ this.queue = queue;
+ this.publisher = publisher;
+ connections = new HashMap<String, ResourceConnection>();
+ }
+
+
+
+ public void run() {
+ /* implement a logic to pick each monitorID object from the queue and do the
+ monitoring
+ */
+ this.startPulling = true;
+ while (this.startPulling && !ServerSettings.isStopAllThreads()) {
+ try {
+ startPulling();
+ // After finishing one iteration of the full queue this thread sleeps 1 second
+ Thread.sleep(10000);
+ } catch (Exception e){
+ // we catch all the exceptions here because no matter what happens we do not stop running this
+ // thread, but ideally we should report proper error messages, but this is handled in startPulling
+ // method, incase something happen in Thread.sleep we handle it with this catch block.
+ e.printStackTrace();
+ logger.error(e.getMessage());
+ }
+ }
+ // thread is going to return so we close all the connections
+ Iterator<String> iterator = connections.keySet().iterator();
+ while(iterator.hasNext()){
+ String next = iterator.next();
+ ResourceConnection resourceConnection = connections.get(next);
+ try {
+ resourceConnection.getCluster().disconnect();
+ } catch (SSHApiException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ }
+ }
+
+ /**
+ * 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 boolean startPulling() throws AiravataMonitorException {
+ // take the top element in the queue and pull the data and put that element
+ // at the tail of the queue
+ //todo this polling will not work with multiple usernames but with single user
+ // and multiple hosts, currently monitoring will work
+ UserMonitorData take = null;
+ JobStatusChangeRequest jobStatus = new JobStatusChangeRequest();
+ MonitorID currentMonitorID = null;
+ HostDescription currentHostDescription = null;
+ try {
+ take = this.queue.take();
+ List<MonitorID> completedJobs = new ArrayList<MonitorID>();
+ List<HostMonitorData> hostMonitorData = take.getHostMonitorData();
+ for (HostMonitorData iHostMonitorData : hostMonitorData) {
+ if (iHostMonitorData.getHost().getType() instanceof GsisshHostType) {
+ currentHostDescription = iHostMonitorData.getHost();
+ GsisshHostType gsisshHostType = (GsisshHostType) iHostMonitorData.getHost().getType();
+ String hostName = gsisshHostType.getHostAddress();
+ ResourceConnection connection = null;
+ if (connections.containsKey(hostName)) {
+ logger.debug("We already have this connection so not going to create one");
+ connection = connections.get(hostName);
+ } else {
+ connection = new ResourceConnection(take.getUserName(), iHostMonitorData, gsisshHostType.getInstalledPath());
+ connections.put(hostName, connection);
+ }
+ List<MonitorID> monitorID = iHostMonitorData.getMonitorIDs();
+ Map<String, JobState> jobStatuses = connection.getJobStatuses(take.getUserName(), monitorID);
+ for (MonitorID iMonitorID : monitorID) {
+ currentMonitorID = iMonitorID;
+ iMonitorID.setStatus(jobStatuses.get(iMonitorID.getJobID()));
+ jobStatus = new JobStatusChangeRequest(iMonitorID);
+ // we have this JobStatus class to handle amqp monitoring
+
+ publisher.publish(jobStatus);
+ // if the job is completed we do not have to put the job to the queue again
+ iMonitorID.setLastMonitored(new Timestamp((new Date()).getTime()));
+
+ // After successful monitoring perform following actions to cleanup the queue, if necessary
+ if (jobStatus.getState().equals(JobState.COMPLETE)) {
+ completedJobs.add(iMonitorID);
+ } else if (iMonitorID.getFailedCount() > 2 && iMonitorID.getStatus().equals(JobState.UNKNOWN)) {
+ logger.error("Tried to monitor the job with ID " + iMonitorID.getJobID() + " But failed 3 times, so skip this Job from Monitor");
+ iMonitorID.setLastMonitored(new Timestamp((new Date()).getTime()));
+ completedJobs.add(iMonitorID);
+ } else {
+ // Evey
+ iMonitorID.setLastMonitored(new Timestamp((new Date()).getTime()));
+ // if the job is complete we remove it from the Map, if any of these maps
+ // get empty this userMonitorData will get delete from the queue
+ }
+ }
+ } else {
+ logger.debug("Qstat Monitor doesn't handle non-gsissh hosts");
+ }
+ }
+ // We have finished all the HostMonitorData object in userMonitorData, now we need to put it back
+ // now the userMonitorData goes back to the tail of the queue
+ queue.put(take);
+ // cleaning up the completed jobs, this method will remove some of the userMonitorData from the queue if
+ // they become empty
+ for(MonitorID completedJob:completedJobs){
+ CommonUtils.removeMonitorFromQueue(queue, completedJob);
+ }
+ } catch (InterruptedException e) {
+ if (!this.queue.contains(take)) {
+ try {
+ this.queue.put(take);
+ } catch (InterruptedException e1) {
+ e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ }
+ logger.error("Error handling the job with Job ID:" + currentMonitorID.getJobID());
+ throw new AiravataMonitorException(e);
+ } catch (SSHApiException e) {
+ logger.error(e.getMessage());
+ if (e.getMessage().contains("Unknown Job Id Error")) {
+ // in this case job is finished or may be the given job ID is wrong
+ jobStatus.setState(JobState.UNKNOWN);
+ publisher.publish(jobStatus);
+ } else if (e.getMessage().contains("illegally formed job identifier")) {
+ logger.error("Wrong job ID is given so dropping the job from monitoring system");
+ } else if (!this.queue.contains(take)) { // we put the job back to the queue only if its state is not unknown
+ if (currentMonitorID == null) {
+ logger.error("Monitoring the jobs failed, for user: " + take.getUserName()
+ + " in Host: " + currentHostDescription.getType().getHostAddress());
+ } else {
+ if (currentMonitorID != null) {
+ if (currentMonitorID.getFailedCount() < 2) {
+ try {
+ currentMonitorID.setFailedCount(currentMonitorID.getFailedCount() + 1);
+ this.queue.put(take);
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
+ } else {
+ logger.error(e.getMessage());
+ logger.error("Tried to monitor the job 3 times, so dropping of the the Job with ID: " + currentMonitorID.getJobID());
+ }
+ }
+ }
+ }
+ throw new AiravataMonitorException("Error retrieving the job status", e);
+ } catch (Exception e) {
+ if (currentMonitorID != null) {
+ if (currentMonitorID.getFailedCount() < 3) {
+ try {
+ currentMonitorID.setFailedCount(currentMonitorID.getFailedCount() + 1);
+ this.queue.put(take);
+ // if we get a wrong status we wait for a while and request again
+ Thread.sleep(10000);
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
+ } else {
+ logger.error(e.getMessage());
+ logger.error("Tryied to monitor the job 3 times, so dropping of the the Job with ID: " + currentMonitorID.getJobID());
+ }
+ }
+ throw new AiravataMonitorException("Error retrieving the job status", e);
+ }
+
+
+ return true;
+ }
+
+
+ /**
+ * This is the method to stop the polling process
+ *
+ * @return if the stopping process is successful return true else false
+ */
+ public boolean stopPulling() {
+ this.startPulling = false;
+ return true;
+ }
+
+ public MonitorPublisher getPublisher() {
+ return publisher;
+ }
+
+ public void setPublisher(MonitorPublisher publisher) {
+ this.publisher = publisher;
+ }
+
+ public BlockingQueue<UserMonitorData> getQueue() {
+ return queue;
+ }
+
+ public void setQueue(BlockingQueue<UserMonitorData> queue) {
+ this.queue = queue;
+ }
+
+ public boolean authenticate() {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Map<String, ResourceConnection> getConnections() {
+ return connections;
+ }
+
+ public boolean isStartPulling() {
+ return startPulling;
+ }
+
+ public void setConnections(Map<String, ResourceConnection> connections) {
+ this.connections = connections;
+ }
+
+ public void setStartPulling(boolean startPulling) {
+ this.startPulling = startPulling;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/ResourceConnection.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/ResourceConnection.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/ResourceConnection.java
new file mode 100644
index 0000000..7a37b88
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/ResourceConnection.java
@@ -0,0 +1,151 @@
+/*
+ *
+ * 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.impl.pull.qstat;
+
+import org.apache.airavata.gfac.monitor.HostMonitorData;
+import org.apache.airavata.gfac.monitor.MonitorID;
+import org.apache.airavata.gsi.ssh.api.SSHApiException;
+import org.apache.airavata.gsi.ssh.api.ServerInfo;
+import org.apache.airavata.gsi.ssh.api.authentication.AuthenticationInfo;
+import org.apache.airavata.gsi.ssh.api.job.JobManagerConfiguration;
+import org.apache.airavata.gsi.ssh.impl.JobStatus;
+import org.apache.airavata.gsi.ssh.impl.PBSCluster;
+import org.apache.airavata.gsi.ssh.util.CommonUtils;
+import org.apache.airavata.model.workspace.experiment.JobState;
+import org.apache.airavata.schemas.gfac.GsisshHostType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+
+public class ResourceConnection {
+ private static final Logger log = LoggerFactory.getLogger(ResourceConnection.class);
+
+ private PBSCluster cluster;
+
+ public ResourceConnection(MonitorID monitorID, String installedPath) throws SSHApiException {
+ AuthenticationInfo authenticationInfo = monitorID.getAuthenticationInfo();
+ String hostAddress = monitorID.getHost().getType().getHostAddress();
+ String userName = monitorID.getUserName();
+ String jobManager = ((GsisshHostType)monitorID.getHost().getType()).getJobManager();
+ JobManagerConfiguration jConfig = null;
+ if (jobManager == null) {
+ log.error("No Job Manager is configured, so we are picking pbs as the default job manager");
+ jConfig = CommonUtils.getPBSJobManager(installedPath);
+ } else {
+ if (org.apache.airavata.gfac.monitor.util.CommonUtils.isPBSHost(monitorID.getHost())) {
+ jConfig = CommonUtils.getPBSJobManager(installedPath);
+ } else if(org.apache.airavata.gfac.monitor.util.CommonUtils.isSlurm(monitorID.getHost())) {
+ jConfig = CommonUtils.getSLURMJobManager(installedPath);
+ } else if(org.apache.airavata.gfac.monitor.util.CommonUtils.isSGE(monitorID.getHost())) {
+ jConfig = CommonUtils.getSGEJobManager(installedPath);
+ }
+ //todo support br2 etc
+ }
+ ServerInfo serverInfo = new ServerInfo(userName, hostAddress, ((GsisshHostType)monitorID.getHost().getType()).getPort());
+ cluster = new PBSCluster(serverInfo, authenticationInfo, jConfig);
+ }
+
+ public ResourceConnection(String userName, HostMonitorData hostMonitorData, String installedPath) throws SSHApiException {
+ AuthenticationInfo authenticationInfo = hostMonitorData.getMonitorIDs().get(0).getAuthenticationInfo();
+ String hostAddress = hostMonitorData.getHost().getType().getHostAddress();
+ String jobManager = ((GsisshHostType)hostMonitorData.getHost().getType()).getJobManager();
+ JobManagerConfiguration jConfig = null;
+ if (jobManager == null) {
+ log.error("No Job Manager is configured, so we are picking pbs as the default job manager");
+ jConfig = CommonUtils.getPBSJobManager(installedPath);
+ } else {
+ if (org.apache.airavata.gfac.monitor.util.CommonUtils.isPBSHost(hostMonitorData.getHost())) {
+ jConfig = CommonUtils.getPBSJobManager(installedPath);
+ } else if(org.apache.airavata.gfac.monitor.util.CommonUtils.isSlurm(hostMonitorData.getHost())) {
+ jConfig = CommonUtils.getSLURMJobManager(installedPath);
+ }else if(org.apache.airavata.gfac.monitor.util.CommonUtils.isSGE(hostMonitorData.getHost())) {
+ jConfig = CommonUtils.getSGEJobManager(installedPath);
+ }
+ //todo support br2 etc
+ }
+ ServerInfo serverInfo = new ServerInfo(userName, hostAddress, ((GsisshHostType)hostMonitorData.getHost().getType()).getPort());
+ cluster = new PBSCluster(serverInfo, authenticationInfo, jConfig);
+ }
+ public JobState getJobStatus(MonitorID monitorID) throws SSHApiException {
+ String jobID = monitorID.getJobID();
+ //todo so currently we execute the qstat for each job but we can use user based monitoring
+ //todo or we should concatenate all the commands and execute them in one go and parse the response
+ return getStatusFromString(cluster.getJobStatus(jobID).toString());
+ }
+
+ public Map<String,JobState> getJobStatuses(String userName,List<MonitorID> monitorIDs) throws SSHApiException {
+ Map<String,JobStatus> treeMap = new TreeMap<String,JobStatus>();
+ Map<String,JobState> treeMap1 = new TreeMap<String,JobState>();
+ // creating a sorted map with all the jobIds and with the predefined
+ // status as UNKNOWN
+ for (MonitorID monitorID : monitorIDs) {
+ treeMap.put(monitorID.getJobID(), JobStatus.U);
+ }
+ //todo so currently we execute the qstat for each job but we can use user based monitoring
+ //todo or we should concatenate all the commands and execute them in one go and parse the response
+ cluster.getJobStatuses(userName,treeMap);
+ for(String key:treeMap.keySet()){
+ treeMap1.put(key,getStatusFromString(treeMap.get(key).toString()));
+ }
+ return treeMap1;
+ }
+ private JobState getStatusFromString(String status) {
+ log.info("parsing the job status returned : " + status);
+ if(status != null){
+ if("C".equals(status) || "CD".equals(status)|| "E".equals(status) || "CG".equals(status)){
+ return JobState.COMPLETE;
+ }else if("H".equals(status) || "h".equals(status)){
+ return JobState.HELD;
+ }else if("Q".equals(status) || "qw".equals(status)){
+ return JobState.QUEUED;
+ }else if("R".equals(status) || "CF".equals(status) || "r".equals(status)){
+ return JobState.ACTIVE;
+ }else if ("T".equals(status)) {
+ return JobState.HELD;
+ } else if ("W".equals(status) || "PD".equals(status)) {
+ return JobState.QUEUED;
+ } else if ("S".equals(status)) {
+ return JobState.SUSPENDED;
+ }else if("CA".equals(status)){
+ return JobState.CANCELED;
+ }else if ("F".equals(status) || "NF".equals(status) || "TO".equals(status)) {
+ return JobState.FAILED;
+ }else if ("PR".equals(status) || "Er".equals(status)) {
+ return JobState.FAILED;
+ }else if ("U".equals(status)){
+ return JobState.UNKNOWN;
+ }
+ }
+ return JobState.UNKNOWN;
+ }
+
+ public PBSCluster getCluster() {
+ return cluster;
+ }
+
+ public void setCluster(PBSCluster cluster) {
+ this.cluster = cluster;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/AMQPMonitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/AMQPMonitor.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/AMQPMonitor.java
new file mode 100644
index 0000000..fbf6e21
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/AMQPMonitor.java
@@ -0,0 +1,263 @@
+/*
+ *
+ * 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.impl.push.amqp;
+
+import com.google.common.eventbus.EventBus;
+import com.google.common.eventbus.Subscribe;
+import com.rabbitmq.client.Channel;
+import com.rabbitmq.client.Connection;
+import org.apache.airavata.common.utils.ServerSettings;
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.gfac.monitor.JobIdentity;
+import org.apache.airavata.gfac.monitor.MonitorID;
+import org.apache.airavata.gfac.monitor.core.PushMonitor;
+import org.apache.airavata.gfac.monitor.event.MonitorPublisher;
+import org.apache.airavata.gfac.monitor.exception.AiravataMonitorException;
+import org.apache.airavata.gfac.monitor.state.JobStatusChangeRequest;
+import org.apache.airavata.gfac.monitor.util.AMQPConnectionUtil;
+import org.apache.airavata.gfac.monitor.util.CommonUtils;
+import org.apache.airavata.model.workspace.experiment.JobState;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.concurrent.BlockingQueue;
+
+/**
+ * This is the implementation for AMQP based finishQueue, this uses
+ * rabbitmq client to recieve AMQP based monitoring data from
+ * mostly excede resources.
+ */
+public class AMQPMonitor extends PushMonitor {
+ private final static Logger logger = LoggerFactory.getLogger(AMQPMonitor.class);
+
+
+ /* this will keep all the channels available in the system, we do not create
+ channels for all the jobs submitted, but we create channels for each user for each
+ host.
+ */
+ private Map<String, Channel> availableChannels;
+
+ private MonitorPublisher publisher;
+
+ private MonitorPublisher localPublisher;
+
+ private BlockingQueue<MonitorID> runningQueue;
+
+ private BlockingQueue<MonitorID> finishQueue;
+
+ private String connectionName;
+
+ private String proxyPath;
+
+ private List<String> amqpHosts;
+
+ private boolean startRegister;
+
+ public AMQPMonitor(){
+
+ }
+ public AMQPMonitor(MonitorPublisher publisher, BlockingQueue<MonitorID> runningQueue,
+ BlockingQueue<MonitorID> finishQueue,
+ String proxyPath,String connectionName,List<String> hosts) {
+ this.publisher = publisher;
+ this.runningQueue = runningQueue; // these will be initialized by the MonitorManager
+ this.finishQueue = finishQueue; // these will be initialized by the MonitorManager
+ this.availableChannels = new HashMap<String, Channel>();
+ this.connectionName = connectionName;
+ this.proxyPath = proxyPath;
+ this.amqpHosts = hosts;
+ this.localPublisher = new MonitorPublisher(new EventBus());
+ this.localPublisher.registerListener(this);
+ }
+
+ public void initialize(String proxyPath, String connectionName, List<String> hosts) {
+ this.availableChannels = new HashMap<String, Channel>();
+ this.connectionName = connectionName;
+ this.proxyPath = proxyPath;
+ this.amqpHosts = hosts;
+ this.localPublisher = new MonitorPublisher(new EventBus());
+ this.localPublisher.registerListener(this);
+ }
+
+ @Override
+ public boolean registerListener(MonitorID monitorID) throws AiravataMonitorException {
+ // we subscribe to read user-host based subscription
+ HostDescription host = monitorID.getHost();
+ String hostAddress = host.getType().getHostAddress();
+ // in amqp case there are no multiple jobs per each host, because once a job is put in to the queue it
+ // will be picked by the Monitor, so jobs will not stay in this queueu but jobs will stay in finishQueue
+ String channelID = CommonUtils.getChannelID(monitorID);
+ if(availableChannels.get(channelID) == null){
+ try {
+ //todo need to fix this rather getting it from a file
+ Connection connection = AMQPConnectionUtil.connect(amqpHosts, connectionName, proxyPath);
+ Channel channel = null;
+ channel = connection.createChannel();
+ availableChannels.put(channelID, channel);
+ String queueName = channel.queueDeclare().getQueue();
+
+ BasicConsumer consumer = new
+ BasicConsumer(new JSONMessageParser(), localPublisher); // here we use local publisher
+ channel.basicConsume(queueName, true, consumer);
+ String filterString = CommonUtils.getRoutingKey(monitorID.getUserName(), hostAddress);
+ // here we queuebind to a particular user in a particular machine
+ channel.queueBind(queueName, "glue2.computing_activity", filterString);
+ logger.info("Using filtering string to monitor: " + filterString);
+ } catch (IOException e) {
+ logger.error("Error creating the connection to finishQueue the job:" + monitorID.getUserName());
+ }
+ }
+ return true;
+ }
+
+ public void run() {
+ // before going to the while true mode we start unregister thread
+ startRegister = true; // this will be unset by someone else
+ while (startRegister || !ServerSettings.isStopAllThreads()) {
+ try {
+ MonitorID take = runningQueue.take();
+ this.registerListener(take);
+ } catch (AiravataMonitorException e) { // catch any exceptino inside the loop
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+ Set<String> strings = availableChannels.keySet();
+ for(String key:strings) {
+ Channel channel = availableChannels.get(key);
+ try {
+ channel.close();
+ } catch (IOException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ }
+ }
+
+ @Subscribe
+ public boolean unRegisterListener(MonitorID monitorID) throws AiravataMonitorException {
+ Iterator<MonitorID> iterator = finishQueue.iterator();
+ MonitorID next = null;
+ while(iterator.hasNext()){
+ next = iterator.next();
+ if(next.getJobID().endsWith(monitorID.getJobID())){
+ break;
+ }
+ }
+ if(next == null) {
+ logger.error("Job has removed from the queue, old obsolete message recieved");
+ return false;
+ }
+ String channelID = CommonUtils.getChannelID(next);
+ if (JobState.FAILED.equals(monitorID.getStatus()) || JobState.COMPLETE.equals(monitorID.getStatus())) {
+ finishQueue.remove(next);
+
+ // if this is the last job in the queue at this point with the same username and same host we
+ // close the channel and close the connection and remove it from availableChannels
+ if (CommonUtils.isTheLastJobInQueue(finishQueue, next)) {
+ logger.info("There are no jobs to monitor for common ChannelID:" + channelID + " , so we unsubscribe it" +
+ ", incase new job created we do subscribe again");
+ Channel channel = availableChannels.get(channelID);
+ if (channel == null) {
+ logger.error("Already Unregistered the listener");
+ throw new AiravataMonitorException("Already Unregistered the listener");
+ } else {
+ try {
+ channel.queueUnbind(channel.queueDeclare().getQueue(), "glue2.computing_activity", CommonUtils.getRoutingKey(next));
+ channel.close();
+ channel.getConnection().close();
+ availableChannels.remove(channelID);
+ } catch (IOException e) {
+ logger.error("Error unregistering the listener");
+ throw new AiravataMonitorException("Error unregistering the listener");
+ }
+ }
+ }
+ }
+ next.setStatus(monitorID.getStatus());
+ publisher.publish(new JobStatusChangeRequest(next, new JobIdentity(next.getExperimentID(), next.getWorkflowNodeID(), next.getTaskID(), next.getJobID()),next.getStatus()));
+ return true;
+ }
+ @Override
+ public boolean stopRegister() throws AiravataMonitorException {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public Map<String, Channel> getAvailableChannels() {
+ return availableChannels;
+ }
+
+ public void setAvailableChannels(Map<String, Channel> availableChannels) {
+ this.availableChannels = availableChannels;
+ }
+
+ public MonitorPublisher getPublisher() {
+ return publisher;
+ }
+
+ public void setPublisher(MonitorPublisher publisher) {
+ this.publisher = publisher;
+ }
+
+ public BlockingQueue<MonitorID> getRunningQueue() {
+ return runningQueue;
+ }
+
+ public void setRunningQueue(BlockingQueue<MonitorID> runningQueue) {
+ this.runningQueue = runningQueue;
+ }
+
+ public BlockingQueue<MonitorID> getFinishQueue() {
+ return finishQueue;
+ }
+
+ public void setFinishQueue(BlockingQueue<MonitorID> finishQueue) {
+ this.finishQueue = finishQueue;
+ }
+
+ public String getProxyPath() {
+ return proxyPath;
+ }
+
+ public void setProxyPath(String proxyPath) {
+ this.proxyPath = proxyPath;
+ }
+
+ public List<String> getAmqpHosts() {
+ return amqpHosts;
+ }
+
+ public void setAmqpHosts(List<String> amqpHosts) {
+ this.amqpHosts = amqpHosts;
+ }
+
+ public boolean isStartRegister() {
+ return startRegister;
+ }
+
+ public void setStartRegister(boolean startRegister) {
+ this.startRegister = startRegister;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/BasicConsumer.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/BasicConsumer.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/BasicConsumer.java
new file mode 100644
index 0000000..1d60c45
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/BasicConsumer.java
@@ -0,0 +1,86 @@
+/*
+ *
+ * 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.impl.push.amqp;
+
+import com.rabbitmq.client.AMQP;
+import com.rabbitmq.client.Consumer;
+import com.rabbitmq.client.Envelope;
+import com.rabbitmq.client.ShutdownSignalException;
+import org.apache.airavata.gfac.monitor.MonitorID;
+import org.apache.airavata.gfac.monitor.core.MessageParser;
+import org.apache.airavata.gfac.monitor.event.MonitorPublisher;
+import org.apache.airavata.gfac.monitor.exception.AiravataMonitorException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BasicConsumer implements Consumer {
+ private final static Logger logger = LoggerFactory.getLogger(AMQPMonitor.class);
+
+ private MessageParser parser;
+
+ private MonitorPublisher publisher;
+
+ public BasicConsumer(MessageParser parser, MonitorPublisher publisher) {
+ this.parser = parser;
+ this.publisher = publisher;
+ }
+
+ public void handleCancel(String consumerTag) {
+ }
+
+ public void handleCancelOk(String consumerTag) {
+ }
+
+ public void handleConsumeOk(String consumerTag) {
+ }
+
+ public void handleDelivery(String consumerTag,
+ Envelope envelope,
+ AMQP.BasicProperties properties,
+ byte[] body) {
+
+ logger.debug("job update for: " + envelope.getRoutingKey());
+ String message = new String(body);
+ message = message.replaceAll("(?m)^", " ");
+ // Here we parse the message and get the job status and push it
+ // to the Event bus, this will be picked by
+// AiravataJobStatusUpdator and store in to registry
+
+ logger.debug("************************************************************");
+ logger.debug("AMQP Message recieved \n" + message);
+ logger.debug("************************************************************");
+ try {
+ String jobID = envelope.getRoutingKey().split("\\.")[0];
+ MonitorID monitorID = new MonitorID(null, jobID, null, null, null, null);
+ monitorID.setStatus(parser.parseMessage(message));
+ publisher.publish(monitorID);
+ } catch (AiravataMonitorException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void handleRecoverOk(String consumerTag) {
+ }
+
+ public void handleShutdownSignal(String consumerTag, ShutdownSignalException sig) {
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/JSONMessageParser.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/JSONMessageParser.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/JSONMessageParser.java
new file mode 100644
index 0000000..72c77d5
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/JSONMessageParser.java
@@ -0,0 +1,78 @@
+/*
+ *
+ * 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.impl.push.amqp;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.airavata.ComputingActivity;
+import org.apache.airavata.gfac.monitor.core.MessageParser;
+import org.apache.airavata.gfac.monitor.exception.AiravataMonitorException;
+import org.apache.airavata.model.workspace.experiment.JobState;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.List;
+
+public class JSONMessageParser implements MessageParser {
+ private final static Logger logger = LoggerFactory.getLogger(JSONMessageParser.class);
+
+ public JobState parseMessage(String message)throws AiravataMonitorException {
+ /*todo write a json message parser here*/
+ logger.debug(message);
+ ObjectMapper objectMapper = new ObjectMapper();
+ try {
+ ComputingActivity computingActivity = objectMapper.readValue(message.getBytes(), ComputingActivity.class);
+ logger.info(computingActivity.getIDFromEndpoint());
+ List<String> stateList = computingActivity.getState();
+ JobState jobState = null;
+ for (String aState : stateList) {
+ jobState = getStatusFromString(aState);
+ }
+ // we get the last value of the state array
+ return jobState;
+ } catch (IOException e) {
+ throw new AiravataMonitorException(e);
+ }
+ }
+
+private JobState getStatusFromString(String status) {
+ logger.info("parsing the job status returned : " + status);
+ if(status != null){
+ if("ipf:finished".equals(status)){
+ return JobState.COMPLETE;
+ }else if("ipf:pending".equals(status)|| "ipf:starting".equals(status)){
+ return JobState.QUEUED;
+ }else if("ipf:running".equals(status) || "ipf:finishing".equals(status)){
+ return JobState.ACTIVE;
+ }else if ("ipf:held".equals(status) || "ipf:teminating".equals(status) || "ipf:teminated".equals(status)) {
+ return JobState.HELD;
+ } else if ("ipf:suspending".equals(status)) {
+ return JobState.SUSPENDED;
+ }else if ("ipf:failed".equals(status)) {
+ return JobState.FAILED;
+ }else if ("ipf:unknown".equals(status)){
+ return JobState.UNKNOWN;
+ }
+ }
+ return JobState.UNKNOWN;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/UnRegisterWorker.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/UnRegisterWorker.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/UnRegisterWorker.java
new file mode 100644
index 0000000..c6e1378
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/UnRegisterWorker.java
@@ -0,0 +1,68 @@
+/*
+ *
+ * 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.impl.push.amqp;
+
+import com.google.common.eventbus.Subscribe;
+import com.rabbitmq.client.Channel;
+import org.apache.airavata.gfac.monitor.MonitorID;
+import org.apache.airavata.gfac.monitor.exception.AiravataMonitorException;
+import org.apache.airavata.gfac.monitor.state.JobStatusChangeRequest;
+import org.apache.airavata.gfac.monitor.util.CommonUtils;
+import org.apache.airavata.model.workspace.experiment.JobState;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Map;
+
+public class UnRegisterWorker{
+ private final static Logger logger = LoggerFactory.getLogger(UnRegisterWorker.class);
+ private Map<String, Channel> availableChannels;
+
+ public UnRegisterWorker(Map<String, Channel> channels) {
+ this.availableChannels = channels;
+ }
+
+ @Subscribe
+ private boolean unRegisterListener(JobStatusChangeRequest jobStatus) throws AiravataMonitorException {
+ MonitorID monitorID = jobStatus.getMonitorID();
+ String channelID = CommonUtils.getChannelID(monitorID);
+ if (JobState.FAILED.equals(jobStatus.getState()) || JobState.COMPLETE.equals(jobStatus.getState())){
+ Channel channel = availableChannels.get(channelID);
+ if (channel == null) {
+ logger.error("Already Unregistered the listener");
+ throw new AiravataMonitorException("Already Unregistered the listener");
+ } else {
+ try {
+ channel.queueUnbind(channel.queueDeclare().getQueue(), "glue2.computing_activity", CommonUtils.getRoutingKey(monitorID));
+ channel.close();
+ channel.getConnection().close();
+ availableChannels.remove(channelID);
+ } catch (IOException e) {
+ logger.error("Error unregistering the listener");
+ throw new AiravataMonitorException("Error unregistering the listener");
+ }
+ }
+ }
+ return true;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/AbstractStateChangeRequest.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/AbstractStateChangeRequest.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/AbstractStateChangeRequest.java
new file mode 100644
index 0000000..10048b0
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/AbstractStateChangeRequest.java
@@ -0,0 +1,27 @@
+/*
+ *
+ * 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.state;
+
+
+public abstract class AbstractStateChangeRequest implements PublisherMessage {
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/ExperimentStatusChangeRequest.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/ExperimentStatusChangeRequest.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/ExperimentStatusChangeRequest.java
new file mode 100644
index 0000000..eecf88d
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/ExperimentStatusChangeRequest.java
@@ -0,0 +1,63 @@
+/*
+ *
+ * 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.state;
+
+import org.apache.airavata.gfac.monitor.ExperimentIdentity;
+import org.apache.airavata.model.workspace.experiment.ExperimentState;
+
+/**
+ * This is the primary job state object used in
+ * through out the monitor module. This use airavata-data-model JobState enum
+ * Ideally after processing each event or monitoring message from remote system
+ * Each monitoring implementation has to return this object with a state and
+ * the monitoring ID
+ */
+public class ExperimentStatusChangeRequest extends AbstractStateChangeRequest {
+ private ExperimentState state;
+ private ExperimentIdentity identity;
+
+ // this constructor can be used in Qstat monitor to handle errors
+ public ExperimentStatusChangeRequest() {
+ }
+
+ public ExperimentStatusChangeRequest(ExperimentIdentity experimentIdentity, ExperimentState state) {
+ this.state = state;
+ setIdentity(experimentIdentity);
+ }
+
+ public ExperimentState getState() {
+ return state;
+ }
+
+ public void setState(ExperimentState state) {
+ this.state = state;
+ }
+
+ public ExperimentIdentity getIdentity() {
+ return identity;
+ }
+
+ public void setIdentity(ExperimentIdentity identity) {
+ this.identity = identity;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/JobStatusChangeRequest.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/JobStatusChangeRequest.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/JobStatusChangeRequest.java
new file mode 100644
index 0000000..da52656
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/JobStatusChangeRequest.java
@@ -0,0 +1,80 @@
+/*
+ *
+ * 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.state;
+
+import org.apache.airavata.gfac.monitor.JobIdentity;
+import org.apache.airavata.gfac.monitor.MonitorID;
+import org.apache.airavata.model.workspace.experiment.JobState;
+
+/**
+ * This is the primary job state object used in
+ * through out the monitor module. This use airavata-data-model JobState enum
+ * Ideally after processing each event or monitoring message from remote system
+ * Each monitoring implementation has to return this object with a state and
+ * the monitoring ID
+ */
+public class JobStatusChangeRequest extends AbstractStateChangeRequest {
+ private JobState state;
+ private JobIdentity identity;
+
+ private MonitorID monitorID;
+
+ // this constructor can be used in Qstat monitor to handle errors
+ public JobStatusChangeRequest() {
+ }
+
+ public JobStatusChangeRequest(MonitorID monitorID) {
+ setIdentity(new JobIdentity(monitorID.getExperimentID(),monitorID.getWorkflowNodeID(),
+ monitorID.getTaskID(),monitorID.getJobID()));
+ setMonitorID(monitorID);
+ this.state = monitorID.getStatus();
+ }
+ public JobStatusChangeRequest(MonitorID monitorID, JobIdentity jobId, JobState state) {
+ setIdentity(jobId);
+ setMonitorID(monitorID);
+ this.state = state;
+ }
+
+ public JobState getState() {
+ return state;
+ }
+
+ public void setState(JobState state) {
+ this.state = state;
+ }
+
+ public JobIdentity getIdentity() {
+ return identity;
+ }
+
+ public void setIdentity(JobIdentity identity) {
+ this.identity = identity;
+ }
+
+ public MonitorID getMonitorID() {
+ return monitorID;
+ }
+
+ public void setMonitorID(MonitorID monitorID) {
+ this.monitorID = monitorID;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/JobStatusInfo.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/JobStatusInfo.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/JobStatusInfo.java
new file mode 100644
index 0000000..9a59b50
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/JobStatusInfo.java
@@ -0,0 +1,48 @@
+/*
+ *
+ * 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.state;
+
+import org.apache.airavata.gsi.ssh.impl.JobStatus;
+
+/**
+ * Based on the job status monitoring we can gather
+ * different informaation about the job, its not simply
+ * the job status, so we need a way to implement
+ * different job statusinfo object to keep job status
+ */
+public interface JobStatusInfo {
+
+ /**
+ * This method can be used to get JobStatusInfo data and
+ * decide the finalJobState
+ *
+ * @param jobState
+ */
+ void setJobStatus(JobStatus jobState);
+
+ /**
+ * After setting the jobState by processing jobinformation
+ * this method can be used to get the JobStatus
+ * @return
+ */
+ JobStatus getJobStatus();
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/PublisherMessage.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/PublisherMessage.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/PublisherMessage.java
new file mode 100644
index 0000000..cbfcb5a
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/PublisherMessage.java
@@ -0,0 +1,26 @@
+/*
+ *
+ * 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.state;
+
+public interface PublisherMessage {
+// public String getType();
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/TaskStatusChangeRequest.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/TaskStatusChangeRequest.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/TaskStatusChangeRequest.java
new file mode 100644
index 0000000..af20707
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/TaskStatusChangeRequest.java
@@ -0,0 +1,61 @@
+/*
+ *
+ * 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.state;
+
+import org.apache.airavata.gfac.monitor.TaskIdentity;
+import org.apache.airavata.model.workspace.experiment.TaskState;
+
+/**
+ * This is the primary job state object used in
+ * through out the monitor module. This use airavata-data-model JobState enum
+ * Ideally after processing each event or monitoring message from remote system
+ * Each monitoring implementation has to return this object with a state and
+ * the monitoring ID
+ */
+public class TaskStatusChangeRequest extends AbstractStateChangeRequest {
+ private TaskState state;
+ private TaskIdentity identity;
+ // this constructor can be used in Qstat monitor to handle errors
+ public TaskStatusChangeRequest() {
+ }
+
+ public TaskStatusChangeRequest(TaskIdentity taskIdentity, TaskState state) {
+ this.state = state;
+ setIdentity(taskIdentity);
+ }
+
+ public TaskState getState() {
+ return state;
+ }
+
+ public void setState(TaskState state) {
+ this.state = state;
+ }
+
+ public TaskIdentity getIdentity() {
+ return identity;
+ }
+
+ public void setIdentity(TaskIdentity identity) {
+ this.identity = identity;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/WorkflowNodeStatusChangeRequest.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/WorkflowNodeStatusChangeRequest.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/WorkflowNodeStatusChangeRequest.java
new file mode 100644
index 0000000..632f2e3
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/WorkflowNodeStatusChangeRequest.java
@@ -0,0 +1,63 @@
+/*
+ *
+ * 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.state;
+
+import org.apache.airavata.gfac.monitor.WorkflowNodeIdentity;
+import org.apache.airavata.model.workspace.experiment.WorkflowNodeState;
+
+/**
+ * This is the primary job state object used in
+ * through out the monitor module. This use airavata-data-model JobState enum
+ * Ideally after processing each event or monitoring message from remote system
+ * Each monitoring implementation has to return this object with a state and
+ * the monitoring ID
+ */
+public class WorkflowNodeStatusChangeRequest extends AbstractStateChangeRequest {
+ private WorkflowNodeState state;
+ private WorkflowNodeIdentity identity;
+
+ // this constructor can be used in Qstat monitor to handle errors
+ public WorkflowNodeStatusChangeRequest() {
+ }
+
+ public WorkflowNodeStatusChangeRequest(WorkflowNodeIdentity identity, WorkflowNodeState state) {
+ this.state = state;
+ setIdentity(identity);
+ }
+
+ public WorkflowNodeState getState() {
+ return state;
+ }
+
+ public void setState(WorkflowNodeState state) {
+ this.state = state;
+ }
+
+ public WorkflowNodeIdentity getIdentity() {
+ return identity;
+ }
+
+ public void setIdentity(WorkflowNodeIdentity identity) {
+ this.identity = identity;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/impl/AmazonJobStatusInfo.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/impl/AmazonJobStatusInfo.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/impl/AmazonJobStatusInfo.java
new file mode 100644
index 0000000..19b051a
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/impl/AmazonJobStatusInfo.java
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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.state.impl;
+
+import org.apache.airavata.gfac.monitor.state.JobStatusInfo;
+import org.apache.airavata.gsi.ssh.impl.JobStatus;
+
+/**
+ * This can be used to store job status information about
+ * amazon jobs, this data could be very different from
+ * a typical grid job
+ */
+public class AmazonJobStatusInfo implements JobStatusInfo {
+ public void setJobStatus(JobStatus jobState) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public JobStatus getJobStatus() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/impl/GridJobStatusInfo.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/impl/GridJobStatusInfo.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/impl/GridJobStatusInfo.java
new file mode 100644
index 0000000..4612c3c
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/state/impl/GridJobStatusInfo.java
@@ -0,0 +1,40 @@
+/*
+ *
+ * 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.state.impl;
+
+import org.apache.airavata.gfac.monitor.state.JobStatusInfo;
+import org.apache.airavata.gsi.ssh.impl.JobStatus;
+
+
+/**
+ * This can be used to keep information about a Grid job
+ * which we can get from qstat polling or from amqp based
+ * monitoring in Grid machines
+ */
+public class GridJobStatusInfo implements JobStatusInfo {
+ public void setJobStatus(JobStatus jobState) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public JobStatus getJobStatus() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/util/AMQPConnectionUtil.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/util/AMQPConnectionUtil.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/util/AMQPConnectionUtil.java
new file mode 100644
index 0000000..b69cf52
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/util/AMQPConnectionUtil.java
@@ -0,0 +1,77 @@
+/*
+ *
+ * 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.util;
+
+import com.rabbitmq.client.Connection;
+import com.rabbitmq.client.ConnectionFactory;
+import com.rabbitmq.client.DefaultSaslConfig;
+
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManagerFactory;
+import java.security.KeyStore;
+import java.util.Collections;
+import java.util.List;
+
+public class AMQPConnectionUtil {
+ public static Connection connect(List<String>hosts,String vhost, String proxyFile) {
+ Collections.shuffle(hosts);
+ for (String host : hosts) {
+ Connection connection = connect(host, vhost, proxyFile);
+ if (host != null) {
+ System.out.println("connected to " + host);
+ return connection;
+ }
+ }
+ return null;
+ }
+
+ public static Connection connect(String host, String vhost, String proxyFile) {
+ Connection connection;
+ try {
+ String keyPassPhrase = "test123";
+ KeyStore ks = X509Helper.keyStoreFromPEM(proxyFile, keyPassPhrase);
+ KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
+ kmf.init(ks, keyPassPhrase.toCharArray());
+
+ KeyStore tks = X509Helper.trustKeyStoreFromCertDir();
+ TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
+ tmf.init(tks);
+
+ SSLContext c = SSLContext.getInstance("SSLv3");
+ c.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+
+ ConnectionFactory factory = new ConnectionFactory();
+ factory.setHost(host);
+ factory.setPort(5671);
+ factory.useSslProtocol(c);
+ factory.setVirtualHost(vhost);
+ factory.setSaslConfig(DefaultSaslConfig.EXTERNAL);
+
+ connection = factory.newConnection();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ return connection;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/util/CommonUtils.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/util/CommonUtils.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/util/CommonUtils.java
new file mode 100644
index 0000000..30f1ae4
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/util/CommonUtils.java
@@ -0,0 +1,172 @@
+/*
+ *
+ * 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.util;
+
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.gfac.monitor.HostMonitorData;
+import org.apache.airavata.gfac.monitor.MonitorID;
+import org.apache.airavata.gfac.monitor.UserMonitorData;
+import org.apache.airavata.gfac.monitor.exception.AiravataMonitorException;
+import org.apache.airavata.schemas.gfac.GsisshHostType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+
+public class CommonUtils {
+ private final static Logger logger = LoggerFactory.getLogger(CommonUtils.class);
+
+ public static boolean isPBSHost(HostDescription host){
+ if("pbs".equals(((GsisshHostType)host.getType()).getJobManager()) ||
+ "".equals(((GsisshHostType)host.getType()).getJobManager())){
+ return true;
+ }else{
+ // default is pbs so we return true
+ return false;
+ }
+ }
+ public static boolean isSlurm(HostDescription host){
+ if("slurm".equals(((GsisshHostType)host.getType()).getJobManager())){
+ return true;
+ }else{
+ // default is pbs so we return true
+ return false;
+ }
+ }
+ public static boolean isSGE(HostDescription host){
+ if("sge".equals(((GsisshHostType)host.getType()).getJobManager())){
+ return true;
+ }else{
+ // default is pbs so we return true
+ return false;
+ }
+ }
+ public static String getChannelID(MonitorID monitorID) {
+ return monitorID.getUserName() + "-" + monitorID.getHost().getType().getHostName();
+ }
+
+ public static String getRoutingKey(MonitorID monitorID) {
+ return "*." + monitorID.getUserName() + "." + monitorID.getHost().getType().getHostAddress();
+ }
+
+ public static String getChannelID(String userName,String hostAddress) {
+ return userName + "-" + hostAddress;
+ }
+
+ public static String getRoutingKey(String userName,String hostAddress) {
+ return "*." + userName + "." + hostAddress;
+ }
+
+ public static void addMonitortoQueue(BlockingQueue<UserMonitorData> queue, MonitorID monitorID) throws AiravataMonitorException {
+ Iterator<UserMonitorData> iterator = queue.iterator();
+ while (iterator.hasNext()) {
+ UserMonitorData next = iterator.next();
+ if (next.getUserName().equals(monitorID.getUserName())) {
+ // then this is the right place to update
+ List<HostMonitorData> monitorIDs = next.getHostMonitorData();
+ for (HostMonitorData host : monitorIDs) {
+ if (host.getHost().equals(monitorID.getHost())) {
+ // ok we found right place to add this monitorID
+ host.addMonitorIDForHost(monitorID);
+ return;
+ }
+ }
+ // there is a userMonitor object for this user name but no Hosts for this host
+ // so we have to create new Hosts
+ HostMonitorData hostMonitorData = new HostMonitorData(monitorID.getHost());
+ hostMonitorData.addMonitorIDForHost(monitorID);
+ next.addHostMonitorData(hostMonitorData);
+ return;
+ }
+ }
+ HostMonitorData hostMonitorData = new HostMonitorData(monitorID.getHost());
+ hostMonitorData.addMonitorIDForHost(monitorID);
+
+ UserMonitorData userMonitorData = new UserMonitorData(monitorID.getUserName());
+ userMonitorData.addHostMonitorData(hostMonitorData);
+ try {
+ queue.put(userMonitorData);
+ } catch (InterruptedException e) {
+ throw new AiravataMonitorException(e);
+ }
+ }
+ public static boolean isTheLastJobInQueue(BlockingQueue<MonitorID> queue,MonitorID monitorID){
+ Iterator<MonitorID> iterator = queue.iterator();
+ while(iterator.hasNext()){
+ MonitorID next = iterator.next();
+ if(monitorID.getUserName().equals(next.getUserName()) && CommonUtils.isEqual(monitorID.getHost(), next.getHost())){
+ return false;
+ }
+ }
+ return true;
+ }
+ public static void removeMonitorFromQueue(BlockingQueue<UserMonitorData> queue,MonitorID monitorID) throws AiravataMonitorException {
+ Iterator<UserMonitorData> iterator = queue.iterator();
+ while(iterator.hasNext()){
+ UserMonitorData next = iterator.next();
+ if(next.getUserName().equals(monitorID.getUserName())){
+ // then this is the right place to update
+ List<HostMonitorData> hostMonitorData = next.getHostMonitorData();
+ for(HostMonitorData iHostMonitorID:hostMonitorData){
+ if(iHostMonitorID.getHost().equals(monitorID.getHost())) {
+ List<MonitorID> monitorIDs = iHostMonitorID.getMonitorIDs();
+ for(MonitorID iMonitorID:monitorIDs){
+ if(iMonitorID.getJobID().equals(monitorID.getJobID())) {
+ // OK we found the object, we cannot do list.remove(object) states of two objects
+ // could be different, thats why we check the jobID
+ monitorIDs.remove(iMonitorID);
+ if(monitorIDs.size()==0) {
+ hostMonitorData.remove(iHostMonitorID);
+ if (hostMonitorData.size() == 0) {
+ // no useful data so we have to remove the element from the queue
+ queue.remove(next);
+ }
+ }
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+ throw new AiravataMonitorException("Cannot find the given MonitorID in the queue with userName " +
+ monitorID.getUserName() + " and jobID " + monitorID.getJobID());
+
+ }
+
+ public static boolean isEqual(HostDescription host1,HostDescription host2) {
+ if ((host1.getType() instanceof GsisshHostType) && (host2.getType() instanceof GsisshHostType)) {
+ GsisshHostType hostType1 = (GsisshHostType)host1.getType();
+ GsisshHostType hostType2 = (GsisshHostType)host2.getType();
+ if(hostType1.getHostAddress().equals(hostType2.getHostAddress())
+ && hostType1.getJobManager().equals(hostType2.getJobManager())
+ && (hostType1.getPort() == hostType2.getPort())
+ && hostType1.getMonitorMode().equals(hostType2.getMonitorMode())){
+ return true;
+ }
+ } else {
+ logger.error("This method is only impmlemented to handle Gsissh host types");
+ }
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/util/X509Helper.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/util/X509Helper.java b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/util/X509Helper.java
new file mode 100644
index 0000000..c29490a
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/gfac/monitor/util/X509Helper.java
@@ -0,0 +1,161 @@
+/*
+ *
+ * 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.util;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.ServerSettings;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.bouncycastle.openssl.PEMReader;
+
+import java.io.*;
+import java.security.*;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.CertificateParsingException;
+import java.security.cert.X509Certificate;
+import java.security.spec.InvalidKeySpecException;
+
+public class X509Helper {
+
+ static {
+ // parsing of RSA key fails without this
+ java.security.Security.addProvider(new BouncyCastleProvider());
+ }
+
+
+
+ public static KeyStore keyStoreFromPEM(String proxyFile,
+ String keyPassPhrase) throws IOException,
+ CertificateException,
+ NoSuchAlgorithmException,
+ InvalidKeySpecException,
+ KeyStoreException {
+ return keyStoreFromPEM(proxyFile,proxyFile,keyPassPhrase);
+ }
+
+ public static KeyStore keyStoreFromPEM(String certFile,
+ String keyFile,
+ String keyPassPhrase) throws IOException,
+ CertificateException,
+ NoSuchAlgorithmException,
+ InvalidKeySpecException,
+ KeyStoreException {
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ X509Certificate cert = (X509Certificate)cf.generateCertificate(new FileInputStream(certFile));
+ //System.out.println(cert.toString());
+
+ // this works for proxy files, too, since it skips over the certificate
+ BufferedReader reader = new BufferedReader(new FileReader(keyFile));
+ String line = null;
+ StringBuilder builder = new StringBuilder();
+ boolean inKey = false;
+ while((line=reader.readLine()) != null) {
+ if (line.contains("-----BEGIN RSA PRIVATE KEY-----")) {
+ inKey = true;
+ }
+ if (inKey) {
+ builder.append(line);
+ builder.append(System.getProperty("line.separator"));
+ }
+ if (line.contains("-----END RSA PRIVATE KEY-----")) {
+ inKey = false;
+ }
+ }
+ String privKeyPEM = builder.toString();
+ //System.out.println(privKeyPEM);
+
+ // using BouncyCastle
+ PEMReader pemParser = new PEMReader(new StringReader(privKeyPEM));
+ Object object = pemParser.readObject();
+
+ PrivateKey privKey = null;
+ if(object instanceof KeyPair){
+ privKey = ((KeyPair)object).getPrivate();
+ }
+ // PEMParser from BouncyCastle is good for reading PEM files, but I didn't want to add that dependency
+ /*
+ // Base64 decode the data
+ byte[] encoded = javax.xml.bind.DatatypeConverter.parseBase64Binary(privKeyPEM);
+
+ // PKCS8 decode the encoded RSA private key
+ java.security.spec.PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encoded);
+ KeyFactory kf = KeyFactory.getInstance("RSA");
+ PrivateKey privKey = kf.generatePrivate(keySpec);
+ //RSAPrivateKey privKey = (RSAPrivateKey)kf.generatePrivate(keySpec);
+ */
+ //System.out.println(privKey.toString());
+
+ KeyStore keyStore = KeyStore.getInstance("PKCS12");
+ keyStore.load(null,null);
+
+ KeyStore.PrivateKeyEntry entry =
+ new KeyStore.PrivateKeyEntry(privKey,
+ new java.security.cert.Certificate[] {(java.security.cert.Certificate)cert});
+ KeyStore.PasswordProtection prot = new KeyStore.PasswordProtection(keyPassPhrase.toCharArray());
+ keyStore.setEntry(cert.getSubjectX500Principal().getName(), entry, prot);
+
+ return keyStore;
+ }
+
+
+ public static KeyStore trustKeyStoreFromCertDir() throws IOException,
+ KeyStoreException,
+ CertificateException,
+ NoSuchAlgorithmException, ApplicationSettingsException {
+ return trustKeyStoreFromCertDir(ServerSettings.getSetting("trusted.cert.location"));
+ }
+
+ public static KeyStore trustKeyStoreFromCertDir(String certDir) throws IOException,
+ KeyStoreException,
+ CertificateException,
+ NoSuchAlgorithmException {
+ KeyStore ks = KeyStore.getInstance("JKS");
+ ks.load(null,null);
+
+ File dir = new File(certDir);
+ for(File file : dir.listFiles()) {
+ if (!file.isFile()) {
+ continue;
+ }
+ if (!file.getName().endsWith(".0")) {
+ continue;
+ }
+
+ try {
+ //System.out.println("reading file "+file.getName());
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ X509Certificate cert = (X509Certificate) cf.generateCertificate(new FileInputStream(file));
+ //System.out.println(cert.toString());
+
+ KeyStore.TrustedCertificateEntry entry = new KeyStore.TrustedCertificateEntry(cert);
+
+ ks.setEntry(cert.getSubjectX500Principal().getName(), entry, null);
+ } catch (KeyStoreException e) {
+ } catch (CertificateParsingException e) {
+ continue;
+ }
+
+ }
+
+ return ks;
+ }
+}
+
[3/9] Separating gfac-monitoring implementation
Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/errors.properties
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/errors.properties b/modules/gfac/gfac-monitor/src/main/resources/errors.properties
new file mode 100644
index 0000000..88c41b8
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/errors.properties
@@ -0,0 +1,197 @@
+#
+#
+# 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.
+#
+
+# Directly copied from jglobus. Not a good way to manager error properties.
+1 = Parameter not supported
+2 = The RSL length is greater than the maximum allowed
+3 = No resources available
+4 = Bad directory specified
+5 = The executable does not exist
+6 = Insufficient funds
+7 = Authentication with the remote server failed
+8 = Job cancelled by user
+9 = Job cancelled by system
+
+10 = Data transfer to the server failed
+11 = The stdin file does not exist
+12 = The connection to the server failed (check host and port)
+13 = The provided RSL 'maxtime' value is invalid (not an integer or must be greater than 0)
+14 = The provided RSL 'count' value is invalid (not an integer or must be greater than 0)
+15 = The job manager received an invalid RSL
+16 = Could not connect to job manager
+17 = The job failed when the job manager attempted to run it
+18 = Paradyn error
+19 = The provided RSL 'jobtype' value is invalid
+
+20 = The provided RSL 'myjob' value is invalid
+21 = The job manager failed to locate an internal script argument file
+22 = The job manager failed to create an internal script argument file
+23 = The job manager detected an invalid job state
+24 = The job manager detected an invalid script response
+25 = The job manager detected an invalid job state
+26 = The provided RSL 'jobtype' value is not supported by this job manager
+27 = Unimplemented
+28 = The job manager failed to create an internal script submission file
+29 = The job manager cannot find the user proxy
+
+30 = The job manager failed to open the user proxy
+31 = The job manager failed to cancel the job as requested
+32 = System memory allocation failed
+33 = The interprocess job communication initialization failed
+34 = The interprocess job communication setup failed
+35 = The provided RSL 'host count' value is invalid
+36 = One of the provided RSL parameters is unsupported
+37 = The provided RSL 'queue' parameter is invalid
+38 = The provided RSL 'project' parameter is invalid
+39 = The provided RSL string includes variables that could not be identified
+
+40 = The provided RSL 'environment' parameter is invalid
+41 = The provided RSL 'dryrun' parameter is invalid
+42 = The provided RSL is invalid (an empty string)
+43 = The job manager failed to stage the executable
+44 = The job manager failed to stage the stdin file
+45 = The requested job manager type is invalid
+46 = The provided RSL 'arguments' parameter is invalid
+47 = The gatekeeper failed to run the job manager
+48 = The provided RSL could not be properly parsed
+49 = There is a version mismatch between GRAM components
+
+50 = The provided RSL 'arguments' parameter is invalid
+51 = The provided RSL 'count' parameter is invalid
+52 = The provided RSL 'directory' parameter is invalid
+53 = The provided RSL 'dryrun' parameter is invalid
+54 = The provided RSL 'environment' parameter is invalid
+55 = The provided RSL 'executable' parameter is invalid
+56 = The provided RSL 'host_count' parameter is invalid
+57 = The provided RSL 'jobtype' parameter is invalid
+58 = The provided RSL 'maxtime' parameter is invalid
+59 = The provided RSL 'myjob' parameter is invalid
+
+60 = The provided RSL 'paradyn' parameter is invalid
+61 = The provided RSL 'project' parameter is invalid
+62 = The provided RSL 'queue' parameter is invalid
+63 = The provided RSL 'stderr' parameter is invalid
+64 = The provided RSL 'stdin' parameter is invalid
+65 = The provided RSL 'stdout' parameter is invalid
+66 = The job manager failed to locate an internal script
+67 = The job manager failed on the system call pipe()
+68 = The job manager failed on the system call fcntl()
+69 = The job manager failed to create the temporary stdout filename
+
+70 = The job manager failed to create the temporary stderr filename
+71 = The job manager failed on the system call fork()
+72 = The executable file permissions do not allow execution
+73 = The job manager failed to open stdout
+74 = The job manager failed to open stderr
+75 = The cache file could not be opened in order to relocate the user proxy
+76 = Cannot access cache files in ~/.globus/.gass_cache, check permissions, quota, and disk space
+77 = The job manager failed to insert the contact in the client contact list
+78 = The contact was not found in the job manager's client contact list
+79 = Connecting to the job manager failed. Possible reasons: job terminated, invalid job contact, network problems, ...
+
+80 = The syntax of the job contact is invalid
+81 = The executable parameter in the RSL is undefined
+82 = The job manager service is misconfigured. condor arch undefined
+83 = The job manager service is misconfigured. condor os undefined
+84 = The provided RSL 'min_memory' parameter is invalid
+85 = The provided RSL 'max_memory' parameter is invalid
+86 = The RSL 'min_memory' value is not zero or greater
+87 = The RSL 'max_memory' value is not zero or greater
+88 = The creation of a HTTP message failed
+89 = Parsing incoming HTTP message failed
+
+90 = The packing of information into a HTTP message failed
+91 = An incoming HTTP message did not contain the expected information
+92 = The job manager does not support the service that the client requested
+93 = The gatekeeper failed to find the requested service
+94 = The jobmanager does not accept any new requests (shutting down)
+95 = The client failed to close the listener associated with the callback URL
+96 = The gatekeeper contact cannot be parsed
+97 = The job manager could not find the 'poe' command
+98 = The job manager could not find the 'mpirun' command
+99 = The provided RSL 'start_time' parameter is invalid"
+100 = The provided RSL 'reservation_handle' parameter is invalid
+
+101 = The provided RSL 'max_wall_time' parameter is invalid
+102 = The RSL 'max_wall_time' value is not zero or greater
+103 = The provided RSL 'max_cpu_time' parameter is invalid
+104 = The RSL 'max_cpu_time' value is not zero or greater
+105 = The job manager is misconfigured, a scheduler script is missing
+106 = The job manager is misconfigured, a scheduler script has invalid permissions
+107 = The job manager failed to signal the job
+108 = The job manager did not recognize/support the signal type
+109 = The job manager failed to get the job id from the local scheduler
+
+110 = The job manager is waiting for a commit signal
+111 = The job manager timed out while waiting for a commit signal
+112 = The provided RSL 'save_state' parameter is invalid
+113 = The provided RSL 'restart' parameter is invalid
+114 = The provided RSL 'two_phase' parameter is invalid
+115 = The RSL 'two_phase' value is not zero or greater
+116 = The provided RSL 'stdout_position' parameter is invalid
+117 = The RSL 'stdout_position' value is not zero or greater
+118 = The provided RSL 'stderr_position' parameter is invalid
+119 = The RSL 'stderr_position' value is not zero or greater
+
+120 = The job manager restart attempt failed
+121 = The job state file doesn't exist
+122 = Could not read the job state file
+123 = Could not write the job state file
+124 = The old job manager is still alive
+125 = The job manager state file TTL expired
+126 = It is unknown if the job was submitted
+127 = The provided RSL 'remote_io_url' parameter is invalid
+128 = Could not write the remote io url file
+129 = The standard output/error size is different
+
+130 = The job manager was sent a stop signal (job is still running)
+131 = The user proxy expired (job is still running)
+132 = The job was not submitted by original jobmanager
+133 = The job manager is not waiting for that commit signal
+134 = The provided RSL scheduler specific parameter is invalid
+135 = The job manager could not stage in a file
+136 = The scratch directory could not be created
+137 = The provided 'gass_cache' parameter is invalid
+138 = The RSL contains attributes which are not valid for job submission
+139 = The RSL contains attributes which are not valid for stdio update
+
+140 = The RSL contains attributes which are not valid for job restart
+141 = The provided RSL 'file_stage_in' parameter is invalid
+142 = The provided RSL 'file_stage_in_shared' parameter is invalid
+143 = The provided RSL 'file_stage_out' parameter is invalid
+144 = The provided RSL 'gass_cache' parameter is invalid
+145 = The provided RSL 'file_cleanup' parameter is invalid
+146 = The provided RSL 'scratch_dir' parameter is invalid
+147 = The provided scheduler-specific RSL parameter is invalid
+148 = A required RSL attribute was not defined in the RSL spec
+149 = The gass_cache attribute points to an invalid cache directory
+
+150 = The provided RSL 'save_state' parameter has an invalid value
+151 = The job manager could not open the RSL attribute validation file
+152 = The job manager could not read the RSL attribute validation file
+153 = The provided RSL 'proxy_timeout' is invalid
+154 = The RSL 'proxy_timeout' value is not greater than zero
+155 = The job manager could not stage out a file
+156 = The job contact string does not match any which the job manager is handling
+157 = Proxy delegation failed
+158 = The job manager could not lock the state lock file
+
+1000 = Failed to start up callback handler
+1003 = Job contact not set
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/AccessPolicy.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/AccessPolicy.json b/modules/gfac/gfac-monitor/src/main/resources/schema/AccessPolicy.json
new file mode 100644
index 0000000..8f6cfe1
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/AccessPolicy.json
@@ -0,0 +1,13 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/AccessPolicy.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Policy.json"}],
+ "properties": {
+ "EndpointID": {
+ "type": "string",
+ "description": "The ID of the Endpoint this AccessPolicy is for"
+ }
+ },
+ "required": ["EndpointID"]
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/Activity.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/Activity.json b/modules/gfac/gfac-monitor/src/main/resources/schema/Activity.json
new file mode 100644
index 0000000..8bd2495
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/Activity.json
@@ -0,0 +1,31 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Activity.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Entity.json"}],
+ "properties": {
+ "UserDomainID": {
+ "type": "string",
+ "description": "An ID"
+ },
+ "EndpointID": {
+ "type": "string",
+ "description": "The ID of the Endpoint managing Activity"
+ },
+ "ShareID": {
+ "type": "string",
+ "description": "The ID of the Share servicing this Activity"
+ },
+ "ResourceID": {
+ "type": "string",
+ "description": "The ID of the Resource executing this Activity"
+ },
+ "ActivityID": {
+ "type": "array",
+ "description": "The IDs of other Activities related to this one",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/AdminDomain.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/AdminDomain.json b/modules/gfac/gfac-monitor/src/main/resources/schema/AdminDomain.json
new file mode 100644
index 0000000..8ed4606
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/AdminDomain.json
@@ -0,0 +1,51 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/AdminDomain.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Domain.json"}],
+ "properties": {
+ "Distributed": {
+ "type": "boolean",
+ "description": "true if the services managed by the AdminDomain are geographically distributed"
+ },
+ "Owner": {
+ "type": "array",
+ "description": "Identification of persons or legal entities that own the resources in this AdminDomain",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ServiceID": {
+ "type": "array",
+ "description": "IDs of Services in this AdminDomain",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ChildDomainID": {
+ "type": "array",
+ "description": "IDs of AdminDomains aggregated by this AdminDomain",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ParentDomainID": {
+ "type": "string",
+ "description": "The ID of the AdminDomain that this AdminDomain participates in"
+ },
+ "ComputingServiceID": {
+ "type": "array",
+ "description": "IDs of ComputingServices in this AdminDomain",
+ "items": {
+ "type": "string"
+ }
+ },
+ "StorageServiceID": {
+ "type": "array",
+ "description": "IDs of StorageServices in this AdminDomain",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/ApplicationEnvironment.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/ApplicationEnvironment.json b/modules/gfac/gfac-monitor/src/main/resources/schema/ApplicationEnvironment.json
new file mode 100644
index 0000000..89c78e0
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/ApplicationEnvironment.json
@@ -0,0 +1,86 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/ApplicationEnvironment.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Entity.json"}],
+ "properties": {
+ "AppName": {
+ "type": "string",
+ "description": "The name of the application"
+ },
+ "AppVersion": {
+ "type": "string",
+ "description": "The version of the application"
+ },
+ "State": {
+ "type": "string",
+ "description": "The current installation state of the application - AppEnvState_t"
+ },
+ "RemovalDate": {
+ "type": "string",
+ "description": "The date/time after which the application may be removed - DateTime_t"
+ },
+ "License": {
+ "type": "string",
+ "description": "The license under which the application is usable - License_t"
+ },
+ "Description": {
+ "type": "string",
+ "description": "A human-readable description of the application"
+ },
+ "BestBenchmark": {
+ "type": "array",
+ "description": "The type(s) of the benchmarks which best describe the sensitivity of this application to the performance of the ExecutionEnvironment - Benchmark_t",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ParallelSupport": {
+ "type": "string",
+ "description": "The type of supported parallel execution - ParallelSupport_t"
+ },
+ "MaxSlots": {
+ "type": "integer",
+ "description": "The maximum number of concurrent slots that may be used to run the application"
+ },
+ "MaxJobs": {
+ "type": "integer",
+ "description": "The maximum number of concurrent jobs that can run the application"
+ },
+ "MaxUserSeats": {
+ "type": "integer",
+ "description": "The maximum number of concurrent users that can run the application"
+ },
+ "FreeSlots": {
+ "type": "integer",
+ "description": "The maximum number slots currently available to run the application"
+ },
+ "FreeJobs": {
+ "type": "integer",
+ "description": "The maximum number of additional jobs that can run the application"
+ },
+ "FreeUserSeats": {
+ "type": "integer",
+ "description": "The maximum number of additional users that can run the application"
+ },
+ "ExecutionEnvironmentID": {
+ "type": "array",
+ "description": "ID(s) of ExecutionEnvironments where this ApplicationEnvironment can be used",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ComputingManagerID": {
+ "type": "string",
+ "description": "ID of the ComputingManager this ApplicationEnvironment is associated with"
+ },
+ "ApplicationHandleID": {
+ "type": "array",
+ "description": "ID(s) of the ApplicationHandles that can be used to refer to this environment",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ "required": ["AppName","ComputingManagerID"]
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/ApplicationHandle.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/ApplicationHandle.json b/modules/gfac/gfac-monitor/src/main/resources/schema/ApplicationHandle.json
new file mode 100644
index 0000000..e7972e9
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/ApplicationHandle.json
@@ -0,0 +1,21 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/ApplicationHandle.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Entity.json"}],
+ "properties": {
+ "Type": {
+ "type": "string",
+ "description": "The type of method used to set up an ApplicationEnvironment - ApplicationHandle_t (open enumeration)"
+ },
+ "Value": {
+ "type": "string",
+ "description": "How to set up the ApplicationEnvironment in the context of the Type"
+ },
+ "ApplicationEnvironmentID": {
+ "type": "string",
+ "description": "The ID of the ApplicationEnvironment this ApplicationHandle refers to"
+ }
+ },
+ "required": ["Type","Value","ApplicationEnvironmentID"]
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/Benchmark.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/Benchmark.json b/modules/gfac/gfac-monitor/src/main/resources/schema/Benchmark.json
new file mode 100644
index 0000000..2b64261
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/Benchmark.json
@@ -0,0 +1,21 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Benchmark.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Entity.json"}],
+ "properties": {
+ "Type": {
+ "type": "string",
+ "description": "The type of the benchmark - Benchmark_t (open enumeration)"
+ },
+ "Value": {
+ "type": "number",
+ "description": "The value of the benchmark"
+ },
+ "ComputingManagerID": {
+ "type": "string",
+ "description": "The ID of the ComputingManager this benchmark is for"
+ }
+ },
+ "required": ["Type","Value"]
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/ComputingActivity.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/ComputingActivity.json b/modules/gfac/gfac-monitor/src/main/resources/schema/ComputingActivity.json
new file mode 100644
index 0000000..5fcae72
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/ComputingActivity.json
@@ -0,0 +1,165 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/ComputingActivity.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Activity.json"}],
+ "properties": {
+ "Type": {
+ "type": "string",
+ "description": "closed enumeration ComputingActivityType_t",
+ "enum": ["collectionelement","parallelelement","single","workflownode"]
+ },
+ "IDFromEndpoint": {
+ "type": "string",
+ "description": "The ID assigned by the ComputingEndpoint"
+ },
+ "LocalIDFromManager": {
+ "type": "string",
+ "description": "The local ID assigned by the ComputingManager"
+ },
+ "State": {
+ "type": "array",
+ "description": "open enumeration ComputingActivityState_t",
+ "items": {
+ "type": "string"
+ },
+ "minItems": 1
+ },
+ "RestartState": {
+ "type": "array",
+ "description": "open enumeration ComputingActivityState_t",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ExitCode": {
+ "type": "integer",
+ "description": "The exit code as returned by the main executable code or script of the job"
+ },
+ "ComputingManagerExitCode": {
+ "type": "string",
+ "description": "The exit code provided by the ComputingManager"
+ },
+ "Error": {
+ "type": "array",
+ "description": "The error messages as provided by the software components involved in the management of the job",
+ "items": {
+ "type": "string"
+ }
+ },
+ "WaitingPosition": {
+ "type": "integer",
+ "description": "The position of the job in the queue, if the job is waiting"
+ },
+ "Owner": {
+ "type": "string",
+ "description": "The Grid identity of the job's owner"
+ },
+ "LocalOwner": {
+ "type": "string",
+ "description": "The local user name of the job's owner"
+ },
+ "RequestedTotalWallTime": {
+ "type": "integer",
+ "description": "The total wall clock time requested by the job"
+ },
+ "RequestedTotalCPUTime": {
+ "type": "integer",
+ "description": "The total CPU time requested by the job"
+ },
+ "RequestedSlots": {
+ "type": "integer",
+ "description": "The number of slots requested for the job"
+ },
+ "RequestedApplicationEnvironment": {
+ "type": "array",
+ "description": "The AppName and Version of the requested ApplicationEnvironments",
+ "items": {
+ "type": "string"
+ }
+ },
+ "StdIn": {
+ "type": "string",
+ "description": "The name of the file used for standard input"
+ },
+ "StdOut": {
+ "type": "string",
+ "description": "The name of the file used for standard output"
+ },
+ "StdErr": {
+ "type": "string",
+ "description": "The name of the file used for standard error"
+ },
+ "LogDir": {
+ "type": "string",
+ "description": "The name of the directory which contains job logs"
+ },
+ "ExecutionNode": {
+ "type": "array",
+ "description": "Hostnames associated with the ExecutionEnvironments running the job",
+ "items": {
+ "type": "string"
+ }
+ },
+ "Queue": {
+ "type": "string",
+ "description": "The name of the ComputingManager queue that held the job before execution"
+ },
+ "UsedTotalWallTime": {
+ "type": "integer",
+ "description": "The total wall clock time consumed by the job so far (slots*seconds)"
+ },
+ "UsedTotalCpuTime": {
+ "type": "integer",
+ "description": "The total CPU time consumed by the job so far (seconds)"
+ },
+ "UsedMainMemory": {
+ "type": "integer",
+ "description": "The physical RAM currently used by the job (MB)"
+ },
+ "SubmissionTime": {
+ "type": "string",
+ "description": "The time when the job was submitted to the ComputingEndpoint (DateTime_t)"
+ },
+ "ComputingManagerSubmissionTime": {
+ "type": "string",
+ "description": "The time when the job was submitted to the ComputingManager (DateTime_t)"
+ },
+ "StartTime": {
+ "type": "string",
+ "description": "The time when the ComputingManager started the job (DateTime_t)"
+ },
+ "EndTime": {
+ "type": "string",
+ "description": "The time when the job ended in the Grid layer (DateTime_t)"
+ },
+ "ComputingManagerEndTime": {
+ "type": "string",
+ "description": "The time when the job ended according to the ComputingManager (DateTime_t)"
+ },
+ "WorkingAreaEraseTime": {
+ "type": "string",
+ "description": "The time when working area will be removed from storage (DateTime_t)"
+ },
+ "ProxyExpirationTime": {
+ "type": "string",
+ "description": "The expiration time of the Grid proxy associated with the job (DateTime_t)"
+ },
+ "SubmissionHost": {
+ "type": "string",
+ "description": "The name of the host from which the job was submitted"
+ },
+ "SubmissionClientName": {
+ "type": "string",
+ "description": "The name of the software client used to submit the job"
+ },
+ "OtherMessages": {
+ "type": "array",
+ "description": "Optional messages provided by either the Grid layer or the ComputingManager",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ "required": ["State","Owner"]
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/ComputingEndpoint.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/ComputingEndpoint.json b/modules/gfac/gfac-monitor/src/main/resources/schema/ComputingEndpoint.json
new file mode 100644
index 0000000..f94f889
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/ComputingEndpoint.json
@@ -0,0 +1,44 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/ComputingEndpoint.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Endpoint.json"}],
+ "properties": {
+ "Staging": {
+ "type": "string",
+ "description": "Supported file staging functionality - Staging_t",
+ "enum": ["none","stagingin","staginginout","stagingout"]
+ },
+ "JobDescription": {
+ "type": "array",
+ "description": "Supported job description languages - JobDescription_t (open Enumeration)",
+ "items": {
+ "type": "string"
+ }
+ },
+ "TotalJobs": {
+ "type": "integer",
+ "description": "The total number of Grid jobs known to the system"
+ },
+ "RunningJobs": {
+ "type": "integer",
+ "description": "The number of Grid jobs which are running in an ExecutionEnvironment"
+ },
+ "WaitingJobs": {
+ "type": "integer",
+ "description": "The number of Grid jobs which are waiting to start executing"
+ },
+ "StagingJobs": {
+ "type": "integer",
+ "description": "The number of Grid jobs staging files before or after execution"
+ },
+ "SuspendedJobs": {
+ "type": "integer",
+ "description": "The number of Grid jobs that started to execute, but are now suspended"
+ },
+ "PreLRMSWaitingJobs": {
+ "type": "integer",
+ "description": "The number of Grid jobs managed by the Grid software, but not yet passed to the LRMS"
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/ComputingManager.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/ComputingManager.json b/modules/gfac/gfac-monitor/src/main/resources/schema/ComputingManager.json
new file mode 100644
index 0000000..aecb114
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/ComputingManager.json
@@ -0,0 +1,117 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/ComputingManager.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Share.json"}],
+ "properties": {
+ "Reservation": {
+ "type": "boolean",
+ "description": "Whether advance reservation is supported (no value implies undefined in ExtendedBoolean_t)"
+ },
+ "BulkSubmission": {
+ "type": "boolean",
+ "description": "Whether multiple jobs can be submitted at once (no value implies undefined in ExtendedBoolean_t)"
+ },
+ "TotalPhysicalCPUs": {
+ "type": "integer",
+ "description": "The total number of physical CPUs managed by this ComputingManager"
+ },
+ "TotalLogicalCPUs": {
+ "type": "integer",
+ "description": "The total number of logical CPUs managed by this ComputingManager"
+ },
+ "TotalSlots": {
+ "type": "integer",
+ "description": "The total number of slots managed by this ComputingManager"
+ },
+ "SlotsUsedByLocalJobs": {
+ "type": "integer",
+ "description": "The number of slots currently used by jobs submitted via a non-Grid interface"
+ },
+ "SlotsUsedByGridJobs": {
+ "type": "integer",
+ "description": "The number of slots currently used by jobs submitted via a non-Grid interface"
+ },
+ "Homogeneous": {
+ "type": "boolean",
+ "description": "Whether this ComputingManager manages only one type of ExecutionEnvironment"
+ },
+ "NetworkInfo": {
+ "type": "array",
+ "description": "The types of internal network connections between ExecutionEnvironments (NetworkInfo_t)",
+ "items": {
+ "type": "string"
+ }
+ },
+ "LocalCPUDistribution": {
+ "type": "boolean",
+ "description": "Classification of the managed ExecutionEnvironments aggregated by the number of logical CPUs"
+ },
+ "WorkingAreaShared": {
+ "type": "boolean",
+ "description": "True if the working area is shared across different ExecutionEnvironments"
+ },
+ "WorkingAreaGuaranteed": {
+ "type": "boolean",
+ "description": "True if the job is guaranteed all of WorkingAreaTotal"
+ },
+ "WorkingAreaTotal": {
+ "type": "integer",
+ "description": "Total size of the working area available to single slot jobs (GB)"
+ },
+ "WorkingAreaFree": {
+ "type": "integer",
+ "description": "The amount of free space in the working area (GB)"
+ },
+ "WorkingAreaLifeTime": {
+ "type": "integer",
+ "description": "The minimum guaranteed lifetime of files created in the working area (seconds)"
+ },
+ "WorkingAreaMultiSlotTotal": {
+ "type": "integer",
+ "description": "The total size of the working area across all ExecutionEnvironments (GB)"
+ },
+ "WorkingAreaMultiSlotFree": {
+ "type": "integer",
+ "description": "The available space in the working area across all ExecutionEnvironments (GB)"
+ },
+ "WorkingAreaMultiSlotLifeTime": {
+ "type": "integer",
+ "description": "The minimum guaranteed lifetime of files created in the working area (seconds)"
+ },
+ "CacheTotal": {
+ "type": "integer",
+ "description": "If local caching of input files is supported, the total size of the area they may be stored in"
+ },
+ "CacheFree": {
+ "type": "integer",
+ "description": "If local caching of input files is supported, the available size of the area they may be stored in"
+ },
+ "TmpDir": {
+ "type": "string",
+ "description": "The absolute path of a temporary directory local to an ExecutionEnvironment"
+ },
+ "ScratchDir": {
+ "type": "string",
+ "description": "The absolute path of a shared directory available for application data"
+ },
+ "ApplicationDir": {
+ "type": "string",
+ "description": "The absolute path of a directory available for installation of persistent application software"
+ },
+ "ApplicationEnvironmentID": {
+ "type": "array",
+ "description": "ID(s) of ApplicationEnvironments provided by this ComputingManager",
+ "items": {
+ "type": "string"
+ }
+ },
+ "BenchmarkID": {
+ "type": "array",
+ "description": "ID(s) of Benchmarks associated with this ComputingManager",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/ComputingService.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/ComputingService.json b/modules/gfac/gfac-monitor/src/main/resources/schema/ComputingService.json
new file mode 100644
index 0000000..9cfde1b
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/ComputingService.json
@@ -0,0 +1,32 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/ComputingService.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Service.json"}],
+ "properties": {
+ "TotalJobs": {
+ "type": "integer",
+ "description": "The total number of Grid jobs known to the system"
+ },
+ "RunningJobs": {
+ "type": "integer",
+ "description": "The number of Grid jobs which are running in an ExecutionEnvironment"
+ },
+ "WaitingJobs": {
+ "type": "integer",
+ "description": "The number of Grid jobs which are waiting to start executing"
+ },
+ "StagingJobs": {
+ "type": "integer",
+ "description": "The number of Grid jobs staging files before or after execution"
+ },
+ "SuspendedJobs": {
+ "type": "integer",
+ "description": "The number of Grid jobs that started to execute, but are now suspended"
+ },
+ "PreLRMSWaitingJobs": {
+ "type": "integer",
+ "description": "The number of Grid jobs managed by the Grid software, but not yet passed to the LRMS"
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/ComputingShare.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/ComputingShare.json b/modules/gfac/gfac-monitor/src/main/resources/schema/ComputingShare.json
new file mode 100644
index 0000000..340c83e
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/ComputingShare.json
@@ -0,0 +1,182 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/ComputingShare.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Share.json"}],
+ "properties": {
+ "MappingQueue": {
+ "type": "string",
+ "description": "The name of the queue in the LRMS where jobs in this share are submitted"
+ },
+ "MaxWallTime": {
+ "type": "integer",
+ "description": "The maximum wall clock time that a single-slot job can run (seconds)"
+ },
+ "MaxMultiSlotWallTime": {
+ "type": "integer",
+ "description": "The maximum wall clock time that a multi-slot job can run (seconds)"
+ },
+ "DefaultWallTime": {
+ "type": "integer",
+ "description": "The default wall clock per slot assumed by the LRMS if a maximum time is not specified (seconds)"
+ },
+ "MaxCPUTime": {
+ "type": "integer",
+ "description": "The maximum pre-slot CPU time that a job can request (seconds)"
+ },
+ "MaxTotalCPUTime": {
+ "type": "integer",
+ "description": "The maximum amount of CPU time that a job can request across all slots assigned to it (seconds)"
+ },
+ "MinCPUTime": {
+ "type": "integer",
+ "description": "The minimum pre-slot CPU time that a job can request (seconds)"
+ },
+ "DefaultCPUTime": {
+ "type": "integer",
+ "description": "The default CPU time limit assumed by the LRMS if a maximum time is not specified (seconds)"
+ },
+ "MaxTotalJobs": {
+ "type": "integer",
+ "description": "The maximum number of jobs that can be in this Share"
+ },
+ "MaxRunningJobs": {
+ "type": "integer",
+ "description": "The maximum number of jobs that can be running in this Share"
+ },
+ "MaxWaitingJobs": {
+ "type": "integer",
+ "description": "The maximum number of jobs that can be waiting in this Share"
+ },
+ "MaxPreLRMSWaitingJobs": {
+ "type": "integer",
+ "description": "The maximum number of jobs that can be waiting in the Grid layer for this Share"
+ },
+ "MaxUserRunningJobs": {
+ "type": "integer",
+ "description": "The maximum number of jobs that can be running in this Share per user"
+ },
+ "MaxSlotsPerJob": {
+ "type": "integer",
+ "description": "The maximum number of slots that can be allocated to a single job in this Share"
+ },
+ "MaxStageInStreams": {
+ "type": "integer",
+ "description": "The maximum number of streams available to stage files in"
+ },
+ "MaxStageOutStreams": {
+ "type": "integer",
+ "description": "The maximum number of streams available to stage files out"
+ },
+ "ScheduingPolicy": {
+ "type": "string",
+ "description": "The scheduling policy used by the share - SchedulingPolicy_t (open enumeration)"
+ },
+ "MaxMainMemory": {
+ "type": "integer",
+ "description": "The maximum amount of physical RAM that a job can use (MB)"
+ },
+ "GuaranteedMainMemory": {
+ "type": "integer",
+ "description": "The amount of physical RAM that a job will have available (MB)"
+ },
+ "MaxVirtualMemory": {
+ "type": "integer",
+ "description": "The maximum amount memory (RAM+swap) that a job can use (MB)"
+ },
+ "GuaranteedVirtualMemory": {
+ "type": "integer",
+ "description": "The amount of memory (RAM+swap) that a job will have available (MB)"
+ },
+ "MaxDiskSpace": {
+ "type": "integer",
+ "description": "The maximum disk space that a job can use in the working area (GB)"
+ },
+ "DefaultStorageServiceID": {
+ "type": "string",
+ "description": "The ID of the default StorageService used to store files"
+ },
+ "Preemption": {
+ "type": "boolean",
+ "description": "Whether jobs can be preempted and resumed (no value implies undefined in ExtendedBoolean_t)"
+ },
+ "ServingState": {
+ "type": "string",
+ "description": "How the Share is currently serving jobs",
+ "enum": ["closed","draining","production","queueing"]
+ },
+ "TotalJobs": {
+ "type": "integer",
+ "description": "The total number of jobs in any state"
+ },
+ "RunningJobs": {
+ "type": "integer",
+ "description": "The number of running jobs submitted through Grid or non-Grid interfaces"
+ },
+ "LocalRunningJobs": {
+ "type": "integer",
+ "description": "The number of running jobs submitted using non-Grid interfaces"
+ },
+ "WaitingJobs": {
+ "type": "integer",
+ "description": "The number of waiting jobs submitted through Grid or non-Grid interfaces"
+ },
+ "LocalWaitingJobs": {
+ "type": "integer",
+ "description": "The number of waiting jobs submitted using non-Grid interfaces"
+ },
+ "SuspendedJobs": {
+ "type": "integer",
+ "description": "The number of suspended jobs submitted through Grid or non-Grid interfaces"
+ },
+ "LocalSuspendedJobs": {
+ "type": "integer",
+ "description": "The number of suspended jobs submitted using non-Grid interfaces"
+ },
+ "StagingJobs": {
+ "type": "integer",
+ "description": "The number of jobs staging files before or after execution"
+ },
+ "PreLRMSWaitingJobs": {
+ "type": "integer",
+ "description": "The number of Grid jobs which have not yet been passed to the LRMS"
+ },
+ "EstimatedAverageWaitingTime": {
+ "type": "integer",
+ "description": "An estimate of the average time a job will wait before it starts to execute (seconds)"
+ },
+ "EstimatedWorstWaitingTime": {
+ "type": "integer",
+ "description": "An estimate of the worst-case time a job will wait before it starts to execute (seconds)"
+ },
+ "FreeSlots": {
+ "type": "integer",
+ "description": "The number of slots which are currently available for use"
+ },
+ "FreeSlotsWithDuration": {
+ "type": "string",
+ "description": "The number of slots which are currently available for use and how long they are available"
+ },
+ "UsedSlots": {
+ "type": "integer",
+ "description": "The number of slots currently in use"
+ },
+ "RequestedSlots": {
+ "type": "integer",
+ "description": "The number of slots needd to execute all waiting and staging jobs"
+ },
+ "ReservationPolicy": {
+ "type": "string",
+ "description": "The policy used for advance reservation - ReservationPolicy_t",
+ "enum": ["mandatory","none","optional"]
+ },
+ "Tag": {
+ "type": "array",
+ "description": "UserDomain-defined tags for this Share",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ "required": ["ServingState"]
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/Contact.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/Contact.json b/modules/gfac/gfac-monitor/src/main/resources/schema/Contact.json
new file mode 100644
index 0000000..436b262
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/Contact.json
@@ -0,0 +1,32 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Contact.json",
+ "description": "A GLUE 2 Contact",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Entity.json"}],
+ "properties": {
+ "Detail": {
+ "type": "string",
+ "description": "A URI embedding the contact information"
+ },
+ "Type": {
+ "type": "string",
+ "description": "closed enumeration ContactType_t",
+ "enum": ["general","security","sysadmin","usersupport"]
+ },
+ "ServiceID": {
+ "type": "array",
+ "description": "The IDs of Services associated with this Contact",
+ "items": {
+ "type": "string"
+ }
+ },
+ "DomainID": {
+ "type": "array",
+ "description": "The IDs of Domains associated with this Contact",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/DataStore.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/DataStore.json b/modules/gfac/gfac-monitor/src/main/resources/schema/DataStore.json
new file mode 100644
index 0000000..8f15447
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/DataStore.json
@@ -0,0 +1,30 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/DataStore.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Resource.json"}],
+ "properties": {
+ "Type": {
+ "type": "string",
+ "description": "The type of storage medium - DataStoreType_t (disk,optical,tape,...)"
+ },
+ "Latency": {
+ "type": "string",
+ "description": "The latency category under normal operating conditions - AccessLatency_t",
+ "enum": ["nearline","offline","online"]
+ },
+ "TotalSize": {
+ "type": "integer",
+ "description": "The total amount of storage (GB)"
+ },
+ "FreeSize": {
+ "type": "integer",
+ "description": "The amount of available storage (GB)"
+ },
+ "UsedSize": {
+ "type": "integer",
+ "description": "The amount of used storage (GB)"
+ }
+ },
+ "required": ["Type","Latency"]
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/Domain.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/Domain.json b/modules/gfac/gfac-monitor/src/main/resources/schema/Domain.json
new file mode 100644
index 0000000..5bd996b
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/Domain.json
@@ -0,0 +1,30 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Domain.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Entity.json"}],
+ "properties": {
+ "Description": {
+ "type": "string",
+ "description": "A description of the Domain"
+ },
+ "WWW": {
+ "type": "array",
+ "description": "URLs of web pages with more information about the Domain",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ContactID": {
+ "type": "array",
+ "description": "IDs of Contacts for this Domain",
+ "items": {
+ "type": "string"
+ }
+ },
+ "LocationID": {
+ "type": "string",
+ "description": "The ID of the primary Location for this Domain"
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/Endpoint.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/Endpoint.json b/modules/gfac/gfac-monitor/src/main/resources/schema/Endpoint.json
new file mode 100644
index 0000000..b75b02a
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/Endpoint.json
@@ -0,0 +1,147 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Endpoint.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Entity.json"}],
+ "properties": {
+ "URL": {
+ "type": "string",
+ "description": "Network location of the endpoint"
+ },
+ "Capability": {
+ "type": "array",
+ "description": "Capability_t (open enumeration)",
+ "items": {
+ "type": "string"
+ }
+ },
+ "Technology": {
+ "type": "string",
+ "description": "EndpointTechnology_t"
+ },
+ "InterfaceName": {
+ "type": "string",
+ "description": "InterfaceName_t"
+ },
+ "InterfaceVersion": {
+ "type": "string",
+ "description": "The version of the primary interface protocol (free format)"
+ },
+ "InterfaceExtension": {
+ "type": "array",
+ "description": "URIs identifying supported extensions to the interface protocol",
+ "items": {
+ "type": "string"
+ }
+ },
+ "WSDL": {
+ "type": "array",
+ "description": "URLs of WSDL document(s) describing the interface",
+ "items": {
+ "type": "string"
+ }
+ },
+ "SupportedProfile": {
+ "type": "array",
+ "description": "URI(s) identifying supported profiles for the Endpoint",
+ "items": {
+ "type": "string"
+ }
+ },
+ "Semantics": {
+ "type": "array",
+ "description": "URL(s) of documents providing human-readable descriptions of the semantics of the Endpoint",
+ "items": {
+ "type": "string"
+ }
+ },
+ "Implementor": {
+ "type": "string",
+ "description": "The name of the main organization implementing the Endpoint"
+ },
+ "ImplementationName": {
+ "type": "string",
+ "description": "The name of the implementation of the Endpoint"
+ },
+ "ImplementationVersion": {
+ "type": "string",
+ "description": "The version of the implementation of the Endpoint"
+ },
+ "QualityLevel": {
+ "type": "string",
+ "description": "QualityLevel_t",
+ "enum": ["development","pre-production","production","testing"]
+ },
+ "HealthState": {
+ "type": "string",
+ "description": "The operational status of the Endpoint",
+ "enum": ["critical","ok","other","unknown","warning"]
+ },
+ "HealthStateInfo": {
+ "type": "string",
+ "description": "A human-readable explanation of the HealthState of this Endpoint"
+ },
+ "ServingState": {
+ "type": "string",
+ "description": "If the endpoint is accepting and serving requests",
+ "enum": ["closed","draining","production","queueing"]
+ },
+ "StartTime": {
+ "type": "string",
+ "description": "The start time of the Service associated with this Endpoint (DateTime_t)"
+ },
+ "IssuerCA": {
+ "type": "string",
+ "description": "The DN of the CA issuing the certificate presented by this Endpoint"
+ },
+ "TrustedCA": {
+ "type": "array",
+ "description": "DN(s) of CAs trusted by this Endpoint",
+ "items": {
+ "type": "string"
+ }
+ },
+ "DowntimeAnnounce": {
+ "type": "string",
+ "description": "When the next scheduled downtime was announced (DateTime_t)"
+ },
+ "DowntimeStart": {
+ "type": "string",
+ "description": "When the next scheduled downtime will start (DateTime_t)"
+ },
+ "DowntimeEnd": {
+ "type": "string",
+ "description": "When the next scheduled downtime will end (DateTime_t)"
+ },
+ "DowntimeInfo": {
+ "type": "string",
+ "description": "Human-readable of the next scheduled downtime"
+ },
+ "ServiceID": {
+ "type": "string",
+ "description": "The ID of the Service associated with this Endpoint"
+ },
+ "ShareID": {
+ "type": "array",
+ "description": "The IDs of the Shares accessible from this Endpoint",
+ "items": {
+ "type": "string"
+ }
+ },
+ "AccessPolicyID": {
+ "type": "array",
+ "description": "IDs of AccessPolicies associated with this Endpoint",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ActivityID": {
+ "type": "array",
+ "description": "IDs of Activities being managed through this Endpoint",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ "required": ["InterfaceName","QualityLevel","HealthState","ServingState","ServiceID"]
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/Entity.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/Entity.json b/modules/gfac/gfac-monitor/src/main/resources/schema/Entity.json
new file mode 100644
index 0000000..5d1ae46
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/Entity.json
@@ -0,0 +1,35 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Entity.json",
+ "type": "object",
+ "properties": {
+ "CreationTime": {
+ "type": "string",
+ "description": "The creation time of this entity in the format: CCYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm]"
+ },
+ "Validity": {
+ "type": "integer",
+ "description": "The number of seconds after CreationTime that this entity should be considered relevant"
+ },
+ "ID": {
+ "type": "string",
+ "description": "A globally unique identifier for this entity"
+ },
+ "Name": {
+ "type": "string",
+ "description": "A human-readable name"
+ },
+ "OtherInfo": {
+ "type": "array",
+ "description": "Placeholder for information that does not fit in any other attribute",
+ "items": {
+ "type": "string"
+ }
+ },
+ "Extension": {
+ "type": "object",
+ "description": "Key/value pairs enabling the association of extra information not captured by the model"
+ }
+ },
+ "required": ["ID"]
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/ExecutionEnvironment.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/ExecutionEnvironment.json b/modules/gfac/gfac-monitor/src/main/resources/schema/ExecutionEnvironment.json
new file mode 100644
index 0000000..77bf876
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/ExecutionEnvironment.json
@@ -0,0 +1,115 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/ExecutionEnvironment.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Resource.json"}],
+ "properties": {
+ "Platform": {
+ "type": "string",
+ "description": "The platform architecture - Platform_t (open enumeration)"
+ },
+ "VirtualMachine": {
+ "type": "boolean",
+ "description": "True if the ExecutionEnvironment is a virtual machine"
+ },
+ "TotalInstances": {
+ "type": "integer",
+ "description": "The total number of ExecutionEnvironment instances"
+ },
+ "UsedInstances": {
+ "type": "integer",
+ "description": "The number of ExecutionEnvironment instances in use"
+ },
+ "UnavailableInstances": {
+ "type": "integer",
+ "description": "The number of ExecutionEnvironment instances that are unavailable"
+ },
+ "PhysicalCPUs": {
+ "type": "integer",
+ "description": "The number of physical CPUs in one ExecutionEnvironment instance"
+ },
+ "LogicalCPUs": {
+ "type": "integer",
+ "description": "The number of logical CPUs in one ExecutionEnvironment instance"
+ },
+ "CPUMultiplicity": {
+ "type": "string",
+ "description": "Information about the CPUs and cores in an execution environment",
+ "enum": ["multicpu-multicore","multicpu-singlecore","singlecpu-multicore","singlecpu-singlecore"]
+ },
+ "CPUVendor": {
+ "type": "string",
+ "description": "The name of the manufacturer of the CPU"
+ },
+ "CPUModel": {
+ "type": "string",
+ "description": "The model of the CPU, as defined by the vendor"
+ },
+ "CPUVersion": {
+ "type": "string",
+ "description": "The specific version name of the CPU, as defined by the vendor"
+ },
+ "CPUClockSpeed": {
+ "type": "integer",
+ "description": "The clock speed of the CPU (MHz)"
+ },
+ "CPUTimeScalingFactor": {
+ "type": "float",
+ "description": "The factor used by the ComputingManager to scale the CPU time limit"
+ },
+ "WallTimeScalingFactor": {
+ "type": "float",
+ "description": "The factor used by the ComputingManager to scale the wallclock time limit"
+ },
+ "MainMemorySize": {
+ "type": "integer",
+ "description": "The total amount of physical RAM in one ExecutionEnvironment instance (MB)"
+ },
+ "VirtualMemorySize": {
+ "type": "integer",
+ "description": "The total amount of virtual memory (RAM+swap) in one ExecutionEnvironment instance (MB)"
+ },
+ "OSFamily": {
+ "type": "string",
+ "description": "The general family of the operating system - OSFamily_t (open enumeration)"
+ },
+ "OSName": {
+ "type": "string",
+ "description": "The specific name of the operating system - OSName_t (open enumeration)"
+ },
+ "OSVersion": {
+ "type": "string",
+ "description": "The version of the operating system, as defined by the vendor"
+ },
+ "ConnectivityIn": {
+ "type": "boolean",
+ "description": "True if direct inbound network connectiity is available to a running job"
+ },
+ "ConnectivityOut": {
+ "type": "boolean",
+ "description": "True if direct outbound network connectiity is available to a running job"
+ },
+ "NetworkInfo": {
+ "type": "array",
+ "description": "The types of internal network connections between ExecutionEnvironments - NetworkInfo_t (open enumeration)",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ApplicationEnvironmentID": {
+ "type": "array",
+ "description": "ID(s) of ApplicationEnvironments available in this ExecutionEnvironment",
+ "items": {
+ "type": "string"
+ }
+ },
+ "BenchmarkID": {
+ "type": "array",
+ "description": "ID(s) of Benchmarks associated with this ExecutionEnvironment",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ "required": ["Platform","MainMemorySize","OSFamily","ConnectivityIn","ConnectivityOut"]
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/Glue2.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/Glue2.json b/modules/gfac/gfac-monitor/src/main/resources/schema/Glue2.json
new file mode 100644
index 0000000..bb80505
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/Glue2.json
@@ -0,0 +1,246 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Glue2.json",
+ "description": "A GLUE 2 document",
+ "type": "object",
+ "properties": {
+ "Entity": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Entity.json"}]
+ }
+ },
+ "Location": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Location.json"}]
+ }
+ },
+ "Contact": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Contact.json"}]
+ }
+ },
+ "Domain": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Domain.json"}]
+ }
+ },
+ "AdminDomain": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/AdminDomain.json"}]
+ }
+ },
+ "UserDomain": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/UserDomain.json"}]
+ }
+ },
+ "Service": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Service.json"}]
+ }
+ },
+ "Endpoint": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Endpoint.json"}]
+ }
+ },
+ "Share": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Share.json"}]
+ }
+ },
+ "Manager": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Manager.json"}]
+ }
+ },
+ "Resource": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Resource.json"}]
+ }
+ },
+ "Activity": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Activity.json"}]
+ }
+ },
+ "Policy": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Policy.json"}]
+ }
+ },
+ "AccessPolicy": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/AccessPolicy.json"}]
+ }
+ },
+ "MappingPolicy": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/MappingPolicy.json"}]
+ }
+ },
+ "ComputingService": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/ComputingService.json"}]
+ }
+ },
+ "ComputingEndpoint": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/ComputingEndpoint.json"}]
+ }
+ },
+ "ComputingShare": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/ComputingShare.json"}]
+ }
+ },
+ "ComputingManager": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/ComputingManager.json"}]
+ }
+ },
+ "Benchmark": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Benchmark.json"}]
+ }
+ },
+ "ExecutionEnvironment": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/ExecutionEnvironment.json"}]
+ }
+ },
+ "ApplicationEnvironment": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/ApplicationEnvironment.json"}]
+ }
+ },
+ "ApplicationHandle": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/ApplicationHandle.json"}]
+ }
+ },
+ "ComputingActivity": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/ComputingActivity.json"}]
+ }
+ },
+ "ToStorageService": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/ToStorageService.json"}]
+ }
+ },
+ "StorageService": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/StorageService.json"}]
+ }
+ },
+ "StorageServiceCapacity": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/StorageServiceCapacity.json"}]
+ }
+ },
+ "StorageAccessProtocol": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/StorageAccessProtocol.json"}]
+ }
+ },
+ "StorageEndpoint": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/StorageEndpoint.json"}]
+ }
+ },
+ "StorageShare": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/StorageShare.json"}]
+ }
+ },
+ "StorageShareCapacity": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/StorageShareCapacity.json"}]
+ }
+ },
+ "StorageManager": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/StorageManager.json"}]
+ }
+ },
+ "DataStore": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/DataStore.json"}]
+ }
+ },
+ "ToComputingService": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/ToComputingService.json"}]
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/Location.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/Location.json b/modules/gfac/gfac-monitor/src/main/resources/schema/Location.json
new file mode 100644
index 0000000..8491cc0
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/Location.json
@@ -0,0 +1,47 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Location.json",
+ "description": "A GLUE 2 Location",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Entity.json"}],
+ "properties": {
+ "Address": {
+ "type": "string",
+ "description": "A free format street address"
+ },
+ "Place": {
+ "type": "string",
+ "description": "Name of town/city"
+ },
+ "Country": {
+ "type": "string",
+ "description": "Name of country"
+ },
+ "PostalCode": {
+ "type": "string",
+ "description": "Postal code"
+ },
+ "Latitude": {
+ "type": "number",
+ "description": "Position north (positive) or south (negative) of the equator in degrees"
+ },
+ "Longitude": {
+ "type": "number",
+ "description": "Position east (positive) or west (negative) of the primary meridian in degrees"
+ },
+ "ServiceID": {
+ "type": "array",
+ "description": "The IDs of Services at this location",
+ "items": {
+ "type": "string"
+ }
+ },
+ "DomainID": {
+ "type": "array",
+ "description": "The IDs of Domains at this location",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/Manager.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/Manager.json b/modules/gfac/gfac-monitor/src/main/resources/schema/Manager.json
new file mode 100644
index 0000000..d1df50a
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/Manager.json
@@ -0,0 +1,28 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Manager.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Entity.json"}],
+ "properties": {
+ "ProductName": {
+ "type": "string",
+ "description": "The name of the software product which implements the Manager"
+ },
+ "ProductVersion": {
+ "type": "string",
+ "description": "The version of the software product which implements the Manager"
+ },
+ "ServiceID": {
+ "type": "string",
+ "description": "The ID of the Service this Share participates in"
+ },
+ "ResourceID": {
+ "type": "array",
+ "description": "ID(s) of Resources associated with this Share",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ "required": ["ProductName","ServiceID","ResourceID"]
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/MappingPolicy.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/MappingPolicy.json b/modules/gfac/gfac-monitor/src/main/resources/schema/MappingPolicy.json
new file mode 100644
index 0000000..268844d
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/MappingPolicy.json
@@ -0,0 +1,13 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/MappingPolicy.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Policy.json"}],
+ "properties": {
+ "ShareID": {
+ "type": "string",
+ "description": "The ID of the Share this MappingPolicy is for"
+ }
+ },
+ "required": ["ShareID"]
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/Policy.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/Policy.json b/modules/gfac/gfac-monitor/src/main/resources/schema/Policy.json
new file mode 100644
index 0000000..f936699
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/Policy.json
@@ -0,0 +1,27 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Policy.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Entity.json"}],
+ "properties": {
+ "Scheme": {
+ "type": "string",
+ "description": "PolicyScheme_t (open enumeration)"
+ },
+ "Rule": {
+ "type": "array",
+ "description": "Policy rules",
+ "items": {
+ "type": "string"
+ }
+ },
+ "UserDomainID": {
+ "type": "array",
+ "description": "The ID(s) of the UserDomains this Policy applies to",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ "required": ["Scheme","Rule","UserDomainID"]
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/Resource.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/Resource.json b/modules/gfac/gfac-monitor/src/main/resources/schema/Resource.json
new file mode 100644
index 0000000..88d08ad
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/Resource.json
@@ -0,0 +1,27 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Resource.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Entity.json"}],
+ "properties": {
+ "ManagerID": {
+ "type": "string",
+ "description": "The ID of the Manager for this Resource"
+ },
+ "ShareID": {
+ "type": "array",
+ "description": "The ID(s) of the Shares this Resource is part of",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ActivityID": {
+ "type": "array",
+ "description": "The ID(s) of Activities consuming from this Share",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ "required": ["ManagerID"]
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/Service.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/Service.json b/modules/gfac/gfac-monitor/src/main/resources/schema/Service.json
new file mode 100644
index 0000000..4662407
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/Service.json
@@ -0,0 +1,75 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Service.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Entity.json"}],
+ "properties": {
+ "Capability": {
+ "type": "array",
+ "description": "Capability_t (open enumeration)",
+ "items": {
+ "type": "string"
+ }
+ },
+ "Type": {
+ "type": "string",
+ "description": "ServiceType_t (open enumeration)"
+ },
+ "QualityLevel": {
+ "type": "string",
+ "description": "QualityLevel_t",
+ "enum": ["development","pre-production","production","testing"]
+ },
+ "StatusInfo": {
+ "type": "array",
+ "description": "URLs of web pages providing additional information",
+ "items": {
+ "type": "string"
+ }
+ },
+ "Complexity": {
+ "type": "string",
+ "description": "A human-readable description of the number of endpoint types, shares, and resources"
+ },
+ "EndpointID": {
+ "type": "array",
+ "description": "The IDs of Endpoints for this Service",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ShareID": {
+ "type": "array",
+ "description": "The IDs of the Shares offered by this Service",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ManagerID": {
+ "type": "array",
+ "description": "The IDs of the Managers of this Service",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ContactID": {
+ "type": "array",
+ "description": "The IDs of Contacts for this Service",
+ "items": {
+ "type": "string"
+ }
+ },
+ "LocationID": {
+ "type": "string",
+ "description": "The ID of the primary Location of this Service"
+ },
+ "ServiceID": {
+ "type": "array",
+ "description": "The IDs of Services related to this Service",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ "required": ["Type","QualityLevel"]
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/Share.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/Share.json b/modules/gfac/gfac-monitor/src/main/resources/schema/Share.json
new file mode 100644
index 0000000..258fc1b
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/Share.json
@@ -0,0 +1,45 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Share.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Entity.json"}],
+ "properties": {
+ "Description": {
+ "type": "string",
+ "description": "A human-readable description of the Share"
+ },
+ "EndpointID": {
+ "type": "array",
+ "description": "The ID(s) of the Endpoints that can be used to access this Share",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ResourceID": {
+ "type": "array",
+ "description": "The ID(s) of the Resources associated with this Share",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ServiceID": {
+ "type": "string",
+ "description": "The ID of the Service this Share participates in"
+ },
+ "ActivityID": {
+ "type": "array",
+ "description": "The ID(s) of Activities consuming from this Share",
+ "items": {
+ "type": "string"
+ }
+ },
+ "MappingPolicyID": {
+ "type": "array",
+ "description": "ID(s) of MappingPolicies associated with this Share",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ "required": ["ServiceID"]
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/StorageAccessProtocol.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/StorageAccessProtocol.json b/modules/gfac/gfac-monitor/src/main/resources/schema/StorageAccessProtocol.json
new file mode 100644
index 0000000..05a830b
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/StorageAccessProtocol.json
@@ -0,0 +1,32 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/StorageAccessProtocol.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Entity.json"}],
+ "properties": {
+ "Type": {
+ "type": "string",
+ "description": "The type of the protocol - StorageAccessProtocol_t"
+ },
+ "Version": {
+ "type": "string",
+ "description": "The version of the protocol supported"
+ },
+ "MaxStreams": {
+ "type": "integer",
+ "description": "The maximum number of parallel network streams which can be usef for a single transfer"
+ },
+ "StorageServiceID": {
+ "type": "string",
+ "description": "The ID of the StorageService this protocol is available for"
+ },
+ "ToComputingServiceID": {
+ "type": "array",
+ "description": "The ID(s) ToComputingService objects that describe connectivity to ComputingServices",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ "required": ["Type","Version","StorageServiceID"]
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/StorageEndpoint.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/StorageEndpoint.json b/modules/gfac/gfac-monitor/src/main/resources/schema/StorageEndpoint.json
new file mode 100644
index 0000000..38b27c4
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/StorageEndpoint.json
@@ -0,0 +1,8 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/StorageEndpoint.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Endpoint.json"}],
+ "properties": {
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/StorageManager.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/StorageManager.json b/modules/gfac/gfac-monitor/src/main/resources/schema/StorageManager.json
new file mode 100644
index 0000000..f3984f6
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/StorageManager.json
@@ -0,0 +1,8 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/StorageManager.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Share.json"}],
+ "properties": {
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/StorageService.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/StorageService.json b/modules/gfac/gfac-monitor/src/main/resources/schema/StorageService.json
new file mode 100644
index 0000000..a03d111
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/StorageService.json
@@ -0,0 +1,22 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/StorageService.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Service.json"}],
+ "properties": {
+ "StorageAccessProtocolID": {
+ "type": "array",
+ "description": "The ID(s) of the StorageAccessProtocols supported by this service",
+ "items": {
+ "type": "string"
+ }
+ },
+ "StorageServiceCapacityID": {
+ "type": "array",
+ "description": "The ID(s) of the StorageServiceCapacities for this Service",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/StorageServiceCapacity.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/StorageServiceCapacity.json b/modules/gfac/gfac-monitor/src/main/resources/schema/StorageServiceCapacity.json
new file mode 100644
index 0000000..a25c204
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/StorageServiceCapacity.json
@@ -0,0 +1,33 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/StorageServiceCapacity.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Entity.json"}],
+ "properties": {
+ "Type": {
+ "type": "string",
+ "description": "The type of storage capacity - StorageCapacity_t"
+ },
+ "TotalSize": {
+ "type": "integer",
+ "description": "The total amount of storage of this type (GB)"
+ },
+ "FreeSize": {
+ "type": "integer",
+ "description": "The amount of currently available storage of this type (GB)"
+ },
+ "UsedSize": {
+ "type": "integer",
+ "description": "The amount storage of this type in use (GB)"
+ },
+ "ReservedSize": {
+ "type": "integer",
+ "description": "The amount storage of this type which is not in use, but has been reserved for use in use (GB)"
+ },
+ "StorageServiceID": {
+ "type": "string",
+ "description": "The ID of the StorageService this capacity describes"
+ }
+ },
+ "required": ["Type","StorageServiceID"]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/StorageShare.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/StorageShare.json b/modules/gfac/gfac-monitor/src/main/resources/schema/StorageShare.json
new file mode 100644
index 0000000..9703118
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/StorageShare.json
@@ -0,0 +1,65 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/StorageShare.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Share.json"}],
+ "properties": {
+ "ServingState": {
+ "type": "string",
+ "description": "How the Share is currently serving jobs",
+ "enum": ["closed","draining","production","queueing"]
+ },
+ "Path": {
+ "type": "string",
+ "description": "A default namespace where files are logically placed when they are stored in this Share"
+ },
+ "AccessMode": {
+ "type": "array",
+ "description": "The type of access allowed for this share - AccessMode_t (undefined)",
+ "items": {
+ "type": "string"
+ }
+ },
+ "SharingID": {
+ "type": "string",
+ "description": "A local identifier common to the set of StorageShares which use the same underling extents"
+ },
+ "AccessLatency": {
+ "type": "string",
+ "description": "The maximum latency category under normal operating conditions",
+ "enum": ["nearline","offline","online"]
+ },
+ "RetentionPolicy": {
+ "type": "string",
+ "description": "The quality of data retention - RetentionPolicy_t"
+ },
+ "ExpirationMode": {
+ "type": "array",
+ "description": "Supported file lifetime modes",
+ "items": {
+ "type": "string",
+ "enum": ["neverexpire","releasewhenexpired","warnwhenexpired"]
+ }
+ },
+ "DefaultLifeTime": {
+ "type": "integer",
+ "description": "The default lifetime assigned to a new file"
+ },
+ "MaximumLifeTime": {
+ "type": "integer",
+ "description": "The maximum lifetime that can be requested for a file"
+ },
+ "Tag": {
+ "type": "string",
+ "description": "An identifier defined by a UserDomain"
+ },
+ "StorageShareCapacityID": {
+ "type": "array",
+ "description": "ID of the StorageShareCapacities associated with this share",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ "required": ["ServingState","SharingID","AccessLatency"]
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/StorageShareCapacity.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/StorageShareCapacity.json b/modules/gfac/gfac-monitor/src/main/resources/schema/StorageShareCapacity.json
new file mode 100644
index 0000000..f392c94
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/StorageShareCapacity.json
@@ -0,0 +1,33 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/StorageShareCapacity.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Entity.json"}],
+ "properties": {
+ "Type": {
+ "type": "string",
+ "description": "The type of storage capacity - StorageCapacity_t"
+ },
+ "TotalSize": {
+ "type": "integer",
+ "description": "The total amount of storage (GB)"
+ },
+ "FreeSize": {
+ "type": "integer",
+ "description": "The amount of available storage (GB)"
+ },
+ "UsedSize": {
+ "type": "integer",
+ "description": "The amount of used storage (GB)"
+ },
+ "ReservedSize": {
+ "type": "integer",
+ "description": "The amount storage which is not occupied, but has been reserved for use (GB)"
+ },
+ "StorageShareID": {
+ "type": "string",
+ "description": "The ID of the StorageShare related to this capacity"
+ }
+ },
+ "required": ["Type","StorageShareID"]
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-monitor/src/main/resources/schema/ToComputingService.json
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/resources/schema/ToComputingService.json b/modules/gfac/gfac-monitor/src/main/resources/schema/ToComputingService.json
new file mode 100644
index 0000000..6d81b80
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/resources/schema/ToComputingService.json
@@ -0,0 +1,32 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/ToComputingService.json",
+ "type": "object",
+ "allOf": [{"$ref": "http://schemas.ogf.org/glue/2013/05/spec_2.0_r1/Entity.json"}],
+ "properties": {
+ "NetworkInfo": {
+ "type": "string",
+ "description": "Type of network connections between the Storage and Computing services (NetworkInfo_t)"
+ },
+ "Bandwidth": {
+ "type": "integer",
+ "description": "The normal bandwidth available between the Storage and Computing services (Mb/s)"
+ },
+ "StorageAccessProtocolID": {
+ "type": "array",
+ "description": "IDs of the protocols that can be used to access the StorageService",
+ "items": {
+ "type": "string"
+ }
+ },
+ "ComputingServiceID": {
+ "type": "string",
+ "description": "The ID of the ComputingService"
+ },
+ "StorageServiceID": {
+ "type": "string",
+ "description": "The ID of the StorageService"
+ }
+ },
+ "required": ["ComputingServiceID","StorageServiceID"]
+}
[6/9] Separating gfac-monitoring implementation
Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/QstatMonitorTestWithMyProxyAuth.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/QstatMonitorTestWithMyProxyAuth.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/QstatMonitorTestWithMyProxyAuth.java
deleted file mode 100644
index 0c9dca8..0000000
--- a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/QstatMonitorTestWithMyProxyAuth.java
+++ /dev/null
@@ -1,167 +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.job;
-
-import com.google.common.eventbus.EventBus;
-import com.google.common.eventbus.Subscribe;
-import org.apache.airavata.commons.gfac.type.HostDescription;
-import org.apache.airavata.gsi.ssh.api.Cluster;
-import org.apache.airavata.gsi.ssh.api.SSHApiException;
-import org.apache.airavata.gsi.ssh.api.ServerInfo;
-import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
-import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
-import org.apache.airavata.gsi.ssh.impl.PBSCluster;
-import org.apache.airavata.gsi.ssh.impl.authentication.MyProxyAuthenticationInfo;
-import org.apache.airavata.gsi.ssh.util.CommonUtils;
-import org.apache.airavata.gfac.monitor.MonitorID;
-import org.apache.airavata.gfac.monitor.UserMonitorData;
-import org.apache.airavata.gfac.monitor.event.MonitorPublisher;
-import org.apache.airavata.gfac.monitor.impl.pull.qstat.QstatMonitor;
-import org.apache.airavata.gfac.monitor.state.JobStatusChangeRequest;
-import org.apache.airavata.schemas.gfac.GsisshHostType;
-import org.junit.Assert;
-import org.testng.annotations.Test;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-
-public class QstatMonitorTestWithMyProxyAuth {
- private String myProxyUserName;
- private String myProxyPassword;
- private String certificateLocation;
- private String pbsFilePath;
- private String workingDirectory;
- private HostDescription hostDescription;
- private MonitorPublisher monitorPublisher;
- private BlockingQueue<UserMonitorData> pullQueue;
- private Thread monitorThread;
-
- @org.testng.annotations.BeforeClass
- public void setUp() throws Exception {
- System.setProperty("myproxy.username", "ogce");
- System.setProperty("myproxy.password", "OpenGwy14");
- System.setProperty("basedir", "/Users/lahirugunathilake/work/airavata/sandbox/gsissh");
- System.setProperty("gsi.working.directory", "/home/ogce");
- System.setProperty("trusted.cert.location", "/Users/lahirugunathilake/Downloads/certificates");
- myProxyUserName = System.getProperty("myproxy.username");
- myProxyPassword = System.getProperty("myproxy.password");
- workingDirectory = System.getProperty("gsi.working.directory");
- certificateLocation = System.getProperty("trusted.cert.location");
- if (myProxyUserName == null || myProxyPassword == null || workingDirectory == null) {
- System.out.println(">>>>>> Please run tests with my proxy user name and password. " +
- "E.g :- mvn clean install -Dmyproxy.username=xxx -Dmyproxy.password=xxx -Dgsi.working.directory=/path<<<<<<<");
- throw new Exception("Need my proxy user name password to run tests.");
- }
-
- monitorPublisher = new MonitorPublisher(new EventBus());
- class InnerClassQstat {
-
- @Subscribe
- private void getStatus(JobStatusChangeRequest status) {
- Assert.assertNotNull(status);
- System.out.println(status.getState().toString());
- monitorThread.interrupt();
- }
- }
- monitorPublisher.registerListener(this);
- pullQueue = new LinkedBlockingQueue<UserMonitorData>();
- QstatMonitor qstatMonitor = new
- QstatMonitor(pullQueue, monitorPublisher);
- try {
- monitorThread = (new Thread(qstatMonitor));
- monitorThread.start();
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- hostDescription = new HostDescription(GsisshHostType.type);
- hostDescription.getType().setHostAddress("trestles.sdsc.edu");
- hostDescription.getType().setHostName("gsissh-gordon");
- ((GsisshHostType) hostDescription.getType()).setPort(22);
- ((GsisshHostType)hostDescription.getType()).setInstalledPath("/opt/torque/bin/");
- }
-
- @Test
- public void testQstatMonitor() throws SSHApiException {
- /* now have to submit a job to some machine and add that job to the queue */
- //Create authentication
- GSIAuthenticationInfo authenticationInfo
- = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
- 7512, 17280000, certificateLocation);
-
- // Server info
- ServerInfo serverInfo = new ServerInfo("ogce", hostDescription.getType().getHostAddress());
-
-
- Cluster pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getPBSJobManager("/opt/torque/bin/"));
-
-
- // Execute command
- System.out.println("Target PBS file path: " + workingDirectory);
- // constructing the job object
- JobDescriptor jobDescriptor = new JobDescriptor();
- jobDescriptor.setWorkingDirectory(workingDirectory);
- jobDescriptor.setShellName("/bin/bash");
- jobDescriptor.setJobName("GSI_SSH_SLEEP_JOB");
- jobDescriptor.setExecutablePath("/bin/echo");
- jobDescriptor.setAllEnvExport(true);
- jobDescriptor.setMailOptions("n");
- jobDescriptor.setStandardOutFile(workingDirectory + File.separator + "application.out");
- jobDescriptor.setStandardErrorFile(workingDirectory + File.separator + "application.err");
- jobDescriptor.setNodes(1);
- jobDescriptor.setProcessesPerNode(1);
- jobDescriptor.setQueueName("normal");
- jobDescriptor.setMaxWallTime("60");
- jobDescriptor.setAcountString("sds128");
- List<String> inputs = new ArrayList<String>();
- jobDescriptor.setOwner("ogce");
- inputs.add("Hello World");
- jobDescriptor.setInputValues(inputs);
- //finished construction of job object
- System.out.println(jobDescriptor.toXML());
- for (int i = 0; i < 1; i++) {
- String jobID = pbsCluster.submitBatchJob(jobDescriptor);
- System.out.println("Job submitted successfully, Job ID: " + jobID);
- MonitorID monitorID = new MonitorID(hostDescription, jobID,null,null,null, "ogce");
- monitorID.setAuthenticationInfo(authenticationInfo);
- try {
- org.apache.airavata.gfac.monitor.util.CommonUtils.addMonitortoQueue(pullQueue, monitorID);
- } catch (Exception e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- }
- try {
-
- monitorThread.join();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Subscribe
- public void testCaseShutDown(JobStatusChangeRequest status) {
- Assert.assertNotNull(status.getState());
- monitorThread.stop();
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/TestGlobalHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/TestGlobalHandler.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/TestGlobalHandler.java
new file mode 100644
index 0000000..c245140
--- /dev/null
+++ b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/TestGlobalHandler.java
@@ -0,0 +1,32 @@
+/*
+ *
+ * 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.job;
+
+import org.apache.airavata.gfac.handler.AbstractHandler;
+import org.apache.airavata.gfac.handler.GFacHandlerException;
+
+import java.util.Map;
+
+public class TestGlobalHandler extends AbstractHandler {
+ public void initProperties(Map<String, String> properties) throws GFacHandlerException {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/TestInHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/TestInHandler.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/TestInHandler.java
new file mode 100644
index 0000000..1c41d8e
--- /dev/null
+++ b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/TestInHandler.java
@@ -0,0 +1,32 @@
+/*
+ *
+ * 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.job;
+
+import org.apache.airavata.gfac.handler.AbstractHandler;
+import org.apache.airavata.gfac.handler.GFacHandlerException;
+
+import java.util.Map;
+
+public class TestInHandler extends AbstractHandler {
+ public void initProperties(Map<String, String> properties) throws GFacHandlerException {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/TestOutHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/TestOutHandler.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/TestOutHandler.java
new file mode 100644
index 0000000..2ebf3d8
--- /dev/null
+++ b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/TestOutHandler.java
@@ -0,0 +1,32 @@
+/*
+ *
+ * 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.job;
+
+import org.apache.airavata.gfac.handler.AbstractHandler;
+import org.apache.airavata.gfac.handler.GFacHandlerException;
+
+import java.util.Map;
+
+public class TestOutHandler extends AbstractHandler {
+ public void initProperties(Map<String, String> properties) throws GFacHandlerException {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/TestProvider.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/TestProvider.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/TestProvider.java
new file mode 100644
index 0000000..3de320a
--- /dev/null
+++ b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/TestProvider.java
@@ -0,0 +1,47 @@
+/*
+ *
+ * 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.job;
+
+import org.apache.airavata.gfac.GFacException;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.provider.AbstractProvider;
+import org.apache.airavata.gfac.provider.GFacProviderException;
+
+import java.util.Map;
+
+public class TestProvider extends AbstractProvider {
+
+ public void cancelJob(String jobId, JobExecutionContext jobExecutionContext) throws GFacProviderException, GFacException {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void initProperties(Map<String, String> properties) throws GFacProviderException, GFacException {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void execute(JobExecutionContext jobExecutionContext) throws GFacProviderException, GFacException {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void dispose(JobExecutionContext jobExecutionContext) throws GFacProviderException, GFacException {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/TestThreadedHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/TestThreadedHandler.java b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/TestThreadedHandler.java
new file mode 100644
index 0000000..08f9c33
--- /dev/null
+++ b/modules/gfac/gfac-core/src/test/java/org/apache/airavata/job/TestThreadedHandler.java
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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.job;
+
+import junit.framework.Assert;
+import org.apache.airavata.gfac.handler.GFacHandlerException;
+import org.apache.airavata.gfac.handler.ThreadedHandler;
+
+import java.util.Map;
+
+public class TestThreadedHandler extends ThreadedHandler {
+
+
+ public void initProperties(Map<String, String> properties) throws GFacHandlerException {
+ }
+
+ public void run() {
+ System.out.println("Invoking TestThreadedHandler");
+ Assert.assertTrue(true);
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/test/resources/gfac-config.xml
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/test/resources/gfac-config.xml b/modules/gfac/gfac-core/src/test/resources/gfac-config.xml
index 7c7e704..da92462 100644
--- a/modules/gfac/gfac-core/src/test/resources/gfac-config.xml
+++ b/modules/gfac/gfac-core/src/test/resources/gfac-config.xml
@@ -9,82 +9,57 @@
WARRANTIES OR CONDITIONS OF ANY ~ KIND, either express or implied. See the
License for the ~ specific language governing permissions and limitations
~ under the License. -->
-
+
<GFac>
+ <DaemonHandlers>
+ <Handler class="org.apache.airavata.job.TestThreadedHandler">
+ </Handler>
+ </DaemonHandlers>
<GlobalHandlers>
<InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.AppDescriptorCheckHandler">
+ <Handler class="org.apache.airavata.job.TestGlobalHandler">
<property name="name" value="value"/>
</Handler>
</InHandlers>
<OutHandlers></OutHandlers>
</GlobalHandlers>
- <Provider class="org.apache.airavata.gfac.provider.impl.LocalProvider" host="org.apache.airavata.schemas.gfac.impl.HostDescriptionTypeImpl">
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.LocalDirectorySetupHandler"/>
- </InHandlers>
- </Provider>
- <Provider class="org.apache.airavata.gfac.provider.impl.GramProvider" host="org.apache.airavata.schemas.gfac.impl.GlobusHostTypeImpl">
- <property name="name" value="value"/>
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GramDirectorySetupHandler">
- <property name="name" value="value"/>
- </Handler>
- <Handler class="org.apache.airavata.gfac.handler.GridFTPInputHandler"/>
- </InHandlers>
- <OutHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GridFTPOutputHandler"/>
- </OutHandlers>
- </Provider>
- <Provider class="org.apache.airavata.gfac.provider.impl.BESProvider" host="org.apache.airavata.schemas.gfac.impl.UnicoreHostTypeImpl">
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GramDirectorySetupHandler"/>
- <Handler class="org.apache.airavata.gfac.handler.GridFTPInputHandler"/>
- </InHandlers>
- <OutHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GridFTPOutputHandler"/>
- </OutHandlers>
- </Provider>
-
- <Provider class="org.apache.airavata.gfac.ec2.EC2Provider" host="org.apache.airavata.schemas.gfac.impl.Ec2HostTypeImpl">
- <InHandlers/>
- <OutHandlers/>
- </Provider>
-
- <Provider class="org.apache.airavata.gfac.provider.impl.HadoopProvider" host="org.apache.airavata.schemas.gfac.impl.HadoopHostTypeImpl">
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.HadoopDeploymentHandler"/>
- <Handler class="org.apache.airavata.gfac.handler.HDFSDataMovementHandler"/>
- </InHandlers>
- <OutHandlers/>
- </Provider>
- <Application name="UltraScan">
+ <Application name="UltraScan" class="org.apache.airavata.job.TestProvider">
<InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GramDirectorySetupHandler"/>
- <Handler class="org.apache.airavata.gfac.handler.GridFTPInputHandler"/>
+ <Handler class="org.apache.airavata.job.TestInHandler"/>
</InHandlers>
<OutHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GridFTPOutputHandler"/>
+ <Handler class="org.apache.airavata.job.TestOutHandler"/>
</OutHandlers>
</Application>
- <Provider class="org.apache.airavata.gfac.provider.impl.SSHProvider" host="org.apache.airavata.schemas.gfac.impl.SSHHostTypeImpl">
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.SSHDirectorySetupHandler"/>
- <Handler class="org.apache.airavata.gfac.handler.GSISSHInputHandler"/>
- </InHandlers>
- <OutHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GSISSHOutputHandler"/>
- </OutHandlers>
- </Provider>
- <Provider class="org.apache.airavata.gfac.provider.impl.GSISSHProvider" host="org.apache.airavata.schemas.gfac.impl.GsisshHostTypeImpl">
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GSISSHDirectorySetupHandler"/>
- <Handler class="org.apache.airavata.gfac.handler.GSISSHInputHandler"/>
- </InHandlers>
- <OutHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GSISSHOutputHandler"/>
- </OutHandlers>
- </Provider>
+
+ <Provider class="org.apache.airavata.job.TestProvider" host="org.apache.airavata.schemas.gfac.impl.GsisshHostTypeImpl" executionMode="async">
+ <InHandlers>
+ <Handler class="org.apache.airavata.job.TestInHandler">
+ <property name="name1" value="value1"/>
+ </Handler>
+ <!--Handler class="org.apache.airavata.gfac.handler.AdvancedSCPInputHandler">
+ <property name="privateKeyPath" value="/Users/lahirugunathilake/.ssh/id_dsa"/>
+ <property name="publicKeyPath" value="/Users/lahirugunathilake/.ssh/id_dsa.pub"/>
+ <property name="userName" value="root"/>
+ <property name="hostName" value="gw98.iu.xsede.org"/>
+ <property name="inputPath" value="/tmp"/>
+ <property name="passPhrase" value="/home/airavata/outputData"/>
+ <property name="password" value="/home/airavata/outputData"/> <either we have to set password or keys, password has higher preference>
+ </Handler-->
+ </InHandlers>
+ <OutHandlers>
+ <Handler class="org.apache.airavata.job.TestOutHandler"/>
+ <!--Handler class="org.apache.airavata.gfac.handler.AdvancedSCPOutputHandler">
+ <property name="privateKeyPath" value="/Users/lahirugunathilake/.ssh/id_dsa"/>
+ <property name="publicKeyPath" value="/Users/lahirugunathilake/.ssh/id_dsa.pub"/>
+ <property name="userName" value="root"/>
+ <property name="hostName" value="gw111.iu.xsede.org"/>
+ <property name="outputPath" value="/tmp"/>
+ <property name="passPhrase" value="/home/airavata/outputData"/>
+ <property name="password" value="/home/airavata/outputData"/> <either we have to set password or keys, password has higher preference>
+ </Handler-->
+ </OutHandlers>
+ </Provider>
</GFac>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-ec2/pom.xml
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-ec2/pom.xml b/modules/gfac/gfac-ec2/pom.xml
index 6851658..344792a 100644
--- a/modules/gfac/gfac-ec2/pom.xml
+++ b/modules/gfac/gfac-ec2/pom.xml
@@ -18,8 +18,8 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>airavata-gfac-ec2</artifactId>
- <name>Airavata GFac Core</name>
- <description>The core GFAC functionality independent from any webservice implementation.</description>
+ <name>Airavata GFac EC2 Implementation</name>
+ <description>The core GFAC EC2 implementation using the framework features</description>
<url>http://airavata.apache.org/</url>
<dependencies>
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-ec2/src/main/java/org/apache/airavata/gfac/ec2/EC2Provider.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-ec2/src/main/java/org/apache/airavata/gfac/ec2/EC2Provider.java b/modules/gfac/gfac-ec2/src/main/java/org/apache/airavata/gfac/ec2/EC2Provider.java
index e773fe6..1ade760 100644
--- a/modules/gfac/gfac-ec2/src/main/java/org/apache/airavata/gfac/ec2/EC2Provider.java
+++ b/modules/gfac/gfac-ec2/src/main/java/org/apache/airavata/gfac/ec2/EC2Provider.java
@@ -36,8 +36,8 @@ import org.apache.airavata.gfac.GFacException;
import org.apache.airavata.gfac.context.JobExecutionContext;
import org.apache.airavata.gfac.ec2.util.AmazonEC2Util;
import org.apache.airavata.gfac.ec2.util.EC2ProviderUtil;
+import org.apache.airavata.gfac.provider.AbstractProvider;
import org.apache.airavata.gfac.provider.GFacProviderException;
-import org.apache.airavata.gfac.provider.impl.AbstractProvider;
import org.apache.airavata.gfac.provider.utils.ProviderUtils;
import org.apache.airavata.gfac.utils.GFacUtils;
import org.apache.airavata.model.workspace.experiment.JobState;
@@ -131,7 +131,7 @@ public class EC2Provider extends AbstractProvider {
new BasicAWSCredentials(amazonSecurityContext.getAccessKey(), amazonSecurityContext.getSecretKey());
AmazonEC2Client ec2client = new AmazonEC2Client(credential);
taskID = jobExecutionContext.getTaskData().getTaskID();
- GFacUtils.saveJobStatus(details, JobState.SETUP, taskID);
+ GFacUtils.saveJobStatus(jobExecutionContext, details, JobState.SETUP);
initEc2Environment(jobExecutionContext, ec2client);
checkConnection(instance, ec2client);
}
@@ -184,7 +184,7 @@ public class EC2Provider extends AbstractProvider {
// Authenticate
int result = sshClient.authenticate(publicKeyAuth);
if(result== AuthenticationProtocolState.FAILED) {
- GFacUtils.saveJobStatus(details, JobState.FAILED, taskID);
+ GFacUtils.saveJobStatus(jobExecutionContext, details, JobState.FAILED);
throw new GFacProviderException("The authentication failed");
} else if(result==AuthenticationProtocolState.PARTIAL) {
throw new GFacProviderException("The authentication succeeded but another"
@@ -192,12 +192,12 @@ public class EC2Provider extends AbstractProvider {
} else if(result==AuthenticationProtocolState.COMPLETE) {
log.info("ssh client authentication is complete...");
}
- GFacUtils.saveJobStatus(details, JobState.SUBMITTED, taskID);
+ GFacUtils.saveJobStatus(jobExecutionContext, details, JobState.SUBMITTED);
SessionChannelClient session = sshClient.openSessionChannel();
log.info("ssh session successfully opened...");
session.requestPseudoTerminal("vt100", 80, 25, 0, 0, "");
session.startShell();
- GFacUtils.saveJobStatus(details, JobState.ACTIVE, taskID);
+ GFacUtils.saveJobStatus(jobExecutionContext, details, JobState.ACTIVE);
session.getOutputStream().write(shellCmd.getBytes());
@@ -228,7 +228,7 @@ public class EC2Provider extends AbstractProvider {
((StringParameterType) outParam.getType()).setValue(executionResult);
jobExecutionContext.getOutMessageContext().addParameter(paramName, outParam);
}
- GFacUtils.saveJobStatus(details, JobState.COMPLETE, taskID);
+ GFacUtils.saveJobStatus(jobExecutionContext, details, JobState.COMPLETE);
} catch (InvalidSshKeyException e) {
throw new GFacProviderException("Invalid SSH key", e);
} catch (IOException e) {
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-ec2/src/test/resources/gfac-config.xml
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-ec2/src/test/resources/gfac-config.xml b/modules/gfac/gfac-ec2/src/test/resources/gfac-config.xml
index 61dca4f..fec698b 100644
--- a/modules/gfac/gfac-ec2/src/test/resources/gfac-config.xml
+++ b/modules/gfac/gfac-ec2/src/test/resources/gfac-config.xml
@@ -19,72 +19,8 @@
</InHandlers>
<OutHandlers></OutHandlers>
</GlobalHandlers>
- <Provider class="org.apache.airavata.gfac.provider.impl.LocalProvider" host="org.apache.airavata.schemas.gfac.impl.HostDescriptionTypeImpl">
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.LocalDirectorySetupHandler"/>
- </InHandlers>
- </Provider>
- <Provider class="org.apache.airavata.gfac.provider.impl.GramProvider" host="org.apache.airavata.schemas.gfac.impl.GlobusHostTypeImpl">
- <property name="name" value="value"/>
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GramDirectorySetupHandler">
- <property name="name" value="value"/>
- </Handler>
- <Handler class="org.apache.airavata.gfac.handler.GridFTPInputHandler"/>
- </InHandlers>
- <OutHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GridFTPOutputHandler"/>
- </OutHandlers>
- </Provider>
- <Provider class="org.apache.airavata.gfac.provider.impl.BESProvider" host="org.apache.airavata.schemas.gfac.impl.UnicoreHostTypeImpl">
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GramDirectorySetupHandler"/>
- <Handler class="org.apache.airavata.gfac.handler.GridFTPInputHandler"/>
- </InHandlers>
- <OutHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GridFTPOutputHandler"/>
- </OutHandlers>
- </Provider>
-
<Provider class="org.apache.airavata.gfac.ec2.EC2Provider" host="org.apache.airavata.schemas.gfac.impl.Ec2HostTypeImpl">
<InHandlers/>
<OutHandlers/>
</Provider>
-
- <Provider class="org.apache.airavata.gfac.provider.impl.HadoopProvider" host="org.apache.airavata.schemas.gfac.impl.HadoopHostTypeImpl">
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.HadoopDeploymentHandler"/>
- <Handler class="org.apache.airavata.gfac.handler.HDFSDataMovementHandler"/>
- </InHandlers>
- <OutHandlers/>
- </Provider>
-
- <Application name="UltraScan">
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GramDirectorySetupHandler"/>
- <Handler class="org.apache.airavata.gfac.handler.GridFTPInputHandler"/>
- </InHandlers>
- <OutHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GridFTPOutputHandler"/>
- </OutHandlers>
- </Application>
-
- <Provider class="org.apache.airavata.gfac.provider.impl.SSHProvider" host="org.apache.airavata.schemas.gfac.impl.SSHHostTypeImpl">
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.SCPDirectorySetupHandler"/>
- <Handler class="org.apache.airavata.gfac.handler.SCPInputHandler"/>
- </InHandlers>
- <OutHandlers>
- <Handler class="org.apache.airavata.gfac.handler.SCPOutputHandler"/>
- </OutHandlers>
- </Provider>
- <Provider class="org.apache.airavata.gfac.provider.impl.GSISSHProvider" host="org.apache.airavata.schemas.gfac.impl.GsisshHostTypeImpl">
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.SCPDirectorySetupHandler"/>
- <Handler class="org.apache.airavata.gfac.handler.SCPInputHandler"/>
- </InHandlers>
- <OutHandlers>
- <Handler class="org.apache.airavata.gfac.handler.SCPOutputHandler"/>
- </OutHandlers>
- </Provider>
</GFac>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/context/security/GSISecurityContext.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/context/security/GSISecurityContext.java b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/context/security/GSISecurityContext.java
index 3eb020f..d8f58a1 100644
--- a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/context/security/GSISecurityContext.java
+++ b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/context/security/GSISecurityContext.java
@@ -29,7 +29,6 @@ import org.apache.airavata.gfac.AbstractSecurityContext;
import org.apache.airavata.gfac.Constants;
import org.apache.airavata.gfac.GFacException;
import org.apache.airavata.gfac.RequestData;
-import org.apache.airavata.gsi.ssh.api.Cluster;
import org.globus.gsi.X509Credential;
import org.globus.gsi.gssapi.GlobusGSSCredentialImpl;
import org.globus.gsi.provider.GlobusProvider;
@@ -61,8 +60,6 @@ public class GSISecurityContext extends AbstractSecurityContext {
private GSSCredential gssCredentials = null;
- private Cluster pbsCluster = null;
-
// Set trusted cert path and add provider
static {
Security.addProvider(new GlobusProvider());
@@ -108,9 +105,6 @@ public class GSISecurityContext extends AbstractSecurityContext {
}
- public GSISecurityContext(Cluster pbsCluster) {
- this.setPbsCluster(pbsCluster);
- }
/**
* Gets GSSCredentials. The process is as follows;
@@ -278,11 +272,4 @@ public class GSISecurityContext extends AbstractSecurityContext {
}
}
- public Cluster getPbsCluster() {
- return pbsCluster;
- }
-
- public void setPbsCluster(Cluster pbsCluster) {
- this.pbsCluster = pbsCluster;
- }
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GramDirectorySetupHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GramDirectorySetupHandler.java b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GramDirectorySetupHandler.java
index feadd72..2a91afd 100644
--- a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GramDirectorySetupHandler.java
+++ b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GramDirectorySetupHandler.java
@@ -49,7 +49,7 @@ import org.slf4j.LoggerFactory;
public class GramDirectorySetupHandler extends AbstractHandler {
private static final Logger log = LoggerFactory.getLogger(GramDirectorySetupHandler.class);
- public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException,GFacException {
+ public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
log.info("Invoking GramDirectorySetupHandler ...");
super.invoke(jobExecutionContext);
String[] gridFTPEndpointArray = null;
@@ -119,17 +119,19 @@ public class GramDirectorySetupHandler extends AbstractHandler {
}
}
if (success == false) {
- GFacUtils.saveErrorDetails(pe.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE, jobExecutionContext.getTaskData().getTaskID());
+ GFacUtils.saveErrorDetails(jobExecutionContext, pe.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE);
throw pe;
}
} catch (SecurityException e) {
throw new GFacHandlerException(e.getMessage(), e);
} catch (ApplicationSettingsException e1) {
throw new GFacHandlerException(e1.getMessage(), e1);
- }
+ } catch (GFacException e) {
+ throw new GFacHandlerException(e);
+ }
}
- public void initProperties(Map<String, String> properties) throws GFacHandlerException, GFacException {
+ public void initProperties(Map<String, String> properties) throws GFacHandlerException {
}
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GridFTPInputHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GridFTPInputHandler.java b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GridFTPInputHandler.java
index 4b1beab..ffbacdd 100644
--- a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GridFTPInputHandler.java
+++ b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GridFTPInputHandler.java
@@ -63,7 +63,7 @@ import org.slf4j.LoggerFactory;
public class GridFTPInputHandler extends AbstractHandler {
private static final Logger log = LoggerFactory.getLogger(AppDescriptorCheckHandler.class);
- public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException,GFacException {
+ public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
log.info("Invoking GridFTPInputHandler ...");
super.invoke(jobExecutionContext);
DataTransferDetails detail = new DataTransferDetails();
@@ -101,7 +101,7 @@ public class GridFTPInputHandler extends AbstractHandler {
status.setTransferState(TransferState.FAILED);
detail.setTransferStatus(status);
registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
- GFacUtils.saveErrorDetails(e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE, jobExecutionContext.getTaskData().getTaskID());
+ GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE);
} catch (Exception e1) {
throw new GFacHandlerException("Error persisting status", e1, e1.getLocalizedMessage());
}
@@ -196,7 +196,7 @@ public class GridFTPInputHandler extends AbstractHandler {
return destURI.getPath();
}
- public void initProperties(Map<String, String> properties) throws GFacHandlerException, GFacException {
+ public void initProperties(Map<String, String> properties) throws GFacHandlerException {
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GridFTPOutputHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GridFTPOutputHandler.java b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GridFTPOutputHandler.java
index e0cb0f8..33e549f 100644
--- a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GridFTPOutputHandler.java
+++ b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/handler/GridFTPOutputHandler.java
@@ -75,7 +75,7 @@ public class GridFTPOutputHandler extends AbstractHandler {
private Registry registry;
- public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException,GFacException {
+ public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
log.info("Invoking GridFTPOutputHandler ...");
super.invoke(jobExecutionContext);
@@ -224,7 +224,7 @@ public class GridFTPOutputHandler extends AbstractHandler {
status.setTransferState(TransferState.FAILED);
detail.setTransferStatus(status);
registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
- GFacUtils.saveErrorDetails(e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE, jobExecutionContext.getTaskData().getTaskID());
+ GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE);
} catch (Exception e1) {
throw new GFacHandlerException("Error persisting status", e1, e1.getLocalizedMessage());
}
@@ -341,7 +341,7 @@ public class GridFTPOutputHandler extends AbstractHandler {
return outputFileStagingPath + File.separator + fileName;
}
- public void initProperties(Map<String, String> properties) throws GFacHandlerException, GFacException {
+ public void initProperties(Map<String, String> properties) throws GFacHandlerException {
}
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/provider/impl/GramProvider.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/provider/impl/GramProvider.java b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/provider/impl/GramProvider.java
index 0cf413c..2ba4b4b 100644
--- a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/provider/impl/GramProvider.java
+++ b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/provider/impl/GramProvider.java
@@ -37,6 +37,7 @@ import org.apache.airavata.gfac.context.JobExecutionContext;
import org.apache.airavata.gfac.context.security.GSISecurityContext;
import org.apache.airavata.gfac.notification.events.JobIDEvent;
import org.apache.airavata.gfac.notification.events.StartExecutionEvent;
+import org.apache.airavata.gfac.provider.AbstractProvider;
import org.apache.airavata.gfac.provider.GFacProviderException;
import org.apache.airavata.gfac.util.GramProviderUtils;
import org.apache.airavata.gfac.utils.GFacUtils;
@@ -56,7 +57,7 @@ import org.ietf.jgss.GSSException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class GramProvider extends AbstractProvider{
+public class GramProvider extends AbstractProvider {
private static final Logger log = LoggerFactory.getLogger(GramJobSubmissionListener.class);
private GramJob job;
@@ -197,7 +198,7 @@ public class GramProvider extends AbstractProvider{
details.setJobID(jobID);
details.setJobDescription(job.getRSL());
jobExecutionContext.setJobDetails(details);
- GFacUtils.saveJobStatus(details, JobState.UN_SUBMITTED, taskID);
+ GFacUtils.saveJobStatus(jobExecutionContext, details, JobState.UN_SUBMITTED);
applicationSaved=true;
String jobStatusMessage = "Un-submitted JobID= " + jobID;
@@ -218,34 +219,34 @@ public class GramProvider extends AbstractProvider{
log.error("Error while submitting commit request - Credentials provided are invalid. Job Id - "
+ job.getIDAsString(), e);
log.info("Attempting to renew credentials and re-submit commit signal...");
- GFacUtils.saveErrorDetails(gssException.getLocalizedMessage(), CorrectiveAction.RETRY_SUBMISSION, ErrorCategory.AIRAVATA_INTERNAL_ERROR, taskID);
+ GFacUtils.saveErrorDetails(jobExecutionContext, gssException.getLocalizedMessage(), CorrectiveAction.RETRY_SUBMISSION, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
renewCredentials(jobExecutionContext);
try {
job.signal(GramJob.SIGNAL_COMMIT_REQUEST);
} catch (GramException e1) {
- GFacUtils.saveErrorDetails(gssException.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR, taskID);
+ GFacUtils.saveErrorDetails(jobExecutionContext, gssException.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
throw new GFacException("Error while sending commit request. Job Id - "
+ job.getIDAsString(), e1);
} catch (GSSException e1) {
- GFacUtils.saveErrorDetails(gssException.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR, taskID);
+ GFacUtils.saveErrorDetails(jobExecutionContext, gssException.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
throw new GFacException("Error while sending commit request. Job Id - "
+ job.getIDAsString() + ". Credentials provided invalid", e1);
}
}
- GFacUtils.updateJobStatus(details, JobState.SUBMITTED);
+ GFacUtils.updateJobStatus(jobExecutionContext, details, JobState.SUBMITTED);
jobStatusMessage = "Submitted JobID= " + job.getIDAsString();
log.info(jobStatusMessage);
jobExecutionContext.getNotifier().publish(new JobIDEvent(jobStatusMessage));
} catch (GSSException e) {
// Renew credentials and re-submit
- GFacUtils.saveErrorDetails(e.getLocalizedMessage(), CorrectiveAction.RETRY_SUBMISSION, ErrorCategory.AIRAVATA_INTERNAL_ERROR, taskID);
+ GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(), CorrectiveAction.RETRY_SUBMISSION, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
reSubmitJob(gateKeeper, jobExecutionContext, globusHostType, e);
} catch (GramException e) {
- GFacUtils.saveErrorDetails(e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR, taskID);
+ GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
throw new GFacException("An error occurred while submitting a job, job id = " + job.getIDAsString(), e);
}
@@ -263,10 +264,10 @@ public class GramProvider extends AbstractProvider{
renewCredentialsAttempt = false;
} catch (GramException e) {
- GFacUtils.saveErrorDetails(e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR, taskID);
+ GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
throw new GFacException("An error occurred while submitting a job, job id = " + job.getIDAsString(), e);
} catch (GSSException e) {
- GFacUtils.saveErrorDetails(e.getLocalizedMessage(), CorrectiveAction.RETRY_SUBMISSION, ErrorCategory.AIRAVATA_INTERNAL_ERROR, taskID);
+ GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(), CorrectiveAction.RETRY_SUBMISSION, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
// Renew credentials and re-submit
reSubmitJob(gateKeeper, jobExecutionContext, globusHostType, e);
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/util/GramJobSubmissionListener.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/util/GramJobSubmissionListener.java b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/util/GramJobSubmissionListener.java
index 5500853..a77864d 100644
--- a/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/util/GramJobSubmissionListener.java
+++ b/modules/gfac/gfac-gram/src/main/java/org/apache/airavata/gfac/util/GramJobSubmissionListener.java
@@ -70,7 +70,7 @@ public class GramJobSubmissionListener implements GramJobListener{
private void setStatus(int status, int error) {
try {
- GFacUtils.updateJobStatus(context.getJobDetails(), GramProviderUtils.getApplicationJobStatus(status));
+ GFacUtils.updateJobStatus(context, context.getJobDetails(), GramProviderUtils.getApplicationJobStatus(status));
} catch (GFacException e) {
log.error("Error persisting status" + e.getLocalizedMessage(), e);
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-gsissh/pom.xml
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gsissh/pom.xml b/modules/gfac/gfac-gsissh/pom.xml
index b05bddf..402619b 100644
--- a/modules/gfac/gfac-gsissh/pom.xml
+++ b/modules/gfac/gfac-gsissh/pom.xml
@@ -30,12 +30,17 @@
<artifactId>slf4j-api</artifactId>
</dependency>
- <!-- GFAC schemas -->
+ <!-- GFAC dependencies -->
<dependency>
<groupId>org.apache.airavata</groupId>
<artifactId>airavata-gfac-core</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-gfac-hpc-monitor</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- Credential Store -->
<dependency>
<groupId>org.apache.airavata</groupId>
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHDirectorySetupHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHDirectorySetupHandler.java b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHDirectorySetupHandler.java
index 66b8094..1b9741d 100644
--- a/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHDirectorySetupHandler.java
+++ b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHDirectorySetupHandler.java
@@ -39,21 +39,24 @@ import java.util.Map;
public class GSISSHDirectorySetupHandler extends AbstractHandler{
private static final Logger log = LoggerFactory.getLogger(GSISSHDirectorySetupHandler.class);
- public void invoke(JobExecutionContext jobExecutionContext) throws GFacException {
- if(jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT) == null){
- try {
+ public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
+ try {
+ if (jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT) == null) {
GFACGSISSHUtils.addSecurityContext(jobExecutionContext);
- } catch (ApplicationSettingsException e) {
- log.error(e.getMessage());
- throw new GFacHandlerException("Error while creating SSHSecurityContext", e, e.getLocalizedMessage());
}
+ } catch (ApplicationSettingsException e) {
+ log.error(e.getMessage());
+ throw new GFacHandlerException("Error while creating SSHSecurityContext", e, e.getLocalizedMessage());
+ } catch (GFacException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
- log.info("Setup SSH job directorties");
- super.invoke(jobExecutionContext);
- makeDirectory(jobExecutionContext);
+ log.info("Setup SSH job directorties");
+ super.invoke(jobExecutionContext);
+ makeDirectory(jobExecutionContext);
}
- private void makeDirectory(JobExecutionContext jobExecutionContext) throws GFacException {
+ private void makeDirectory(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
+ try {
Cluster cluster = ((GSISecurityContext) jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getPbsCluster();
if (cluster == null) {
throw new GFacHandlerException("Security context is not set properly");
@@ -61,7 +64,7 @@ public class GSISSHDirectorySetupHandler extends AbstractHandler{
log.info("Successfully retrieved the Security Context");
}
ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType();
- try {
+
String workingDirectory = app.getScratchWorkingDirectory();
cluster.makeDirectory(workingDirectory);
cluster.makeDirectory(app.getScratchWorkingDirectory());
@@ -84,7 +87,7 @@ public class GSISSHDirectorySetupHandler extends AbstractHandler{
detail.setTransferStatus(status);
try {
registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
- GFacUtils.saveErrorDetails(e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE, jobExecutionContext.getTaskData().getTaskID());
+ GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE);
} catch (Exception e1) {
throw new GFacHandlerException("Error persisting status", e1, e1.getLocalizedMessage());
}
@@ -92,7 +95,7 @@ public class GSISSHDirectorySetupHandler extends AbstractHandler{
}
}
- public void initProperties(Map<String, String> properties) throws GFacHandlerException, GFacException {
+ public void initProperties(Map<String, String> properties) throws GFacHandlerException {
}
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHInputHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHInputHandler.java b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHInputHandler.java
index 80f30f0..6f4fafd 100644
--- a/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHInputHandler.java
+++ b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHInputHandler.java
@@ -45,27 +45,26 @@ import java.io.IOException;
import java.util.*;
public class GSISSHInputHandler extends AbstractHandler {
-
private static final Logger log = LoggerFactory.getLogger(GSISSHInputHandler.class);
- public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException, GFacException {
- if(jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT) == null){
- try {
- GFACGSISSHUtils.addSecurityContext(jobExecutionContext);
- } catch (ApplicationSettingsException e) {
- log.error(e.getMessage());
- throw new GFacHandlerException("Error while creating SSHSecurityContext", e, e.getLocalizedMessage());
- }
- }
- log.info("Invoking SCPInputHandler");
- super.invoke(jobExecutionContext);
-
+ public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
+ MessageContext inputNew = new MessageContext();
DataTransferDetails detail = new DataTransferDetails();
TransferStatus status = new TransferStatus();
-
- MessageContext inputNew = new MessageContext();
try {
+ if (jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT) == null) {
+ try {
+ GFACGSISSHUtils.addSecurityContext(jobExecutionContext);
+ } catch (ApplicationSettingsException e) {
+ log.error(e.getMessage());
+ throw new GFacHandlerException("Error while creating SSHSecurityContext", e, e.getLocalizedMessage());
+ }
+ }
+ log.info("Invoking SCPInputHandler");
+ super.invoke(jobExecutionContext);
+
+
MessageContext input = jobExecutionContext.getInMessageContext();
Set<String> parameters = input.getParameters().keySet();
for (String paramName : parameters) {
@@ -82,8 +81,8 @@ public class GSISSHInputHandler extends AbstractHandler {
status.setTransferState(TransferState.UPLOAD);
detail.setTransferStatus(status);
detail.setTransferDescription("Input Data Staged: " + stageInputFiles);
- registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
- newFiles.add(stageInputFiles);
+ registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
+ newFiles.add(stageInputFiles);
}
((URIArrayType) actualParameter.getType()).setValueArray(newFiles.toArray(new String[newFiles.size()]));
}
@@ -94,11 +93,11 @@ public class GSISSHInputHandler extends AbstractHandler {
status.setTransferState(TransferState.FAILED);
detail.setTransferStatus(status);
try {
- GFacUtils.saveErrorDetails(e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE, jobExecutionContext.getTaskData().getTaskID());
- registry.add(ChildDataType.DATA_TRANSFER_DETAIL,detail, jobExecutionContext.getTaskData().getTaskID());
- } catch (Exception e1) {
- throw new GFacHandlerException("Error persisting status", e1, e1.getLocalizedMessage());
- }
+ GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE);
+ registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
+ } catch (Exception e1) {
+ throw new GFacHandlerException("Error persisting status", e1, e1.getLocalizedMessage());
+ }
throw new GFacHandlerException("Error while input File Staging", e, e.getLocalizedMessage());
}
jobExecutionContext.setInMessageContext(inputNew);
@@ -121,7 +120,7 @@ public class GSISSHInputHandler extends AbstractHandler {
String substring = paramValue.substring(i + 1);
try {
String targetFile = app.getInputDataDirectory() + File.separator + substring;
- if(paramValue.startsWith("file")){
+ if (paramValue.startsWith("file")) {
paramValue = paramValue.substring(paramValue.indexOf(":") + 1, paramValue.length());
}
cluster.scpTo(targetFile, paramValue);
@@ -131,7 +130,7 @@ public class GSISSHInputHandler extends AbstractHandler {
}
}
- public void initProperties(Map<String, String> properties) throws GFacHandlerException, GFacException {
+ public void initProperties(Map<String, String> properties) throws GFacHandlerException {
}
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHOutputHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHOutputHandler.java b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHOutputHandler.java
index fd80d56..3855248 100644
--- a/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHOutputHandler.java
+++ b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/handler/GSISSHOutputHandler.java
@@ -56,7 +56,7 @@ import java.util.Set;
public class GSISSHOutputHandler extends AbstractHandler{
private static final Logger log = LoggerFactory.getLogger(GSISSHOutputHandler.class);
- public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException, GFacException {
+ public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
if(jobExecutionContext.getApplicationContext().getHostDescription().getType() instanceof GsisshHostType) { // this is because we don't have the right jobexecution context
// so attempting to get it from the registry
if (Constants.PUSH.equals(((GsisshHostType) jobExecutionContext.getApplicationContext().getHostDescription().getType()).getMonitorMode())) {
@@ -87,14 +87,17 @@ public class GSISSHOutputHandler extends AbstractHandler{
}
}
}
+ try {
+ if (jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT) == null) {
- if (jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT) == null) {
- try {
GFACGSISSHUtils.addSecurityContext(jobExecutionContext);
- } catch (ApplicationSettingsException e) {
- log.error(e.getMessage());
- throw new GFacHandlerException("Error while creating SSHSecurityContext", e, e.getLocalizedMessage());
}
+ } catch (ApplicationSettingsException e) {
+ log.error(e.getMessage());
+ throw new GFacHandlerException("Error while creating SSHSecurityContext", e, e.getLocalizedMessage());
+ } catch (GFacException e) {
+ log.error(e.getMessage());
+ throw new GFacHandlerException("Error while creating SSHSecurityContext", e, e.getLocalizedMessage());
}
super.invoke(jobExecutionContext);
DataTransferDetails detail = new DataTransferDetails();
@@ -201,7 +204,7 @@ public class GSISSHOutputHandler extends AbstractHandler{
status.setTransferState(TransferState.FAILED);
detail.setTransferStatus(status);
registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
- GFacUtils.saveErrorDetails(e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE, jobExecutionContext.getTaskData().getTaskID());
+ GFacUtils.saveErrorDetails(jobExecutionContext, e.getLocalizedMessage(), CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.FILE_SYSTEM_FAILURE);
} catch (Exception e1) {
throw new GFacHandlerException("Error persisting status", e1, e1.getLocalizedMessage());
}
@@ -210,7 +213,7 @@ public class GSISSHOutputHandler extends AbstractHandler{
}
- public void initProperties(Map<String, String> properties) throws GFacHandlerException, GFacException {
+ public void initProperties(Map<String, String> properties) throws GFacHandlerException {
}
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/provider/impl/GSISSHProvider.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/provider/impl/GSISSHProvider.java b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/provider/impl/GSISSHProvider.java
index 06e2f4a..3cfe599 100644
--- a/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/provider/impl/GSISSHProvider.java
+++ b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/provider/impl/GSISSHProvider.java
@@ -20,11 +20,17 @@
*/
package org.apache.airavata.gfac.provider.impl;
+import org.apache.airavata.gfac.Constants;
import org.apache.airavata.gfac.GFacException;
import org.apache.airavata.gfac.context.JobExecutionContext;
import org.apache.airavata.gfac.context.security.GSISecurityContext;
+import org.apache.airavata.gfac.cpi.GFacImpl;
+import org.apache.airavata.gfac.handler.ThreadedHandler;
+import org.apache.airavata.gfac.monitor.handlers.GridPullMonitorHandler;
import org.apache.airavata.gfac.notification.events.StartExecutionEvent;
+import org.apache.airavata.gfac.provider.AbstractProvider;
import org.apache.airavata.gfac.provider.GFacProviderException;
+import org.apache.airavata.gfac.util.GFACGSISSHUtils;
import org.apache.airavata.gfac.utils.GFacUtils;
import org.apache.airavata.gsi.ssh.api.Cluster;
import org.apache.airavata.gsi.ssh.api.SSHApiException;
@@ -33,14 +39,16 @@ import org.apache.airavata.model.workspace.experiment.CorrectiveAction;
import org.apache.airavata.model.workspace.experiment.ErrorCategory;
import org.apache.airavata.model.workspace.experiment.JobDetails;
import org.apache.airavata.model.workspace.experiment.JobState;
+import org.apache.airavata.schemas.gfac.GsisshHostType;
import org.apache.airavata.schemas.gfac.HostDescriptionType;
import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.List;
import java.util.Map;
-public class GSISSHProvider extends AbstractProvider{
+public class GSISSHProvider extends AbstractProvider {
private static final Logger log = LoggerFactory.getLogger(GSISSHProvider.class);
public void initProperties(Map<String, String> properties) throws GFacProviderException, GFacException {
@@ -71,7 +79,7 @@ public class GSISSHProvider extends AbstractProvider{
log.info("Successfully retrieved the Security Context");
}
// This installed path is a mandetory field, because this could change based on the computing resource
- JobDescriptor jobDescriptor = GFacUtils.createJobDescriptor(jobExecutionContext, app, cluster);
+ JobDescriptor jobDescriptor = GFACGSISSHUtils.createJobDescriptor(jobExecutionContext, app, cluster);
log.info(jobDescriptor.toXML());
@@ -81,25 +89,43 @@ public class GSISSHProvider extends AbstractProvider{
jobExecutionContext.setJobDetails(jobDetails);
if(jobID == null){
jobDetails.setJobID("none");
- GFacUtils.saveJobStatus(jobDetails, JobState.FAILED, taskID);
+ GFacUtils.saveJobStatus(jobExecutionContext, jobDetails, JobState.FAILED);
}else{
jobDetails.setJobID(jobID);
- GFacUtils.saveJobStatus(jobDetails, JobState.SUBMITTED, taskID);
+ GFacUtils.saveJobStatus(jobExecutionContext, jobDetails, JobState.SUBMITTED);
}
+
+ // Now job has submitted to the resource, its up to the Provider to parse the information to daemon handler
+ // to perform monitoring, daemon handlers can be accessed from anywhere
+ List<ThreadedHandler> daemonHandlers = GFacImpl.getDaemonHandlers();
+ GridPullMonitorHandler pullMonitorHandler = null;
+ for(ThreadedHandler threadedHandler:daemonHandlers){
+ if(threadedHandler instanceof GridPullMonitorHandler){
+ pullMonitorHandler = (GridPullMonitorHandler)threadedHandler;
+ }
+ }
+ // we know this hos is type GsiSSHHostType
+ String monitorMode = ((GsisshHostType) host).getMonitorMode();
+ if("".equals(monitorMode) || monitorMode == null || org.apache.airavata.common.utils.Constants.PULL.equals(monitorMode)){
+ log.info("Job is launched successfully now parsing it to monitoring in pull mode, JobID Returned: " + jobID);
+ pullMonitorHandler.invoke(jobExecutionContext);
+ }else{
+ log.error("Currently we only support Pull monitoring");
+ }
} catch (SSHApiException e) {
String error = "Error submitting the job to host " + host.getHostAddress() + " message: " + e.getMessage();
log.error(error);
jobDetails.setJobID("none");
- GFacUtils.saveJobStatus(jobDetails,JobState.FAILED,taskID);
- GFacUtils.saveErrorDetails(error, CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR, taskID);
+ GFacUtils.saveJobStatus(jobExecutionContext, jobDetails,JobState.FAILED);
+ GFacUtils.saveErrorDetails(jobExecutionContext, error, CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
throw new GFacProviderException(error, e);
} catch (Exception e) {
String error = "Error submitting the job to host " + host.getHostAddress() + " message: " + e.getMessage();
log.error(error);
jobDetails.setJobID("none");
- GFacUtils.saveJobStatus(jobDetails,JobState.FAILED,taskID);
- GFacUtils.saveErrorDetails(error, CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR, taskID);
+ GFacUtils.saveJobStatus(jobExecutionContext, jobDetails,JobState.FAILED);
+ GFacUtils.saveErrorDetails(jobExecutionContext, error, CorrectiveAction.CONTACT_SUPPORT, ErrorCategory.AIRAVATA_INTERNAL_ERROR);
throw new GFacProviderException(error, e);
}
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/util/GFACGSISSHUtils.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/util/GFACGSISSHUtils.java b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/util/GFACGSISSHUtils.java
index d0f92c1..0351d00 100644
--- a/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/util/GFACGSISSHUtils.java
+++ b/modules/gfac/gfac-gsissh/src/main/java/org/apache/airavata/gfac/util/GFACGSISSHUtils.java
@@ -21,24 +21,33 @@
package org.apache.airavata.gfac.util;
import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.StringUtil;
+import org.apache.airavata.commons.gfac.type.ActualParameter;
import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.commons.gfac.type.MappingFactory;
import org.apache.airavata.gfac.Constants;
import org.apache.airavata.gfac.GFacException;
import org.apache.airavata.gfac.RequestData;
import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.context.MessageContext;
import org.apache.airavata.gfac.context.security.GSISecurityContext;
import org.apache.airavata.gsi.ssh.api.Cluster;
import org.apache.airavata.gsi.ssh.api.SSHApiException;
import org.apache.airavata.gsi.ssh.api.ServerInfo;
import org.apache.airavata.gsi.ssh.api.authentication.GSIAuthenticationInfo;
+import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
import org.apache.airavata.gsi.ssh.api.job.JobManagerConfiguration;
import org.apache.airavata.gsi.ssh.impl.PBSCluster;
import org.apache.airavata.gsi.ssh.impl.authentication.MyProxyAuthenticationInfo;
import org.apache.airavata.gsi.ssh.util.CommonUtils;
+import org.apache.airavata.model.workspace.experiment.ComputationalResourceScheduling;
+import org.apache.airavata.model.workspace.experiment.TaskDetails;
import org.apache.airavata.schemas.gfac.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.*;
+
public class GFACGSISSHUtils {
private final static Logger logger = LoggerFactory.getLogger(GFACGSISSHUtils.class);
@@ -95,4 +104,89 @@ public class GFACGSISSHUtils {
}
jobExecutionContext.addSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT,context);
}
+ public static JobDescriptor createJobDescriptor(JobExecutionContext jobExecutionContext,
+ ApplicationDeploymentDescriptionType app, Cluster cluster) {
+ JobDescriptor jobDescriptor = new JobDescriptor();
+ // this is common for any application descriptor
+ jobDescriptor.setInputDirectory(app.getInputDataDirectory());
+ jobDescriptor.setOutputDirectory(app.getOutputDataDirectory());
+ jobDescriptor.setExecutablePath(app.getExecutableLocation());
+ jobDescriptor.setStandardOutFile(app.getStandardOutput());
+ jobDescriptor.setStandardErrorFile(app.getStandardError());
+ Random random = new Random();
+ int i = random.nextInt();
+ jobDescriptor.setJobName(app.getApplicationName().getStringValue() + String.valueOf(i));
+ jobDescriptor.setWorkingDirectory(app.getStaticWorkingDirectory());
+
+
+ List<String> inputValues = new ArrayList<String>();
+ MessageContext input = jobExecutionContext.getInMessageContext();
+ Map<String, Object> inputs = input.getParameters();
+ Set<String> keys = inputs.keySet();
+ for (String paramName : keys) {
+ ActualParameter actualParameter = (ActualParameter) inputs.get(paramName);
+ if ("URIArray".equals(actualParameter.getType().getType().toString()) || "StringArray".equals(actualParameter.getType().getType().toString())
+ || "FileArray".equals(actualParameter.getType().getType().toString())) {
+ String[] values = null;
+ if (actualParameter.getType() instanceof URIArrayType) {
+ values = ((URIArrayType) actualParameter.getType()).getValueArray();
+ } else if (actualParameter.getType() instanceof StringArrayType) {
+ values = ((StringArrayType) actualParameter.getType()).getValueArray();
+ } else if (actualParameter.getType() instanceof FileArrayType) {
+ values = ((FileArrayType) actualParameter.getType()).getValueArray();
+ }
+ String value = StringUtil.createDelimiteredString(values, " ");
+ inputValues.add(value);
+ } else {
+ String paramValue = MappingFactory.toString(actualParameter);
+ inputValues.add(paramValue);
+ }
+ }
+ jobDescriptor.setInputValues(inputValues);
+
+ // this part will fill out the hpcApplicationDescriptor
+ if (app instanceof HpcApplicationDeploymentType) {
+ HpcApplicationDeploymentType applicationDeploymentType
+ = (HpcApplicationDeploymentType) app;
+ jobDescriptor.setShellName("/bin/bash");
+ jobDescriptor.setAllEnvExport(true);
+ jobDescriptor.setMailOptions("n");
+ jobDescriptor.setNodes(applicationDeploymentType.getNodeCount());
+ jobDescriptor.setProcessesPerNode(applicationDeploymentType.getProcessorsPerNode());
+ jobDescriptor.setMaxWallTime(String.valueOf(applicationDeploymentType.getMaxWallTime()));
+ jobDescriptor.setJobSubmitter(applicationDeploymentType.getJobSubmitterCommand());
+ if (applicationDeploymentType.getProjectAccount() != null) {
+ if (applicationDeploymentType.getProjectAccount().getProjectAccountNumber() != null) {
+ jobDescriptor.setAcountString(applicationDeploymentType.getProjectAccount().getProjectAccountNumber());
+ }
+ }
+ if (applicationDeploymentType.getQueue() != null) {
+ if (applicationDeploymentType.getQueue().getQueueName() != null) {
+ jobDescriptor.setQueueName(applicationDeploymentType.getQueue().getQueueName());
+ }
+ }
+ jobDescriptor.setOwner(((PBSCluster) cluster).getServerInfo().getUserName());
+ TaskDetails taskData = jobExecutionContext.getTaskData();
+ if (taskData != null && taskData.isSetTaskScheduling()) {
+ ComputationalResourceScheduling computionnalResource = taskData.getTaskScheduling();
+ if (computionnalResource.getNodeCount() > 0) {
+ jobDescriptor.setNodes(computionnalResource.getNodeCount());
+ }
+ if (computionnalResource.getComputationalProjectAccount() != null) {
+ jobDescriptor.setAcountString(computionnalResource.getComputationalProjectAccount());
+ }
+ if (computionnalResource.getQueueName() != null) {
+ jobDescriptor.setQueueName(computionnalResource.getQueueName());
+ }
+ if (computionnalResource.getTotalCPUCount() > 0) {
+ jobDescriptor.setProcessesPerNode(computionnalResource.getTotalCPUCount());
+ }
+ if (computionnalResource.getWallTimeLimit() > 0) {
+ jobDescriptor.setMaxWallTime(String.valueOf(computionnalResource.getWallTimeLimit()));
+ }
+ }
+
+ }
+ return jobDescriptor;
+ }
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-hadoop/src/main/java/org/apache/airavata/gfac/handler/HDFSDataMovementHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-hadoop/src/main/java/org/apache/airavata/gfac/handler/HDFSDataMovementHandler.java b/modules/gfac/gfac-hadoop/src/main/java/org/apache/airavata/gfac/handler/HDFSDataMovementHandler.java
index aafcdec..49eadf4 100644
--- a/modules/gfac/gfac-hadoop/src/main/java/org/apache/airavata/gfac/handler/HDFSDataMovementHandler.java
+++ b/modules/gfac/gfac-hadoop/src/main/java/org/apache/airavata/gfac/handler/HDFSDataMovementHandler.java
@@ -21,7 +21,6 @@
package org.apache.airavata.gfac.handler;
-import org.apache.airavata.gfac.GFacException;
import org.apache.airavata.gfac.context.JobExecutionContext;
import org.apache.airavata.gfac.context.MessageContext;
import org.apache.airavata.gfac.provider.utils.HadoopUtils;
@@ -96,7 +95,7 @@ public class HDFSDataMovementHandler implements GFacHandler {
private void handleOutPath(JobExecutionContext jobExecutionContext){}
- public void initProperties(Map<String, String> properties) throws GFacHandlerException, GFacException {
+ public void initProperties(Map<String, String> properties) throws GFacHandlerException {
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-hadoop/src/main/java/org/apache/airavata/gfac/handler/HadoopDeploymentHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-hadoop/src/main/java/org/apache/airavata/gfac/handler/HadoopDeploymentHandler.java b/modules/gfac/gfac-hadoop/src/main/java/org/apache/airavata/gfac/handler/HadoopDeploymentHandler.java
index f72afd1..c7de3f9 100644
--- a/modules/gfac/gfac-hadoop/src/main/java/org/apache/airavata/gfac/handler/HadoopDeploymentHandler.java
+++ b/modules/gfac/gfac-hadoop/src/main/java/org/apache/airavata/gfac/handler/HadoopDeploymentHandler.java
@@ -23,7 +23,6 @@ package org.apache.airavata.gfac.handler;
import com.google.common.io.Files;
import org.apache.airavata.commons.gfac.type.HostDescription;
-import org.apache.airavata.gfac.GFacException;
import org.apache.airavata.gfac.context.JobExecutionContext;
import org.apache.airavata.gfac.context.MessageContext;
import org.apache.airavata.schemas.gfac.HadoopHostType;
@@ -71,6 +70,7 @@ public class HadoopDeploymentHandler implements GFacHandler {
* configuration provided. If there is a already deployed hadoop cluster this will skip
* deployment.
*
+ *
* @param jobExecutionContext job execution context containing all the required configurations
* and runtime information.
* @throws GFacHandlerException
@@ -268,7 +268,7 @@ public class HadoopDeploymentHandler implements GFacHandler {
return ((HadoopHostType)hostDescription.getType()).getHadoopConfigurationDirectory();
}
- public void initProperties(Map<String, String> properties) throws GFacHandlerException, GFacException {
+ public void initProperties(Map<String, String> properties) throws GFacHandlerException {
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-hadoop/src/main/java/org/apache/airavata/gfac/provider/impl/HadoopProvider.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-hadoop/src/main/java/org/apache/airavata/gfac/provider/impl/HadoopProvider.java b/modules/gfac/gfac-hadoop/src/main/java/org/apache/airavata/gfac/provider/impl/HadoopProvider.java
index c20e2ea..0fc8b47 100644
--- a/modules/gfac/gfac-hadoop/src/main/java/org/apache/airavata/gfac/provider/impl/HadoopProvider.java
+++ b/modules/gfac/gfac-hadoop/src/main/java/org/apache/airavata/gfac/provider/impl/HadoopProvider.java
@@ -31,6 +31,7 @@ import org.apache.airavata.commons.gfac.type.ActualParameter;
import org.apache.airavata.gfac.GFacException;
import org.apache.airavata.gfac.context.JobExecutionContext;
import org.apache.airavata.gfac.context.MessageContext;
+import org.apache.airavata.gfac.provider.AbstractProvider;
import org.apache.airavata.gfac.provider.GFacProviderException;
import org.apache.airavata.gfac.provider.utils.HadoopUtils;
import org.apache.airavata.schemas.gfac.HadoopApplicationDeploymentDescriptionType;
@@ -55,7 +56,7 @@ import sun.reflect.generics.reflectiveObjects.NotImplementedException;
* Executes hadoop job using the cluster configuration provided by handlers in
* in-flow.
*/
-public class HadoopProvider extends AbstractProvider{
+public class HadoopProvider extends AbstractProvider {
private static final Logger logger = LoggerFactory.getLogger(HadoopProvider.class);
private boolean isWhirrBasedDeployment = false;
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-hadoop/src/test/resources/gfac-config.xml
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-hadoop/src/test/resources/gfac-config.xml b/modules/gfac/gfac-hadoop/src/test/resources/gfac-config.xml
index 7c7e704..f43a5fb 100644
--- a/modules/gfac/gfac-hadoop/src/test/resources/gfac-config.xml
+++ b/modules/gfac/gfac-hadoop/src/test/resources/gfac-config.xml
@@ -19,37 +19,6 @@
</InHandlers>
<OutHandlers></OutHandlers>
</GlobalHandlers>
- <Provider class="org.apache.airavata.gfac.provider.impl.LocalProvider" host="org.apache.airavata.schemas.gfac.impl.HostDescriptionTypeImpl">
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.LocalDirectorySetupHandler"/>
- </InHandlers>
- </Provider>
- <Provider class="org.apache.airavata.gfac.provider.impl.GramProvider" host="org.apache.airavata.schemas.gfac.impl.GlobusHostTypeImpl">
- <property name="name" value="value"/>
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GramDirectorySetupHandler">
- <property name="name" value="value"/>
- </Handler>
- <Handler class="org.apache.airavata.gfac.handler.GridFTPInputHandler"/>
- </InHandlers>
- <OutHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GridFTPOutputHandler"/>
- </OutHandlers>
- </Provider>
- <Provider class="org.apache.airavata.gfac.provider.impl.BESProvider" host="org.apache.airavata.schemas.gfac.impl.UnicoreHostTypeImpl">
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GramDirectorySetupHandler"/>
- <Handler class="org.apache.airavata.gfac.handler.GridFTPInputHandler"/>
- </InHandlers>
- <OutHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GridFTPOutputHandler"/>
- </OutHandlers>
- </Provider>
-
- <Provider class="org.apache.airavata.gfac.ec2.EC2Provider" host="org.apache.airavata.schemas.gfac.impl.Ec2HostTypeImpl">
- <InHandlers/>
- <OutHandlers/>
- </Provider>
<Provider class="org.apache.airavata.gfac.provider.impl.HadoopProvider" host="org.apache.airavata.schemas.gfac.impl.HadoopHostTypeImpl">
<InHandlers>
@@ -68,23 +37,4 @@
<Handler class="org.apache.airavata.gfac.handler.GridFTPOutputHandler"/>
</OutHandlers>
</Application>
-
- <Provider class="org.apache.airavata.gfac.provider.impl.SSHProvider" host="org.apache.airavata.schemas.gfac.impl.SSHHostTypeImpl">
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.SSHDirectorySetupHandler"/>
- <Handler class="org.apache.airavata.gfac.handler.GSISSHInputHandler"/>
- </InHandlers>
- <OutHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GSISSHOutputHandler"/>
- </OutHandlers>
- </Provider>
- <Provider class="org.apache.airavata.gfac.provider.impl.GSISSHProvider" host="org.apache.airavata.schemas.gfac.impl.GsisshHostTypeImpl">
- <InHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GSISSHDirectorySetupHandler"/>
- <Handler class="org.apache.airavata.gfac.handler.GSISSHInputHandler"/>
- </InHandlers>
- <OutHandlers>
- <Handler class="org.apache.airavata.gfac.handler.GSISSHOutputHandler"/>
- </OutHandlers>
- </Provider>
</GFac>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-local/src/main/java/org/apache/airavata/gfac/handler/LocalDirectorySetupHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-local/src/main/java/org/apache/airavata/gfac/handler/LocalDirectorySetupHandler.java b/modules/gfac/gfac-local/src/main/java/org/apache/airavata/gfac/handler/LocalDirectorySetupHandler.java
index 8174a3d..8a11c2a 100644
--- a/modules/gfac/gfac-local/src/main/java/org/apache/airavata/gfac/handler/LocalDirectorySetupHandler.java
+++ b/modules/gfac/gfac-local/src/main/java/org/apache/airavata/gfac/handler/LocalDirectorySetupHandler.java
@@ -21,7 +21,6 @@
package org.apache.airavata.gfac.handler;
import org.apache.airavata.commons.gfac.type.ApplicationDescription;
-import org.apache.airavata.gfac.GFacException;
import org.apache.airavata.gfac.context.JobExecutionContext;
import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
import org.apache.airavata.schemas.gfac.HostDescriptionType;
@@ -56,7 +55,7 @@ public class LocalDirectorySetupHandler implements GFacHandler{
}
}
- public void initProperties(Map<String, String> properties) throws GFacHandlerException, GFacException {
+ public void initProperties(Map<String, String> properties) throws GFacHandlerException {
}
}
[8/9] Separating gfac-monitoring implementation
Posted by la...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/MonitorID.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/MonitorID.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/MonitorID.java
deleted file mode 100644
index a481564..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/MonitorID.java
+++ /dev/null
@@ -1,238 +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.commons.gfac.type.HostDescription;
-import org.apache.airavata.gfac.context.JobExecutionContext;
-import org.apache.airavata.gsi.ssh.api.authentication.AuthenticationInfo;
-import org.apache.airavata.gsi.ssh.impl.authentication.MyProxyAuthenticationInfo;
-import org.apache.airavata.model.workspace.experiment.JobState;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.sql.Timestamp;
-import java.util.Date;
-import java.util.Map;
-
-/*
-This is the object which contains the data to identify a particular
-Job to start the monitoring
-*/
-public class MonitorID {
- private final static Logger logger = LoggerFactory.getLogger(MonitorID.class);
-
- private String userName;
-
- private Timestamp jobStartedTime;
-
- private Timestamp lastMonitored;
-
- private HostDescription host;
-
- private AuthenticationInfo authenticationInfo = null;
-
- private Map<String, Object> parameters;
-
- private String experimentID;
-
- private String workflowNodeID;
-
- private String taskID;
-
- private String jobID;
-
- private int failedCount = 0;
-
- private JobState state;
-
- private JobExecutionContext jobExecutionContext;
-
- public MonitorID(HostDescription host, String jobID,String taskID, String workflowNodeID, String experimentID, String userName) {
- this.host = host;
- this.jobStartedTime = new Timestamp((new Date()).getTime());
- this.userName = userName;
- this.jobID = jobID;
- this.taskID = taskID;
- this.experimentID = experimentID;
- this.workflowNodeID = workflowNodeID;
- }
-
- public MonitorID(HostDescription host, String jobID,String taskID, String workflowNodeID, String experimentID, String userName,AuthenticationInfo authenticationInfo) {
- this.host = host;
- this.jobStartedTime = new Timestamp((new Date()).getTime());
- this.authenticationInfo = authenticationInfo;
- this.userName = userName;
- // if we give myproxyauthenticationInfo, so we try to use myproxy user as the user
- if(this.authenticationInfo != null){
- if(this.authenticationInfo instanceof MyProxyAuthenticationInfo){
- this.userName = ((MyProxyAuthenticationInfo)this.authenticationInfo).getUserName();
- }
- }
- this.workflowNodeID = workflowNodeID;
- this.jobID = jobID;
- this.taskID = taskID;
- this.experimentID = experimentID;
- }
- public HostDescription getHost() {
- return host;
- }
-
- public void setHost(HostDescription host) {
- this.host = host;
- }
-
- public Timestamp getLastMonitored() {
- return lastMonitored;
- }
-
- public void setLastMonitored(Timestamp lastMonitored) {
- this.lastMonitored = lastMonitored;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- public String getJobID() {
- return jobID;
- }
-
- public void setJobID(String jobID) {
- this.jobID = jobID;
- }
-
- public Timestamp getJobStartedTime() {
- return jobStartedTime;
- }
-
- public void setJobStartedTime(Timestamp jobStartedTime) {
- this.jobStartedTime = jobStartedTime;
- }
-
- public AuthenticationInfo getAuthenticationInfo() {
- return authenticationInfo;
- }
-
- public void setAuthenticationInfo(AuthenticationInfo authenticationInfo) {
- this.authenticationInfo = authenticationInfo;
- }
-
- public void addParameter(String key,Object value) {
- this.parameters.put(key, value);
- }
-
- public Object getParameter(String key) {
- return this.parameters.get(key);
- }
-
- public Map<String, Object> getParameters() {
- return parameters;
- }
-
- public void setParameters(Map<String, Object> parameters) {
- this.parameters = parameters;
- }
-
- 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 int getFailedCount() {
- return failedCount;
- }
-
- public void setFailedCount(int failedCount) {
- this.failedCount = failedCount;
- }
-
- public JobState getStatus() {
- return state;
- }
-
- public void setStatus(JobState status) {
- // this logic is going to be useful for fast finishing jobs
- // because in some machines job state vanishes quicckly when the job is done
- // during that case job state comes as unknown.so we handle it here.
- if (this.state != null && status.equals(JobState.UNKNOWN)) {
- if (getFailedCount() > 2) {
- switch (this.state) {
- case ACTIVE:
- this.state = JobState.COMPLETE;
- break;
- case QUEUED:
- this.state = JobState.COMPLETE;
- break;
- }
- } else {
- try {
- // when state becomes unknown we sleep for a while
- Thread.sleep(10000);
- } catch (InterruptedException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- setFailedCount(getFailedCount() + 1);
- }
- } else {
- // normal scenario
- this.state = status;
- }
- }
-
- public String getWorkflowNodeID() {
- return workflowNodeID;
- }
-
- public void setWorkflowNodeID(String workflowNodeID) {
- this.workflowNodeID = workflowNodeID;
- }
-
- public JobExecutionContext getJobExecutionContext() {
- return jobExecutionContext;
- }
-
- public void setJobExecutionContext(JobExecutionContext jobExecutionContext) {
- this.jobExecutionContext = jobExecutionContext;
- }
-
- // public String getWorkflowNodeID() {
-// return workflowNodeID;
-// }
-//
-// public void setWorkflowNodeID(String workflowNodeID) {
-// this.workflowNodeID = workflowNodeID;
-// }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/MonitorManager.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/MonitorManager.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/MonitorManager.java
deleted file mode 100644
index b703a0a..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/MonitorManager.java
+++ /dev/null
@@ -1,347 +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 com.google.common.eventbus.EventBus;
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.Constants;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.gfac.monitor.core.Monitor;
-import org.apache.airavata.gfac.monitor.core.PullMonitor;
-import org.apache.airavata.gfac.monitor.core.PushMonitor;
-import org.apache.airavata.gfac.monitor.event.MonitorPublisher;
-import org.apache.airavata.gfac.monitor.exception.AiravataMonitorException;
-import org.apache.airavata.gfac.monitor.impl.LocalJobMonitor;
-import org.apache.airavata.gfac.monitor.impl.pull.qstat.QstatMonitor;
-import org.apache.airavata.gfac.monitor.impl.push.amqp.AMQPMonitor;
-import org.apache.airavata.gfac.monitor.util.CommonUtils;
-import org.apache.airavata.persistance.registry.jpa.impl.RegistryImpl;
-import org.apache.airavata.registry.cpi.Registry;
-import org.apache.airavata.schemas.gfac.GlobusHostType;
-import org.apache.airavata.schemas.gfac.GsisshHostType;
-import org.apache.airavata.schemas.gfac.SSHHostType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-
-/*
-this is the manager class for monitoring system of airavata,
-This simply handle the monitoring flow of the system.
-Keeps available jobs to monitor in a queue and once they are done
-remove them from the queue, this will be done by AiravataJobUpdator.
- */
-public class MonitorManager {
- private final static Logger logger = LoggerFactory.getLogger(MonitorManager.class);
-
- private final static String ACTIVITY_LISTENERS = "activity.listeners";
-
- private List<PullMonitor> pullMonitors; //todo though we have a List we only support one at a time
-
- private List<PushMonitor> pushMonitors; //todo we need to support multiple monitors dynamically
-
- private BlockingQueue<UserMonitorData> pullQueue;
-
- private BlockingQueue<MonitorID> pushQueue;
-
- private BlockingQueue<MonitorID> localJobQueue;
-
- private BlockingQueue<MonitorID> finishQueue;
-
- private MonitorPublisher monitorPublisher;
-
- private Monitor localJobMonitor;
-
- private Registry registry;
-
- /**
- * This will initialize the major monitoring system.
- */
- public MonitorManager() {
- this(new RegistryImpl());
- }
-
- public MonitorManager(Registry registry) {
- pullMonitors = new ArrayList<PullMonitor>();
- pushMonitors = new ArrayList<PushMonitor>();
- pullQueue = new LinkedBlockingQueue<UserMonitorData>();
- pushQueue = new LinkedBlockingQueue<MonitorID>();
- finishQueue = new LinkedBlockingQueue<MonitorID>();
- localJobQueue = new LinkedBlockingQueue<MonitorID>();
- monitorPublisher = new MonitorPublisher(new EventBus());
- this.registry = registry;
- loadActivityMonitors();
- }
-
- private void loadActivityMonitors(){
- try {
- String activityListenersString = ServerSettings.getSetting(ACTIVITY_LISTENERS);
- if (activityListenersString!=null){
- String[] activityListenerClasses = activityListenersString.split(",");
- for (String activityListenerClassName : activityListenerClasses) {
- try {
- activityListenerClassName=activityListenerClassName.trim();
- Class<?> classInstance = MonitorManager.class
- .getClassLoader().loadClass(activityListenerClassName);
- AbstractActivityListener monitor=(AbstractActivityListener)classInstance.newInstance();
- registerListener(monitor);
- } catch (ClassNotFoundException e) {
- logger.error("Error while locating activity monitor implementation \""+activityListenerClassName+"\"!!!",e);
- } catch (InstantiationException e) {
- logger.error("Error while initiating activity monitor instance \""+activityListenerClassName+"\"!!!",e);
- } catch (IllegalAccessException e) {
- logger.error("Error while initiating activity monitor instance \""+activityListenerClassName+"\"!!!",e);
- } catch (ClassCastException e){
- logger.error("Invalid activity monitor \""+activityListenerClassName+"\"!!!",e);
- }
- }
- }
- } catch (ApplicationSettingsException e1) {
- logger.warn("Error in reading activity monitors!!!", e1);
- }
-
- }
- /**
- * This can be use to add an empty AMQPMonitor object to the monitor system
- * and tihs method will take care of the initialization
- * todo may be we need to move this to some other class
- * @param monitor
- */
- public void addAMQPMonitor(AMQPMonitor monitor) {
- monitor.setPublisher(this.getMonitorPublisher());
- monitor.setFinishQueue(this.getFinishQueue());
- monitor.setRunningQueue(this.getPushQueue());
- addPushMonitor(monitor);
- }
-
-
- /**
- * This can be use to add an empty AMQPMonitor object to the monitor system
- * and tihs method will take care of the initialization
- * todo may be we need to move this to some other class
- * @param monitor
- */
- public void addLocalMonitor(LocalJobMonitor monitor) {
- monitor.setPublisher(this.getMonitorPublisher());
- monitor.setJobQueue(this.getLocalJobQueue());
- localJobMonitor = monitor;
- }
-
- /**
- * This can be used to adda a QstatMonitor and it will take care of
- * the initialization of QstatMonitor
- * //todo may be we need to move this to some other class
- * @param qstatMonitor
- */
- public void addQstatMonitor(QstatMonitor qstatMonitor) {
- qstatMonitor.setPublisher(this.getMonitorPublisher());
- qstatMonitor.setQueue(this.getPullQueue());
- addPullMonitor(qstatMonitor);
-
- }
-
- /**
- * To deal with the statuses users can write their own listener and implement their own logic
- *
- * @param listener Any class can be written and if you want the JobStatus object to be taken from the bus, just
- * have to put @subscribe as an annotation to your method to recieve the JobStatus object from the bus.
- */
- public void registerListener(Object listener) {
- monitorPublisher.registerListener(listener);
- if (listener instanceof AbstractActivityListener){
- ((AbstractActivityListener)listener).setup(registry, getFinishQueue(), getMonitorPublisher(), this);
- }
- }
-
- public void registerListener(AbstractActivityListener listener) {
- registerListener((Object)listener);
- }
-
- /**
- * To remove listeners of changing statuses
- *
- * @param listener Any class can be written and if you want the JobStatus object to be taken from the bus, just
- * have to put @subscribe as an annotation to your method to recieve the JobStatus object from the bus.
- */
- public void unregisterListener(Object listener) {
- monitorPublisher.unregisterListener(listener);
- }
-
- /**
- * todo write
- *
- * @param monitor
- */
- public void addPushMonitor(PushMonitor monitor) {
- pushMonitors.add(monitor);
- }
-
- /**
- * todo write
- *
- * @param monitor
- */
- public void addPullMonitor(PullMonitor monitor) {
- pullMonitors.add(monitor);
- }
-
-
- /**
- * Adding this method will trigger the thread in launchMonitor and notify it
- * This is going to be useful during the startup of the launching process
- * @param monitorID
- * @throws AiravataMonitorException
- * @throws InterruptedException
- */
- public void addAJobToMonitor(MonitorID monitorID) throws AiravataMonitorException, InterruptedException {
-
- if (monitorID.getHost().getType() instanceof GsisshHostType) {
- GsisshHostType host = (GsisshHostType) monitorID.getHost().getType();
- if ("".equals(host.getMonitorMode()) || host.getMonitorMode() == null
- || Constants.PULL.equals(host.getMonitorMode())) {
- CommonUtils.addMonitortoQueue(pullQueue, monitorID);
- } else if (Constants.PUSH.equals(host.getMonitorMode())) {
- pushQueue.put(monitorID);
- finishQueue.put(monitorID);
- }
- } else if(monitorID.getHost().getType() instanceof GlobusHostType){
- logger.error("Monitoring does not support GlubusHostType resources");
- } else if(monitorID.getHost().getType() instanceof SSHHostType) {
- logger.error("Monitoring does not support GlubusHostType resources");
- localJobQueue.add(monitorID);
- } else {
- // we assume this is a type of localJobtype
- localJobQueue.add(monitorID);
- }
- }
-
- /**
- * This method should be invoked before adding any elements to monitorQueue
- * In this method we assume that we give higher preference to Push
- * Monitorig mechanism if there's any configured, otherwise Pull
- * monitoring will be launched.
- * Ex: If there's a reasource which doesn't support Push, we have
- * to live with Pull MOnitoring.
- *
- * @throws AiravataMonitorException
- */
- public void launchMonitor() throws AiravataMonitorException {
- //no push monitor is configured so we launch pull monitor
- if(localJobMonitor != null){
- (new Thread(localJobMonitor)).start();
- }
-
- for (PullMonitor monitor : pullMonitors) {
- (new Thread(monitor)).start();
- }
-
- //todo fix this
- for (PushMonitor monitor : pushMonitors) {
- (new Thread(monitor)).start();
- }
- }
-
- /**
- * This method should be invoked before adding any elements to monitorQueue
- * In this method we assume that we give higher preference to Push
- * Monitorig mechanism if there's any configured, otherwise Pull
- * monitoring will be launched.
- * Ex: If there's a reasource which doesn't support Push, we have
- * to live with Pull MOnitoring.
- *
- * @throws AiravataMonitorException
- */
- public void stopMonitor() throws AiravataMonitorException {
- //no push monitor is configured so we launch pull monitor
- if(localJobMonitor != null){
- (new Thread(localJobMonitor)).interrupt();
- }
-
- for (PullMonitor monitor : pullMonitors) {
- (new Thread(monitor)).interrupt();
- }
-
- //todo fix this
- for (PushMonitor monitor : pushMonitors) {
- (new Thread(monitor)).interrupt();
- }
- }
- /* getter setters for the private variables */
-
- public List<PullMonitor> getPullMonitors() {
- return pullMonitors;
- }
-
- public void setPullMonitors(List<PullMonitor> pullMonitors) {
- this.pullMonitors = pullMonitors;
- }
-
- public List<PushMonitor> getPushMonitors() {
- return pushMonitors;
- }
-
- public void setPushMonitors(List<PushMonitor> pushMonitors) {
- this.pushMonitors = pushMonitors;
- }
-
- public BlockingQueue<UserMonitorData> getPullQueue() {
- return pullQueue;
- }
-
- public void setPullQueue(BlockingQueue<UserMonitorData> pullQueue) {
- this.pullQueue = pullQueue;
- }
-
- public MonitorPublisher getMonitorPublisher() {
- return monitorPublisher;
- }
-
- public void setMonitorPublisher(MonitorPublisher monitorPublisher) {
- this.monitorPublisher = monitorPublisher;
- }
-
- public BlockingQueue<MonitorID> getFinishQueue() {
- return finishQueue;
- }
-
- public void setFinishQueue(BlockingQueue<MonitorID> finishQueue) {
- this.finishQueue = finishQueue;
- }
-
- public BlockingQueue<MonitorID> getPushQueue() {
- return pushQueue;
- }
-
- public void setPushQueue(BlockingQueue<MonitorID> pushQueue) {
- this.pushQueue = pushQueue;
- }
-
- public BlockingQueue<MonitorID> getLocalJobQueue() {
- return localJobQueue;
- }
-
- public void setLocalJobQueue(BlockingQueue<MonitorID> localJobQueue) {
- this.localJobQueue = localJobQueue;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/TaskIdentity.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/TaskIdentity.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/TaskIdentity.java
deleted file mode 100644
index c6d386e..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/TaskIdentity.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;
-
-public class TaskIdentity extends WorkflowNodeIdentity {
- private String taskId;
-
- public TaskIdentity(String experimentId, String workflowNodeId, String taskId) {
- super(experimentId,workflowNodeId);
- setTaskId(taskId);
- }
- public String getTaskId() {
- return taskId;
- }
-
- public void setTaskId(String taskId) {
- this.taskId = taskId;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/UserMonitorData.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/UserMonitorData.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/UserMonitorData.java
deleted file mode 100644
index 022d17c..0000000
--- a/modules/gfac/gfac-core/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/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/WorkflowNodeIdentity.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/WorkflowNodeIdentity.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/WorkflowNodeIdentity.java
deleted file mode 100644
index e569c52..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/WorkflowNodeIdentity.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;
-
-public class WorkflowNodeIdentity extends ExperimentIdentity {
- private String workflowNodeID;
- public WorkflowNodeIdentity(String experimentId, String workflowNodeId) {
- super(experimentId);
- setWorkflowNodeID(workflowNodeId);
- }
- public String getWorkflowNodeID() {
- return workflowNodeID;
- }
-
- public void setWorkflowNodeID(String workflowNodeID) {
- this.workflowNodeID = workflowNodeID;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/command/ExperimentCancelRequest.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/command/ExperimentCancelRequest.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/command/ExperimentCancelRequest.java
deleted file mode 100644
index f19decf..0000000
--- a/modules/gfac/gfac-core/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/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/command/TaskCancelRequest.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/command/TaskCancelRequest.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/command/TaskCancelRequest.java
deleted file mode 100644
index b45e01c..0000000
--- a/modules/gfac/gfac-core/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/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/core/AiravataAbstractMonitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/core/AiravataAbstractMonitor.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/core/AiravataAbstractMonitor.java
deleted file mode 100644
index da6baf8..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/core/AiravataAbstractMonitor.java
+++ /dev/null
@@ -1,46 +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.event.MonitorPublisher;
-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 MonitorPublisher 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);
- protected MonitorPublisher publisher;
-
- public MonitorPublisher getPublisher() {
- return publisher;
- }
-
- public void setPublisher(MonitorPublisher publisher) {
- this.publisher = publisher;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/core/MessageParser.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/core/MessageParser.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/core/MessageParser.java
deleted file mode 100644
index a003f55..0000000
--- a/modules/gfac/gfac-core/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.workspace.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/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/core/Monitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/core/Monitor.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/core/Monitor.java
deleted file mode 100644
index d2fede5..0000000
--- a/modules/gfac/gfac-core/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 extends Runnable {
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/core/PullMonitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/core/PullMonitor.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/core/PullMonitor.java
deleted file mode 100644
index efdf89c..0000000
--- a/modules/gfac/gfac-core/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/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/core/PushMonitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/core/PushMonitor.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/core/PushMonitor.java
deleted file mode 100644
index 8e13252..0000000
--- a/modules/gfac/gfac-core/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.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/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/event/MonitorPublisher.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/event/MonitorPublisher.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/event/MonitorPublisher.java
deleted file mode 100644
index 52487fe..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/event/MonitorPublisher.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.event;
-
-import com.google.common.eventbus.EventBus;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class MonitorPublisher{
- private final static Logger logger = LoggerFactory.getLogger(MonitorPublisher.class);
- private EventBus eventBus;
-
- public MonitorPublisher(EventBus eventBus) {
- this.eventBus = eventBus;
- }
-
- public void registerListener(Object listener) {
- eventBus.register(listener);
- }
-
- public void unregisterListener(Object listener) {
- eventBus.unregister(listener);
- }
-
- public void publish(Object o) {
- eventBus.post(o);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/exception/AiravataMonitorException.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/exception/AiravataMonitorException.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/exception/AiravataMonitorException.java
deleted file mode 100644
index 3acef66..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/exception/AiravataMonitorException.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.exception;
-
-public class AiravataMonitorException extends Exception {
- private static final long serialVersionUID = -2849422320139467602L;
-
- public AiravataMonitorException(Throwable e) {
- super(e);
- }
-
- public AiravataMonitorException(String message) {
- super(message, null);
- }
-
- public AiravataMonitorException(String message, Throwable e) {
- super(message, e);
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/LocalJobMonitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/LocalJobMonitor.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/LocalJobMonitor.java
deleted file mode 100644
index a64b484..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/LocalJobMonitor.java
+++ /dev/null
@@ -1,59 +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.impl;
-
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.gfac.monitor.JobIdentity;
-import org.apache.airavata.gfac.monitor.MonitorID;
-import org.apache.airavata.gfac.monitor.core.AiravataAbstractMonitor;
-import org.apache.airavata.gfac.monitor.state.JobStatusChangeRequest;
-import org.apache.airavata.model.workspace.experiment.JobState;
-
-import java.util.concurrent.BlockingQueue;
-
-/**
- * This monitor can be used to monitor a job which runs locally,
- * Since its a local job job doesn't have states, once it get executed
- * then the job starts running
- */
-public class LocalJobMonitor extends AiravataAbstractMonitor {
- // Though we have a qeuue here, it not going to be used in local jobs
- BlockingQueue<MonitorID> jobQueue;
-
- public void run() {
- do {
- try {
- MonitorID take = jobQueue.take();
- getPublisher().publish(new JobStatusChangeRequest(take, new JobIdentity(take.getExperimentID(), take.getWorkflowNodeID(), take.getTaskID(), take.getJobID()), JobState.COMPLETE));
- } catch (Exception e) {
- e.printStackTrace();
- }
- } while (!ServerSettings.isStopAllThreads());
- }
-
- public BlockingQueue<MonitorID> getJobQueue() {
- return jobQueue;
- }
-
- public void setJobQueue(BlockingQueue<MonitorID> jobQueue) {
- this.jobQueue = jobQueue;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/QstatMonitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/QstatMonitor.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/QstatMonitor.java
deleted file mode 100644
index 020d9ae..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/QstatMonitor.java
+++ /dev/null
@@ -1,262 +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.impl.pull.qstat;
-
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.commons.gfac.type.HostDescription;
-import org.apache.airavata.gfac.monitor.HostMonitorData;
-import org.apache.airavata.gfac.monitor.JobIdentity;
-import org.apache.airavata.gfac.monitor.MonitorID;
-import org.apache.airavata.gfac.monitor.UserMonitorData;
-import org.apache.airavata.gfac.monitor.core.PullMonitor;
-import org.apache.airavata.gfac.monitor.event.MonitorPublisher;
-import org.apache.airavata.gfac.monitor.exception.AiravataMonitorException;
-import org.apache.airavata.gfac.monitor.state.JobStatusChangeRequest;
-import org.apache.airavata.gfac.monitor.util.CommonUtils;
-import org.apache.airavata.gsi.ssh.api.SSHApiException;
-import org.apache.airavata.model.workspace.experiment.JobState;
-import org.apache.airavata.schemas.gfac.GsisshHostType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.sql.Timestamp;
-import java.util.*;
-import java.util.concurrent.BlockingQueue;
-
-/**
- * This monitor is based on qstat command which can be run
- * in grid resources and retrieve the job status.
- */
-public class QstatMonitor extends PullMonitor {
- private final static Logger logger = LoggerFactory.getLogger(QstatMonitor.class);
-
- // I think this should use DelayedBlocking Queue to do the monitoring*/
- private BlockingQueue<UserMonitorData> queue;
-
- private boolean startPulling = false;
-
- private Map<String, ResourceConnection> connections;
-
- private MonitorPublisher publisher;
-
- public QstatMonitor(){
- connections = new HashMap<String, ResourceConnection>();
- }
- public QstatMonitor(BlockingQueue<UserMonitorData> queue, MonitorPublisher publisher) {
- this.queue = queue;
- this.publisher = publisher;
- connections = new HashMap<String, ResourceConnection>();
- }
-
- public void run() {
- /* implement a logic to pick each monitorID object from the queue and do the
- monitoring
- */
- this.startPulling = true;
- while (this.startPulling && !ServerSettings.isStopAllThreads()) {
- try {
- startPulling();
- // After finishing one iteration of the full queue this thread sleeps 1 second
- Thread.sleep(10000);
- } catch (Exception e){
- // we catch all the exceptions here because no matter what happens we do not stop running this
- // thread, but ideally we should report proper error messages, but this is handled in startPulling
- // method, incase something happen in Thread.sleep we handle it with this catch block.
- e.printStackTrace();
- logger.error(e.getMessage());
- }
- }
- // thread is going to return so we close all the connections
- Iterator<String> iterator = connections.keySet().iterator();
- while(iterator.hasNext()){
- String next = iterator.next();
- ResourceConnection resourceConnection = connections.get(next);
- try {
- resourceConnection.getCluster().disconnect();
- } catch (SSHApiException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- }
- }
-
- /**
- * 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 boolean startPulling() throws AiravataMonitorException {
- // take the top element in the queue and pull the data and put that element
- // at the tail of the queue
- //todo this polling will not work with multiple usernames but with single user
- // and multiple hosts, currently monitoring will work
- UserMonitorData take = null;
- JobStatusChangeRequest jobStatus = new JobStatusChangeRequest();
- MonitorID currentMonitorID = null;
- HostDescription currentHostDescription = null;
- try {
- take = this.queue.take();
- List<MonitorID> completedJobs = new ArrayList<MonitorID>();
- List<HostMonitorData> hostMonitorData = take.getHostMonitorData();
- for (HostMonitorData iHostMonitorData : hostMonitorData) {
- if (iHostMonitorData.getHost().getType() instanceof GsisshHostType) {
- currentHostDescription = iHostMonitorData.getHost();
- GsisshHostType gsisshHostType = (GsisshHostType) iHostMonitorData.getHost().getType();
- String hostName = gsisshHostType.getHostAddress();
- ResourceConnection connection = null;
- if (connections.containsKey(hostName)) {
- logger.debug("We already have this connection so not going to create one");
- connection = connections.get(hostName);
- } else {
- connection = new ResourceConnection(take.getUserName(), iHostMonitorData, gsisshHostType.getInstalledPath());
- connections.put(hostName, connection);
- }
- List<MonitorID> monitorID = iHostMonitorData.getMonitorIDs();
- Map<String, JobState> jobStatuses = connection.getJobStatuses(take.getUserName(), monitorID);
- for (MonitorID iMonitorID : monitorID) {
- currentMonitorID = iMonitorID;
- iMonitorID.setStatus(jobStatuses.get(iMonitorID.getJobID()));
- jobStatus = new JobStatusChangeRequest(iMonitorID);
- // we have this JobStatus class to handle amqp monitoring
-
- publisher.publish(jobStatus);
- // if the job is completed we do not have to put the job to the queue again
- iMonitorID.setLastMonitored(new Timestamp((new Date()).getTime()));
-
- // After successful monitoring perform following actions to cleanup the queue, if necessary
- if (jobStatus.getState().equals(JobState.COMPLETE)) {
- completedJobs.add(iMonitorID);
- } else if (iMonitorID.getFailedCount() > 2 && iMonitorID.getStatus().equals(JobState.UNKNOWN)) {
- logger.error("Tried to monitor the job with ID " + iMonitorID.getJobID() + " But failed 3 times, so skip this Job from Monitor");
- iMonitorID.setLastMonitored(new Timestamp((new Date()).getTime()));
- completedJobs.add(iMonitorID);
- } else {
- // Evey
- iMonitorID.setLastMonitored(new Timestamp((new Date()).getTime()));
- // if the job is complete we remove it from the Map, if any of these maps
- // get empty this userMonitorData will get delete from the queue
- }
- }
- } else {
- logger.debug("Qstat Monitor doesn't handle non-gsissh hosts");
- }
- }
- // We have finished all the HostMonitorData object in userMonitorData, now we need to put it back
- // now the userMonitorData goes back to the tail of the queue
- queue.put(take);
- // cleaning up the completed jobs, this method will remove some of the userMonitorData from the queue if
- // they become empty
- for(MonitorID completedJob:completedJobs){
- CommonUtils.removeMonitorFromQueue(queue, completedJob);
- }
- } catch (InterruptedException e) {
- if (!this.queue.contains(take)) {
- try {
- this.queue.put(take);
- } catch (InterruptedException e1) {
- e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- }
- logger.error("Error handling the job with Job ID:" + currentMonitorID.getJobID());
- throw new AiravataMonitorException(e);
- } catch (SSHApiException e) {
- logger.error(e.getMessage());
- if (e.getMessage().contains("Unknown Job Id Error")) {
- // in this case job is finished or may be the given job ID is wrong
- jobStatus.setState(JobState.UNKNOWN);
- publisher.publish(jobStatus);
- } else if (e.getMessage().contains("illegally formed job identifier")) {
- logger.error("Wrong job ID is given so dropping the job from monitoring system");
- } else if (!this.queue.contains(take)) { // we put the job back to the queue only if its state is not unknown
- if (currentMonitorID == null) {
- logger.error("Monitoring the jobs failed, for user: " + take.getUserName()
- + " in Host: " + currentHostDescription.getType().getHostAddress());
- } else {
- if (currentMonitorID != null) {
- if (currentMonitorID.getFailedCount() < 2) {
- try {
- currentMonitorID.setFailedCount(currentMonitorID.getFailedCount() + 1);
- this.queue.put(take);
- } catch (InterruptedException e1) {
- e1.printStackTrace();
- }
- } else {
- logger.error(e.getMessage());
- logger.error("Tried to monitor the job 3 times, so dropping of the the Job with ID: " + currentMonitorID.getJobID());
- }
- }
- }
- }
- throw new AiravataMonitorException("Error retrieving the job status", e);
- } catch (Exception e) {
- if (currentMonitorID != null) {
- if (currentMonitorID.getFailedCount() < 3) {
- try {
- currentMonitorID.setFailedCount(currentMonitorID.getFailedCount() + 1);
- this.queue.put(take);
- // if we get a wrong status we wait for a while and request again
- Thread.sleep(10000);
- } catch (InterruptedException e1) {
- e1.printStackTrace();
- }
- } else {
- logger.error(e.getMessage());
- logger.error("Tryied to monitor the job 3 times, so dropping of the the Job with ID: " + currentMonitorID.getJobID());
- }
- }
- throw new AiravataMonitorException("Error retrieving the job status", e);
- }
-
-
- return true;
- }
-
-
- /**
- * This is the method to stop the polling process
- *
- * @return if the stopping process is successful return true else false
- */
- public boolean stopPulling() {
- this.startPulling = false;
- return true;
- }
-
- public MonitorPublisher getPublisher() {
- return publisher;
- }
-
- public void setPublisher(MonitorPublisher publisher) {
- this.publisher = publisher;
- }
-
- public BlockingQueue<UserMonitorData> getQueue() {
- return queue;
- }
-
- public void setQueue(BlockingQueue<UserMonitorData> queue) {
- this.queue = queue;
- }
-
- public boolean authenticate() {
- return false; //To change body of implemented methods use File | Settings | File Templates.
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/ResourceConnection.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/ResourceConnection.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/ResourceConnection.java
deleted file mode 100644
index 7a37b88..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/pull/qstat/ResourceConnection.java
+++ /dev/null
@@ -1,151 +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.impl.pull.qstat;
-
-import org.apache.airavata.gfac.monitor.HostMonitorData;
-import org.apache.airavata.gfac.monitor.MonitorID;
-import org.apache.airavata.gsi.ssh.api.SSHApiException;
-import org.apache.airavata.gsi.ssh.api.ServerInfo;
-import org.apache.airavata.gsi.ssh.api.authentication.AuthenticationInfo;
-import org.apache.airavata.gsi.ssh.api.job.JobManagerConfiguration;
-import org.apache.airavata.gsi.ssh.impl.JobStatus;
-import org.apache.airavata.gsi.ssh.impl.PBSCluster;
-import org.apache.airavata.gsi.ssh.util.CommonUtils;
-import org.apache.airavata.model.workspace.experiment.JobState;
-import org.apache.airavata.schemas.gfac.GsisshHostType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-
-public class ResourceConnection {
- private static final Logger log = LoggerFactory.getLogger(ResourceConnection.class);
-
- private PBSCluster cluster;
-
- public ResourceConnection(MonitorID monitorID, String installedPath) throws SSHApiException {
- AuthenticationInfo authenticationInfo = monitorID.getAuthenticationInfo();
- String hostAddress = monitorID.getHost().getType().getHostAddress();
- String userName = monitorID.getUserName();
- String jobManager = ((GsisshHostType)monitorID.getHost().getType()).getJobManager();
- JobManagerConfiguration jConfig = null;
- if (jobManager == null) {
- log.error("No Job Manager is configured, so we are picking pbs as the default job manager");
- jConfig = CommonUtils.getPBSJobManager(installedPath);
- } else {
- if (org.apache.airavata.gfac.monitor.util.CommonUtils.isPBSHost(monitorID.getHost())) {
- jConfig = CommonUtils.getPBSJobManager(installedPath);
- } else if(org.apache.airavata.gfac.monitor.util.CommonUtils.isSlurm(monitorID.getHost())) {
- jConfig = CommonUtils.getSLURMJobManager(installedPath);
- } else if(org.apache.airavata.gfac.monitor.util.CommonUtils.isSGE(monitorID.getHost())) {
- jConfig = CommonUtils.getSGEJobManager(installedPath);
- }
- //todo support br2 etc
- }
- ServerInfo serverInfo = new ServerInfo(userName, hostAddress, ((GsisshHostType)monitorID.getHost().getType()).getPort());
- cluster = new PBSCluster(serverInfo, authenticationInfo, jConfig);
- }
-
- public ResourceConnection(String userName, HostMonitorData hostMonitorData, String installedPath) throws SSHApiException {
- AuthenticationInfo authenticationInfo = hostMonitorData.getMonitorIDs().get(0).getAuthenticationInfo();
- String hostAddress = hostMonitorData.getHost().getType().getHostAddress();
- String jobManager = ((GsisshHostType)hostMonitorData.getHost().getType()).getJobManager();
- JobManagerConfiguration jConfig = null;
- if (jobManager == null) {
- log.error("No Job Manager is configured, so we are picking pbs as the default job manager");
- jConfig = CommonUtils.getPBSJobManager(installedPath);
- } else {
- if (org.apache.airavata.gfac.monitor.util.CommonUtils.isPBSHost(hostMonitorData.getHost())) {
- jConfig = CommonUtils.getPBSJobManager(installedPath);
- } else if(org.apache.airavata.gfac.monitor.util.CommonUtils.isSlurm(hostMonitorData.getHost())) {
- jConfig = CommonUtils.getSLURMJobManager(installedPath);
- }else if(org.apache.airavata.gfac.monitor.util.CommonUtils.isSGE(hostMonitorData.getHost())) {
- jConfig = CommonUtils.getSGEJobManager(installedPath);
- }
- //todo support br2 etc
- }
- ServerInfo serverInfo = new ServerInfo(userName, hostAddress, ((GsisshHostType)hostMonitorData.getHost().getType()).getPort());
- cluster = new PBSCluster(serverInfo, authenticationInfo, jConfig);
- }
- public JobState getJobStatus(MonitorID monitorID) throws SSHApiException {
- String jobID = monitorID.getJobID();
- //todo so currently we execute the qstat for each job but we can use user based monitoring
- //todo or we should concatenate all the commands and execute them in one go and parse the response
- return getStatusFromString(cluster.getJobStatus(jobID).toString());
- }
-
- public Map<String,JobState> getJobStatuses(String userName,List<MonitorID> monitorIDs) throws SSHApiException {
- Map<String,JobStatus> treeMap = new TreeMap<String,JobStatus>();
- Map<String,JobState> treeMap1 = new TreeMap<String,JobState>();
- // creating a sorted map with all the jobIds and with the predefined
- // status as UNKNOWN
- for (MonitorID monitorID : monitorIDs) {
- treeMap.put(monitorID.getJobID(), JobStatus.U);
- }
- //todo so currently we execute the qstat for each job but we can use user based monitoring
- //todo or we should concatenate all the commands and execute them in one go and parse the response
- cluster.getJobStatuses(userName,treeMap);
- for(String key:treeMap.keySet()){
- treeMap1.put(key,getStatusFromString(treeMap.get(key).toString()));
- }
- return treeMap1;
- }
- private JobState getStatusFromString(String status) {
- log.info("parsing the job status returned : " + status);
- if(status != null){
- if("C".equals(status) || "CD".equals(status)|| "E".equals(status) || "CG".equals(status)){
- return JobState.COMPLETE;
- }else if("H".equals(status) || "h".equals(status)){
- return JobState.HELD;
- }else if("Q".equals(status) || "qw".equals(status)){
- return JobState.QUEUED;
- }else if("R".equals(status) || "CF".equals(status) || "r".equals(status)){
- return JobState.ACTIVE;
- }else if ("T".equals(status)) {
- return JobState.HELD;
- } else if ("W".equals(status) || "PD".equals(status)) {
- return JobState.QUEUED;
- } else if ("S".equals(status)) {
- return JobState.SUSPENDED;
- }else if("CA".equals(status)){
- return JobState.CANCELED;
- }else if ("F".equals(status) || "NF".equals(status) || "TO".equals(status)) {
- return JobState.FAILED;
- }else if ("PR".equals(status) || "Er".equals(status)) {
- return JobState.FAILED;
- }else if ("U".equals(status)){
- return JobState.UNKNOWN;
- }
- }
- return JobState.UNKNOWN;
- }
-
- public PBSCluster getCluster() {
- return cluster;
- }
-
- public void setCluster(PBSCluster cluster) {
- this.cluster = cluster;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/AMQPMonitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/AMQPMonitor.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/AMQPMonitor.java
deleted file mode 100644
index fbf6e21..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/AMQPMonitor.java
+++ /dev/null
@@ -1,263 +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.impl.push.amqp;
-
-import com.google.common.eventbus.EventBus;
-import com.google.common.eventbus.Subscribe;
-import com.rabbitmq.client.Channel;
-import com.rabbitmq.client.Connection;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.commons.gfac.type.HostDescription;
-import org.apache.airavata.gfac.monitor.JobIdentity;
-import org.apache.airavata.gfac.monitor.MonitorID;
-import org.apache.airavata.gfac.monitor.core.PushMonitor;
-import org.apache.airavata.gfac.monitor.event.MonitorPublisher;
-import org.apache.airavata.gfac.monitor.exception.AiravataMonitorException;
-import org.apache.airavata.gfac.monitor.state.JobStatusChangeRequest;
-import org.apache.airavata.gfac.monitor.util.AMQPConnectionUtil;
-import org.apache.airavata.gfac.monitor.util.CommonUtils;
-import org.apache.airavata.model.workspace.experiment.JobState;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.*;
-import java.util.concurrent.BlockingQueue;
-
-/**
- * This is the implementation for AMQP based finishQueue, this uses
- * rabbitmq client to recieve AMQP based monitoring data from
- * mostly excede resources.
- */
-public class AMQPMonitor extends PushMonitor {
- private final static Logger logger = LoggerFactory.getLogger(AMQPMonitor.class);
-
-
- /* this will keep all the channels available in the system, we do not create
- channels for all the jobs submitted, but we create channels for each user for each
- host.
- */
- private Map<String, Channel> availableChannels;
-
- private MonitorPublisher publisher;
-
- private MonitorPublisher localPublisher;
-
- private BlockingQueue<MonitorID> runningQueue;
-
- private BlockingQueue<MonitorID> finishQueue;
-
- private String connectionName;
-
- private String proxyPath;
-
- private List<String> amqpHosts;
-
- private boolean startRegister;
-
- public AMQPMonitor(){
-
- }
- public AMQPMonitor(MonitorPublisher publisher, BlockingQueue<MonitorID> runningQueue,
- BlockingQueue<MonitorID> finishQueue,
- String proxyPath,String connectionName,List<String> hosts) {
- this.publisher = publisher;
- this.runningQueue = runningQueue; // these will be initialized by the MonitorManager
- this.finishQueue = finishQueue; // these will be initialized by the MonitorManager
- this.availableChannels = new HashMap<String, Channel>();
- this.connectionName = connectionName;
- this.proxyPath = proxyPath;
- this.amqpHosts = hosts;
- this.localPublisher = new MonitorPublisher(new EventBus());
- this.localPublisher.registerListener(this);
- }
-
- public void initialize(String proxyPath, String connectionName, List<String> hosts) {
- this.availableChannels = new HashMap<String, Channel>();
- this.connectionName = connectionName;
- this.proxyPath = proxyPath;
- this.amqpHosts = hosts;
- this.localPublisher = new MonitorPublisher(new EventBus());
- this.localPublisher.registerListener(this);
- }
-
- @Override
- public boolean registerListener(MonitorID monitorID) throws AiravataMonitorException {
- // we subscribe to read user-host based subscription
- HostDescription host = monitorID.getHost();
- String hostAddress = host.getType().getHostAddress();
- // in amqp case there are no multiple jobs per each host, because once a job is put in to the queue it
- // will be picked by the Monitor, so jobs will not stay in this queueu but jobs will stay in finishQueue
- String channelID = CommonUtils.getChannelID(monitorID);
- if(availableChannels.get(channelID) == null){
- try {
- //todo need to fix this rather getting it from a file
- Connection connection = AMQPConnectionUtil.connect(amqpHosts, connectionName, proxyPath);
- Channel channel = null;
- channel = connection.createChannel();
- availableChannels.put(channelID, channel);
- String queueName = channel.queueDeclare().getQueue();
-
- BasicConsumer consumer = new
- BasicConsumer(new JSONMessageParser(), localPublisher); // here we use local publisher
- channel.basicConsume(queueName, true, consumer);
- String filterString = CommonUtils.getRoutingKey(monitorID.getUserName(), hostAddress);
- // here we queuebind to a particular user in a particular machine
- channel.queueBind(queueName, "glue2.computing_activity", filterString);
- logger.info("Using filtering string to monitor: " + filterString);
- } catch (IOException e) {
- logger.error("Error creating the connection to finishQueue the job:" + monitorID.getUserName());
- }
- }
- return true;
- }
-
- public void run() {
- // before going to the while true mode we start unregister thread
- startRegister = true; // this will be unset by someone else
- while (startRegister || !ServerSettings.isStopAllThreads()) {
- try {
- MonitorID take = runningQueue.take();
- this.registerListener(take);
- } catch (AiravataMonitorException e) { // catch any exceptino inside the loop
- e.printStackTrace();
- } catch (InterruptedException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- } catch (Exception e){
- e.printStackTrace();
- }
- }
- Set<String> strings = availableChannels.keySet();
- for(String key:strings) {
- Channel channel = availableChannels.get(key);
- try {
- channel.close();
- } catch (IOException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- }
- }
-
- @Subscribe
- public boolean unRegisterListener(MonitorID monitorID) throws AiravataMonitorException {
- Iterator<MonitorID> iterator = finishQueue.iterator();
- MonitorID next = null;
- while(iterator.hasNext()){
- next = iterator.next();
- if(next.getJobID().endsWith(monitorID.getJobID())){
- break;
- }
- }
- if(next == null) {
- logger.error("Job has removed from the queue, old obsolete message recieved");
- return false;
- }
- String channelID = CommonUtils.getChannelID(next);
- if (JobState.FAILED.equals(monitorID.getStatus()) || JobState.COMPLETE.equals(monitorID.getStatus())) {
- finishQueue.remove(next);
-
- // if this is the last job in the queue at this point with the same username and same host we
- // close the channel and close the connection and remove it from availableChannels
- if (CommonUtils.isTheLastJobInQueue(finishQueue, next)) {
- logger.info("There are no jobs to monitor for common ChannelID:" + channelID + " , so we unsubscribe it" +
- ", incase new job created we do subscribe again");
- Channel channel = availableChannels.get(channelID);
- if (channel == null) {
- logger.error("Already Unregistered the listener");
- throw new AiravataMonitorException("Already Unregistered the listener");
- } else {
- try {
- channel.queueUnbind(channel.queueDeclare().getQueue(), "glue2.computing_activity", CommonUtils.getRoutingKey(next));
- channel.close();
- channel.getConnection().close();
- availableChannels.remove(channelID);
- } catch (IOException e) {
- logger.error("Error unregistering the listener");
- throw new AiravataMonitorException("Error unregistering the listener");
- }
- }
- }
- }
- next.setStatus(monitorID.getStatus());
- publisher.publish(new JobStatusChangeRequest(next, new JobIdentity(next.getExperimentID(), next.getWorkflowNodeID(), next.getTaskID(), next.getJobID()),next.getStatus()));
- return true;
- }
- @Override
- public boolean stopRegister() throws AiravataMonitorException {
- return false; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public Map<String, Channel> getAvailableChannels() {
- return availableChannels;
- }
-
- public void setAvailableChannels(Map<String, Channel> availableChannels) {
- this.availableChannels = availableChannels;
- }
-
- public MonitorPublisher getPublisher() {
- return publisher;
- }
-
- public void setPublisher(MonitorPublisher publisher) {
- this.publisher = publisher;
- }
-
- public BlockingQueue<MonitorID> getRunningQueue() {
- return runningQueue;
- }
-
- public void setRunningQueue(BlockingQueue<MonitorID> runningQueue) {
- this.runningQueue = runningQueue;
- }
-
- public BlockingQueue<MonitorID> getFinishQueue() {
- return finishQueue;
- }
-
- public void setFinishQueue(BlockingQueue<MonitorID> finishQueue) {
- this.finishQueue = finishQueue;
- }
-
- public String getProxyPath() {
- return proxyPath;
- }
-
- public void setProxyPath(String proxyPath) {
- this.proxyPath = proxyPath;
- }
-
- public List<String> getAmqpHosts() {
- return amqpHosts;
- }
-
- public void setAmqpHosts(List<String> amqpHosts) {
- this.amqpHosts = amqpHosts;
- }
-
- public boolean isStartRegister() {
- return startRegister;
- }
-
- public void setStartRegister(boolean startRegister) {
- this.startRegister = startRegister;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/553caa08/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/BasicConsumer.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/BasicConsumer.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/BasicConsumer.java
deleted file mode 100644
index 1d60c45..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/monitor/impl/push/amqp/BasicConsumer.java
+++ /dev/null
@@ -1,86 +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.impl.push.amqp;
-
-import com.rabbitmq.client.AMQP;
-import com.rabbitmq.client.Consumer;
-import com.rabbitmq.client.Envelope;
-import com.rabbitmq.client.ShutdownSignalException;
-import org.apache.airavata.gfac.monitor.MonitorID;
-import org.apache.airavata.gfac.monitor.core.MessageParser;
-import org.apache.airavata.gfac.monitor.event.MonitorPublisher;
-import org.apache.airavata.gfac.monitor.exception.AiravataMonitorException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class BasicConsumer implements Consumer {
- private final static Logger logger = LoggerFactory.getLogger(AMQPMonitor.class);
-
- private MessageParser parser;
-
- private MonitorPublisher publisher;
-
- public BasicConsumer(MessageParser parser, MonitorPublisher publisher) {
- this.parser = parser;
- this.publisher = publisher;
- }
-
- public void handleCancel(String consumerTag) {
- }
-
- public void handleCancelOk(String consumerTag) {
- }
-
- public void handleConsumeOk(String consumerTag) {
- }
-
- public void handleDelivery(String consumerTag,
- Envelope envelope,
- AMQP.BasicProperties properties,
- byte[] body) {
-
- logger.debug("job update for: " + envelope.getRoutingKey());
- String message = new String(body);
- message = message.replaceAll("(?m)^", " ");
- // Here we parse the message and get the job status and push it
- // to the Event bus, this will be picked by
-// AiravataJobStatusUpdator and store in to registry
-
- logger.debug("************************************************************");
- logger.debug("AMQP Message recieved \n" + message);
- logger.debug("************************************************************");
- try {
- String jobID = envelope.getRoutingKey().split("\\.")[0];
- MonitorID monitorID = new MonitorID(null, jobID, null, null, null, null);
- monitorID.setStatus(parser.parseMessage(message));
- publisher.publish(monitorID);
- } catch (AiravataMonitorException e) {
- e.printStackTrace();
- }
- }
-
- public void handleRecoverOk(String consumerTag) {
- }
-
- public void handleShutdownSignal(String consumerTag, ShutdownSignalException sig) {
- }
-
-}