airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1533210 - in /airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac: handler/SCPDirectorySetupHandler.java handler/SCPOutputHandler.java provider/impl/GSISSHProvider.java
Date Thu, 17 Oct 2013 19:01:58 GMT
Author: lahiru
Date: Thu Oct 17 19:01:58 2013
New Revision: 1533210

URL: http://svn.apache.org/r1533210
Log:
fixing some moreissues in gsissh.

Modified:
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPDirectorySetupHandler.java
    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

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPDirectorySetupHandler.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPDirectorySetupHandler.java?rev=1533210&r1=1533209&r2=1533210&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPDirectorySetupHandler.java
(original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/SCPDirectorySetupHandler.java
Thu Oct 17 19:01:58 2013
@@ -32,7 +32,9 @@ import net.schmizz.sshj.transport.Transp
 import org.apache.airavata.gfac.Constants;
 import org.apache.airavata.gfac.GFacException;
 import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.context.security.GSISecurityContext;
 import org.apache.airavata.gfac.context.security.SSHSecurityContext;
+import org.apache.airavata.gfac.provider.GFacProviderException;
 import org.apache.airavata.gsi.ssh.api.Cluster;
 import org.apache.airavata.gsi.ssh.api.SSHApiException;
 import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
@@ -42,25 +44,31 @@ import org.slf4j.LoggerFactory;
 public class SCPDirectorySetupHandler implements GFacHandler{
     private static final Logger log = LoggerFactory.getLogger(SCPDirectorySetupHandler.class);
 
-	public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException,GFacException
{
+	public void invoke(JobExecutionContext jobExecutionContext) throws GFacException {
 		log.info("Setup SSH job directorties");
 		makeDirectory(jobExecutionContext);
 
 	}
-	private void makeDirectory(JobExecutionContext context) throws GFacHandlerException,GFacException
{
-		SSHSecurityContext securityContext = (SSHSecurityContext)context.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT);
-		ApplicationDeploymentDescriptionType app = context.getApplicationContext().getApplicationDeploymentDescription().getType();
-		Session session = null;
+	private void makeDirectory(JobExecutionContext jobExecutionContext) throws GFacException
{
+		Cluster cluster = null;
+            if (jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)
!= null) {
+                cluster = ((GSISecurityContext) jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getPbsCluster();
+            } else {
+                cluster = ((SSHSecurityContext) jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT)).getPbsCluster();
+            }
+            if (cluster == null) {
+                throw new GFacHandlerException("Security context is not set properly");
+            } else {
+                log.info("Successfully retrieved the Security Context");
+            }
+		ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType();
 		try {
-            Cluster pbsCluster = securityContext.getPbsCluster();
-            pbsCluster.makeDirectory(app.getScratchWorkingDirectory());
-            pbsCluster.makeDirectory(app.getInputDataDirectory());
-            pbsCluster.makeDirectory(app.getOutputDataDirectory());
+            cluster.makeDirectory(app.getScratchWorkingDirectory());
+            cluster.makeDirectory(app.getInputDataDirectory());
+            cluster.makeDirectory(app.getOutputDataDirectory());
 		} catch (SSHApiException e) {
             throw new GFacHandlerException("Error executing the Handler: " + SCPDirectorySetupHandler.class,e);
 //To change body of catch statement use File | Settings | File Templates.
-        } finally {
-			securityContext.closeSession(session);
-		}
+        }
 	}
 
     public void initProperties(Map<String, String> properties) throws GFacHandlerException,
GFacException {

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=1533210&r1=1533209&r2=1533210&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
Thu Oct 17 19:01:58 2013
@@ -58,9 +58,17 @@ public class SCPOutputHandler implements
         ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext()
                 .getApplicationDeploymentDescription().getType();
         try {
-            SSHSecurityContext securityContext = (SSHSecurityContext) jobExecutionContext
-                    .getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT);
-            Cluster pbsCluster = securityContext.getPbsCluster();
+            Cluster cluster = null;
+            if (jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)
!= null) {
+                cluster = ((GSISecurityContext) jobExecutionContext.getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT)).getPbsCluster();
+            } else {
+                cluster = ((SSHSecurityContext) jobExecutionContext.getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT)).getPbsCluster();
+            }
+            if (cluster == null) {
+                throw new GFacProviderException("Security context is not set properly");
+            } else {
+                log.info("Successfully retrieved the Security Context");
+            }
 
             // Get the Stdouts and StdErrs
             String timeStampedServiceName = GFacUtils.createUniqueNameForService(jobExecutionContext.getServiceName());
@@ -68,9 +76,9 @@ public class SCPOutputHandler implements
             File localStdErrFile = File.createTempFile(timeStampedServiceName, "stderr");
 
             log.info("Downloading file : " + app.getStandardError() + " to : " + localStdErrFile.getAbsolutePath());
-            pbsCluster.scpFrom(app.getStandardOutput(), localStdOutFile.getAbsolutePath());
+            cluster.scpFrom(app.getStandardOutput(), localStdOutFile.getAbsolutePath());
             log.info("Downloading file : " + app.getStandardOutput() + " to : " + localStdOutFile.getAbsolutePath());
-            pbsCluster.scpFrom(app.getStandardError(), localStdErrFile.getAbsolutePath());
+            cluster.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=1533210&r1=1533209&r2=1533210&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
Thu Oct 17 19:01:58 2013
@@ -78,7 +78,7 @@ public class GSISSHProvider implements G
             }
             // This installed path is a mandetory field, because this could change based
on the computing resource
             JobDescriptor jobDescriptor = new JobDescriptor();
-            jobDescriptor.setWorkingDirectory(app.getScratchWorkingDirectory());
+            jobDescriptor.setWorkingDirectory(app.getStaticWorkingDirectory());
             jobDescriptor.setShellName("/bin/bash");
             Random random = new Random();
             int i = random.nextInt();



Mime
View raw message