Return-Path: X-Original-To: apmail-airavata-commits-archive@www.apache.org Delivered-To: apmail-airavata-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DBD8210B79 for ; Thu, 17 Oct 2013 19:02:26 +0000 (UTC) Received: (qmail 53549 invoked by uid 500); 17 Oct 2013 19:02:25 -0000 Delivered-To: apmail-airavata-commits-archive@airavata.apache.org Received: (qmail 53112 invoked by uid 500); 17 Oct 2013 19:02:24 -0000 Mailing-List: contact commits-help@airavata.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airavata.apache.org Delivered-To: mailing list commits@airavata.apache.org Received: (qmail 53094 invoked by uid 99); 17 Oct 2013 19:02:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Oct 2013 19:02:23 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Oct 2013 19:02:19 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 815C723888E4; Thu, 17 Oct 2013 19:01:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@airavata.apache.org From: lahiru@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131017190158.815C723888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 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();