airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1530385 - in /airavata/trunk/modules/gfac-core/src: main/java/org/apache/airavata/gfac/handler/ main/java/org/apache/airavata/gfac/provider/impl/ test/java/org/apache/airavata/core/gfac/services/impl/ test/resources/
Date Tue, 08 Oct 2013 18:45:03 GMT
Author: lahiru
Date: Tue Oct  8 18:45:03 2013
New Revision: 1530385

URL: http://svn.apache.org/r1530385
Log:
adding ssh capablity to gfac-core.

Modified:
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPOutputHandler.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GSISSHProvider.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/SSHProvider.java
    airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BigRed2Test.java
    airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTest.java
    airavata/trunk/modules/gfac-core/src/test/resources/gfac-config.xml

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPOutputHandler.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPOutputHandler.java?rev=1530385&r1=1530384&r2=1530385&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPOutputHandler.java
(original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPOutputHandler.java
Tue Oct  8 18:45:03 2013
@@ -27,7 +27,6 @@ import java.util.Map;
 
 import net.schmizz.sshj.connection.ConnectionException;
 import net.schmizz.sshj.transport.TransportException;
-import net.schmizz.sshj.xfer.scp.SCPFileTransfer;
 
 import org.apache.airavata.commons.gfac.type.ActualParameter;
 import org.apache.airavata.gfac.GFacException;
@@ -35,6 +34,7 @@ import org.apache.airavata.gfac.context.
 import org.apache.airavata.gfac.context.security.SSHSecurityContext;
 import org.apache.airavata.gfac.utils.GFacUtils;
 import org.apache.airavata.gfac.utils.OutputUtils;
+import org.apache.airavata.gsi.ssh.api.Cluster;
 import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
 import org.apache.xmlbeans.XmlException;
 
@@ -45,17 +45,17 @@ public class SCPOutputHandler implements
 		ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext()
 				.getApplicationDeploymentDescription().getType();
 		try {
-			SSHSecurityContext securityContext = (SSHSecurityContext) jobExecutionContext
+            SSHSecurityContext securityContext = (SSHSecurityContext) jobExecutionContext
 					.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT);
+            Cluster pbsCluster = securityContext.getPbsCluster();
 
 			// Get the Stdouts and StdErrs
 			String timeStampedServiceName = GFacUtils.createUniqueNameForService(jobExecutionContext.getServiceName());
 			File localStdOutFile = File.createTempFile(timeStampedServiceName, "stdout");
 			File localStdErrFile = File.createTempFile(timeStampedServiceName, "stderr");
 
-			SCPFileTransfer fileTransfer = securityContext.getSSHClient().newSCPFileTransfer();
-			fileTransfer.download(app.getStandardOutput(), localStdOutFile.getAbsolutePath());
-			fileTransfer.download(app.getStandardError(), localStdErrFile.getAbsolutePath());
+			pbsCluster.scpFrom(app.getStandardOutput(), localStdOutFile.getAbsolutePath());
+			pbsCluster.scpFrom(app.getStandardError(), localStdErrFile.getAbsolutePath());
 
 			String stdOutStr = GFacUtils.readFileToString(localStdOutFile.getAbsolutePath());
 			String stdErrStr = GFacUtils.readFileToString(localStdErrFile.getAbsolutePath());

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GSISSHProvider.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GSISSHProvider.java?rev=1530385&r1=1530384&r2=1530385&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GSISSHProvider.java
(original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/GSISSHProvider.java
Tue Oct  8 18:45:03 2013
@@ -128,14 +128,4 @@ public class GSISSHProvider implements G
     public void cancelJob(String jobId, JobExecutionContext jobExecutionContext) throws GFacException
{
         //To change body of implemented methods use File | Settings | File Templates.
     }
-
-    private String maxWallTimeCalculator(int maxWalltime) {
-        if (maxWalltime < 60) {
-            return "00:" + maxWalltime + ":00";
-        } else {
-            int minutes = maxWalltime % 60;
-            int hours = maxWalltime / 60;
-            return hours + ":" + minutes + ":00";
-        }
-    }
 }

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/SSHProvider.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/SSHProvider.java?rev=1530385&r1=1530384&r2=1530385&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/SSHProvider.java
(original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/SSHProvider.java
Tue Oct  8 18:45:03 2013
@@ -53,6 +53,7 @@ import org.apache.airavata.registry.api.
 import org.apache.airavata.registry.api.workflow.ApplicationJob.ApplicationJobStatus;
 import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
 import org.apache.airavata.schemas.gfac.NameValuePairType;
+import org.apache.airavata.schemas.gfac.SSHHostType;
 import org.apache.airavata.schemas.gfac.URIArrayType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -67,6 +68,7 @@ public class SSHProvider implements GFac
 	private String jobID=null;
 
 	public void initialize(JobExecutionContext jobExecutionContext) throws GFacProviderException,GFacException
{
+        if(!((SSHHostType)jobExecutionContext.getApplicationContext().getHostDescription()).getHpcResource()){
 		jobID="SSH_"+jobExecutionContext.getApplicationContext().getHostDescription().getType().getHostAddress()+"_"+Calendar.getInstance().getTimeInMillis();
 		
 		securityContext = (SSHSecurityContext) jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT);
@@ -82,6 +84,7 @@ public class SSHProvider implements GFac
 		} catch (IOException e) {
 			throw new GFacProviderException(e.getLocalizedMessage(), e);
 		}
+        }
 	}
 
 	private void saveApplicationJob(JobExecutionContext jobExecutionContext, String executableName)
{
@@ -95,6 +98,7 @@ public class SSHProvider implements GFac
 	}
 
 	public void execute(JobExecutionContext jobExecutionContext) throws GFacProviderException
{
+        if(((SSHHostType)jobExecutionContext.getApplicationContext().getHostDescription()).getHpcResource()){
 		ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType();
 		Session session = null;
 		try {
@@ -130,6 +134,14 @@ public class SSHProvider implements GFac
 		}finally{
 			securityContext.closeSession(session);
 		}
+        }else {
+            GSISSHProvider gsisshProvider = new GSISSHProvider();
+            try {
+                gsisshProvider.execute(jobExecutionContext);
+            } catch (GFacException e) {
+                throw new GFacProviderException(e.getMessage(), e);
+            }
+        }
 
 	}
 

Modified: airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BigRed2Test.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BigRed2Test.java?rev=1530385&r1=1530384&r2=1530385&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BigRed2Test.java
(original)
+++ airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/BigRed2Test.java
Tue Oct  8 18:45:03 2013
@@ -79,7 +79,6 @@ public class BigRed2Test {
         HostDescription host = new HostDescription(GsisshHostType.type);
         host.getType().setHostAddress(hostAddress);
         host.getType().setHostName(hostName);
-        ((GsisshHostType) host.getType()).setInstalledParentPath("/opt/torque/torque-4.2.3.1/bin/");
         /*
         * App
         */
@@ -119,7 +118,7 @@ public class BigRed2Test {
         app.setStandardError(tempDir + File.separator + app.getApplicationName().getStringValue()
+ ".stderr");
         app.setMaxWallTime(5);
         app.setJobSubmitterCommand("aprun -n 1");
-
+        app.setInstalledParentPath("/opt/torque/torque-4.2.3.1/bin/");
 
         /*
         * Service
@@ -151,7 +150,7 @@ public class BigRed2Test {
 
         jobExecutionContext = new JobExecutionContext(gFacConfiguration, serv.getType().getName());
         // Adding security context
-        jobExecutionContext.addSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT, getSecurityContext(host));
+        jobExecutionContext.addSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT, getSecurityContext(app));
         ApplicationContext applicationContext = new ApplicationContext();
         jobExecutionContext.setApplicationContext(applicationContext);
         applicationContext.setServiceDescription(serv);
@@ -171,11 +170,11 @@ public class BigRed2Test {
 //		((StringParameterType)echo_input.getType()).setValue("echo_output=hello");
         outMessage.addParameter("echo_output", echo_out);
 
-        jobExecutionContext.setOutMessageContext(outMessage);
+        jobExecutionContext.setOutMessageContext(   outMessage);
 
     }
 
-    private SecurityContext getSecurityContext(HostDescription host) {
+    private SecurityContext getSecurityContext(HpcApplicationDeploymentType app) {
         AuthenticationInfo authenticationInfo = new DefaultPasswordAuthenticationInfo(this.password);
         // Server info
         ServerInfo serverInfo = new ServerInfo(this.userName, this.hostName);
@@ -183,7 +182,7 @@ public class BigRed2Test {
         Cluster pbsCluster = null;
         try {
              pbsCluster = new PBSCluster(serverInfo, authenticationInfo,
-                     ((GsisshHostType)host.getType()).getInstalledParentPath());
+                     (app.getInstalledParentPath()));
         } catch (SSHApiException e) {
             e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
         }

Modified: airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTest.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTest.java?rev=1530385&r1=1530384&r2=1530385&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTest.java
(original)
+++ airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/GSISSHProviderTest.java
Tue Oct  8 18:45:03 2013
@@ -81,7 +81,7 @@ public class GSISSHProviderTest {
         HostDescription host = new HostDescription(GsisshHostType.type);
         host.getType().setHostAddress(hostAddress);
         host.getType().setHostName(hostName);
-        ((GsisshHostType) host.getType()).setInstalledParentPath("/opt/torque/bin/");
+
         /*
         * App
         */
@@ -125,7 +125,7 @@ public class GSISSHProviderTest {
         app.setStandardOutput(tempDir + File.separator + app.getApplicationName().getStringValue()
+ ".stdout");
         app.setStandardError(tempDir + File.separator + app.getApplicationName().getStringValue()
+ ".stderr");
         app.setMaxWallTime(5);
-
+        app.setInstalledParentPath("/opt/torque/bin/");
 
         /*
         * Service
@@ -157,7 +157,7 @@ public class GSISSHProviderTest {
 
         jobExecutionContext = new JobExecutionContext(gFacConfiguration, serv.getType().getName());
         // Adding security context
-        jobExecutionContext.addSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT, getSecurityContext());
+        jobExecutionContext.addSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT, getSecurityContext(app));
         ApplicationContext applicationContext = new ApplicationContext();
         jobExecutionContext.setApplicationContext(applicationContext);
         applicationContext.setServiceDescription(serv);
@@ -181,7 +181,7 @@ public class GSISSHProviderTest {
 
     }
 
-    private SecurityContext getSecurityContext() {
+    private SecurityContext getSecurityContext(HpcApplicationDeploymentType app) {
         GSIAuthenticationInfo authenticationInfo
                 = new MyProxyAuthenticationInfo(myProxyUserName, myProxyPassword, "myproxy.teragrid.org",
                 7512, 17280000, certificateLocation);
@@ -190,7 +190,7 @@ public class GSISSHProviderTest {
         ServerInfo serverInfo = new ServerInfo("ogce", "trestles.sdsc.edu");
         Cluster pbsCluster = null;
         try {
-            pbsCluster = new PBSCluster(serverInfo, authenticationInfo, "/opt/torque/bin/");
+            pbsCluster = new PBSCluster(serverInfo, authenticationInfo, app.getInstalledParentPath());
         } catch (SSHApiException e) {
             e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
         }

Modified: airavata/trunk/modules/gfac-core/src/test/resources/gfac-config.xml
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/test/resources/gfac-config.xml?rev=1530385&r1=1530384&r2=1530385&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/test/resources/gfac-config.xml (original)
+++ airavata/trunk/modules/gfac-core/src/test/resources/gfac-config.xml Tue Oct  8 18:45:03
2013
@@ -84,7 +84,7 @@
             <Handler class="org.apache.airavata.gfac.handler.SCPInputHandler"/>
         </InHandlers>
         <OutHandlers>
-            <!--Handler class="org.apache.airavata.gfac.handler.SCPOutputHandler"/-->
+            <Handler class="org.apache.airavata.gfac.handler.SCPOutputHandler"/>
         </OutHandlers>
     </Provider>
 </GFac>
\ No newline at end of file



Mime
View raw message