falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajayyad...@apache.org
Subject falcon git commit: FALCON-1743 Entity summary does not work via prism.
Date Mon, 14 Mar 2016 10:04:16 GMT
Repository: falcon
Updated Branches:
  refs/heads/master d08d3bdbe -> 6b097cb26


FALCON-1743 Entity summary does not work via prism.

Author: Ajay Yadava <ajaynsit@gmail.com>

Reviewers: Sandeep Samudrala, Pallavi Rao, Deepak Barr

Closes #65 from ajayyadava/1743


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

Branch: refs/heads/master
Commit: 6b097cb26fc3e4173bfbc8d66f393eb5880804c1
Parents: d08d3bd
Author: Ajay Yadava <ajaynsit@gmail.com>
Authored: Mon Mar 14 15:33:47 2016 +0530
Committer: Ajay Yadava <ajaynsit@gmail.com>
Committed: Mon Mar 14 15:33:47 2016 +0530

----------------------------------------------------------------------
 .../falcon/resource/EntitySummaryResult.java    | 15 +++++++++
 .../proxy/SchedulableEntityManagerProxy.java    | 34 ++++++++++++++++----
 2 files changed, 42 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/falcon/blob/6b097cb2/client/src/main/java/org/apache/falcon/resource/EntitySummaryResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/resource/EntitySummaryResult.java b/client/src/main/java/org/apache/falcon/resource/EntitySummaryResult.java
index 3ebfe26..4d42b42 100644
--- a/client/src/main/java/org/apache/falcon/resource/EntitySummaryResult.java
+++ b/client/src/main/java/org/apache/falcon/resource/EntitySummaryResult.java
@@ -67,6 +67,21 @@ public class EntitySummaryResult extends APIResult {
         this.entitySummaries = entitySummaries;
     }
 
+    @Override
+    public Object[] getCollection() {
+        return entitySummaries;
+    }
+
+    @Override
+    public void setCollection(Object[] items) {
+        if (items == null) {
+            setEntitySummaries(new EntitySummary[0]);
+        } else {
+            EntitySummary[] summaries = Arrays.copyOf(items, items.length, EntitySummary[].class);
+            setEntitySummaries(summaries);
+        }
+    }
+
     /**
      * A single entity object inside entity summary result.
      */

http://git-wip-us.apache.org/repos/asf/falcon/blob/6b097cb2/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java
b/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java
index 2dc727d..168f18e 100644
--- a/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java
+++ b/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java
@@ -659,7 +659,7 @@ public class SchedulableEntityManagerProxy extends AbstractSchedulableEntityMana
     /**
      * Given an EntityType and cluster, get list of entities along with summary of N recent
instances of each entity.
      * @param type Valid options are feed or process.
-     * @param cluster Show entities that belong to this cluster.
+     * @param clusterName Show entities that belong to this cluster.
      * @param startStr <optional param> Show entity summaries from this date. Date
format is yyyy-MM-dd'T'HH:mm'Z'.
      *                 By default, it is set to (end - 2 days).
      * @param endStr <optional param> Show entity summary up to this date. Date format
is yyyy-MM-dd'T'HH:mm'Z'.
@@ -690,20 +690,40 @@ public class SchedulableEntityManagerProxy extends AbstractSchedulableEntityMana
     @Override
     public EntitySummaryResult getEntitySummary(
             @Dimension("type") @PathParam("type") final String type,
-            @Dimension("cluster") @QueryParam("cluster") final String cluster,
-            @DefaultValue("") @QueryParam("start") String startStr,
-            @DefaultValue("") @QueryParam("end") String endStr,
+            @Dimension("cluster") @QueryParam("cluster") final String clusterName,
+            @DefaultValue("") @QueryParam("start") final String startStr,
+            @DefaultValue("") @QueryParam("end") final String endStr,
             @DefaultValue("") @QueryParam("fields") final String entityFields,
             @DefaultValue("") @QueryParam("filterBy") final String entityFilter,
             @DefaultValue("") @QueryParam("tags") final String entityTags,
             @DefaultValue("") @QueryParam("orderBy") final String entityOrderBy,
-            @DefaultValue("asc") @QueryParam("sortOrder") String entitySortOrder,
+            @DefaultValue("asc") @QueryParam("sortOrder") final String entitySortOrder,
             @DefaultValue("0") @QueryParam("offset") final Integer entityOffset,
             @DefaultValue("10") @QueryParam("numResults") final Integer numEntities,
             @DefaultValue("7") @QueryParam("numInstances") final Integer numInstanceResults,
             @DefaultValue("") @QueryParam("doAs") final String doAsUser) {
-        return super.getEntitySummary(type, cluster, startStr, endStr, entityFields, entityFilter,
-                entityTags, entityOrderBy, entitySortOrder, entityOffset, numEntities, numInstanceResults,
doAsUser);
+        final String entityName = null;
+        return new EntityProxy<EntitySummaryResult>(type, null, EntitySummaryResult.class)
{
+            @Override
+            protected Set<String> getColosToApply() {
+                Set<String> result = new HashSet<>();
+                try {
+                    Cluster cluster = EntityUtil.getEntity(EntityType.CLUSTER, clusterName);
+                    result.add(cluster.getColo());
+                } catch (FalconException e) {
+                    // ignore, just return blank result
+                }
+                return result;
+            }
+
+            @Override
+            protected EntitySummaryResult doExecute(String colo) throws FalconException {
+                EntitySummaryResult es = getEntityManager(colo).invoke("getEntitySummary",
type, clusterName, startStr,
+                    endStr, entityFields, entityFilter, entityTags, entityOrderBy, entitySortOrder,
entityOffset,
+                    numEntities, numInstanceResults, doAsUser);
+                return es;
+            }
+        }.execute();
     }
 
     /**


Mime
View raw message