airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject git commit: gateway profile cpi impl - AIRAVATA-1318
Date Thu, 03 Jul 2014 20:53:39 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 59a7443ac -> a7ce476c0


gateway profile cpi impl - AIRAVATA-1318


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

Branch: refs/heads/master
Commit: a7ce476c03ab129b08da452636c6a8a0959299e2
Parents: 59a7443
Author: Chathuri Wimalasena <kamalasini@gmail.com>
Authored: Thu Jul 3 16:53:32 2014 -0400
Committer: Chathuri Wimalasena <kamalasini@gmail.com>
Committed: Thu Jul 3 16:53:32 2014 -0400

----------------------------------------------------------------------
 .../org/airavata/appcatalog/cpi/AppCatalog.java |   7 +
 .../org/airavata/appcatalog/cpi/GProfile.java   |  60 ++++++
 .../catalog/data/impl/GatewayProfileImpl.java   | 193 +++++++++++++++++++
 .../data/util/AppCatalogThriftConversion.java   |  36 +++-
 .../jpa/utils/ThriftDataModelConversion.java    |   4 +
 5 files changed, 297 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/a7ce476c/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/AppCatalog.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/AppCatalog.java
b/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/AppCatalog.java
index 2bbebf9..74cc56e 100644
--- a/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/AppCatalog.java
+++ b/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/AppCatalog.java
@@ -18,4 +18,11 @@ public interface AppCatalog {
      * @return application deployment interface
      */
     ApplicationDeployment getApplicationDeployment() throws AppCatalogException;
+
+    /**
+     * Get Gateway profile interface
+     * @return Gateway profile interface
+     * @throws AppCatalogException
+     */
+    GProfile getGatewayProfile() throws AppCatalogException;
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/a7ce476c/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/GProfile.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/GProfile.java
b/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/GProfile.java
new file mode 100644
index 0000000..696b643
--- /dev/null
+++ b/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/GProfile.java
@@ -0,0 +1,60 @@
+package org.airavata.appcatalog.cpi;
+
+import org.apache.airavata.model.appcatalog.computeresource.DataMovementProtocol;
+import org.apache.airavata.model.appcatalog.computeresource.JobSubmissionProtocol;
+import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayProfile;
+
+public interface GProfile {
+    /**
+     * This method will add a gateway profile
+     * @param gatewayProfile gateway profile
+     * @return gateway id
+     */
+    String addGatewayProfile (GatewayProfile gatewayProfile) throws AppCatalogException;
+
+    /**
+     * This method will update a gateway profile
+     * @param gatewayId unique gateway id
+     * @param updatedProfile updated profile
+     */
+    void updateGatewayProfile (String gatewayId, GatewayProfile updatedProfile) throws AppCatalogException;
+
+    /**
+     *
+     * @param gatewayId
+     * @return
+     */
+    GatewayProfile getGatewayProfile (String gatewayId) throws AppCatalogException;
+
+    /**
+     *
+     * @param gatewayId
+     * @param hostId
+     * @return
+     */
+    JobSubmissionProtocol getPreferedJobSubmissionProtocol (String gatewayId, String hostId)
throws AppCatalogException;
+
+    /**
+     *
+     * @param gatewayId
+     * @param hostId
+     * @return
+     */
+    DataMovementProtocol getPreferedDMProtocol (String gatewayId, String hostId) throws AppCatalogException;
+
+
+    /**
+     * This method will remove a gateway profile
+     * @param gatewayId unique gateway id
+     * @return true or false
+     */
+    boolean removeGatewayProfile (String gatewayId) throws AppCatalogException;
+
+    /**
+     * This method will check whether gateway profile exists
+     * @param gatewayId unique gateway id
+     * @return true or false
+     */
+    boolean isGatewayProfileExists (String gatewayId) throws AppCatalogException;
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/a7ce476c/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/GatewayProfileImpl.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/GatewayProfileImpl.java
b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/GatewayProfileImpl.java
new file mode 100644
index 0000000..546437f
--- /dev/null
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/GatewayProfileImpl.java
@@ -0,0 +1,193 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.aiaravata.application.catalog.data.impl;
+
+import org.airavata.appcatalog.cpi.AppCatalogException;
+import org.airavata.appcatalog.cpi.GProfile;
+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.computeresource.DataMovementProtocol;
+import org.apache.airavata.model.appcatalog.computeresource.JobSubmissionProtocol;
+import org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference;
+import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayProfile;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class GatewayProfileImpl implements GProfile {
+    private final static Logger logger = LoggerFactory.getLogger(GatewayProfileImpl.class);
+
+    @Override
+    public String addGatewayProfile(GatewayProfile gatewayProfile) throws AppCatalogException
{
+        try {
+            GatewayProfileResource profileResource = new GatewayProfileResource();
+            profileResource.setGatewayName(gatewayProfile.getGatewayName());
+            profileResource.setGatewayID(AppCatalogUtils.getID(gatewayProfile.getGatewayName()));
+            profileResource.setGatewayDesc(gatewayProfile.getGatewayDescription());
+            profileResource.save();
+            gatewayProfile.setGatewayID(profileResource.getGatewayID());
+            List<ComputeResourcePreference> computeResourcePreferences = gatewayProfile.getComputeResourcePreferences();
+            if (computeResourcePreferences != null && !computeResourcePreferences.isEmpty()){
+                for (ComputeResourcePreference preference : computeResourcePreferences ){
+                    ComputeHostPreferenceResource resource = new ComputeHostPreferenceResource();
+                    resource.setGatewayProfile(profileResource);
+                    resource.setResourceId(preference.getComputeResourceId());
+                    ComputeHostResource computeHostResource = new ComputeHostResource();
+                    resource.setComputeHostResource((ComputeHostResource)computeHostResource.get(preference.getComputeResourceId()));
+                    resource.setGatewayId(profileResource.getGatewayID());
+                    resource.setOverrideByAiravata(preference.isOverridebyAiravata());
+                    resource.setPreferredJobProtocol(preference.getPreferredJobSubmissionProtocol());
+                    resource.setPreferedDMProtocol(preference.getPreferredDataMovementProtocol());
+                    resource.setBatchQueue(preference.getPreferredBatchQueue());
+                    resource.setProjectNumber(preference.getAllocationProjectNumber());
+                    resource.setScratchLocation(preference.getScratchLocation());
+                    resource.save();
+                }
+            }
+            return profileResource.getGatewayID();
+        }catch (Exception e) {
+            logger.error("Error while saving gateway profile...", e);
+            throw new AppCatalogException(e);
+        }
+    }
+
+    @Override
+    public void updateGatewayProfile(String gatewayId, GatewayProfile updatedProfile) throws
AppCatalogException {
+        try {
+            GatewayProfileResource profileResource = new GatewayProfileResource();
+            GatewayProfileResource existingGP = (GatewayProfileResource)profileResource.get(gatewayId);
+            existingGP.setGatewayName(updatedProfile.getGatewayName());
+            existingGP.setGatewayDesc(updatedProfile.getGatewayDescription());
+            existingGP.save();
+
+            List<ComputeResourcePreference> computeResourcePreferences = updatedProfile.getComputeResourcePreferences();
+            if (computeResourcePreferences != null && !computeResourcePreferences.isEmpty()){
+                for (ComputeResourcePreference preference : computeResourcePreferences ){
+                    ComputeHostPreferenceResource resource = new ComputeHostPreferenceResource();
+                    Map<String, String> ids = new HashMap<String, String>();
+                    ids.put(AbstractResource.ComputeResourcePreferenceConstants.GATEWAY_ID,
gatewayId);
+                    ids.put(AbstractResource.ComputeResourcePreferenceConstants.RESOURCE_ID,
preference.getComputeResourceId());
+                    ComputeHostPreferenceResource existingPreferenceResource = (ComputeHostPreferenceResource)resource.get(ids);
+
+                    existingPreferenceResource.setGatewayProfile(existingGP);
+                    existingPreferenceResource.setResourceId(preference.getComputeResourceId());
+                    ComputeHostResource computeHostResource = new ComputeHostResource();
+                    existingPreferenceResource.setComputeHostResource((ComputeHostResource)computeHostResource.get(preference.getComputeResourceId()));
+                    existingPreferenceResource.setGatewayId(gatewayId);
+                    existingPreferenceResource.setOverrideByAiravata(preference.isOverridebyAiravata());
+                    existingPreferenceResource.setPreferredJobProtocol(preference.getPreferredJobSubmissionProtocol());
+                    existingPreferenceResource.setPreferedDMProtocol(preference.getPreferredDataMovementProtocol());
+                    existingPreferenceResource.setBatchQueue(preference.getPreferredBatchQueue());
+                    existingPreferenceResource.setProjectNumber(preference.getAllocationProjectNumber());
+                    existingPreferenceResource.setScratchLocation(preference.getScratchLocation());
+                    existingPreferenceResource.save();
+                }
+            }
+        }catch (Exception e) {
+            logger.error("Error while updating gateway profile...", e);
+            throw new AppCatalogException(e);
+        }
+    }
+
+    @Override
+    public GatewayProfile getGatewayProfile(String gatewayId) throws AppCatalogException
{
+        try {
+            GatewayProfileResource resource = new GatewayProfileResource();
+            GatewayProfileResource gwresource = (GatewayProfileResource)resource.get(gatewayId);
+            ComputeHostPreferenceResource prefResource = new ComputeHostPreferenceResource();
+            List<Resource> computePrefList = prefResource.get(AbstractResource.ComputeResourcePreferenceConstants.GATEWAY_ID,
gatewayId);
+            List<ComputeResourcePreference> computeResourcePreferences = AppCatalogThriftConversion.getComputeResourcePreferences(computePrefList);
+            return AppCatalogThriftConversion.getGatewayProfile(gwresource, computeResourcePreferences);
+        }catch (Exception e) {
+            logger.error("Error while retrieving gateway profile...", e);
+            throw new AppCatalogException(e);
+        }
+    }
+
+    @Override
+    public JobSubmissionProtocol getPreferedJobSubmissionProtocol(String gatewayId, String
hostId) throws AppCatalogException{
+        try {
+            ComputeHostPreferenceResource prefResource = new ComputeHostPreferenceResource();
+            List<Resource> computePrefList = prefResource.get(AbstractResource.ComputeResourcePreferenceConstants.GATEWAY_ID,
gatewayId);
+            if (computePrefList != null && !computePrefList.isEmpty()){
+                for (Resource pref : computePrefList){
+                    ComputeHostPreferenceResource preferenceResource = (ComputeHostPreferenceResource)pref;
+                    if (preferenceResource.getResourceId().equals(hostId)){
+                        return JobSubmissionProtocol.valueOf(preferenceResource.getPreferredJobProtocol());
+                    }
+                }
+            }
+        }catch (Exception e) {
+            logger.error("Error while retrieving job submission protocol for given host and
gateway...", e);
+            throw new AppCatalogException(e);
+        }
+        return null;
+    }
+
+    @Override
+    public DataMovementProtocol getPreferedDMProtocol(String gatewayId, String hostId) throws
AppCatalogException{
+        try {
+            ComputeHostPreferenceResource prefResource = new ComputeHostPreferenceResource();
+            List<Resource> computePrefList = prefResource.get(AbstractResource.ComputeResourcePreferenceConstants.GATEWAY_ID,
gatewayId);
+            if (computePrefList != null && !computePrefList.isEmpty()){
+                for (Resource pref : computePrefList){
+                    ComputeHostPreferenceResource preferenceResource = (ComputeHostPreferenceResource)pref;
+                    if (preferenceResource.getResourceId().equals(hostId)){
+                        return DataMovementProtocol.valueOf(preferenceResource.getPreferedDMProtocol());
+                    }
+                }
+            }
+        }catch (Exception e) {
+            logger.error("Error while retrieving data movement protocol for given host and
gateway...", e);
+            throw new AppCatalogException(e);
+        }
+        return null;
+    }
+
+
+    @Override
+    public boolean removeGatewayProfile(String gatewayId) throws AppCatalogException {
+       try {
+           GatewayProfileResource resource = new GatewayProfileResource();
+           resource.remove(gatewayId);
+           return true;
+       }catch (Exception e) {
+           logger.error("Error while deleting gateway profile...", e);
+           throw new AppCatalogException(e);
+       }
+    }
+
+    @Override
+    public boolean isGatewayProfileExists(String gatewayId) throws AppCatalogException {
+        try {
+            GatewayProfileResource resource = new GatewayProfileResource();
+            return resource.isExists(gatewayId);
+        }catch (Exception e) {
+            logger.error("Error while retrieving gateway profile...", e);
+            throw new AppCatalogException(e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/a7ce476c/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 027c313..89fa8b3 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,6 @@
 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;
@@ -33,6 +31,8 @@ import org.apache.airavata.model.appcatalog.appinterface.DataType;
 import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType;
 import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType;
 import org.apache.airavata.model.appcatalog.computeresource.*;
+import org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference;
+import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayProfile;
 
 import java.util.*;
 
@@ -40,7 +40,7 @@ public class AppCatalogThriftConversion {
     public static ComputeHostResource getComputeHostResource (ComputeResourceDescription
description){
         ComputeHostResource resource = new ComputeHostResource();
         resource.setHostName(description.getHostName());
-        resource.setDescription(description.getResourceDescription());
+        resource.setDescription(description.getComputeResourceDescription());
         resource.setPreferredJobSubmissionProtocol(description.getPreferredJobSubmissionProtocol());
         resource.setPreferredJobSubmissionProtocol(description.getResourceId());
         return resource;
@@ -470,4 +470,34 @@ public class AppCatalogThriftConversion {
         return pathList;
     }
 
+    public static ComputeResourcePreference getComputeResourcePreference (ComputeHostPreferenceResource
resource){
+        ComputeResourcePreference preference = new ComputeResourcePreference();
+        preference.setComputeResourceId(resource.getResourceId());
+        preference.setOverridebyAiravata(resource.getOverrideByAiravata());
+        preference.setPreferredJobSubmissionProtocol(resource.getPreferredJobProtocol());
+        preference.setPreferredDataMovementProtocol(resource.getPreferedDMProtocol());
+        preference.setPreferredBatchQueue(resource.getBatchQueue());
+        preference.setScratchLocation(resource.getScratchLocation());
+        preference.setAllocationProjectNumber(resource.getProjectNumber());
+        return preference;
+    }
+
+    public static List<ComputeResourcePreference> getComputeResourcePreferences (List<Resource>
resources){
+        List<ComputeResourcePreference> preferences = new ArrayList<ComputeResourcePreference>();
+        if (resources != null && !resources.isEmpty()){
+            for (Resource resource : resources){
+                 preferences.add(getComputeResourcePreference((ComputeHostPreferenceResource)resource));
+            }
+        }
+        return preferences;
+    }
+
+    public static GatewayProfile getGatewayProfile (GatewayProfileResource gw, List<ComputeResourcePreference>
preferences){
+        GatewayProfile gatewayProfile = new GatewayProfile();
+        gatewayProfile.setGatewayID(gw.getGatewayID());
+        gatewayProfile.setGatewayDescription(gw.getGatewayDesc());
+        gatewayProfile.setGatewayName(gw.getGatewayName());
+        gatewayProfile.setComputeResourcePreferences(preferences);
+        return gatewayProfile;
+    }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/a7ce476c/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java
b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java
index 26f5dc4..1bd5fe5 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java
@@ -24,6 +24,7 @@ package org.apache.airavata.persistance.registry.jpa.utils;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayProfile;
 import org.apache.airavata.model.workspace.Project;
 import org.apache.airavata.model.workspace.experiment.ActionableGroup;
 import org.apache.airavata.model.workspace.experiment.AdvancedInputDataHandling;
@@ -624,4 +625,7 @@ public class ThriftDataModelConversion {
         }
         return null;
     }
+
+
+
 }


Mime
View raw message