Adding getExperimentStatistics API method

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

Branch: refs/heads/master
Commit: 2c6620f03f5d5ba9d7255f65156adffbe687ff18
Parents: 3224e72
Author: Supun Nakandala <[email protected]>
Authored: Wed Jun 10 22:23:17 2015 +0530
Committer: Supun Nakandala <[email protected]>
Committed: Wed Jun 10 22:23:17 2015 +0530

----------------------------------------------------------------------
 .../server/handler/AiravataServerHandler.java   |    36 +
 .../java/org/apache/airavata/api/Airavata.java  | 16246 +++++++++--------
 .../experiment/ExperimentStatistics.java        |  1280 ++
 .../airavata-api/airavataAPI.thrift             |    15 +
 .../airavata-api/experimentModel.thrift         |    11 +
 .../catalog/impl/ExperimentCatalogImpl.java     |     3 +
 .../catalog/impl/ExperimentRegistry.java        |    51 +
 .../resources/ExperimentStatisticsResource.java |   133 +
 .../catalog/resources/WorkerResource.java       |   287 +-
 .../cpi/ExperimentCatalogModelType.java         |     1 +
 10 files changed, 10515 insertions(+), 7548 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/2c6620f0/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
----------------------------------------------------------------------
diff --git 
a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
 
b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
index 3f0fc0d..915973a 100644
--- 
a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
+++ 
b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
@@ -1003,6 +1003,42 @@ public class AiravataServerHandler implements 
Airavata.Iface {
     }
 
     /**
+     * Get Experiment execution statisitics by sending the gateway id and the 
time period interested in.
+     * This method will retrun an ExperimentStatistics object which contains 
the number of successfully
+     * completed experiments, failed experiments etc.
+     * @param gatewayId
+     * @param fromTime
+     * @param toTime
+     * @return
+     * @throws InvalidRequestException
+     * @throws AiravataClientException
+     * @throws AiravataSystemException
+     * @throws TException
+     */
+    @Override
+    public ExperimentStatistics getExperimentStatistics(String gatewayId, long 
fromTime, long toTime) throws InvalidRequestException, AiravataClientException, 
AiravataSystemException, TException {
+        if (!isGatewayExist(gatewayId)){
+            logger.error("Gateway does not exist.Please provide a valid 
gateway id...");
+            throw new 
AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
+        }
+        try {
+            Map<String, String> filters = new HashMap();
+            filters.put(Constants.FieldConstants.ExperimentConstants.GATEWAY, 
gatewayId);
+            
filters.put(Constants.FieldConstants.ExperimentConstants.FROM_DATE, 
fromTime+"");
+            filters.put(Constants.FieldConstants.ExperimentConstants.TO_DATE, 
toTime+"");
+
+            List<Object> results = 
experimentCatalog.search(ExperimentCatalogModelType.EXPERIMENT_STATISTICS, 
filters);
+            return (ExperimentStatistics) results.get(0);
+        }catch (Exception e) {
+            logger.error("Error while retrieving experiments", e);
+            AiravataSystemException exception = new AiravataSystemException();
+            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+            exception.setMessage("Error while retrieving experiments. More 
info : " + e.getMessage());
+            throw exception;
+        }
+    }
+
+    /**
      * Get all Experiments within a Project
      *
      * @param projectId

Reply via email to