airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shame...@apache.org
Subject git commit: Fixed NPE of scheduler and changed gfac-config.xml
Date Thu, 06 Nov 2014 16:31:45 GMT
Repository: airavata
Updated Branches:
  refs/heads/gfac_appcatalog_int 3eea1a309 -> d8176e813


Fixed NPE of scheduler and changed gfac-config.xml


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/d8176e81
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/d8176e81
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/d8176e81

Branch: refs/heads/gfac_appcatalog_int
Commit: d8176e813b6cf7bb0fe5ec118f502781c4615ff9
Parents: 3eea1a3
Author: shamrath <shameerainfo@gmail.com>
Authored: Thu Nov 6 11:31:39 2014 -0500
Committer: shamrath <shameerainfo@gmail.com>
Committed: Thu Nov 6 11:31:39 2014 -0500

----------------------------------------------------------------------
 .../tools/RegisterSampleApplications.java       |  8 +--
 .../server/src/main/resources/gfac-config.xml   |  6 +--
 .../org/apache/airavata/gfac/Constants.java     |  3 ++
 .../org/apache/airavata/gfac/Scheduler.java     | 56 ++++++++++++++++----
 .../airavata/gfac/core/utils/GFacUtils.java     | 26 ++++++++-
 5 files changed, 82 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/d8176e81/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/tools/RegisterSampleApplications.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/tools/RegisterSampleApplications.java
b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/tools/RegisterSampleApplications.java
index bd4023b..b5fc2b2 100644
--- a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/tools/RegisterSampleApplications.java
+++ b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/tools/RegisterSampleApplications.java
@@ -1092,12 +1092,12 @@ public class RegisterSampleApplications {
 
 
             ComputeResourcePreference stampedeResourcePreferences = RegisterSampleApplicationsUtils.
-                    createComputeResourcePreference(stampedeResourceId, "TG-STA110014S",
false, null, null, null,
-                            "/scratch/01437/ogce/gta-work-dirs");
+                    createComputeResourcePreference(stampedeResourceId, "TG-STA110014S",
false, null,
+                            JobSubmissionProtocol.SSH, DataMovementProtocol.SCP, "/scratch/01437/ogce/gta-work-dirs");
 
             ComputeResourcePreference trestlesResourcePreferences = RegisterSampleApplicationsUtils.
-                    createComputeResourcePreference(trestlesResourceId, "sds128", false,
null, null, null,
-                            "/oasis/scratch/trestles/ogce/temp_project/gta-work-dirs");
+                    createComputeResourcePreference(trestlesResourceId, "sds128", false,
null, JobSubmissionProtocol.SSH,
+                            DataMovementProtocol.SCP, "/oasis/scratch/trestles/ogce/temp_project/gta-work-dirs");
 
             ComputeResourcePreference bigRedResourcePreferences = RegisterSampleApplicationsUtils.
                     createComputeResourcePreference(bigredResourceId, "TG-STA110014S", false,
null, null, null,

http://git-wip-us.apache.org/repos/asf/airavata/blob/d8176e81/modules/configuration/server/src/main/resources/gfac-config.xml
----------------------------------------------------------------------
diff --git a/modules/configuration/server/src/main/resources/gfac-config.xml b/modules/configuration/server/src/main/resources/gfac-config.xml
index 85421c4..502192f 100644
--- a/modules/configuration/server/src/main/resources/gfac-config.xml
+++ b/modules/configuration/server/src/main/resources/gfac-config.xml
@@ -22,7 +22,7 @@
         </InHandlers>
         <OutHandlers></OutHandlers>
     </GlobalHandlers>
-    <Provider class="org.apache.airavata.gfac.local.provider.impl.LocalProvider" host="org.apache.airavata.schemas.gfac.impl.HostDescriptionTypeImpl">
+    <Provider class="org.apache.airavata.gfac.local.provider.impl.LocalProvider" submission="LOCAL">
         <InHandlers>
             <Handler class="org.apache.airavata.gfac.local.handler.LocalDirectorySetupHandler"/>
         </InHandlers>
@@ -65,7 +65,7 @@
         </OutHandlers>
     </Application>
 
-     <Provider class="org.apache.airavata.gfac.ssh.provider.impl.SSHProvider" host="org.apache.airavata.schemas.gfac.impl.SSHHostTypeImpl"
executionMode="async">
+     <Provider class="org.apache.airavata.gfac.ssh.provider.impl.SSHProvider" submission="SSH"
executionMode="async">
          <InHandlers>
             <Handler class="org.apache.airavata.gfac.ssh.handler.SSHDirectorySetupHandler"/>
             <Handler class="org.apache.airavata.gfac.ssh.handler.SSHInputHandler"/>
@@ -74,7 +74,7 @@
             <Handler class="org.apache.airavata.gfac.ssh.handler.SSHOutputHandler"/>
         </OutHandlers>
     </Provider>
-    <Provider class="org.apache.airavata.gfac.gsissh.provider.impl.GSISSHProvider" host="org.apache.airavata.schemas.gfac.impl.GsisshHostTypeImpl"
executionMode="async">
+    <Provider class="org.apache.airavata.gfac.gsissh.provider.impl.GSISSHProvider" submission="SSH"
security="GSI" executionMode="async">
              <InHandlers>
                 <Handler class="org.apache.airavata.gfac.gsissh.handler.GSISSHDirectorySetupHandler"/>
                  <!--Handler class="org.apache.airavata.gfac.ssh.handler.AdvancedSCPInputHandler">

http://git-wip-us.apache.org/repos/asf/airavata/blob/d8176e81/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/Constants.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/Constants.java
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/Constants.java
index 69d4a4a..c1550df 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/Constants.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/Constants.java
@@ -34,10 +34,13 @@ public class Constants {
 
 	public static final String XPATH_EXPR_PROVIDER_HANDLERS_START = "/GFac/Provider[@class='";
     public static final String XPATH_EXPR_PROVIDER_ON_HOST = "/GFac/Provider[@host='";
+    public static final String XPATH_EXPR_PROVIDER_ON_SUBMISSION = "/GFac/Provider[@submission='";
 	public static final String XPATH_EXPR_PROVIDER_INFLOW_HANDLERS_END = "']/InHandlers/Handler";
 	public static final String XPATH_EXPR_PROVIDER_OUTFLOW_HANDLERS_END = "']/OutHandlers/Handler";
 
 	public static final String GFAC_CONFIG_CLASS_ATTRIBUTE = "class";
+	public static final String GFAC_CONFIG_SECURITY_ATTRIBUTE = "security";
+	public static final String GFAC_CONFIG_SUBMISSION_ATTRIBUTE = "submission";
     public static final String GFAC_CONFIG_EXECUTION_MODE_ATTRIBUTE = "executionMode";
 	public static final String GFAC_CONFIG_APPLICATION_NAME_ATTRIBUTE = "class";
 	public static final String NEWLINE = System.getProperty("line.separator");

http://git-wip-us.apache.org/repos/asf/airavata/blob/d8176e81/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/Scheduler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/Scheduler.java
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/Scheduler.java
index 2bd612c..0dae029 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/Scheduler.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/Scheduler.java
@@ -21,15 +21,24 @@
 
 package org.apache.airavata.gfac;
 
+import org.airavata.appcatalog.cpi.AppCatalog;
+import org.airavata.appcatalog.cpi.AppCatalogException;
+import org.apache.aiaravata.application.catalog.data.impl.AppCatalogFactory;
 import org.apache.airavata.commons.gfac.type.HostDescription;
 import org.apache.airavata.gfac.core.context.JobExecutionContext;
 import org.apache.airavata.gfac.core.provider.GFacProvider;
 import org.apache.airavata.gfac.core.provider.GFacProviderConfig;
 import org.apache.airavata.gfac.core.provider.GFacProviderException;
+import org.apache.airavata.gfac.core.utils.GFacUtils;
 import org.apache.airavata.model.appcatalog.computeresource.JobSubmissionInterface;
+import org.apache.airavata.model.appcatalog.computeresource.JobSubmissionProtocol;
+import org.apache.airavata.model.appcatalog.computeresource.LOCALSubmission;
+import org.apache.airavata.model.appcatalog.computeresource.SSHJobSubmission;
+import org.apache.airavata.model.appcatalog.computeresource.SecurityProtocol;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
 
 import javax.xml.parsers.DocumentBuilder;
@@ -109,15 +118,44 @@ public class Scheduler {
             if (provider == null) {
 
                 List<JobSubmissionInterface> jobSubmissionInterfaces = jobExecutionContext.getApplicationContext().getComputeResourceDescription().getJobSubmissionInterfaces();
-                String hostClass = jobExecutionContext.getPreferredJobSubmissionProtocol().toString();
-                providerClassName = GFacConfiguration.getAttributeValue(GFacConfiguration.getHandlerDoc(),
Constants.XPATH_EXPR_PROVIDER_ON_HOST + hostClass + "']", Constants.GFAC_CONFIG_CLASS_ATTRIBUTE);
-                Class<? extends GFacProvider> aClass1 = Class.forName(providerClassName).asSubclass(GFacProvider.class);
-                provider = aClass1.newInstance();
-                //loading the provider properties
-                aClass = GFacConfiguration.getProviderConfig(GFacConfiguration.getHandlerDoc(),
Constants.XPATH_EXPR_PROVIDER_HANDLERS_START +
-                        providerClassName + "']", Constants.GFAC_CONFIG_APPLICATION_NAME_ATTRIBUTE);
-                if(!aClass.isEmpty()){
-                    provider.initProperties(aClass.get(0).getProperties());
+                JobSubmissionProtocol jobSubmissionProtocol = jobExecutionContext.getPreferredJobSubmissionProtocol();
+                SSHJobSubmission sshJobSubmission;
+                LOCALSubmission localSubmission;
+                String securityProtocol = null;
+                try {
+                    AppCatalog appCatalog = AppCatalogFactory.getAppCatalog();
+                    if (jobSubmissionProtocol == JobSubmissionProtocol.SSH) {
+                        sshJobSubmission = appCatalog.getComputeResource().getSSHJobSubmission(
+                                jobExecutionContext.getPreferredJobSubmissionInterface().getJobSubmissionInterfaceId());
+                        if (sshJobSubmission != null) {
+                            securityProtocol  = sshJobSubmission.getSecurityProtocol().toString();
+                        }
+                    }else if (jobSubmissionProtocol == JobSubmissionProtocol.LOCAL) {
+                        localSubmission = appCatalog.getComputeResource().getLocalJobSubmission(jobExecutionContext.getPreferredJobSubmissionInterface().getJobSubmissionInterfaceId());
+                    }
+                    List<Element> elements = GFacUtils.getElementList(GFacConfiguration.getHandlerDoc(),
Constants.XPATH_EXPR_PROVIDER_ON_SUBMISSION + jobSubmissionProtocol + "']");
+                    for (Element element : elements) {
+                        String security = element.getAttribute(Constants.GFAC_CONFIG_SECURITY_ATTRIBUTE);
+                        if (securityProtocol == null && security == null) {
+                            providerClassName = element.getAttribute(Constants.GFAC_CONFIG_CLASS_ATTRIBUTE);
+                        }else if (securityProtocol.equals(security)) {
+                            providerClassName = element.getAttribute(Constants.GFAC_CONFIG_CLASS_ATTRIBUTE);
+                        }
+                    }
+                    if (providerClassName == null) {
+                        throw new GFacException("Couldn't find provider class");
+                    }
+
+                    Class<? extends GFacProvider> aClass1 = Class.forName(providerClassName).asSubclass(GFacProvider.class);
+                    provider = aClass1.newInstance();
+                    //loading the provider properties
+                    aClass = GFacConfiguration.getProviderConfig(GFacConfiguration.getHandlerDoc(),
Constants.XPATH_EXPR_PROVIDER_HANDLERS_START +
+                            providerClassName + "']", Constants.GFAC_CONFIG_APPLICATION_NAME_ATTRIBUTE);
+                    if (!aClass.isEmpty()) {
+                        provider.initProperties(aClass.get(0).getProperties());
+                    }
+                } catch (AppCatalogException e) {
+                    throw new GFacException("Couldn't retrieve job submission protocol from
app catalog ");
                 }
             }
         } catch (XPathExpressionException e) {

http://git-wip-us.apache.org/repos/asf/airavata/blob/d8176e81/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/utils/GFacUtils.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/utils/GFacUtils.java
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/utils/GFacUtils.java
index 6fb2115..c5a96f9 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/utils/GFacUtils.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/utils/GFacUtils.java
@@ -52,7 +52,16 @@ import org.apache.zookeeper.*;
 import org.apache.zookeeper.data.Stat;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
 import java.io.*;
 import java.net.InetAddress;
 import java.net.URISyntaxException;
@@ -151,6 +160,21 @@ public class GFacUtils {
 		return name + "_" + date;
 	}
 
+    public static List<Element> getElementList(Document doc, String expression) throws
XPathExpressionException {
+        XPathFactory xPathFactory = XPathFactory.newInstance();
+        XPath xPath = xPathFactory.newXPath();
+        XPathExpression expr = xPath.compile(expression);
+        NodeList nodeList = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
+        List<Element> elementList = new ArrayList<Element>();
+        for (int i = 0; i < nodeList.getLength(); i++) {
+            Node item = nodeList.item(i);
+            if (item instanceof Element) {
+                elementList.add((Element) item);
+            }
+        }
+        return elementList;
+    }
+
 	public static String createGsiftpURIAsString(String host, String localPath)
 			throws URISyntaxException {
 		StringBuffer buf = new StringBuffer();


Mime
View raw message