airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject git commit: adding more implementation of registry cpi - AIRAVATA-1006
Date Fri, 07 Feb 2014 18:35:33 GMT
Updated Branches:
  refs/heads/master 57d3cf8d3 -> 03bd52d81


adding more implementation of registry cpi - AIRAVATA-1006


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

Branch: refs/heads/master
Commit: 03bd52d819b20e361108cf5c4d17608b6f02b085
Parents: 57d3cf8
Author: chathuri <chathuri@apache.org>
Authored: Fri Feb 7 13:35:22 2014 -0500
Committer: chathuri <chathuri@apache.org>
Committed: Fri Feb 7 13:35:22 2014 -0500

----------------------------------------------------------------------
 .../registry/jpa/impl/ExperimentRegistry.java   |  59 +++++++---
 .../registry/jpa/impl/RegistryImpl.java         |  35 +++++-
 .../registry/jpa/impl/UserRegistry.java         |  32 ++++++
 .../registry/jpa/resources/WorkerResource.java  |   1 +
 .../jpa/utils/ThriftDataModelConversion.java    | 112 +++++++++++++++++++
 .../apache/airavata/registry/cpi/Registry.java  |   4 +-
 .../airavata/registry/cpi/utils/Constants.java  |   1 +
 7 files changed, 226 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/03bd52d8/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
index f9e1d6f..b2c816b 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
@@ -25,10 +25,8 @@ import org.apache.airavata.common.exception.ApplicationSettingsException;
 import org.apache.airavata.model.experiment.*;
 import org.apache.airavata.persistance.registry.jpa.Resource;
 import org.apache.airavata.persistance.registry.jpa.ResourceType;
-import org.apache.airavata.persistance.registry.jpa.resources.ExperimentConfigDataResource;
-import org.apache.airavata.persistance.registry.jpa.resources.ExperimentInputResource;
-import org.apache.airavata.persistance.registry.jpa.resources.ExperimentMetadataResource;
-import org.apache.airavata.persistance.registry.jpa.resources.GatewayResource;
+import org.apache.airavata.persistance.registry.jpa.resources.*;
+import org.apache.airavata.persistance.registry.jpa.utils.ThriftDataModelConversion;
 import org.apache.airavata.registry.cpi.DependentDataType;
 import org.apache.airavata.registry.cpi.utils.Constants;
 import org.slf4j.Logger;
@@ -39,6 +37,7 @@ import java.util.*;
 
 public class ExperimentRegistry {
     private GatewayRegistry gatewayRegistry;
+    private UserRegistry userRegistry;
     private final static Logger logger = LoggerFactory.getLogger(ExperimentRegistry.class);
 
     public void add(BasicMetadata basicMetadata) {
@@ -336,17 +335,51 @@ public class ExperimentRegistry {
         exConfigResource.save();
     }
 
-    public void update(ConfigurationData configurationData, String experimentID) {
-
-    }
-
-
-    public void update(DependentDataType dataType, Object identifier, Object field, Object
value) {
-
+    public List<BasicMetadata> getExperimentMetaDataList (String fieldName, Object
value){
+        List<BasicMetadata> metadataList = new ArrayList<BasicMetadata>();
+        try {
+            gatewayRegistry = new GatewayRegistry();
+            GatewayResource gateway = gatewayRegistry.getGateway();
+            if (fieldName.equals(Constants.FieldConstants.BasicMetadataConstants.USER_NAME)){
+                userRegistry = new UserRegistry();
+                WorkerResource worker = userRegistry.getWorker(gateway.getGatewayName(),
(String) value);
+                List<Resource> resources = worker.get(ResourceType.EXPERIMENT_METADATA);
+                for (Resource resource : resources){
+                    ExperimentMetadataResource ex =  (ExperimentMetadataResource)resource;
+                    BasicMetadata basicMetadata = ThriftDataModelConversion.getBasicMetadata(ex);
+                    metadataList.add(basicMetadata);
+                }
+                return metadataList;
+            }else {
+                logger.error("Unsupported field type for Experiment meta data");
+            }
+        } catch (ApplicationSettingsException e) {
+            logger.error("Unable to read airavata-server properties", e.getMessage());
+        }
+        return metadataList;
     }
 
-    public List<Object> get(DependentDataType dataType, Object filteredBy, Object value)
{
-        return null;
+    public List<ConfigurationData> getConfigurationDataList (String fieldName, Object
value){
+        List<ConfigurationData> configDataList = new ArrayList<ConfigurationData>();
+        try {
+            gatewayRegistry = new GatewayRegistry();
+            GatewayResource gateway = gatewayRegistry.getGateway();
+            if (fieldName.equals(Constants.FieldConstants.ConfigurationDataConstants.EXPERIMENT_ID)){
+                ExperimentMetadataResource exBasicData = (ExperimentMetadataResource) gateway.get(ResourceType.EXPERIMENT_METADATA,
(String)value);
+                List<Resource> resources = exBasicData.get(ResourceType.EXPERIMENT_CONFIG_DATA);
+                for (Resource resource : resources){
+                    ExperimentConfigDataResource configDataResource = (ExperimentConfigDataResource)resource;
+                    ConfigurationData conData = ThriftDataModelConversion.getConfigurationData(configDataResource);
+                    configDataList.add(conData);
+                }
+                return configDataList;
+            }else {
+                logger.error("Unsupported field type for Experiment meta data");
+            }
+        } catch (ApplicationSettingsException e) {
+            logger.error("Unable to read airavata-server properties", e.getMessage());
+        }
+        return configDataList;
     }
 
     public Object getValue(DependentDataType dataType, Object identifier, Object field) {

http://git-wip-us.apache.org/repos/asf/airavata/blob/03bd52d8/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryImpl.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryImpl.java
b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryImpl.java
index ca394bc..2e0f40f 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryImpl.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryImpl.java
@@ -30,6 +30,7 @@ import org.apache.airavata.registry.cpi.Registry;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.ArrayList;
 import java.util.List;
 
 public class RegistryImpl implements Registry {
@@ -77,6 +78,7 @@ public class RegistryImpl implements Registry {
                 break;
             case EXPERIMENT_CONFIGURATION_DATA:
                 experimentRegistry.update(newObjectToUpdate, (String)identifier);
+                break;
             default:
                 logger.error("Unsupported data type...", new UnsupportedOperationException());
                 throw new UnsupportedOperationException();
@@ -92,6 +94,7 @@ public class RegistryImpl implements Registry {
                 break;
             case EXPERIMENT_CONFIGURATION_DATA:
                 experimentRegistry.updateExpConfigDataField((String) identifier, field, value);
+                break;
             default:
                 logger.error("Unsupported data type...", new UnsupportedOperationException());
                 throw new UnsupportedOperationException();
@@ -99,12 +102,38 @@ public class RegistryImpl implements Registry {
     }
 
     @Override
-    public List<Object> get(DataType dataType, Object fieldName, Object value) {
-        return null;
+    /**
+     * This method is to retrieve list of objects according to a given criteria
+     * @param dataType Data type is a predefined type which the programmer should choose
according to the object he
+     *                 is going to save in to registry
+     * @param fieldName FieldName is the field that filtering should be done. For example,
if we want to retrieve all
+     *                   the experiments for a given user, filterBy will be "userName"
+     * @param value value for the filtering field. In the experiment case, value for "userName"
can be "admin"
+     * @return List of objects according to the given criteria
+     */
+    public List<Object> get(DataType dataType, String fieldName, Object value) {
+        List<Object> result = new ArrayList<Object>();
+        switch (dataType){
+            case EXPERIMENT_BASIC_DATA:
+                List<BasicMetadata> experimentMetaDataList = experimentRegistry.getExperimentMetaDataList(fieldName,
value);
+                for (BasicMetadata basicMetadata : experimentMetaDataList){
+                    result.add(basicMetadata);
+                }
+                return result;
+            case EXPERIMENT_CONFIGURATION_DATA:
+                List<ConfigurationData> configurationDataList = experimentRegistry.getConfigurationDataList(fieldName,
value);
+                for (ConfigurationData configData : configurationDataList){
+                    result.add(configData);
+                }
+                return result;
+            default:
+                logger.error("Unsupported data type...", new UnsupportedOperationException());
+                throw new UnsupportedOperationException();
+        }
     }
 
     @Override
-    public Object getValue(DataType dataType, Object identifier, Object field) {
+    public Object getValue(DataType dataType, Object identifier, String field) {
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/03bd52d8/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/UserRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/UserRegistry.java
b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/UserRegistry.java
new file mode 100644
index 0000000..670f155
--- /dev/null
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/UserRegistry.java
@@ -0,0 +1,32 @@
+/*
+ *
+ * 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.airavata.persistance.registry.jpa.impl;
+
+import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
+import org.apache.airavata.persistance.registry.jpa.resources.WorkerResource;
+
+public class UserRegistry {
+    public WorkerResource getWorker (String gatewayName, String username) {
+        WorkerResource worker = (WorkerResource)ResourceUtils.getWorker(gatewayName, username);
+        return worker;
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/03bd52d8/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java
b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java
index 114416d..32e8941 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java
@@ -277,6 +277,7 @@ public class WorkerResource extends AbstractResource {
 			case EXPERIMENT_METADATA:
                 generator = new QueryGenerator(EXPERIMENT_METADATA);
                 generator.setParameter(ExperimentMetadataConstants.GATEWAY_NAME, gateway.getGatewayName());
+                generator.setParameter(ExperimentMetadataConstants.EXECUTION_USER, user);
                 q = generator.selectQuery(em);
 	            for (Object o : q.getResultList()) {
 	            	Experiment_Metadata experiment = (Experiment_Metadata) o;

http://git-wip-us.apache.org/repos/asf/airavata/blob/03bd52d8/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
new file mode 100644
index 0000000..c46099d
--- /dev/null
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java
@@ -0,0 +1,112 @@
+/*
+ *
+ * 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.airavata.persistance.registry.jpa.utils;
+
+import org.apache.airavata.model.experiment.*;
+import org.apache.airavata.persistance.registry.jpa.Resource;
+import org.apache.airavata.persistance.registry.jpa.ResourceType;
+import org.apache.airavata.persistance.registry.jpa.resources.ExperimentConfigDataResource;
+import org.apache.airavata.persistance.registry.jpa.resources.ExperimentInputResource;
+import org.apache.airavata.persistance.registry.jpa.resources.ExperimentMetadataResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ThriftDataModelConversion {
+    private final static Logger logger = LoggerFactory.getLogger(ThriftDataModelConversion.class);
+
+    public static BasicMetadata getBasicMetadata (ExperimentMetadataResource exmetadata){
+        BasicMetadata bsmd = new BasicMetadata();
+        bsmd.setUserName(exmetadata.getExecutionUser());
+        bsmd.setShareExperimentPublicly(exmetadata.isShareExp());
+        bsmd.setExperimentDescription(exmetadata.getDescription());
+        bsmd.setExperimentName(exmetadata.getExperimentName());
+        return bsmd;
+    }
+
+    public static ConfigurationData getConfigurationData (ExperimentConfigDataResource excd){
+        ConfigurationData configData = new ConfigurationData();
+        configData.setBasicMetadata(getBasicMetadata(excd.getExMetadata()));
+        configData.setApplicationId(excd.getApplicationID());
+        configData.setApplicationVersion(excd.getApplicationVersion());
+        configData.setWorkflowTemplateId(excd.getWorkflowTemplateId());
+        configData.setWorklfowTemplateVersion(excd.getWorkflowTemplateVersion());
+        configData.setExperimentInputs(getExperimentInputs(excd.getExMetadata()));
+
+
+        return configData;
+    }
+
+    private static Map<String, String> getExperimentInputs (ExperimentMetadataResource
exmdr){
+        List<Resource> resources = exmdr.get(ResourceType.EXPERIMENT_INPUT);
+        Map<String, String> exInputs = new HashMap<String, String>();
+        for (Resource resource : resources){
+            ExperimentInputResource exInput = (ExperimentInputResource)resource;
+            exInputs.put(exInput.getExperimentKey(), exInput.getValue());
+        }
+        return exInputs;
+    }
+
+    private static ComputationalResourceScheduling getComputationalResourceScheduling (ExperimentConfigDataResource
excdr){
+        ComputationalResourceScheduling scheduling = new ComputationalResourceScheduling();
+        scheduling.setAiravataAutoSchedule(excdr.isAiravataAutoSchedule());
+        scheduling.setOverrideManualScheduledParams(excdr.isOverrideManualSchedule());
+        scheduling.setResourceHostId(excdr.getResourceHostID());
+        scheduling.setTotalCPUCount(excdr.getCpuCount());
+        scheduling.setNodeCount(excdr.getNodeCount());
+        scheduling.setNumberOfThreads(excdr.getNumberOfThreads());
+        scheduling.setQueueName(excdr.getQueueName());
+        scheduling.setWallTimeLimit(excdr.getWallTimeLimit());
+        scheduling.setJobStartTime((int)excdr.getJobStartTime().getTime());
+        scheduling.setTotalPhysicalMemory(excdr.getPhysicalMemory());
+        scheduling.setComputationalProjectAccount(excdr.getProjectAccount());
+        return scheduling;
+    }
+
+    private static AdvancedInputDataHandling getAdvanceInputDataHandling(ExperimentConfigDataResource
excd){
+        AdvancedInputDataHandling adih = new AdvancedInputDataHandling();
+        adih.setStageInputFilesToWorkingDir(excd.isStageInputsToWDir());
+        adih.setWorkingDirectoryParent(excd.getWorkingDirParent());
+        adih.setUniqueWorkingDirectory(excd.getWorkingDir());
+        adih.setCleanUpWorkingDirAfterJob(excd.isCleanAfterJob());
+        return adih;
+    }
+
+    private static AdvancedOutputDataHandling getAdvanceOutputDataHandling(ExperimentConfigDataResource
excd){
+        AdvancedOutputDataHandling outputDataHandling = new AdvancedOutputDataHandling();
+        outputDataHandling.setOutputdataDir(excd.getOutputDataDir());
+        outputDataHandling.setDataRegistryURL(excd.getDataRegURL());
+        outputDataHandling.setPersistOutputData(excd.isPersistOutputData());
+        return outputDataHandling;
+    }
+
+    private static QualityOfServiceParams getQOSParams (ExperimentConfigDataResource excd){
+        QualityOfServiceParams qosParams = new QualityOfServiceParams();
+        qosParams.setStartExecutionAt(excd.getStartExecutionAt());
+        qosParams.setExecuteBefore(excd.getExecuteBefore());
+        qosParams.setNumberofRetries(excd.getNumberOfRetries());
+        return qosParams;
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/03bd52d8/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/Registry.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/Registry.java
b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/Registry.java
index 6a3c434..2222ccc 100644
--- a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/Registry.java
+++ b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/Registry.java
@@ -83,7 +83,7 @@ public interface Registry {
      * @param value value for the filtering field. In the experiment case, value for "userName"
can be "admin"
      * @return List of objects according to the given criteria
      */
-    public List<Object> get(DataType dataType, Object fieldName, Object value);
+    public List<Object> get(DataType dataType, String fieldName, Object value);
 
     /**
      * This method is to retrieve a specific value for a given field.
@@ -96,7 +96,7 @@ public interface Registry {
      * @return return the value for the specific field where data model is identified by
the unique identifier that has
      *         given
      */
-    public Object getValue (DataType dataType, Object identifier, Object field);
+    public Object getValue (DataType dataType, Object identifier, String field);
 
     /**
      * This method is to remove a item from the registry

http://git-wip-us.apache.org/repos/asf/airavata/blob/03bd52d8/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/utils/Constants.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/utils/Constants.java
b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/utils/Constants.java
index 1556d06..e0e52f9 100644
--- a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/utils/Constants.java
+++ b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/utils/Constants.java
@@ -31,6 +31,7 @@ public class Constants {
         }
 
         public final class ConfigurationDataConstants {
+            public static final String EXPERIMENT_ID = "experimentId";
             public static final String APPLICATION_ID = "applicationId";
             public static final String APPLICATION_VERSION = "applicationVersion";
             public static final String WORKFLOW_TEMPLATE_ID = "workflowTemplateId";


Mime
View raw message