Author: lahiru
Date: Wed Aug 28 20:25:02 2013
New Revision: 1518364
URL: http://svn.apache.org/r1518364
Log:
adding pbs generation to gsissh
Added:
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/JobDescriptor.java
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/JobType.java
airavata/sandbox/gsissh/src/main/resources/PBSTemplate.xslt
airavata/sandbox/gsissh/src/main/resources/schemas/
airavata/sandbox/gsissh/src/main/resources/schemas/PBSJobDescriptor.xsd
airavata/sandbox/gsissh/src/main/resources/schemas/gsissh-schemas.xsdconfig
Modified:
airavata/sandbox/gsissh/pom.xml
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/CommandOutput.java
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SCPTo.java
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SSHApi.java
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApi.java
airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTest.java
Modified: airavata/sandbox/gsissh/pom.xml
URL:
http://svn.apache.org/viewvc/airavata/sandbox/gsissh/pom.xml?rev=1518364&r1=1518363&r2=1518364&view=diff
==============================================================================
--- airavata/sandbox/gsissh/pom.xml (original)
+++ airavata/sandbox/gsissh/pom.xml Wed Aug 28 20:25:02 2013
@@ -81,6 +81,11 @@
<artifactId>bcgss</artifactId>
<version>146</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.xmlbeans</groupId>
+ <artifactId>xmlbeans</artifactId>
+ <version>${xmlbeans.version}</version>
+ </dependency>
</dependencies>
<build>
@@ -109,7 +114,26 @@
<testSourceDirectory>${basedir}\src\test\java\</testSourceDirectory>
</configuration>
</plugin>
-
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>xmlbeans-maven-plugin</artifactId>
+ <version>2.3.3</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>xmlbeans</goal>
+ </goals>
+ </execution>
+ </executions>
+ <inherited>true</inherited>
+ <configuration>
+
<schemaDirectory>src/main/resources/schemas</schemaDirectory>
+ <xmlConfigs>
+ <xmlConfig
implementation="java.io.File">src/main/resources/schemas/gsissh-schemas.xsdconfig</xmlConfig>
+ </xmlConfigs>
+
<outputJar>target/generated/${project.artifactId}-${project.version}.jar</outputJar>
+ </configuration>
+ </plugin>
</plugins>
<testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
<testOutputDirectory>${project.build.directory}/test-classes</testOutputDirectory>
@@ -128,6 +152,7 @@
<log4j.version>1.2.17</log4j.version>
<org.slf4j.version>1.7.2</org.slf4j.version>
<skipTests>false</skipTests>
+ <xmlbeans.version>2.5.0</xmlbeans.version>
</properties>
</project>
Modified:
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/CommandOutput.java
URL:
http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/CommandOutput.java?rev=1518364&r1=1518363&r2=1518364&view=diff
==============================================================================
---
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/CommandOutput.java
(original)
+++
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/CommandOutput.java
Wed Aug 28 20:25:02 2013
@@ -35,7 +35,7 @@ import java.io.OutputStream;
public interface CommandOutput {
/**
- * Gets the output of the command as an stream.
+ * Gets the output of the command as a stream.
* @param channel Command output as a stream.
*/
void onOutput(Channel channel);
Modified:
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SCPTo.java
URL:
http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SCPTo.java?rev=1518364&r1=1518363&r2=1518364&view=diff
==============================================================================
---
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SCPTo.java
(original)
+++
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SCPTo.java
Wed Aug 28 20:25:02 2013
@@ -189,12 +189,9 @@ public class SCPTo {
return session;
}
+
static int checkAck(InputStream in) throws IOException {
int b = in.read();
- // b may be 0 for success,
- // 1 for error,
- // 2 for fatal error,
- // -1
if (b == 0) return b;
if (b == -1) return b;
Modified:
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SSHApi.java
URL:
http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SSHApi.java?rev=1518364&r1=1518363&r2=1518364&view=diff
==============================================================================
---
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SSHApi.java
(original)
+++
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/SSHApi.java
Wed Aug 28 20:25:02 2013
@@ -27,6 +27,8 @@ package org.apache.airavata.gsi.ssh.api;
* Time: 3:12 PM
*/
+import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
+
/**
* An API to executed commands/jobs using GSI-SSH or SSH.
*/
@@ -44,7 +46,11 @@ public interface SSHApi {
AuthenticationInfo authenticationInfo,
CommandOutput commandOutput) throws
SSHApiException;
- void submitJob(CommandInfo commandInfo, ServerInfo serverInfo,
- AuthenticationInfo authenticationInfo, CommandOutput
commandOutput,
- String pbsFilePath,String workingDirectory)throws
SSHApiException;
+ void submitAsyncJobWithPBS(ServerInfo serverInfo,
+ AuthenticationInfo authenticationInfo,
+ String pbsFilePath, JobDescriptor
jobDescriptor) throws SSHApiException;
+//
+ void submitAsyncJob(ServerInfo serverInfo,
+ AuthenticationInfo authenticationInfo,
+ JobDescriptor jobDescriptor) throws
SSHApiException;
}
Added:
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/JobDescriptor.java
URL:
http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/JobDescriptor.java?rev=1518364&view=auto
==============================================================================
---
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/JobDescriptor.java
(added)
+++
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/JobDescriptor.java
Wed Aug 28 20:25:02 2013
@@ -0,0 +1,155 @@
+/*
+ *
+ * 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.gsi.ssh.api.job;
+
+import org.apache.airavata.gsi.ssh.api.CommandInfo;
+import org.apache.airavata.gsi.ssh.api.CommandOutput;
+import org.apache.airavata.gsi.ssh.x2012.x12.InputList;
+import org.apache.airavata.gsi.ssh.x2012.x12.JobDescriptorDocument;
+import org.apache.airavata.gsi.ssh.x2012.x12.PbsParams;
+import org.apache.airavata.gsi.ssh.x2012.x12.impl.PbsParamsImpl;
+import org.apache.xmlbeans.XmlException;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * This class define a job with required parameters, based on this
configuration API is generating a Pbs script and
+ * submit the job to the computing resource
+ */
+public class JobDescriptor {
+
+ private JobDescriptorDocument jobDescriptionDocument;
+
+ private CommandInfo commandInfo;
+
+ private CommandOutput commandOutput;
+
+ public JobDescriptor() {
+ jobDescriptionDocument = JobDescriptorDocument.Factory.newInstance();
+ jobDescriptionDocument.addNewJobDescriptor();
+ }
+
+ public JobDescriptor(JobDescriptorDocument jobDescriptorDocument) {
+ this.jobDescriptionDocument = jobDescriptorDocument;
+ }
+
+
+ public JobDescriptor(CommandOutput commandOutput) {
+ jobDescriptionDocument = JobDescriptorDocument.Factory.newInstance();
+ jobDescriptionDocument.addNewJobDescriptor();
+ this.commandOutput = commandOutput;
+ }
+
+
+ public String toXML() {
+ return jobDescriptionDocument.xmlText();
+ }
+
+ public JobDescriptorDocument getJobDescriptorDocument() {
+ return this.jobDescriptionDocument;
+ }
+
+ public static JobDescriptor fromXML(String xml)
+ throws XmlException {
+ JobDescriptorDocument parse = JobDescriptorDocument.Factory
+ .parse(xml);
+ JobDescriptor jobDescriptor = new JobDescriptor(parse);
+ return jobDescriptor;
+ }
+
+ public void setCommandInfo(CommandInfo commandInfo) {
+ this.commandInfo = commandInfo;
+ }
+
+ public void setCommandOutput(CommandOutput commandOutput) {
+ this.commandOutput = commandOutput;
+ }
+
+ public CommandInfo getCommandInfo() {
+ return commandInfo;
+ }
+
+ public CommandOutput getCommandOutput() {
+ return commandOutput;
+ }
+
+ //todo write bunch of setter getters to set and get jobdescription
parameters
+ public void setWorkingDirectory(String workingDirectory) {
+
this.getJobDescriptorDocument().getJobDescriptor().setWorkingDirectory(workingDirectory);
+ }
+
+ public String getWorkingDirectory() {
+ return
this.getJobDescriptorDocument().getJobDescriptor().getWorkingDirectory();
+ }
+
+ public void setShellName(String shellName) {
+
this.getJobDescriptorDocument().getJobDescriptor().setShellName(shellName);
+ }
+
+ public void setJobName(String name) {
+ this.getJobDescriptorDocument().getJobDescriptor().setJobName(name);
+ }
+
+ public void setExecutablePath(String name) {
+
this.getJobDescriptorDocument().getJobDescriptor().setExecutablePath(name);
+ }
+
+ public void setAllEnvExport(boolean name) {
+
this.getJobDescriptorDocument().getJobDescriptor().setAllEnvExport(name);
+ }
+
+ public void setMailOptions(String name) {
+
this.getJobDescriptorDocument().getJobDescriptor().setMailOptions(name);
+ }
+
+ public void setStandardOutFile(String name) {
+
this.getJobDescriptorDocument().getJobDescriptor().setStandardOutFile(name);
+ }
+
+ public void setStandardErrorFile(String name) {
+
this.getJobDescriptorDocument().getJobDescriptor().setStandardErrorFile(name);
+ }
+
+ public void setNodes(int name) {
+ this.getJobDescriptorDocument().getJobDescriptor().setNodes(name);
+ }
+
+ public void setProcessesPerNode(int name) {
+
this.getJobDescriptorDocument().getJobDescriptor().setProcessesPerNode(name);
+ }
+
+ public void setMaxWallTime(String name) {
+
this.getJobDescriptorDocument().getJobDescriptor().setMaxWallTime(name);
+ }
+
+ public void setAcountString(String name) {
+
this.getJobDescriptorDocument().getJobDescriptor().setAcountString(name);
+ }
+
+ public void setInputValues(List<String> inputValue){
+ InputList inputList =
this.getJobDescriptorDocument().getJobDescriptor().addNewInputs();
+ inputList.setInputArray(inputValue.toArray(new
String[inputValue.size()]));
+ }
+}
+
Added:
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/JobType.java
URL:
http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/JobType.java?rev=1518364&view=auto
==============================================================================
---
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/JobType.java
(added)
+++
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/JobType.java
Wed Aug 28 20:25:02 2013
@@ -0,0 +1,12 @@
+package org.apache.airavata.gsi.ssh.api.job;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lahirugunathilake
+ * Date: 8/22/13
+ * Time: 7:19 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public enum JobType {
+ SERIAL, SINGLE, MPI, MULTIPLE, CONDOR
+}
Modified:
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApi.java
URL:
http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApi.java?rev=1518364&r1=1518363&r2=1518364&view=diff
==============================================================================
---
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApi.java
(original)
+++
airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApi.java
Wed Aug 28 20:25:02 2013
@@ -21,16 +21,26 @@
package org.apache.airavata.gsi.ssh.impl;
+import bsh.StringUtil;
import com.jcraft.jsch.*;
import org.apache.airavata.gsi.ssh.api.*;
+import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
import org.apache.airavata.gsi.ssh.config.ConfigReader;
import org.apache.airavata.gsi.ssh.jsch.ExtendedJSch;
+import org.apache.commons.codec.binary.StringUtils;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.xmlbeans.impl.store.Path;
+import org.bouncycastle.crypto.prng.RandomGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.swing.*;
-import java.io.IOException;
-import java.io.InputStream;
+import javax.xml.transform.*;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import java.io.*;
+import java.security.SecureRandom;
/**
* User: AmilaJ ([email protected])
@@ -139,25 +149,72 @@ public class DefaultSSHApi implements SS
}
- public void submitJob(CommandInfo commandInfo, ServerInfo serverInfo,
- AuthenticationInfo authenticationInfo,
- CommandOutput commandOutput, String pbsFilePath,
String workingDirectory) throws SSHApiException {
+ public void submitAsyncJobWithPBS(ServerInfo serverInfo,
+ AuthenticationInfo authenticationInfo,
+ String pbsFilePath, JobDescriptor
jobDescriptor) throws SSHApiException {
try {
+
SCPTo scpTo = new SCPTo(serverInfo, authenticationInfo, new
ConfigReader());
- scpTo.scpTo(workingDirectory, pbsFilePath);
+ scpTo.scpTo(jobDescriptor.getWorkingDirectory(), pbsFilePath);
+
} catch (JSchException e) {
throw new SSHApiException("An exception occurred while connecting
to server." +
"Connecting server - " + serverInfo.getHost() + ":" +
serverInfo.getPort() +
" connecting user name - "
+ serverInfo.getUserName(), e);
- } catch (IOException e){
- throw new SSHApiException("An exception occurred while connecting
to server." +
+ } catch (IOException e) {
+ throw new SSHApiException("An exception occurred while connecting
to server." +
"Connecting server - " + serverInfo.getHost() + ":" +
serverInfo.getPort() +
" connecting user name - "
+ serverInfo.getUserName(), e);
}
-
this.executeCommand(commandInfo,serverInfo,authenticationInfo,commandOutput);
+ // since this is a constant we do not ask users to fill this
+ RawCommandInfo rawCommandInfo = new
RawCommandInfo("/opt/torque/bin/qsub " +
+ jobDescriptor.getWorkingDirectory() + File.separator +
FilenameUtils.getName(pbsFilePath));
+
+ this.executeCommand(rawCommandInfo, serverInfo, authenticationInfo,
jobDescriptor.getCommandOutput());
}
+ public void submitAsyncJob(ServerInfo serverInfo, AuthenticationInfo
authenticationInfo, JobDescriptor jobDescriptor) throws SSHApiException {
+ TransformerFactory factory = TransformerFactory.newInstance();
+ String xsltPath = "src" + File.separator + "main" + File.separator +
"resources" + File.separator + "PBSTemplate.xslt";
+ Source xslt = new StreamSource(new File(xsltPath));
+ Transformer transformer = null;
+ StringWriter results = new StringWriter();
+
+ try {
+ // generate the pbs script using xslt
+ transformer = factory.newTransformer(xslt);
+ Source text = new StreamSource(new
ByteArrayInputStream(jobDescriptor.toXML().getBytes()));
+ transformer.transform(text, new StreamResult(results));
+
+ System.out.println("***********************************");
+ System.out.println(results.toString());
+ System.out.println("***********************************");
+
+ // creating a temporary file using pbs script generated above
+ int number = new SecureRandom().nextInt();
+ number = (number < 0 ? -number : number);
+
+ File tempPBSFile = new File(Integer.toString(number) + ".pbs");
+ FileUtils.writeStringToFile(tempPBSFile, results.toString());
+
+ //reusing submitAsyncJobWithPBS method to submit a job
+
+ this.submitAsyncJobWithPBS(serverInfo, authenticationInfo,
tempPBSFile.getAbsolutePath(), jobDescriptor);
+ tempPBSFile.delete();
+ } catch (TransformerConfigurationException e) {
+ throw new SSHApiException("Error parsing PBS transformation", e);
+ } catch (TransformerException e) {
+ throw new SSHApiException("Error generating PBS script", e);
+ } catch (IOException e) {
+ throw new SSHApiException("An exception occurred while connecting
to server." +
+ "Connecting server - " + serverInfo.getHost() + ":" +
serverInfo.getPort() +
+ " connecting user name - "
+ + serverInfo.getUserName(), e);
+ }
+
+
+ }
}
Added: airavata/sandbox/gsissh/src/main/resources/PBSTemplate.xslt
URL:
http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/resources/PBSTemplate.xslt?rev=1518364&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/resources/PBSTemplate.xslt (added)
+++ airavata/sandbox/gsissh/src/main/resources/PBSTemplate.xslt Wed Aug 28
20:25:02 2013
@@ -0,0 +1,34 @@
+<!--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
+#
+##PBS -S <xsl:value-of select="ns:shellName"/>
+#PBS -m <xsl:value-of select="ns:mailOptions"/>
+#PBS -A <xsl:value-of select="ns:acountString"/>
+#PBS -l walltime=<xsl:value-of select="ns:maxWallTime"/>
+#PBS -o <xsl:value-of select="ns:standardOutFile"/>
+#PBS -e <xsl:value-of select="ns:standardErrorFile"/>
+#PBS -l nodes=<xsl:value-of select="ns:nodes"/>:ppn=<xsl:value-of
select="ns:processesPerNode"/>
+<xsl:text>
</xsl:text>
+<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>
+cd <xsl:text> </xsl:text><xsl:value-of
select="ns:workingDirectory"/><xsl:text>
</xsl:text>
+<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:template>
+
+</xsl:stylesheet>
\ No newline at end of file
Added: airavata/sandbox/gsissh/src/main/resources/schemas/PBSJobDescriptor.xsd
URL:
http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/resources/schemas/PBSJobDescriptor.xsd?rev=1518364&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/resources/schemas/PBSJobDescriptor.xsd
(added)
+++ airavata/sandbox/gsissh/src/main/resources/schemas/PBSJobDescriptor.xsd Wed
Aug 28 20:25:02 2013
@@ -0,0 +1,55 @@
+<?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. -->
+
+<schema targetNamespace="http://airavata.apache.org/gsi/ssh/2012/12"
xmlns:gsissh="http://airavata.apache.org/gsi/ssh/2012/12"
+ xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+
+ <element name="JobDescriptor" type="gsissh:pbsParams" />
+
+ <complexType name="pbsParams">
+ <sequence>
+ <element name="shellName" type="xsd:string"
minOccurs="0" maxOccurs="1" default="/bin/bash"/>
+ <element name="jobName" type="xsd:string" minOccurs="0"
maxOccurs="1"/>
+ <element name="allEnvExport" type="xsd:boolean" minOccurs="0 "
maxOccurs="1" default="true"/>
+ <element name="mailOptions" type="xsd:string"
minOccurs="0" maxOccurs="1" />
+ <element name="acountString" type="xsd:string"
minOccurs="0" maxOccurs="1" />
+ <element name="maxWallTime" type="xsd:string"
minOccurs="0" maxOccurs="1" default="1:00:00"/>
+ <element name="standardOutFile" type="xsd:string" minOccurs="0"
maxOccurs="1" />
+ <element name="standardErrorFile" type="xsd:string" minOccurs="0"
maxOccurs="1" />
+ <element name="outputDirectory" type="xsd:string"
minOccurs="0" maxOccurs="1" />
+ <element name="inputDirectory" type="xsd:string" minOccurs="0"
maxOccurs="1" />
+ <element name="nodes" type="xsd:int" minOccurs="0" maxOccurs="1"
default="1"/>
+ <element name="processesPerNode" type="xsd:int" minOccurs="0"
maxOccurs="1" default="1" />
+ <element name="workingDirectory" type="xsd:string" minOccurs="0"
maxOccurs="1" />
+ <element name="executablePath" type="xsd:string" minOccurs="0"
maxOccurs="1" />
+ <element name="inputs" type="gsissh:inputList" minOccurs="1"
maxOccurs="1"/>
+ <element name="exports" type="gsissh:exportProperties"
minOccurs="1" maxOccurs="1"/>
+ </sequence>
+ </complexType>
+ <complexType name="inputList">
+ <sequence>
+ <element name="input" type="xsd:string" minOccurs="0"
maxOccurs="unbounded" />
+ </sequence>
+ </complexType>
+ <complexType name="exportProperties">
+ <sequence>
+
+ <element name="name" minOccurs="1"
maxOccurs="unbounded">
+ <complexType>
+ <simpleContent>
+ <extension base="xsd:string">
+ <attribute name="value"
type="xsd:string" use="required" />
+ </extension>
+ </simpleContent>
+ </complexType>
+ </element>
+
+ </sequence>
+ </complexType>
+</schema>
\ No newline at end of file
Added:
airavata/sandbox/gsissh/src/main/resources/schemas/gsissh-schemas.xsdconfig
URL:
http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/resources/schemas/gsissh-schemas.xsdconfig?rev=1518364&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/resources/schemas/gsissh-schemas.xsdconfig
(added)
+++ airavata/sandbox/gsissh/src/main/resources/schemas/gsissh-schemas.xsdconfig
Wed Aug 28 20:25:02 2013
@@ -0,0 +1,14 @@
+<!--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. -->
+
+<xb:config xmlns:xb="http://www.bea.com/2002/09/xbean/config">
+
+ <xb:namespace uri="http://airavata.apache.org/schemas/gsi/ssh/2012/12">
+ <xb:package>org.apache.airavata.gsi.ssh</xb:package>
+ </xb:namespace>
+</xb:config>
\ No newline at end of file
Modified:
airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTest.java
URL:
http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTest.java?rev=1518364&r1=1518363&r2=1518364&view=diff
==============================================================================
---
airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTest.java
(original)
+++
airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTest.java
Wed Aug 28 20:25:02 2013
@@ -22,10 +22,19 @@
package org.apache.airavata.gsi.ssh.impl;
import org.apache.airavata.gsi.ssh.api.*;
+import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
+import org.apache.airavata.gsi.ssh.x2012.x12.ExportProperties;
+import org.apache.airavata.gsi.ssh.x2012.x12.InputList;
+import org.apache.commons.io.FilenameUtils;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import java.io.File;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
/**
* User: AmilaJ ([email protected])
@@ -44,6 +53,9 @@ public class DefaultSSHApiTest {
@BeforeTest
public void setUp() throws Exception {
+ System.setProperty("myproxy.user", "ogce");
+ System.setProperty("myproxy.password", "Jdas7wph");
+ System.setProperty("basedir",
"/Users/lahirugunathilake/work/airavata/sandbox/gsissh");
myProxyUserName = System.getProperty("myproxy.user");
myProxyPassword = System.getProperty("myproxy.password");
@@ -55,9 +67,11 @@ public class DefaultSSHApiTest {
certificateLocation = pomFileDirectory.getAbsolutePath() +
"/certificates";
- pbsFilePath = pomFileDirectory.getAbsolutePath() + File.separator +
"src" + File.separator + "test" + File.separator + "resources" + File.separator
+ "sleep.pbs";
+ pbsFilePath = pomFileDirectory.getAbsolutePath() + File.separator +
"src" + File.separator + "test" + File.separator + "resources" + File.separator
+ "sleep.pbs";
+
+ String randomPBSFile = Integer.toString((new Random()).nextInt());
+ workingDirectory = File.separator + "home" + File.separator + "ogce";
- workingDirectory = File.separator + "home" + File.separator + "ogce" ;
if (myProxyUserName == null || myProxyPassword == 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 <<<<<<<");
@@ -70,16 +84,16 @@ public class DefaultSSHApiTest {
@Test
public void testExecuteCommand() throws Exception {
- // Create authentication
+ // Create authentication
AuthenticationInfo authenticationInfo
= new MyProxyAuthenticationInfo(myProxyUserName,
myProxyPassword, "myproxy.teragrid.org",
7512, 17280000);
// Create command
- CommandInfo commandInfo = new RawCommandInfo("/opt/torque/bin/qstat");
+ CommandInfo commandInfo = new RawCommandInfo("/bin/ls");
// Server info
- ServerInfo serverInfo = new ServerInfo("ogce" ,"trestles.sdsc.edu");
+ ServerInfo serverInfo = new ServerInfo("ogce", "trestles.sdsc.edu");
// Output
CommandOutput commandOutput = new SystemCommandOutput();
@@ -102,7 +116,7 @@ public class DefaultSSHApiTest {
CommandInfo commandInfo = new RawCommandInfo("/opt/torque/bin/qsub
/home/ogce/test.pbs");
// Server info
- ServerInfo serverInfo = new ServerInfo("ogce" ,"trestles.sdsc.edu");
+ ServerInfo serverInfo = new ServerInfo("ogce", "trestles.sdsc.edu");
// Output
CommandOutput commandOutput = new SystemCommandOutput();
@@ -115,17 +129,44 @@ public class DefaultSSHApiTest {
}
@Test
- public void testSubmitJob() throws Exception {
+ public void testsubmitAsyncJobWithPBS() throws Exception {
// Create authentication
AuthenticationInfo authenticationInfo
= new MyProxyAuthenticationInfo(myProxyUserName,
myProxyPassword, "myproxy.teragrid.org",
7512, 17280000);
// Create command
- CommandInfo commandInfo = new RawCommandInfo("/opt/torque/bin/qsub
/home/ogce/sleep.pbs");
+ CommandInfo commandInfo = new RawCommandInfo("/opt/torque/bin/qsub
/home/ogce/sleep1.pbs");
+
+ // Server info
+ ServerInfo serverInfo = new ServerInfo("ogce", "trestles.sdsc.edu");
+
+ // Output
+ CommandOutput commandOutput = new SystemCommandOutput();
+
+ // Get the API
+ SSHApi sshApi = SSHApiFactory.createSSHApi(this.certificateLocation);
+
+ // Execute command
+ System.out.println("Target PBS file path: " + workingDirectory);
+ System.out.println("Local PBS File path: " + pbsFilePath);
+ JobDescriptor jobDescriptor = new JobDescriptor(commandOutput);
+ //Here we give working directory as a file name to replace the file,
to allow multiple test runs with the same
+ //file name
+ jobDescriptor.setWorkingDirectory(workingDirectory);
+ sshApi.submitAsyncJobWithPBS(serverInfo, authenticationInfo,
pbsFilePath, jobDescriptor);
+ System.out.println(jobDescriptor.toXML());
+ }
+
+ @Test
+ public void testsubmitAsyncJob() throws Exception {
+ // Create authentication
+ AuthenticationInfo authenticationInfo
+ = new MyProxyAuthenticationInfo(myProxyUserName,
myProxyPassword, "myproxy.teragrid.org",
+ 7512, 17280000);
// Server info
- ServerInfo serverInfo = new ServerInfo("ogce" ,"trestles.sdsc.edu");
+ ServerInfo serverInfo = new ServerInfo("ogce", "trestles.sdsc.edu");
// Output
CommandOutput commandOutput = new SystemCommandOutput();
@@ -134,6 +175,26 @@ public class DefaultSSHApiTest {
SSHApi sshApi = SSHApiFactory.createSSHApi(this.certificateLocation);
// Execute command
- sshApi.submitJob(commandInfo, serverInfo, authenticationInfo,
commandOutput, pbsFilePath, workingDirectory);
+ System.out.println("Target PBS file path: " + workingDirectory);
+ System.out.println("Local PBS File path: " + pbsFilePath);
+ String workingDirectory = File.separator + "home" + File.separator +
"ogce" + File.separator + "gsissh";
+ JobDescriptor jobDescriptor = new JobDescriptor(commandOutput);
+ 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.setMaxWallTime("1:00:00");
+ jobDescriptor.setAcountString("sds128");
+ List<String> inputs = new ArrayList<String>();
+ inputs.add("Hello World");
+ jobDescriptor.setInputValues(inputs);
+ System.out.println(jobDescriptor.toXML());
+ sshApi.submitAsyncJob(serverInfo, authenticationInfo, jobDescriptor);
}
}