You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by am...@apache.org on 2013/06/20 05:14:28 UTC
svn commit: r1494843 [1/2] - in /airavata/sandbox/grid-tools/gram-client: ./
src/main/java/org/apache/airavata/jobsubmission/
src/main/java/org/apache/airavata/jobsubmission/gram/
src/main/java/org/apache/airavata/jobsubmission/gram/notifier/ src/main/...
Author: amilaj
Date: Thu Jun 20 03:14:27 2013
New Revision: 1494843
URL: http://svn.apache.org/r1494843
Log:
Adding gram functionality changes for jglobus 2
Added:
airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/ExecutionContext.java
- copied, changed from r1485754, airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/ExectionContext.java
airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/GFacException.java
airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/GramJobSubmissionManager.java
- copied, changed from r1485754, airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/GramJobSubmission.java
airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/ListenerQueue.java
airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/RSLGenerator.java
airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/errors.properties
airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/notifier/
airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/notifier/GramJobLogger.java
airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/notifier/GramJobNotifier.java
airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/persistence/
airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/persistence/DBJobPersistenceManager.java
airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/persistence/JobData.java
airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/persistence/JobPersistenceManager.java
airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/persistence/PersistenceGramJobNotifier.java
airavata/sandbox/grid-tools/gram-client/src/test/
airavata/sandbox/grid-tools/gram-client/src/test/java/
airavata/sandbox/grid-tools/gram-client/src/test/java/org/
airavata/sandbox/grid-tools/gram-client/src/test/java/org/apache/
airavata/sandbox/grid-tools/gram-client/src/test/java/org/apache/airavata/
airavata/sandbox/grid-tools/gram-client/src/test/java/org/apache/airavata/jobsubmission/
airavata/sandbox/grid-tools/gram-client/src/test/java/org/apache/airavata/jobsubmission/gram/
airavata/sandbox/grid-tools/gram-client/src/test/java/org/apache/airavata/jobsubmission/gram/GramJobSubmissionManagerTest.java
airavata/sandbox/grid-tools/gram-client/src/test/java/org/apache/airavata/jobsubmission/gram/LoneStarGramTest.java
airavata/sandbox/grid-tools/gram-client/src/test/java/org/apache/airavata/jobsubmission/gram/StampedeGramTest.java
airavata/sandbox/grid-tools/gram-client/src/test/java/org/apache/airavata/jobsubmission/gram/TrestlesGramTest.java
airavata/sandbox/grid-tools/gram-client/src/test/resources/
airavata/sandbox/grid-tools/gram-client/src/test/resources/airavata-myproxy-client.properties
Removed:
airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/CancelJob.java
airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/JobListener.java
airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/JobStatus.java
airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/JobSubmission.java
airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/ExectionContext.java
airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/GramJobSubmission.java
airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/security/
Modified:
airavata/sandbox/grid-tools/gram-client/pom.xml
airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/JobSubmissionListener.java
airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/utils/ServiceConstants.java
airavata/sandbox/grid-tools/gram-client/src/main/resources/airavata-gram-client.properties
Modified: airavata/sandbox/grid-tools/gram-client/pom.xml
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/pom.xml?rev=1494843&r1=1494842&r2=1494843&view=diff
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/pom.xml (original)
+++ airavata/sandbox/grid-tools/gram-client/pom.xml Thu Jun 20 03:14:27 2013
@@ -12,111 +12,202 @@
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/maven-v4_0_0.xsd">
- <!-- the version of maven's project object model -->
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <!-- the version of maven's project object model -->
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.airavata</groupId>
- <artifactId>airavata-gram-client</artifactId>
- <name>Airavata Gram Client</name>
- <description>Standalone test client to experiment and test GRAM .</description>
- <version>0.1-SNAPSHOT</version>
- <packaging>jar</packaging>
-
- <repositories>
- <repository>
- <name>ogce.m2.all</name>
- <id>ogce.m2.all</id>
- <url>http://community.ucs.indiana.edu:9090/archiva/repository/ogce.m2.all</url>
- </repository>
- </repositories>
-
-
- <dependencies>
-
- <dependency>
- <groupId>cog-jglobus</groupId>
- <artifactId>cog-jglobus</artifactId>
- <version>1.8.0_1</version>
- </dependency>
-
- <dependency>
- <groupId>cog-4_1_6_rc2</groupId>
- <artifactId>puretls</artifactId>
- <type>jar</type>
- <version>cog-4_1_6</version>
- </dependency>
-
- <dependency>
- <groupId>cog-4_1_6_rc2</groupId>
- <artifactId>cryptix32</artifactId>
- <type>jar</type>
- <version>cog-4_1_6</version>
- </dependency>
-
- <dependency>
- <groupId>cog-4_1_6_rc2</groupId>
- <artifactId>jce-jdk13</artifactId>
- <version>131</version>
- <type>jar</type>
- </dependency>
-
- <dependency>
- <groupId>cog-4_1_6_rc2</groupId>
- <artifactId>cryptix-asn1</artifactId>
- <type>jar</type>
- <version>cog-4_1_6</version>
- </dependency>
- <dependency>
- <groupId>cog-4_1_6_rc2</groupId>
- <artifactId>commons-digester</artifactId>
- <type>jar</type>
- <version>cog-4_1_6</version>
- </dependency>
-
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.0.4</version>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.13</version>
- </dependency>
-
-
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <phase>package</phase>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <configuration>
- <outputDirectory>target/lib</outputDirectory>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>true</overWriteSnapshots>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-gram-client</artifactId>
+ <name>Airavata Gram Client</name>
+ <description>Standalone test client to experiment and test GRAM .</description>
+ <version>0.1-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <repositories>
+ <repository>
+ <name>ogce.m2.all</name>
+ <id>ogce.m2.all</id>
+ <url>http://community.ucs.indiana.edu:9090/archiva/repository/ogce.m2.all</url>
+ </repository>
+ </repositories>
+
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-myproxy-client</artifactId>
+ <version>0.1-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jglobus</groupId>
+ <artifactId>gss</artifactId>
+ <version>2.0.6-rc2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jglobus</groupId>
+ <artifactId>gram</artifactId>
+ <version>2.0.6-rc2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.13</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>${derby.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derbyclient</artifactId>
+ <version>${derby.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derbynet</artifactId>
+ <version>${derby.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derbytools</artifactId>
+ <version>${derby.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.airavata</groupId>
+ <artifactId>airavata-common-utils</artifactId>
+ <version>0.8-SNAPSHOT</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <version>1.4</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.version}</version>
+ <configuration>
+ <failIfNoTests>false</failIfNoTests>
+ <skipTests>${skipTests}</skipTests>
+ <workingDirectory>${project.build.testOutputDirectory}</workingDirectory>
+ <systemPropertyVariables>
+ <projectDirectory>${basedir}</projectDirectory>
+ </systemPropertyVariables>
+
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>target/lib</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <properties>
+ <surefire.version>2.12</surefire.version>
+ <junit.version>4.7</junit.version>
+ <derby.version>10.9.1.0</derby.version>
+ <skipTests>false</skipTests>
+ </properties>
</project>
Copied: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/ExecutionContext.java (from r1485754, airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/ExectionContext.java)
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/ExecutionContext.java?p2=airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/ExecutionContext.java&p1=airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/ExectionContext.java&r1=1485754&r2=1494843&rev=1494843&view=diff
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/ExectionContext.java (original)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/ExecutionContext.java Thu Jun 20 03:14:27 2013
@@ -24,16 +24,19 @@ package org.apache.airavata.jobsubmissio
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import java.util.Properties;
+import org.apache.airavata.jobsubmission.gram.notifier.GramJobNotifier;
import org.apache.airavata.jobsubmission.utils.ServiceConstants;
-public class ExectionContext {
+public class ExecutionContext {
private String testingHost;
private String lonestarGRAM;
- private String rangerGRAM;
+ private String stampedeGRAM;
private String trestlesGRAM;
private String workingDir;
@@ -58,9 +61,16 @@ public class ExectionContext {
private String jobType;
private String arguments;
+ private boolean interactive;
+
+ private String userName;
+ private String password;
+
+ private List<GramJobNotifier> gramJobNotifierList = new ArrayList<GramJobNotifier>();
+
public static final String PROPERTY_FILE = "airavata-gram-client.properties";
- public ExectionContext() throws IOException {
+ public ExecutionContext() throws IOException {
loadConfigration();
}
@@ -75,7 +85,7 @@ public class ExectionContext {
String testinghost = properties.getProperty(ServiceConstants.TESTINGHOST);
String lonestargram = properties.getProperty(ServiceConstants.LONESTARGRAMEPR);
- String rangergram = properties.getProperty(ServiceConstants.RANGERGRAMEPR);
+ String stampedeGram = properties.getProperty(ServiceConstants.STAMPEDE_GRAM_EPR);
String trestlesgram = properties.getProperty(ServiceConstants.TRESTLESGRAMEPR);
String exec = properties.getProperty(ServiceConstants.EXECUTABLE);
@@ -94,8 +104,8 @@ public class ExectionContext {
if (lonestargram != null) {
this.lonestarGRAM = lonestargram;
}
- if (rangergram != null) {
- this.rangerGRAM = rangergram;
+ if (stampedeGram != null) {
+ this.stampedeGRAM = stampedeGram;
}
if (trestlesgram != null) {
this.trestlesGRAM = trestlesgram;
@@ -157,18 +167,32 @@ public class ExectionContext {
this.lonestarGRAM = lonestarGRAM;
}
- public String getRangerGRAM() {
- return rangerGRAM;
+ public String getStampedeGRAM() {
+ return stampedeGRAM;
}
- public void setRangerGRAM(String rangerGRAM) {
- this.rangerGRAM = rangerGRAM;
+ public void setStampedeGRAM(String stampedeGRAM) {
+ this.stampedeGRAM = stampedeGRAM;
}
public String getTrestlesGRAM() {
return trestlesGRAM;
}
+ public String getGRAMEndPoint() {
+
+ if (this.getHost().equals("trestles")) {
+ return this.getTrestlesGRAM();
+ } else if (this.getHost().equals("stampede")) {
+ return this.getStampedeGRAM();
+ } else if (this.getHost().equals("lonestar")) {
+ return this.getLonestarGRAM();
+ } else {
+ throw new RuntimeException("Invalid host " + this.getHost() );
+ }
+
+ }
+
public void setTrestlesGRAM(String trestlesGRAM) {
this.trestlesGRAM = trestlesGRAM;
}
@@ -459,4 +483,36 @@ public class ExectionContext {
public String getArguments() {
return arguments;
}
+
+ public boolean isInteractive() {
+ return interactive;
+ }
+
+ public void setInteractive(boolean interactive) {
+ this.interactive = interactive;
+ }
+
+ public void addGramJobNotifier(GramJobNotifier gramJobNotifier) {
+ this.gramJobNotifierList.add(gramJobNotifier);
+ }
+
+ public List<GramJobNotifier> getGramJobNotifierList() {
+ return Collections.unmodifiableList(gramJobNotifierList);
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
}
Added: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/GFacException.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/GFacException.java?rev=1494843&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/GFacException.java (added)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/GFacException.java Thu Jun 20 03:14:27 2013
@@ -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.jobsubmission.gram;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 6/18/13
+ * Time: 4:21 PM
+ */
+
+public class GFacException extends Exception {
+
+ public GFacException(String message) {
+ super(message);
+ }
+
+ public GFacException(Exception exception) {
+ super(exception);
+ }
+}
Copied: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/GramJobSubmissionManager.java (from r1485754, airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/GramJobSubmission.java)
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/GramJobSubmissionManager.java?p2=airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/GramJobSubmissionManager.java&p1=airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/GramJobSubmission.java&r1=1485754&r2=1494843&rev=1494843&view=diff
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/GramJobSubmission.java (original)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/GramJobSubmissionManager.java Thu Jun 20 03:14:27 2013
@@ -21,120 +21,129 @@
package org.apache.airavata.jobsubmission.gram;
+import org.apache.airavata.jobsubmission.gram.persistence.JobData;
+import org.apache.airavata.jobsubmission.gram.persistence.JobPersistenceManager;
+import org.apache.airavata.jobsubmission.gram.persistence.PersistenceGramJobNotifier;
import org.apache.log4j.Logger;
import org.globus.gram.GramAttributes;
import org.globus.gram.GramException;
import org.globus.gram.GramJob;
+import org.globus.gram.WaitingForCommitException;
+import org.globus.gram.internal.GRAMConstants;
import org.ietf.jgss.GSSCredential;
import org.ietf.jgss.GSSException;
-public class GramJobSubmission {
+import java.net.MalformedURLException;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
- private static final String MULTIPLE = "multiple";
+public class GramJobSubmissionManager {
- private static final String MPI = "mpi";
+ private static final Logger log = Logger.getLogger(GramJobSubmissionManager.class);
- private static final String SINGLE = "single";
+ private static final Map<String, GramJob> currentlyExecutingJobs = new ConcurrentHashMap<String, GramJob>();
- private static final String CONDOR = "CONDOR";
+ private RSLGenerator rslGenerator;
- private static final Logger log = Logger.getLogger(GramJobSubmission.class);
+ private JobPersistenceManager jobPersistenceManager;
- public void executeJob(GSSCredential gssCred, ExectionContext appExecContext, StringBuffer buffer) throws Exception {
+ public GramJobSubmissionManager(JobPersistenceManager jobPersistenceManager) {
+ this.jobPersistenceManager = jobPersistenceManager;
+ this.rslGenerator = new RSLGenerator();
+ }
+
+ public String executeJob(GSSCredential gssCred, String contactString,
+ ExecutionContext appExecContext) throws Exception {
try {
+ //TODO remove when porting
log.setLevel(org.apache.log4j.Level.ALL);
- String contact = "";
- if (appExecContext.getTestingHost().equals("trestles")) {
- contact = appExecContext.getTrestlesGRAM();
- } else if (appExecContext.getTestingHost().equals("ranger")) {
- contact = appExecContext.getRangerGRAM();
- } else if (appExecContext.getTestingHost().equals("lonestar")) {
- contact = appExecContext.getLonestarGRAM();
- }
- GramAttributes jobAttr = configureRemoteJob(appExecContext);
+
+ appExecContext.addGramJobNotifier(new PersistenceGramJobNotifier(this.jobPersistenceManager));
+
+ GramAttributes jobAttr = rslGenerator.configureRemoteJob(appExecContext);
String rsl = jobAttr.toRSL();
- GramJob job = new GramJob(rsl);
+ GramJob job = new GramJob(rsl + "(twoPhase=yes)");
log.info("RSL = " + rsl);
- JobSubmissionListener listener = new JobSubmissionListener(job, buffer);
+ JobSubmissionListener listener = new JobSubmissionListener(appExecContext.getGramJobNotifierList());
job.setCredentials(gssCred);
job.addListener(listener);
- log.info("Request to contact:" + contact);
- job.request(contact);
+ log.info("Request to contact:" + contactString);
+
+ try {
+
+ job.request(true, contactString, appExecContext.isInteractive());
+
+ } catch(WaitingForCommitException e) {
- log.info("JobID = " + job.getIDAsString());
+ log.info("JobID = " + job.getIDAsString());
+
+ jobPersistenceManager.updateJobStatus(new JobData(job.getIDAsString(),
+ GRAMConstants.STATUS_UNSUBMITTED));
+
+ ListenerQueue listenerQueue = ListenerQueue.getInstance();
+ listenerQueue.addJob(job);
+
+ currentlyExecutingJobs.put(job.getIDAsString(), job);
+
+ log.debug("Two phase commit: sending COMMIT_REQUEST signal");
+ job.signal(GramJob.SIGNAL_COMMIT_REQUEST);
+ }
+
+ return job.getIDAsString();
- listener.waitFor();
- job.removeListener(listener);
} catch (GramException ge) {
ge.printStackTrace();
log.error(ge, ge.getCause());
- buffer.append(System.currentTimeMillis() + "#id#FAILED#" + ge.getMessage());
} catch (GSSException gss) {
gss.printStackTrace();
log.error(gss, gss.getCause());
- buffer.append(System.currentTimeMillis() + "#id#FAILED#" + gss.getMessage());
} catch (Exception e) {
e.printStackTrace();
log.error(e, e.getCause());
- buffer.append(System.currentTimeMillis() + "#id#FAILED#" + e.getMessage());
}
+
+ return null;
}
- protected GramAttributes configureRemoteJob(ExectionContext appExecContext) throws Exception {
- GramAttributes jobAttr = new GramAttributes();
- jobAttr.setExecutable(appExecContext.getExecutable());
- if (appExecContext.getWorkingDir() != null) {
- jobAttr.setDirectory(appExecContext.getWorkingDir());
- jobAttr.setStdout(appExecContext.getStdOut());
- jobAttr.setStderr(appExecContext.getStderr());
- }
- if (appExecContext.getMaxWallTime() != null && appExecContext.getMaxWallTime() > 0) {
- log.info("Setting max wall clock time to " + appExecContext.getMaxWallTime());
- jobAttr.setMaxWallTime(appExecContext.getMaxWallTime());
- jobAttr.set("proxy_timeout", "1");
- }
- if (appExecContext.getPcount() != null && appExecContext.getPcount() >= 1) {
- log.info("Setting number of procs to " + appExecContext.getPcount());
- jobAttr.setNumProcs(appExecContext.getPcount());
- }
- if (appExecContext.getHostCount() != null && appExecContext.getHostCount() >= 1) {
- jobAttr.set("hostCount", String.valueOf(appExecContext.getHostCount()));
- }
+ public void cancelJob(String jobId) throws GramException, GSSException {
- if (appExecContext.getProjectName() != null) {
- log.info("Setting project to " + appExecContext.getProjectName());
- jobAttr.setProject(appExecContext.getProjectName());
+ if (currentlyExecutingJobs.containsKey(jobId)) {
+ GramJob gramJob = currentlyExecutingJobs.get(jobId);
+ if (gramJob != null) {
+ gramJob.cancel();
+ gramJob.signal(GramJob.SIGNAL_COMMIT_END);
+ }
}
- if (appExecContext.getQueue() != null) {
- jobAttr.setQueue(appExecContext.getQueue());
- }
- if (appExecContext.getArguments() != null) {
- jobAttr.set("arguments", appExecContext.getArguments());
- }
- String jobType = SINGLE;
+ }
- if (appExecContext.getJobType() != null) {
- jobType = appExecContext.getJobType();
- }
- if (jobType.equals(SINGLE)) {
- log.info("Setting job type to single");
- jobAttr.setJobType(GramAttributes.JOBTYPE_SINGLE);
- } else if (jobType.equals(MPI)) {
- log.info("Setting job type to mpi");
- jobAttr.setJobType(GramAttributes.JOBTYPE_MPI);
- } else if (jobType.equals(MULTIPLE)) {
- log.info("Setting job type to multiple");
- jobAttr.setJobType(GramAttributes.JOBTYPE_MULTIPLE);
- } else if (jobType.equals(CONDOR)) {
- log.info("Setting job type to condor");
- jobAttr.setJobType(GramAttributes.JOBTYPE_CONDOR);
+ public void startMonitoringRunningJobs(GSSCredential gssCred, ExecutionContext appExecContext) throws GFacException, MalformedURLException {
+
+ ListenerQueue listenerQueue = ListenerQueue.getInstance();
+
+ List<JobData> jobDataList = this.jobPersistenceManager.getRunningJobs();
+
+ appExecContext.addGramJobNotifier(new PersistenceGramJobNotifier(this.jobPersistenceManager));
+ JobSubmissionListener listener = new JobSubmissionListener(appExecContext.getGramJobNotifierList());
+
+ for (JobData jobData : jobDataList) {
+
+ GramJob gramJob = new GramJob(null);
+ gramJob.setID(jobData.getJobId());
+ gramJob.setCredentials(gssCred);
+ gramJob.addListener(listener);
+
+
+ log.info("Adding job " + jobData.getJobId() + " in state " + jobData.getState()
+ + " to monitoring queue");
+
+ listenerQueue.addJob(gramJob);
}
- return jobAttr;
}
}
Modified: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/JobSubmissionListener.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/JobSubmissionListener.java?rev=1494843&r1=1494842&r2=1494843&view=diff
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/JobSubmissionListener.java (original)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/JobSubmissionListener.java Thu Jun 20 03:14:27 2013
@@ -21,86 +21,123 @@
package org.apache.airavata.jobsubmission.gram;
+import org.apache.airavata.jobsubmission.gram.notifier.GramJobNotifier;
import org.apache.log4j.Logger;
+import org.globus.gram.GramException;
import org.globus.gram.GramJob;
import org.globus.gram.GramJobListener;
+import org.globus.gram.internal.GRAMProtocolErrorConstants;
+import org.ietf.jgss.GSSException;
+
+import java.util.List;
public class JobSubmissionListener implements GramJobListener {
- private static final String DELIMITER = "#";
- private boolean finished;
- private int error;
- private int status;
- private StringBuffer buffer;
+ private int currentStatus = -43;
- private GramJob job;
+ private boolean isSubmitted = false;
private static final Logger log = Logger.getLogger(JobSubmissionListener.class);
- public JobSubmissionListener(GramJob job, StringBuffer buffer) {
- this.buffer = buffer;
- this.job = job;
- }
-
- // waits for DONE or FAILED status
- public void waitFor() throws InterruptedException {
- while (!finished) {
-
- // job status is changed but method isn't invoked
- if (status != 0) {
- if (job.getStatus() != status) {
- log.info("invoke method manually");
- statusChanged(job);
- } else {
- log.info("job " + job.getIDAsString() + " have same status: " + GramJob.getStatusAsString(status));
- }
- } else {
- log.info("Status is zero");
- }
+ private List<GramJobNotifier> gramJobNotifierList;
- synchronized (this) {
- wait(20 * 1000l);
- }
- }
+ public JobSubmissionListener(List<GramJobNotifier> notifiers) {
+ this.gramJobNotifierList = notifiers;
}
+
public synchronized void statusChanged(GramJob job) {
log.debug("Listener: statusChanged triggered");
int jobStatus = job.getStatus();
- String jobId = job.getIDAsString();
- String statusString = job.getStatusAsString();
- log.info("Job Status: " + statusString + "(" + jobStatus + ")");
- buffer.append(formatJobStatus(jobId, statusString));
- log.debug(formatJobStatus(jobId, statusString));
-
- status = jobStatus;
- if (jobStatus == GramJob.STATUS_DONE) {
- finished = true;
- } else if (jobStatus == GramJob.STATUS_FAILED) {
- finished = true;
- error = job.getError();
- log.info("Job Error Code: " + error);
- buffer.append(DELIMITER + error);
- }
- buffer.append("\n");
- // notify wait thread to wake up if done
- if (finished) {
- notify();
+ if (currentStatus != jobStatus) {
+ currentStatus = jobStatus;
+
+ if (currentStatus == GramJob.STATUS_FAILED) {
+ int error = job.getError();
+
+ log.debug("Job Error Code: " + error);
+
+ try {
+ job.unbind();
+
+ if (error == GRAMProtocolErrorConstants.USER_CANCELLED) {
+ for(GramJobNotifier notifier : gramJobNotifierList) {
+ notifier.OnCancel(job);
+ }
+ } else if (error == GRAMProtocolErrorConstants.ERROR_AUTHORIZATION) {
+ for(GramJobNotifier notifier : gramJobNotifierList) {
+ notifier.OnAuthorisationDenied(job);
+ }
+ } else {
+ for(GramJobNotifier notifier : gramJobNotifierList) {
+ notifier.OnError(job);
+ }
+ }
+
+ } catch (Exception e) {
+ for(GramJobNotifier notifier : gramJobNotifierList) {
+ notifier.OnListenerError(job, e);
+ }
+ }
+ } else if (currentStatus == GramJob.STATUS_DONE) {
+ try {
+ job.unbind();
+
+ for(GramJobNotifier notifier : gramJobNotifierList) {
+ notifier.OnCompletion(job);
+ }
+
+ } catch (Exception e) {
+ for(GramJobNotifier notifier : gramJobNotifierList) {
+ notifier.OnListenerError(job, e);
+ }
+ }
+ } else if (currentStatus == GramJob.STATUS_ACTIVE) {
+
+ for(GramJobNotifier notifier : gramJobNotifierList) {
+ notifier.OnActive(job);
+ }
+ } else if (currentStatus == GramJob.STATUS_PENDING) {
+
+ for(GramJobNotifier notifier : gramJobNotifierList) {
+ notifier.OnPending(job);
+ }
+ } else if (currentStatus == GramJob.STATUS_UNSUBMITTED) {
+
+ for(GramJobNotifier notifier : gramJobNotifierList) {
+ notifier.OnUnSubmit(job);
+ }
+ } else if (currentStatus == GramJob.STATUS_STAGE_IN) {
+
+ for(GramJobNotifier notifier : gramJobNotifierList) {
+ notifier.OnFilesStagedIn(job);
+ }
+ } else if (currentStatus == GramJob.STATUS_STAGE_OUT) {
+
+ for(GramJobNotifier notifier : gramJobNotifierList) {
+ notifier.OnFilesStagedOut(job);
+ }
+ } else if (currentStatus == GramJob.STATUS_SUSPENDED) {
+
+ for(GramJobNotifier notifier : gramJobNotifierList) {
+ notifier.OnSuspend(job);
+ }
+ }
}
}
public static String formatJobStatus(String jobid, String jobstatus) {
- return System.currentTimeMillis() + DELIMITER + jobid + DELIMITER + jobstatus;
+ return System.currentTimeMillis() + " " + jobid + " " + jobstatus;
}
- public int getError() {
+ /*public int getError() {
return error;
}
public int getStatus() {
return status;
- }
+ }*/
public void wakeup() {
try {
Added: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/ListenerQueue.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/ListenerQueue.java?rev=1494843&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/ListenerQueue.java (added)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/ListenerQueue.java Thu Jun 20 03:14:27 2013
@@ -0,0 +1,136 @@
+/*
+ *
+ * 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.jobsubmission.gram;
+
+import org.globus.gram.GramException;
+import org.globus.gram.GramJob;
+import org.ietf.jgss.GSSException;
+
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 6/17/13
+ * Time: 2:15 PM
+ */
+
+public class ListenerQueue extends Thread {
+
+ private final Queue<JobListenerThread> qe;
+
+ private static ListenerQueue listenerQueue;
+
+ private boolean shutDown = false;
+
+ private ListenerQueue() {
+ qe = new ConcurrentLinkedQueue<JobListenerThread>();
+ }
+
+ public static ListenerQueue getInstance() {
+
+ if (null == listenerQueue) {
+ listenerQueue = new ListenerQueue();
+ return listenerQueue;
+ } else {
+ return listenerQueue;
+ }
+ }
+
+ public void run() {
+
+ while (!shutDown) {
+
+ startListener();
+
+ try {
+ synchronized (qe) {
+ qe.wait();
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ }
+ }
+
+ public void stopListenerQueue() {
+ shutDown = true;
+
+ synchronized (qe) {
+ qe.notify();
+ }
+
+ listenerQueue = null;
+
+ try {
+ this.join();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+
+ }
+
+ public void startListenerQueue() {
+ shutDown = false;
+ this.start();
+ }
+
+ public void startListener() {
+
+ while(!qe.isEmpty()) {
+ JobListenerThread jobListenerThread = qe.poll();
+ jobListenerThread.start();
+ }
+ }
+
+ public synchronized void addJob(GramJob job) {
+
+ qe.offer(new JobListenerThread(job));
+
+ synchronized (qe) {
+ qe.notifyAll();
+ }
+ }
+
+ class JobListenerThread extends Thread {
+
+ private GramJob listeningJob;
+
+ public JobListenerThread(GramJob job) {
+ listeningJob = job;
+ }
+
+ public void run() {
+ try {
+ listeningJob.bind();
+ } catch (GramException e) {
+ e.printStackTrace();
+ } catch (GSSException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+
+}
Added: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/RSLGenerator.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/RSLGenerator.java?rev=1494843&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/RSLGenerator.java (added)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/RSLGenerator.java Thu Jun 20 03:14:27 2013
@@ -0,0 +1,105 @@
+/*
+ *
+ * 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.jobsubmission.gram;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 6/18/13
+ * Time: 10:24 AM
+ */
+
+import org.apache.log4j.Logger;
+import org.globus.gram.GramAttributes;
+
+/**
+ * Responsible for generating the RSL from descriptors. Based on execution contexts.
+ */
+public class RSLGenerator {
+
+ private static final String MULTIPLE = "multiple";
+
+ private static final String MPI = "mpi";
+
+ private static final String SINGLE = "single";
+
+ private static final String CONDOR = "CONDOR";
+
+ private static final Logger log = Logger.getLogger(RSLGenerator.class);
+
+ protected GramAttributes configureRemoteJob(ExecutionContext appExecContext) throws Exception {
+ GramAttributes jobAttr = new GramAttributes();
+ jobAttr.setExecutable(appExecContext.getExecutable());
+ if (appExecContext.getWorkingDir() != null) {
+ jobAttr.setDirectory(appExecContext.getWorkingDir());
+ jobAttr.setStdout(appExecContext.getStdOut());
+ jobAttr.setStderr(appExecContext.getStderr());
+ }
+
+ if (appExecContext.getMaxWallTime() != null && appExecContext.getMaxWallTime() > 0) {
+ log.info("Setting max wall clock time to " + appExecContext.getMaxWallTime());
+ jobAttr.setMaxWallTime(appExecContext.getMaxWallTime());
+ jobAttr.set("proxy_timeout", "1");
+ }
+ if (appExecContext.getPcount() != null && appExecContext.getPcount() >= 1) {
+ log.info("Setting number of procs to " + appExecContext.getPcount());
+ jobAttr.setNumProcs(appExecContext.getPcount());
+ }
+
+ if (appExecContext.getHostCount() != null && appExecContext.getHostCount() >= 1) {
+ jobAttr.set("hostCount", String.valueOf(appExecContext.getHostCount()));
+ }
+
+ if (appExecContext.getProjectName() != null) {
+ log.info("Setting project to " + appExecContext.getProjectName());
+ jobAttr.setProject(appExecContext.getProjectName());
+ }
+
+ if (appExecContext.getQueue() != null) {
+ jobAttr.setQueue(appExecContext.getQueue());
+ }
+ if (appExecContext.getArguments() != null) {
+ jobAttr.set("arguments", appExecContext.getArguments());
+ }
+ String jobType = SINGLE;
+
+ if (appExecContext.getJobType() != null) {
+ jobType = appExecContext.getJobType();
+ }
+ if (jobType.equals(SINGLE)) {
+ log.info("Setting job type to single");
+ jobAttr.setJobType(GramAttributes.JOBTYPE_SINGLE);
+ } else if (jobType.equals(MPI)) {
+ log.info("Setting job type to mpi");
+ jobAttr.setJobType(GramAttributes.JOBTYPE_MPI);
+ } else if (jobType.equals(MULTIPLE)) {
+ log.info("Setting job type to multiple");
+ jobAttr.setJobType(GramAttributes.JOBTYPE_MULTIPLE);
+ } else if (jobType.equals(CONDOR)) {
+ log.info("Setting job type to condor");
+ jobAttr.setJobType(GramAttributes.JOBTYPE_CONDOR);
+ }
+
+
+ return jobAttr;
+ }
+
+}
Added: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/errors.properties
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/errors.properties?rev=1494843&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/errors.properties (added)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/errors.properties Thu Jun 20 03:14:27 2013
@@ -0,0 +1,176 @@
+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
Added: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/notifier/GramJobLogger.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/notifier/GramJobLogger.java?rev=1494843&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/notifier/GramJobLogger.java (added)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/notifier/GramJobLogger.java Thu Jun 20 03:14:27 2013
@@ -0,0 +1,105 @@
+/*
+ *
+ * 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.jobsubmission.gram.notifier;
+
+import org.apache.log4j.Logger;
+import org.globus.gram.GramJob;
+import org.ietf.jgss.GSSException;
+
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 6/18/13
+ * Time: 10:59 AM
+ */
+
+public class GramJobLogger implements GramJobNotifier {
+
+ private static final Logger log = Logger.getLogger(GramJobLogger.class);
+
+ private static ResourceBundle resources;
+
+ private String format = "Job Id [ %s ] is in [ %s ] state.";
+
+ static {
+ try {
+ resources = ResourceBundle.getBundle("org.apache.airavata.jobsubmission.gram.errors",
+ Locale.getDefault());
+ } catch (MissingResourceException mre) {
+ System.err.println("org.globus.gram.internal.gram.errors.properties not found");
+ }
+ }
+
+
+ public void OnPending(GramJob job) {
+ log.info(String.format(format, job.getIDAsString(), "PENDING"));
+ }
+
+ public void OnActive(GramJob job) {
+ log.info(String.format(format, job.getIDAsString(), "ACTIVE"));
+ }
+
+ public void OnError(GramJob job) {
+ log.info(String.format("Job Id [ %s ] is in %s state. Error code - %d and description - %s",
+ job.getIDAsString(), "[ ERROR ]", job.getError(),"TODO fix bundle loading"));
+ }
+
+ public void OnCompletion(GramJob job) {
+ log.info(String.format(format, job.getIDAsString(), "COMPLETE"));
+ }
+
+ public void OnCancel(GramJob job) {
+ log.info(String.format(format, job.getIDAsString(), "USER-CANCELED"));
+ }
+
+ public void OnSuspend(GramJob job) {
+ log.info(String.format(format, job.getIDAsString(), "SUSPEND"));
+ }
+
+ public void OnUnSubmit(GramJob job) {
+ log.info(String.format(format, job.getIDAsString(), "UN-SUBMITTED"));
+ }
+
+ public void OnFilesStagedIn(GramJob job) {
+ log.info(String.format(format, job.getIDAsString(), "FILES-STAGED-IN"));
+ }
+
+ public void OnFilesStagedOut(GramJob job) {
+ log.info(String.format(format, job.getIDAsString(), "FILES-STAGED-OUT"));
+ }
+
+ public void OnListenerError(GramJob job, Exception e) {
+ log.error("An error occurred while monitoring job id - " + job.getIDAsString(), e);
+ }
+
+ public void OnAuthorisationDenied(GramJob job) {
+ try {
+ log.error("Authorisation denied for job execution. User name - "
+ + job.getCredentials().getName().toString());
+ } catch (GSSException e) {
+ log.error("An error occurred while logging authorisation information - ", e);
+ }
+ }
+}
Added: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/notifier/GramJobNotifier.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/notifier/GramJobNotifier.java?rev=1494843&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/notifier/GramJobNotifier.java (added)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/notifier/GramJobNotifier.java Thu Jun 20 03:14:27 2013
@@ -0,0 +1,56 @@
+/*
+ *
+ * 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.jobsubmission.gram.notifier;
+
+import org.globus.gram.GramJob;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 6/18/13
+ * Time: 10:45 AM
+ */
+
+public interface GramJobNotifier {
+
+ void OnPending(GramJob job);
+
+ void OnActive(GramJob job);
+
+ void OnError (GramJob job);
+
+ void OnCompletion(GramJob job);
+
+ void OnCancel (GramJob job);
+
+ void OnSuspend (GramJob job);
+
+ void OnUnSubmit (GramJob job);
+
+ void OnFilesStagedIn (GramJob job);
+
+ void OnFilesStagedOut (GramJob job);
+
+ void OnListenerError(GramJob job, Exception e);
+
+ void OnAuthorisationDenied(GramJob job);
+
+}
Added: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/persistence/DBJobPersistenceManager.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/persistence/DBJobPersistenceManager.java?rev=1494843&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/persistence/DBJobPersistenceManager.java (added)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/persistence/DBJobPersistenceManager.java Thu Jun 20 03:14:27 2013
@@ -0,0 +1,219 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.jobsubmission.gram.persistence;
+
+import org.apache.airavata.common.utils.DBUtil;
+import org.apache.airavata.jobsubmission.gram.GFacException;
+import org.apache.log4j.Logger;
+import org.globus.gram.internal.GRAMConstants;
+
+import java.sql.*;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 6/18/13
+ * Time: 4:16 PM
+ */
+
+public class DBJobPersistenceManager implements JobPersistenceManager {
+
+ private DBUtil dbUtil;
+
+ private static final Logger log = Logger.getLogger(DBJobPersistenceManager.class);
+
+
+ public DBJobPersistenceManager(DBUtil db) {
+ this.dbUtil = db;
+ }
+
+ public synchronized void updateJobStatus(JobData jobData) throws GFacException{
+
+ if (jobData.getState() == GRAMConstants.STATUS_UNSUBMITTED) {
+ insertJob(jobData);
+ } else {
+
+ String sql = "update gram_job set status = ? where job_id = ?";
+
+ Connection connection = null;
+ PreparedStatement stmt = null;
+
+ try {
+ connection = getConnection();
+ stmt = connection.prepareStatement(sql);
+ stmt.setInt(1, jobData.getState());
+ stmt.setString(2, jobData.getJobId());
+
+ stmt.executeUpdate();
+ connection.commit();
+
+ } catch (SQLException e) {
+ throw new GFacException(e);
+ } finally {
+ try {
+ if (stmt != null) {
+ stmt.close();
+ }
+
+ if (connection != null) {
+ connection.close();
+ }
+
+ } catch (SQLException e) {
+ log.error("Error closing streams", e);
+ }
+ }
+ }
+ }
+
+ private void insertJob(JobData jobData) throws GFacException {
+
+ String sql = "insert into gram_job values (?, ?)";
+
+ PreparedStatement stmt = null;
+ Connection connection = null;
+
+ try {
+ connection = getConnection();
+ stmt = connection.prepareStatement(sql);
+ stmt.setString(1, jobData.getJobId());
+ stmt.setInt(2, jobData.getState());
+
+ stmt.executeUpdate();
+ } catch (SQLException e) {
+ throw new GFacException(e);
+ } finally {
+ try {
+ if (stmt != null) {
+ stmt.close();
+ }
+
+ if (connection != null) {
+ connection.close();
+ }
+
+ } catch (SQLException e) {
+ log.error("Error closing streams", e);
+ }
+ }
+
+ }
+
+ public List<JobData> getRunningJobs() throws GFacException {
+
+ String sql = "select * from gram_job where status not in (?, ?, ?)";
+
+ int[] statuses = new int[3];
+ statuses[0] = GRAMConstants.STATUS_UNSUBMITTED;
+ statuses[1] = GRAMConstants.STATUS_DONE;
+ statuses[2] = GRAMConstants.STATUS_FAILED;
+
+ return getJobs(sql, statuses);
+ }
+
+ public List<JobData> getFailedJobs() throws GFacException {
+
+ String sql = "select * from gram_job where status in (?)";
+
+ int[] statuses = new int[1];
+ statuses[0] = GRAMConstants.STATUS_FAILED;
+
+ return getJobs(sql, statuses);
+ }
+
+ public List<JobData> getUnSubmittedJobs() throws GFacException {
+
+ String sql = "select * from gram_job where status in (?)";
+
+ int[] statuses = new int[1];
+ statuses[0] = GRAMConstants.STATUS_UNSUBMITTED;
+
+ return getJobs(sql, statuses);
+ }
+
+ public List<JobData> getSuccessfullyCompletedJobs() throws GFacException {
+
+ String sql = "select * from gram_job where status in (?)";
+
+ int[] statuses = new int[1];
+ statuses[0] = GRAMConstants.STATUS_DONE;
+
+ return getJobs(sql, statuses);
+
+ }
+
+
+ protected List<JobData> getJobs(String sql, int[] statuses) throws GFacException {
+
+ List<JobData> jobs = new ArrayList<JobData>();
+
+ PreparedStatement preparedStatement = null;
+ Connection connection = null;
+
+ try {
+ connection = getConnection();
+ preparedStatement = connection.prepareStatement(sql);
+
+ int index = 1;
+ for (int status : statuses) {
+ preparedStatement.setInt(index, status);
+ ++index;
+ }
+
+ ResultSet resultSet = preparedStatement.executeQuery();
+
+ while (resultSet.next()) {
+
+ String jobId = resultSet.getString("job_id");
+ int state = resultSet.getInt("status");
+
+ jobs.add(new JobData(jobId, state));
+ }
+
+ } catch (SQLException e) {
+ throw new GFacException(e);
+ } finally {
+ try {
+ if (preparedStatement != null) {
+ preparedStatement.close();
+ }
+
+ if (connection != null) {
+ connection.close();
+ }
+
+ } catch (SQLException e) {
+ log.error("Error closing connection", e);
+ }
+ }
+
+ return jobs;
+ }
+
+ private synchronized Connection getConnection() throws SQLException {
+ Connection connection = dbUtil.getConnection();
+ connection.setAutoCommit(true);
+
+ return connection;
+ }
+}
Added: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/persistence/JobData.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/persistence/JobData.java?rev=1494843&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/persistence/JobData.java (added)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/persistence/JobData.java Thu Jun 20 03:14:27 2013
@@ -0,0 +1,55 @@
+/*
+ *
+ * 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.jobsubmission.gram.persistence;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 6/18/13
+ * Time: 2:34 PM
+ */
+
+public class JobData {
+
+ private String jobId;
+ private int state;
+
+ public JobData(String id, int state) {
+ this.jobId = id;
+ this.state = state;
+ }
+
+ public String getJobId() {
+ return jobId;
+ }
+
+ public void setJobId(String jobId) {
+ this.jobId = jobId;
+ }
+
+ public int getState() {
+ return state;
+ }
+
+ public void setState(int state) {
+ this.state = state;
+ }
+}
Added: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/persistence/JobPersistenceManager.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/persistence/JobPersistenceManager.java?rev=1494843&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/persistence/JobPersistenceManager.java (added)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/persistence/JobPersistenceManager.java Thu Jun 20 03:14:27 2013
@@ -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.jobsubmission.gram.persistence;
+
+import org.apache.airavata.jobsubmission.gram.GFacException;
+
+import java.util.List;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 6/18/13
+ * Time: 2:23 PM
+ */
+
+public interface JobPersistenceManager {
+
+ void updateJobStatus (JobData jobData) throws GFacException;
+
+ List<JobData> getRunningJobs() throws GFacException;
+
+ List<JobData> getFailedJobs() throws GFacException;
+
+ List<JobData> getUnSubmittedJobs() throws GFacException;
+
+ List<JobData> getSuccessfullyCompletedJobs() throws GFacException;
+
+}
Added: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/persistence/PersistenceGramJobNotifier.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/persistence/PersistenceGramJobNotifier.java?rev=1494843&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/persistence/PersistenceGramJobNotifier.java (added)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/gram/persistence/PersistenceGramJobNotifier.java Thu Jun 20 03:14:27 2013
@@ -0,0 +1,93 @@
+/*
+ *
+ * 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.jobsubmission.gram.persistence;
+
+import org.apache.airavata.jobsubmission.gram.GFacException;
+import org.apache.airavata.jobsubmission.gram.notifier.GramJobNotifier;
+import org.globus.gram.GramJob;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 6/18/13
+ * Time: 3:49 PM
+ */
+
+public class PersistenceGramJobNotifier implements GramJobNotifier {
+
+ private JobPersistenceManager jobPersistenceManager;
+
+ public PersistenceGramJobNotifier(JobPersistenceManager persistenceManager) {
+ this.jobPersistenceManager = persistenceManager;
+ }
+
+ public void OnPending(GramJob job) {
+ try {
+ this.jobPersistenceManager.updateJobStatus(new JobData(job.getIDAsString(), job.getStatus()));
+ } catch (GFacException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void OnActive(GramJob job) {}
+
+ public void OnError(GramJob job) {
+ try {
+ this.jobPersistenceManager.updateJobStatus(new JobData(job.getIDAsString(), job.getStatus()));
+ } catch (GFacException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void OnCompletion(GramJob job) {
+ try {
+ this.jobPersistenceManager.updateJobStatus(new JobData(job.getIDAsString(), job.getStatus()));
+ } catch (GFacException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void OnCancel(GramJob job) {
+ try {
+ this.jobPersistenceManager.updateJobStatus(new JobData(job.getIDAsString(), job.getStatus()));
+ } catch (GFacException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void OnSuspend(GramJob job) {}
+
+ public void OnUnSubmit(GramJob job) {}
+
+ public void OnFilesStagedIn(GramJob job) {}
+
+ public void OnFilesStagedOut(GramJob job) {}
+
+ public void OnListenerError(GramJob job, Exception e) {}
+
+ public void OnAuthorisationDenied(GramJob job) {
+ try {
+ this.jobPersistenceManager.updateJobStatus(new JobData(job.getIDAsString(), job.getStatus()));
+ } catch (GFacException e) {
+ e.printStackTrace();
+ }
+ }
+}
Modified: airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/utils/ServiceConstants.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/utils/ServiceConstants.java?rev=1494843&r1=1494842&r2=1494843&view=diff
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/utils/ServiceConstants.java (original)
+++ airavata/sandbox/grid-tools/gram-client/src/main/java/org/apache/airavata/jobsubmission/utils/ServiceConstants.java Thu Jun 20 03:14:27 2013
@@ -34,7 +34,7 @@ public class ServiceConstants {
public static final String TESTINGHOST = "testing.host";
public static final String LONESTARGRAMEPR = "lonestar.gram.endpoint";
- public static final String RANGERGRAMEPR = "ranger.gram.endpoint";
+ public static final String STAMPEDE_GRAM_EPR = "stampede.gram.endpoint";
public static final String TRESTLESGRAMEPR = "trestles.gram.endpoint";
public static final String EXECUTABLE = "executable";
Modified: airavata/sandbox/grid-tools/gram-client/src/main/resources/airavata-gram-client.properties
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/main/resources/airavata-gram-client.properties?rev=1494843&r1=1494842&r2=1494843&view=diff
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/main/resources/airavata-gram-client.properties (original)
+++ airavata/sandbox/grid-tools/gram-client/src/main/resources/airavata-gram-client.properties Thu Jun 20 03:14:27 2013
@@ -14,15 +14,15 @@ testing.host=trestles
lonestar.gram.endpoint=gridftp1.ls4.tacc.utexas.edu:2119/jobmanager-sge
## TACC Stampede
-stampede.gram.endpoint=login5.stampede.tacc.utexas.edu:2119/jobmanager-slurm
+stampede.gram.endpoint=login5.stampede.tacc.utexas.edu:2119/jobmanager-slurm3
## SDSC Trestles
trestles.gram.endpoint=trestles-login2.sdsc.edu:2119/jobmanager-pbstest2
-executable=/bin/hostname
+executable=/bin/sleep
arguments=30
queue=normal
-project_number=TG-STA110014S
+project_number=TG-MCB070039N
jobtype=single
maxwalltime=1
processors=1
Added: airavata/sandbox/grid-tools/gram-client/src/test/java/org/apache/airavata/jobsubmission/gram/GramJobSubmissionManagerTest.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/grid-tools/gram-client/src/test/java/org/apache/airavata/jobsubmission/gram/GramJobSubmissionManagerTest.java?rev=1494843&view=auto
==============================================================================
--- airavata/sandbox/grid-tools/gram-client/src/test/java/org/apache/airavata/jobsubmission/gram/GramJobSubmissionManagerTest.java (added)
+++ airavata/sandbox/grid-tools/gram-client/src/test/java/org/apache/airavata/jobsubmission/gram/GramJobSubmissionManagerTest.java Thu Jun 20 03:14:27 2013
@@ -0,0 +1,232 @@
+/*
+ *
+ * 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.jobsubmission.gram;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.airavata.common.utils.DBUtil;
+import org.apache.airavata.common.utils.DerbyUtil;
+import org.apache.airavata.jobsubmission.gram.notifier.GramJobLogger;
+import org.apache.airavata.jobsubmission.gram.persistence.DBJobPersistenceManager;
+import org.apache.airavata.jobsubmission.gram.persistence.JobData;
+import org.apache.airavata.jobsubmission.gram.persistence.JobPersistenceManager;
+import org.apache.airavata.security.myproxy.SecurityContext;
+import org.apache.log4j.Logger;
+import org.globus.gsi.provider.GlobusProvider;
+
+import java.security.Security;
+import java.util.List;
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 6/12/13
+ * Time: 10:24 AM
+ */
+
+public class GramJobSubmissionManagerTest extends TestCase {
+
+ static {
+ Security.addProvider(new GlobusProvider());
+ }
+
+ private static final Logger logger = Logger.getLogger(GramJobSubmissionManagerTest.class);
+
+ protected static String hostAddress = "localhost";
+ protected static int port = 20000;
+ protected static String userName = "admin";
+ protected static String password = "admin";
+ protected static String driver = "org.apache.derby.jdbc.ClientDriver";
+
+ public void setUp() throws Exception{
+
+ DerbyUtil.startDerbyInServerMode(getHostAddress(), getPort(), getUserName(), getPassword());
+
+ String createTable = "CREATE TABLE gram_job\n" +
+ "(\n" +
+ " job_id VARCHAR(256) NOT NULL,\n" +
+ " status int NOT NULL,\n" +
+ " PRIMARY KEY (job_id)\n" +
+ ")";
+
+
+ String dropTable = "drop table gram_job";
+
+ try {
+ executeSQL(dropTable);
+ } catch (Exception e) {}
+
+ executeSQL(createTable);
+
+ }
+
+ public static void executeSQL(String sql) throws Exception {
+ DBUtil dbUtil = new DBUtil(getJDBCUrl(), getUserName(), getPassword(), getDriver());
+ dbUtil.executeSQL(sql);
+ }
+
+ public static String getJDBCUrl() {
+ return "jdbc:derby://" + getHostAddress() + ":" + getPort() + "/persistent_data;create=true;user=" + getUserName() + ";password=" + getPassword();
+ }
+
+ public static String getHostAddress() {
+ return hostAddress;
+ }
+
+ public static int getPort() {
+ return port;
+ }
+
+ public static String getUserName() {
+ return userName;
+ }
+
+ public static String getPassword() {
+ return password;
+ }
+
+ public static String getDriver() {
+ return driver;
+ }
+
+ public DBUtil getDbUtil () throws Exception {
+ return new DBUtil(getJDBCUrl(), getUserName(), getPassword(), getDriver());
+
+ }
+
+ // Dummy test case just avoid failures
+ public void testDummy() {}
+
+ public void executeJob(ExecutionContext executionContext) throws Exception {
+
+ ListenerQueue listenerQueue = ListenerQueue.getInstance();
+ listenerQueue.start();
+
+ SecurityContext context = new SecurityContext();
+ context.login();
+
+ JobPersistenceManager jobPersistenceManager
+ = new DBJobPersistenceManager(getDbUtil());
+ GramJobSubmissionManager gramJobSubmissionManager
+ = new GramJobSubmissionManager(jobPersistenceManager);
+
+
+
+ String jobId = gramJobSubmissionManager.executeJob(context.getRawCredential(),
+ executionContext.getGRAMEndPoint(),
+ executionContext);
+
+ Assert.assertNotNull(jobId);
+
+ listenerQueue.join(2 * 60 * 1000);
+
+ logger.info("Checking whether job is in successful state in the persistence store");
+
+ List<JobData> list = jobPersistenceManager.getSuccessfullyCompletedJobs();
+ Assert.assertEquals(1, list.size());
+
+ Assert.assertEquals(jobId, list.get(0).getJobId());
+
+ listenerQueue.stopListenerQueue();
+
+ }
+
+ public void monitoringRunningJobs(ExecutionContext executionContext) throws Exception {
+
+ ListenerQueue listenerQueue = ListenerQueue.getInstance();
+ listenerQueue.startListenerQueue();
+
+ SecurityContext context = new SecurityContext();
+ context.login();
+
+ JobPersistenceManager jobPersistenceManager
+ = new DBJobPersistenceManager(getDbUtil());
+ GramJobSubmissionManager gramJobSubmissionManager
+ = new GramJobSubmissionManager(jobPersistenceManager);
+
+ executionContext.addGramJobNotifier(new GramJobLogger());
+
+ String jobId = gramJobSubmissionManager.executeJob(context.getRawCredential(),
+ executionContext.getTrestlesGRAM(),
+ executionContext);
+
+ listenerQueue.join(1000);
+
+ listenerQueue.stopListenerQueue();
+
+ logger.info("=================== Process Finished - Monitoring Stopped ==========================");
+
+ Assert.assertNotNull(jobId);
+
+ listenerQueue = ListenerQueue.getInstance();
+ listenerQueue.startListenerQueue();
+
+ logger.info("=================== Monitoring Stored Jobs ==========================");
+
+ gramJobSubmissionManager.startMonitoringRunningJobs(context.getRawCredential(), executionContext);
+
+ listenerQueue.join(1 * 60 * 1000);
+
+ listenerQueue.stopListenerQueue();
+
+ }
+
+ public void cancelJob(ExecutionContext executionContext) throws Exception {
+
+ ListenerQueue listenerQueue = ListenerQueue.getInstance();
+ listenerQueue.startListenerQueue();
+
+ SecurityContext context = new SecurityContext(executionContext.getUserName(), executionContext.getPassword());
+ context.login();
+
+ JobPersistenceManager jobPersistenceManager
+ = new DBJobPersistenceManager(getDbUtil());
+ GramJobSubmissionManager gramJobSubmissionManager
+ = new GramJobSubmissionManager(jobPersistenceManager);
+
+ executionContext.addGramJobNotifier(new GramJobLogger());
+
+ executionContext.setHost("trestles");
+
+ String jobId = gramJobSubmissionManager.executeJob(context.getRawCredential(),
+ executionContext.getTrestlesGRAM(),
+ executionContext);
+
+ Thread.sleep(30 * 1000);
+
+ Assert.assertNotNull(jobId);
+
+ gramJobSubmissionManager.cancelJob(jobId);
+
+
+ logger.info("========== End of test case ==============");
+
+ listenerQueue.join(1 * 30 * 1000);
+
+ listenerQueue.stopListenerQueue();
+ }
+
+
+ public static ExecutionContext getDefaultExecutionContext() throws Exception {
+
+ return new ExecutionContext();
+ }
+}