airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject git commit: app-catalog cpi for app-deployment - AIRAVATA-1228
Date Mon, 30 Jun 2014 19:54:15 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 506593c48 -> 3c2b11cb2


app-catalog cpi for app-deployment - AIRAVATA-1228


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

Branch: refs/heads/master
Commit: 3c2b11cb2fa6a20a3606950090dd7ae85500c36b
Parents: 506593c
Author: Chathuri Wimalasena <kamalasini@gmail.com>
Authored: Mon Jun 30 15:54:10 2014 -0400
Committer: Chathuri Wimalasena <kamalasini@gmail.com>
Committed: Mon Jun 30 15:54:10 2014 -0400

----------------------------------------------------------------------
 .../appcatalog/cpi/ApplicationDeployment.java   |   2 +-
 .../data/impl/ApplicationDeploymentImpl.java    | 117 ++++++++++++++++++-
 .../data/util/AppCatalogThriftConversion.java   |  88 +++++++++++++-
 3 files changed, 199 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/3c2b11cb/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/ApplicationDeployment.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/ApplicationDeployment.java
b/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/ApplicationDeployment.java
index e23b442..fc87f59 100644
--- a/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/ApplicationDeployment.java
+++ b/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/ApplicationDeployment.java
@@ -18,7 +18,7 @@ public interface ApplicationDeployment {
      * @param deploymentId unique deployment id
      * @return application deployment
      */
-    String getApplicationDeployement (String deploymentId) throws AppCatalogException;
+    ApplicationDeploymentDescription getApplicationDeployement (String deploymentId) throws
AppCatalogException;
 
     /**
      * This method will return a list of application deployments according to given search
criteria

http://git-wip-us.apache.org/repos/asf/airavata/blob/3c2b11cb/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/ApplicationDeploymentImpl.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/ApplicationDeploymentImpl.java
b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/ApplicationDeploymentImpl.java
index 85343a2..63ce10d 100644
--- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/ApplicationDeploymentImpl.java
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/ApplicationDeploymentImpl.java
@@ -23,7 +23,11 @@ package org.apache.aiaravata.application.catalog.data.impl;
 
 import org.airavata.appcatalog.cpi.AppCatalogException;
 import org.airavata.appcatalog.cpi.ApplicationDeployment;
+import org.apache.aiaravata.application.catalog.data.resources.*;
+import org.apache.aiaravata.application.catalog.data.util.AppCatalogThriftConversion;
+import org.apache.aiaravata.application.catalog.data.util.AppCatalogUtils;
 import org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription;
+import org.apache.airavata.model.appcatalog.appdeployment.SetEnvPaths;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -35,26 +39,129 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment
{
 
     @Override
     public String addApplicationDeployment(ApplicationDeploymentDescription deploymentDescription)
throws AppCatalogException {
-        return null;
+        try {
+            AppDeploymentResource deploymentResource = new AppDeploymentResource();
+            ComputeHostResource computeHostResource = new ComputeHostResource();
+            AppModuleResource moduleResource = new AppModuleResource();
+            if (!computeHostResource.isExists(deploymentDescription.getComputeHostId())){
+                logger.error("Compute host does not exist in the system. Please create a
Compute host first...");
+                throw new AppCatalogException("Compute host does not exist in the system.
Please create a Compute host first...");
+            }
+            if (!moduleResource.isExists(deploymentDescription.getAppModuleId())){
+                logger.error("Application module does not exist in the system. Please create
an application module first...");
+                throw new AppCatalogException("Application module does not exist in the system.
Please create an application module first...");
+            }
+            AppModuleResource module = (AppModuleResource)moduleResource.get(deploymentDescription.getAppModuleId());
+            deploymentResource.setDeploymentId(AppCatalogUtils.getID(module.getModuleName()));
+            deploymentResource.setAppModuleId(deploymentDescription.getAppModuleId());
+            deploymentResource.setModuleResource(module);
+            deploymentResource.setHostId(deploymentDescription.getComputeHostId());
+            deploymentResource.setHostResource((ComputeHostResource)computeHostResource.get(deploymentDescription.getComputeHostId()));
+            deploymentResource.setAppDes(deploymentDescription.getAppDeploymentDescription());
+            deploymentResource.setExecutablePath(deploymentDescription.getExecutablePath());
+            deploymentResource.setEnvModuleLoadCMD(deploymentDescription.getModuleLoadCmd());
+            deploymentResource.save();
+            deploymentDescription.setAppDeploymentId(deploymentResource.getDeploymentId());
+
+            List<SetEnvPaths> libPrependPaths = deploymentDescription.getLibPrependPaths();
+            if (libPrependPaths != null && !libPrependPaths.isEmpty()){
+                for (SetEnvPaths path : libPrependPaths){
+                    LibraryPrepandPathResource prepandPathResource = new LibraryPrepandPathResource();
+                    prepandPathResource.setAppDeploymentResource(deploymentResource);
+                    prepandPathResource.setName(path.getName());
+                    prepandPathResource.setValue(path.getValue());
+                    prepandPathResource.setDeploymentId(deploymentResource.getDeploymentId());
+                    prepandPathResource.save();
+                }
+            }
+
+            List<SetEnvPaths> libApendPaths = deploymentDescription.getLibAppendPaths();
+            if (libApendPaths != null && !libApendPaths.isEmpty()){
+                for (SetEnvPaths path : libApendPaths){
+                    LibraryApendPathResource apendPathResource = new LibraryApendPathResource();
+                    apendPathResource.setAppDeploymentResource(deploymentResource);
+                    apendPathResource.setName(path.getName());
+                    apendPathResource.setValue(path.getValue());
+                    apendPathResource.setDeploymentId(deploymentResource.getDeploymentId());
+                    apendPathResource.save();
+                }
+            }
+            List<SetEnvPaths> setEnvironment = deploymentDescription.getSetEnvironment();
+            if (setEnvironment != null && !setEnvironment.isEmpty()){
+                for (SetEnvPaths path : setEnvironment){
+                    AppEnvironmentResource environmentResource = new AppEnvironmentResource();
+                    environmentResource.setAppDeploymentResource(deploymentResource);
+                    environmentResource.setName(path.getName());
+                    environmentResource.setValue(path.getValue());
+                    environmentResource.setDeploymentId(deploymentResource.getDeploymentId());
+                    environmentResource.save();
+                }
+            }
+            return deploymentResource.getDeploymentId();
+        }catch (Exception e) {
+            logger.error("Error while saving application deployment...", e);
+            throw new AppCatalogException(e);
+        }
     }
 
     @Override
-    public String getApplicationDeployement(String deploymentId) throws AppCatalogException
{
-        return null;
+    public ApplicationDeploymentDescription getApplicationDeployement(String deploymentId)
throws AppCatalogException {
+        try {
+            AppDeploymentResource deploymentResource = new AppDeploymentResource();
+            AppDeploymentResource appDep = (AppDeploymentResource)deploymentResource.get(deploymentId);
+            return AppCatalogThriftConversion.getApplicationDeploymentDescription(appDep);
+        }catch (Exception e) {
+            logger.error("Error while retrieving application deployment...", e);
+            throw new AppCatalogException(e);
+        }
     }
 
     @Override
     public List<ApplicationDeploymentDescription> getApplicationDeployements(Map<String,
String> filters) throws AppCatalogException {
+        try {
+            AppDeploymentResource resource = new AppDeploymentResource();
+            for (String fieldName : filters.keySet() ){
+                if (fieldName.equals(AbstractResource.ApplicationDeploymentConstants.APP_MODULE_ID)){
+                    List<Resource> resources = resource.get(AbstractResource.ApplicationDeploymentConstants.APP_MODULE_ID,
filters.get(fieldName));
+                    if (resources != null && !resources.isEmpty()){
+                        return AppCatalogThriftConversion.getAppDepDescList(resources);
+                    }
+                }else if (fieldName.equals(AbstractResource.ApplicationDeploymentConstants.COMPUTE_HOST_ID)){
+                    List<Resource> resources = resource.get(AbstractResource.ApplicationDeploymentConstants.COMPUTE_HOST_ID,
filters.get(fieldName));
+                    if (resources != null && !resources.isEmpty()){
+                        return AppCatalogThriftConversion.getAppDepDescList(resources);
+                    }
+                } else {
+                    logger.error("Unsupported field name for app deployment.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Unsupported field name for app deployment.");
+                }
+            }
+        }catch (Exception e){
+            logger.error("Error while retrieving app deployment list...", e);
+            throw new AppCatalogException(e);
+        }
         return null;
     }
 
     @Override
     public boolean isAppDeploymentExists(String deploymentId) throws AppCatalogException
{
-        return false;
+        try {
+           AppDeploymentResource deploymentResource = new AppDeploymentResource();
+            return deploymentResource.isExists(deploymentId);
+        }catch (Exception e){
+            logger.error("Error while retrieving app deployment...", e);
+            throw new AppCatalogException(e);
+        }
     }
 
     @Override
     public void removeAppDeployment(String deploymentId) throws AppCatalogException {
-
+        try {
+            AppDeploymentResource deploymentResource = new AppDeploymentResource();
+            deploymentResource.remove(deploymentId);
+        }catch (Exception e){
+            logger.error("Error while deleting app deployment...", e);
+            throw new AppCatalogException(e);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/3c2b11cb/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogThriftConversion.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogThriftConversion.java
b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogThriftConversion.java
index 977d524..1771639 100644
--- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogThriftConversion.java
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/util/AppCatalogThriftConversion.java
@@ -22,8 +22,12 @@
 package org.apache.aiaravata.application.catalog.data.util;
 
 import org.airavata.appcatalog.cpi.AppCatalogException;
+import org.apache.aiaravata.application.catalog.data.model.ApplicationDeployment;
+import org.apache.aiaravata.application.catalog.data.model.LibraryPrepandPath;
 import org.apache.aiaravata.application.catalog.data.resources.*;
+import org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription;
 import org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule;
+import org.apache.airavata.model.appcatalog.appdeployment.SetEnvPaths;
 import org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription;
 import org.apache.airavata.model.appcatalog.appinterface.DataType;
 import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType;
@@ -235,7 +239,7 @@ public class AppCatalogThriftConversion {
     public static List<SSHJobSubmission> getSSHSubmissionList (List<Resource>
resources) throws AppCatalogException {
         List<SSHJobSubmission> list = new ArrayList<SSHJobSubmission>();
         for (Resource resource : resources){
-            list.add(getSSHJobSubmissionDescription((SSHSubmissionResource)resource));
+            list.add(getSSHJobSubmissionDescription((SSHSubmissionResource) resource));
         }
         return list;
     }
@@ -363,7 +367,8 @@ public class AppCatalogThriftConversion {
             inputs.add(getInputDataObjType((ApplicationInputResource) resource));
         }
         return inputs;
-    } 
+    }
+
     public static InputDataObjectType getInputDataObjType (ApplicationInputResource input){
         InputDataObjectType inputDataObjectType = new InputDataObjectType();
         inputDataObjectType.setName(input.getInputKey());
@@ -391,5 +396,84 @@ public class AppCatalogThriftConversion {
         return outputDataObjectType;
     }
 
+    public static ApplicationDeploymentDescription getApplicationDeploymentDescription (AppDeploymentResource
resource) throws AppCatalogException {
+        ApplicationDeploymentDescription description = new ApplicationDeploymentDescription();
+        description.setAppDeploymentId(resource.getDeploymentId());
+        description.setAppModuleId(resource.getAppModuleId());
+        description.setComputeHostId(resource.getHostId());
+        description.setExecutablePath(resource.getExecutablePath());
+        description.setAppDeploymentDescription(resource.getAppDes());
+        description.setModuleLoadCmd(resource.getEnvModuleLoadCMD());
+
+        LibraryPrepandPathResource prepandPathResource = new LibraryPrepandPathResource();
+        List<Resource> libPrepandPaths = prepandPathResource.get(AbstractResource.LibraryPrepandPathConstants.DEPLOYMENT_ID,
resource.getDeploymentId());
+        if (libPrepandPaths != null && !libPrepandPaths.isEmpty()){
+            description.setLibPrependPaths(getLibPrepandPaths(libPrepandPaths));
+        }
+
+        LibraryApendPathResource apendPathResource = new LibraryApendPathResource();
+        List<Resource> libApendPaths = apendPathResource.get(AbstractResource.LibraryPrepandPathConstants.DEPLOYMENT_ID,
resource.getDeploymentId());
+        if (libApendPaths != null && !libApendPaths.isEmpty()){
+            description.setLibAppendPaths(getLibApendPaths(libApendPaths));
+        }
+
+        AppEnvironmentResource appEnvironmentResource = new AppEnvironmentResource();
+        List<Resource> appEnvList = appEnvironmentResource.get(AbstractResource.LibraryPrepandPathConstants.DEPLOYMENT_ID,
resource.getDeploymentId());
+        if (appEnvList != null && !appEnvList.isEmpty()){
+            description.setSetEnvironment(getAppEnvPaths(appEnvList));
+        }
+        return description;
+    }
+
+    public static List<ApplicationDeploymentDescription> getAppDepDescList (List<Resource>
resources) throws AppCatalogException {
+        List<ApplicationDeploymentDescription> appList = new ArrayList<ApplicationDeploymentDescription>();
+        for (Resource resource : resources){
+            appList.add(getApplicationDeploymentDescription((AppDeploymentResource)resource));
+        }
+        return appList;
+    }
+
+    public static SetEnvPaths getSetEnvPath(Resource resource){
+        SetEnvPaths envPaths = new SetEnvPaths();
+        if (resource instanceof LibraryPrepandPathResource){
+            envPaths.setName(((LibraryPrepandPathResource) resource).getName());
+            envPaths.setValue(((LibraryPrepandPathResource) resource).getValue());
+            return envPaths;
+        }else if (resource instanceof LibraryApendPathResource){
+            envPaths.setName(((LibraryApendPathResource) resource).getName());
+            envPaths.setValue(((LibraryApendPathResource) resource).getValue());
+            return envPaths;
+        }else if (resource instanceof AppEnvironmentResource){
+            envPaths.setName(((AppEnvironmentResource) resource).getName());
+            envPaths.setValue(((AppEnvironmentResource) resource).getValue());
+            return envPaths;
+        }else {
+            return null;
+        }
+    }
+
+    public static List<SetEnvPaths> getLibPrepandPaths (List<Resource> prepandPaths){
+        List<SetEnvPaths> pathList = new ArrayList<SetEnvPaths>();
+        for (Resource resource : prepandPaths){
+            pathList.add(getSetEnvPath(resource));
+        }
+        return pathList;
+    }
+
+    public static List<SetEnvPaths> getLibApendPaths (List<Resource> appendPaths){
+        List<SetEnvPaths> pathList = new ArrayList<SetEnvPaths>();
+        for (Resource resource : appendPaths){
+            pathList.add(getSetEnvPath(resource));
+        }
+        return pathList;
+    }
+
+    public static List<SetEnvPaths> getAppEnvPaths (List<Resource> appEnvPaths){
+        List<SetEnvPaths> pathList = new ArrayList<SetEnvPaths>();
+        for (Resource resource : appEnvPaths){
+            pathList.add(getSetEnvPath(resource));
+        }
+        return pathList;
+    }
 
 }


Mime
View raw message