airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1519854 - in /airavata/sandbox/gsissh/src: main/java/org/apache/airavata/gsi/ssh/api/ main/java/org/apache/airavata/gsi/ssh/api/job/ main/java/org/apache/airavata/gsi/ssh/impl/ main/resources/schemas/ test/java/org/apache/airavata/gsi/ssh/...
Date Tue, 03 Sep 2013 21:21:23 GMT
Author: lahiru
Date: Tue Sep  3 21:21:23 2013
New Revision: 1519854

URL: http://svn.apache.org/r1519854
Log:
adding new set of features to gsissh api.

Added:
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/Cluster.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/Core.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/Machine.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/GSISSHAPI.java
Modified:
    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/api/job/JobDescriptor.java
    airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApi.java
    airavata/sandbox/gsissh/src/main/resources/schemas/PBSJobDescriptor.xsd
    airavata/sandbox/gsissh/src/test/java/org/apache/airavata/gsi/ssh/impl/DefaultSSHApiTest.java

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/Cluster.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/Cluster.java?rev=1519854&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/Cluster.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/Cluster.java Tue
Sep  3 21:21:23 2013
@@ -0,0 +1,38 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.gsi.ssh.api;
+
+public class Cluster {
+
+    private Machine[] Nodes;
+/**
+ *
+ * @return cluster Nodes as array of machines
+ */
+    public Machine[] getNodes() {
+        return Nodes;
+    }
+
+    public void setNodes(Machine[] Nodes) {
+        this.Nodes = Nodes;
+    }
+
+}

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/Core.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/Core.java?rev=1519854&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/Core.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/Core.java Tue Sep
 3 21:21:23 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.gsi.ssh.api;
+
+import org.apache.airavata.gsi.ssh.api.job.JobDescriptor;
+
+public class Core {
+    private JobDescriptor job;
+    private String id;
+
+    public Core(String id) {
+        this.id = id;
+        this.job = null;
+    }
+
+    /**
+     * @return core's id
+     */
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    /**
+     * @return job running on the core
+     */
+    public JobDescriptor getJob() {
+        return job;
+    }
+
+    public void setJob(JobDescriptor job) {
+        this.job = job;
+    }
+
+}

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/Machine.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/Machine.java?rev=1519854&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/Machine.java (added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/Machine.java Tue
Sep  3 21:21:23 2013
@@ -0,0 +1,104 @@
+/*
+ *
+ * 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;
+
+import java.util.HashMap;
+
+public class Machine {
+    private String Name;
+    private Core[] Cores;
+    private String state;
+    private HashMap<String, String> status;
+    private String np;
+    private String ntype;
+
+    /**
+     * @return the machine's name
+     */
+    public String getName() {
+        return Name;
+    }
+
+    public void setName(String Name) {
+        this.Name = Name;
+    }
+
+    /**
+     * @return machine cores as an array
+     */
+    public Core[] getCores() {
+        return Cores;
+    }
+
+    public void setCores(Core[] Cores) {
+        this.Cores = Cores;
+    }
+
+
+    /**
+     * @return the machine state
+     */
+    public String getState() {
+        return state;
+    }
+
+    public void setState(String state) {
+        this.state = state;
+    }
+
+    /**
+     * @return the status
+     */
+    public HashMap<String, String> getStatus() {
+        return status;
+    }
+
+    public void setStatus(HashMap<String, String> status) {
+        this.setStatus(status);
+    }
+
+
+    /**
+     * @return the number of cores in the machine
+     */
+    public String getNp() {
+        return np;
+    }
+
+
+    public void setNp(String np) {
+        this.np = np;
+    }
+
+    /**
+     * @return the ntype of the machine
+     */
+    public String getNtype() {
+        return ntype;
+    }
+
+
+    public void setNtype(String ntype) {
+        this.ntype = ntype;
+    }
+
+
+}

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=1519854&r1=1519853&r2=1519854&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 Tue
Sep  3 21:21:23 2013
@@ -71,4 +71,9 @@ public interface SSHApi {
     String submitAsyncJob(ServerInfo serverInfo,
                                AuthenticationInfo authenticationInfo,
                                JobDescriptor jobDescriptor) throws SSHApiException;
+
+    Cluster getCluster(ServerInfo serverInfo, AuthenticationInfo authenticationInfo) throws
SSHApiException;
+
+
+    JobDescriptor getJobById(ServerInfo serverInfo,AuthenticationInfo authenticationInfo,
String jobID)throws SSHApiException;
 }

Modified: 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=1519854&r1=1519853&r2=1519854&view=diff
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/JobDescriptor.java
(original)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/api/job/JobDescriptor.java
Tue Sep  3 21:21:23 2013
@@ -132,5 +132,30 @@ public class JobDescriptor {
         InputList inputList = this.getJobDescriptorDocument().getJobDescriptor().addNewInputs();
         inputList.setInputArray(inputValue.toArray(new String[inputValue.size()]));
     }
+
+    public void setJobID(String jobID) {
+        this.getJobDescriptorDocument().getJobDescriptor().setJobID(jobID);
+    }
+
+    public void setQueueName(String queueName) {
+        this.getJobDescriptorDocument().getJobDescriptor().setQueueName(queueName);
+    }
+     public void setStatus(String queueName) {
+        this.getJobDescriptorDocument().getJobDescriptor().setStatus(queueName);
+    }
+
+
+  public void getShellName() {
+        this.getJobDescriptorDocument().getJobDescriptor().getShellName();
+    }
+
+    public String getJobName() {
+        return this.getJobDescriptorDocument().getJobDescriptor().getJobName();
+    }
+
+    public String getJobId(){
+        return this.getJobDescriptorDocument().getJobDescriptor().getJobID();
+    }
+
 }
 

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=1519854&r1=1519853&r2=1519854&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
Tue Sep  3 21:21:23 2013
@@ -228,7 +228,7 @@ public class DefaultSSHApi implements SS
             //reusing submitAsyncJobWithPBS method to submit a job
 
             String jobID = this.submitAsyncJobWithPBS(serverInfo, authenticationInfo, tempPBSFile.getAbsolutePath(),
jobDescriptor);
-            return jobID;
+            return jobID.replace("\n","");
         } catch (TransformerConfigurationException e) {
             throw new SSHApiException("Error parsing PBS transformation", e);
         } catch (TransformerException e) {
@@ -241,7 +241,165 @@ public class DefaultSSHApi implements SS
         } finally {
             tempPBSFile.delete();
         }
+    }
+
+    public Cluster getCluster(ServerInfo serverInfo, AuthenticationInfo authenticationInfo)
throws SSHApiException {
+        RawCommandInfo rawCommandInfo = new RawCommandInfo("/opt/torque/bin/qnodes");
+
+        StandardOutReader stdOutReader = new StandardOutReader();
+        this.executeCommand(rawCommandInfo, serverInfo, authenticationInfo, stdOutReader);
+        String result = stdOutReader.getStdOutput();
+        String[] Nodes = result.split("\n");
+        String[] line;
+        String header, value;
+        Machine Node;
+        Core[] Cores = null;
+        ArrayList<Machine> Machines = new ArrayList<Machine>();
+        int i = 0;
+        while (i < Nodes.length) {
+            Node = new Machine();
+            Node.setName(Nodes[i]);
+            i++;
+
+            while (i < Nodes.length) {
+                if (!Nodes[i].startsWith(" ")) {
+                    i++;
+                    break;
+                }
+
+                line = Nodes[i].split("=");
+                header = line[0].trim();
+                value = line[1].trim();
 
+                if ("state".equals(header))
+                    Node.setState(value);
+                else if ("np".equals(header)) {
+                    Node.setNp(value);
+                    int np = Integer.parseInt(Node.getNp());
+                    Cores = new Core[np];
+                    for (int n = 0; n < np; n++) {
+                        Cores[n] = new Core("" + n);
+                    }
+                } else if ("ntype".equals(header))
+                    Node.setNtype(value);
+                else if ("jobs".equals(header)) {
+                    String[] jobs = value.split(", ");
+                    JobDescriptor jo = new JobDescriptor();
+                    //Job[] Jobs = new Job[jobs.length];
+                    for (int j = 0; j < jobs.length; j++) {
+                        String[] c = jobs[j].split("/");
+                        String Jid = c[1];
+                        jo = this.getJobById(serverInfo, authenticationInfo, Jid);
+                        int core = Integer.parseInt(c[0]);
+                        Cores[core].setJob(jo);
+
+                    }
+
+
+                }
+                i++;
+            }
+            Node.setCores(Cores);
+            Machines.add(Node);
+        }
+        Cluster c = new Cluster();
+        c.setNodes(Machines.toArray(new Machine[Machines.size()]));
+        return c;
+    }
+
+    public JobDescriptor getJobById(ServerInfo serverInfo, AuthenticationInfo authenticationInfo,
String jobID) throws SSHApiException {
+        RawCommandInfo rawCommandInfo = new RawCommandInfo("/opt/torque/bin/qstat -f " +
jobID);
+
+        StandardOutReader stdOutReader = new StandardOutReader();
+        this.executeCommand(rawCommandInfo, serverInfo, authenticationInfo, stdOutReader);
+        String result = stdOutReader.getStdOutput();
+        String[] info = result.split("\n");
+        JobDescriptor jobDescriptor = new JobDescriptor();
+        String header = "";
+        String value = "";
+        String[] line;
+        for (int i = 0; i < info.length; i++) {
+            if (info[i].contains("=")) {
+                line = info[i].split("=", 2);
+            } else {
+                line = info[i].split(":", 2);
+            }
+            if (line.length >= 2) {
+                header = line[0].trim();
+                //                  System.out.println("Header = " + header);
+                value = line[1].trim();
+//                    System.out.println("value = " + value);
+
+                if (header.equals("Variable_List")) {
+                    while (info[i + 1].startsWith("\t")) {
+                        value += info[i + 1];
+                        i++;
+                    }
+                    value = value.replaceAll("\t", "");
+//                        jobDescriptor.VariablesList=value;
+//                        jobDescriptor.analyzeVariableList(value);
+                } else if ("Job Id".equals(header))
+                    jobDescriptor.setJobID(value);
+                else if ("Job_Name".equals(header))
+                    jobDescriptor.setJobName(value);
+
+                else if ("Job_Owner".equals(header)) {
+//                       jobDescriptor.setOwner(value);
+                } else if ("resources_used.cput".equals(header)) {
+//                       jobDescriptor.setUsedcput(value);
+                } else if ("resources_used.mem".equals(header)) {
+//                       jobDescriptor.setUsedMem(value);
+                } else if ("resources_used.walltime".equals(header)) {
+//                       jobDescriptor.setEllapsedTime(value);
+                } else if ("job_state".equals(header))
+                    jobDescriptor.setStatus(value);
+
+                else if ("queue".equals(header))
+                    jobDescriptor.setQueueName(value);
+                else if ("ctime".equals(header)) {
+//                       jobDescriptor.setCtime(value);
+                } else if ("qtime".equals(header)) {
+//                       jobDescriptor.setQtime(value);
+                } else if ("mtime".equals(header)) {
+//                       jobDescriptor.setMtime(value);
+                } else if ("start_time".equals(header)) {
+//                        jobDescriptor.setStime(value);
+                } else if ("comp_time".equals(header)) {
+//                            jobDescriptor.setComp_time(value);
+                } else if ("exec_host".equals(header)) {
+//                       jobDescriptor.setExecuteNode(value);
+                } else if ("Output_Path".equals(header)) {
+                    if (info[i + 1].contains("=") || info[i + 1].contains(":"))
+                        jobDescriptor.setStandardOutFile(value);
+                    else {
+                        jobDescriptor.setStandardOutFile(value + info[i + 1].trim());
+                        i++;
+                    }
+                } else if ("Error_Path".equals(header)) {
+                    if (info[i + 1].contains("=") || info[i + 1].contains(":"))
+                        jobDescriptor.setStandardErrorFile(value);
+                    else {
+                        String st = info[i + 1].trim();
+                        jobDescriptor.setStandardErrorFile(value + st);
+                        i++;
+                    }
+
+                } else if ("submit_args".equals(header)) {
+                    while (i + 1 < info.length) {
+                        if (info[i + 1].startsWith("\t")) {
+                            value += info[i + 1];
+                            i++;
+                        } else
+                            break;
+                    }
+                    value = value.replaceAll("\t", "");
+//                         jobDescriptor.setSubmitArgs (value);
+                }
+
+
+            }
+        }
+        return jobDescriptor;
 
     }
 }

Added: airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/GSISSHAPI.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/GSISSHAPI.java?rev=1519854&view=auto
==============================================================================
--- airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/GSISSHAPI.java
(added)
+++ airavata/sandbox/gsissh/src/main/java/org/apache/airavata/gsi/ssh/impl/GSISSHAPI.java
Tue Sep  3 21:21:23 2013
@@ -0,0 +1,24 @@
+/*
+ *
+ * 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.impl;
+
+public class GSISSHAPI {
+}

Modified: 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=1519854&r1=1519853&r2=1519854&view=diff
==============================================================================
--- airavata/sandbox/gsissh/src/main/resources/schemas/PBSJobDescriptor.xsd (original)
+++ airavata/sandbox/gsissh/src/main/resources/schemas/PBSJobDescriptor.xsd Tue Sep  3 21:21:23
2013
@@ -14,7 +14,9 @@
 
 	<complexType name="pbsParams">
 		<sequence>
+            <element name="jobID" type="xsd:string" minOccurs="0" maxOccurs="1"/>
 			<element name="shellName" type="xsd:string" minOccurs="0" maxOccurs="1" default="/bin/bash"/>
+            <element name="queueName" type="xsd:string" minOccurs="0" maxOccurs="1" default="normal"/>
             <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" />
@@ -30,6 +32,7 @@
             <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"/>
+            <element name="status" type="xsd:string" minOccurs="0" maxOccurs="1"/>
 		</sequence>
 	</complexType>
     <complexType name="inputList">

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=1519854&r1=1519853&r2=1519854&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
Tue Sep  3 21:21:23 2013
@@ -26,6 +26,7 @@ import org.apache.airavata.gsi.ssh.api.j
 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.AssertJUnit;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
@@ -53,9 +54,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");
+//        System.setProperty("myproxy.user", "ogce");
+//        System.setProperty("myproxy.password", "");
+//        System.setProperty("basedir", "/Users/lahirugunathilake/work/airavata/sandbox/gsissh");
         myProxyUserName = System.getProperty("myproxy.user");
         myProxyPassword = System.getProperty("myproxy.password");
 
@@ -129,7 +130,7 @@ public class DefaultSSHApiTest {
     }
 
     @Test
-    public void testsubmitAsyncJobWithPBS() throws Exception {
+    public void testSubmitAsyncJobWithPBS() throws Exception {
         // Create authentication
         AuthenticationInfo authenticationInfo
                 = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
@@ -154,7 +155,7 @@ public class DefaultSSHApiTest {
     }
 
     @Test
-    public void testsubmitAsyncJob() throws Exception {
+    public void testSubmitAsyncJob() throws Exception {
         // Create authentication
         AuthenticationInfo authenticationInfo
                 = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
@@ -190,5 +191,69 @@ public class DefaultSSHApiTest {
         System.out.println(jobDescriptor.toXML());
         String jobID = sshApi.submitAsyncJob(serverInfo, authenticationInfo, jobDescriptor);
         System.out.println("JobID returned : " + jobID);
+
+//        Cluster cluster = sshApi.getCluster(serverInfo, authenticationInfo);
+        JobDescriptor jobById = sshApi.getJobById(serverInfo, authenticationInfo, jobID);
+        AssertJUnit.assertEquals(jobById.getJobId(),jobID);
+    }
+
+    @Test
+    public void testGetCluster()throws Exception{
+//        AuthenticationInfo authenticationInfo
+//                = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
+//                7512, 17280000);
+//        // Server info
+//        ServerInfo serverInfo = new ServerInfo("ogce", "trestles.sdsc.edu");
+//        // Get the API
+//        SSHApi sshApi = SSHApiFactory.createSSHApi(this.certificateLocation);
+//        Cluster cluster = sshApi.getCluster(serverInfo, authenticationInfo);
+//        System.out.println(cluster.getNodes()[0].getName());
+//        System.out.println(cluster.getNodes()[0].getNp());
+//        System.out.println(cluster.getNodes()[0].getState());
+//        System.out.println(cluster.getNodes()[0].getCores()[0].getId());
+//        System.out.println(cluster.getNodes()[0].getName());
+
+    }
+    @Test
+    public void testsubmitAsyncJobWithFailure() 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");
+
+
+        // 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);
+        String workingDirectory = File.separator + "home" + File.separator + "ogce" + File.separator
+ "gsissh";
+        JobDescriptor jobDescriptor = new JobDescriptor();
+        jobDescriptor.setWorkingDirectory(workingDirectory);
+        jobDescriptor.setShellName("/bin/bash");
+        jobDescriptor.setJobName("GSI_SSH_SLEEP_JOB");
+        jobDescriptor.setExecutablePath("/bin/echo");
+        jobDescriptor.setAllEnvExport(true);
+        jobDescriptor.setMailOptions("n");
+        jobDescriptor.setStandardOutFile(workingDirectory + File.separator + "application.out");
+        jobDescriptor.setStandardErrorFile(workingDirectory + File.separator + "application.err");
+        jobDescriptor.setNodes(1);
+        jobDescriptor.setProcessesPerNode(100);
+        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());
+        try {
+            String jobID = sshApi.submitAsyncJob(serverInfo, authenticationInfo, jobDescriptor);
+            System.out.println("JobID returned : " + jobID);
+        } catch (SSHApiException e) {
+            System.out.println(e.getMessage());
+        }
     }
 }



Mime
View raw message