You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@falcon.apache.org by sr...@apache.org on 2014/12/01 04:19:11 UTC

incubator-falcon git commit: FALCON-877 Pagination API should have a cap on number of results returned. Contributed by Ajay Yadav

Repository: incubator-falcon
Updated Branches:
  refs/heads/master eafab696c -> 107e804fc


FALCON-877 Pagination API should have a cap on number of results returned. Contributed by Ajay Yadav


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

Branch: refs/heads/master
Commit: 107e804fc57b5f6509066dcd298e94b1c17be062
Parents: eafab69
Author: srikanth.sundarrajan <sr...@apache.org>
Authored: Mon Dec 1 08:35:44 2014 +0530
Committer: srikanth.sundarrajan <sr...@apache.org>
Committed: Mon Dec 1 08:35:44 2014 +0530

----------------------------------------------------------------------
 CHANGES.txt                                      | 19 +++++++++++--------
 common/src/main/resources/runtime.properties     |  1 +
 .../falcon/resource/AbstractEntityManager.java   | 15 +++++++++++++++
 .../falcon/resource/EntityManagerTest.java       |  7 +++++++
 src/conf/runtime.properties                      |  2 +-
 5 files changed, 35 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/107e804f/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 02c4e1d..7c3df35 100755
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -7,20 +7,23 @@ Trunk (Unreleased)
   NEW FEATURES
 
   IMPROVEMENTS
-   FALCON-784 Update release notes in CHANGES.txt in branch and trunk 
-   (Venkatesh Seetharam)
+   FALCON-877 Pagination API should have a cap on number of results 
+   returned (Ajay Yadav via Srikanth Sundarrajan)
 
-   FALCON-782 Update trunk version to 0.7-incubating-SNAPSHOT (Venkatesh 
-   Seetharam)
+   FALCON-734 Document when to use Distributed Mode vs. Embedded Mode
+   (Ajay Yadav via Srikanth Sundarrajan)
+
+   FALCON-805 Create store to store feed properties like name against 
+   it's path (Ajay Yadav via Srikanth Sundarrajan)
 
    FALCON-807 Fix order of actual and expected expression in assert 
    statements in webapp module (Ajay Yadav via Srikanth Sundarrajan)
 
-   FALCON-805 Create store to store feed properties like name against 
-   it's path (Ajay Yadav via Srikanth Sundarrajan)
+   FALCON-784 Update release notes in CHANGES.txt in branch and trunk 
+   (Venkatesh Seetharam)
 
-   FALCON-734 Document when to use Distributed Mode vs. Embedded Mode
-   (Ajay Yadav via Srikanth Sundarrajan)
+   FALCON-782 Update trunk version to 0.7-incubating-SNAPSHOT (Venkatesh 
+   Seetharam)
 
   OPTIMIZATIONS
    FALCON-913 Change the default values of log clean up services

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/107e804f/common/src/main/resources/runtime.properties
----------------------------------------------------------------------
diff --git a/common/src/main/resources/runtime.properties b/common/src/main/resources/runtime.properties
index 424c00d..8d465e8 100644
--- a/common/src/main/resources/runtime.properties
+++ b/common/src/main/resources/runtime.properties
@@ -23,3 +23,4 @@
 
 *.falcon.replication.workflow.maxmaps=5
 *.falcon.replication.workflow.mapbandwidth=100
+webservices.default.max.results.per.page=100

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/107e804f/prism/src/main/java/org/apache/falcon/resource/AbstractEntityManager.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/resource/AbstractEntityManager.java b/prism/src/main/java/org/apache/falcon/resource/AbstractEntityManager.java
index 8cf4701..b6e1cec 100644
--- a/prism/src/main/java/org/apache/falcon/resource/AbstractEntityManager.java
+++ b/prism/src/main/java/org/apache/falcon/resource/AbstractEntityManager.java
@@ -61,6 +61,7 @@ public abstract class AbstractEntityManager {
 
     protected static final int XML_DEBUG_LEN = 10 * 1024;
     protected static final String DEFAULT_NUM_RESULTS = "10";
+    protected static final int MAX_RESULTS = getMaxResultsPerPage();
 
     private AbstractWorkflowEngine workflowEngine;
     protected ConfigurationStore configStore = ConfigurationStore.get();
@@ -73,6 +74,18 @@ public abstract class AbstractEntityManager {
         }
     }
 
+    private static int getMaxResultsPerPage() {
+        Integer result = 100;
+        final String key = "webservices.default.max.results.per.page";
+        String value = RuntimeProperties.get().getProperty(key, result.toString());
+        try {
+            result = Integer.valueOf(value);
+        } catch (NumberFormatException e) {
+            LOG.warn("Invalid value:{} for key:{} in runtime.properties", value, key);
+        }
+        return result;
+    }
+
     protected void checkColo(String colo) {
         if (!DeploymentUtil.getCurrentColo().equals(colo)) {
             throw FalconWebException.newException(
@@ -814,6 +827,8 @@ public abstract class AbstractEntityManager {
             // No elements to return
             return 0;
         }
+
+        numresults = numresults <= MAX_RESULTS ? numresults : MAX_RESULTS;
         int retLen = arraySize - offset;
         if (retLen > numresults) {
             retLen = numresults;

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/107e804f/prism/src/test/java/org/apache/falcon/resource/EntityManagerTest.java
----------------------------------------------------------------------
diff --git a/prism/src/test/java/org/apache/falcon/resource/EntityManagerTest.java b/prism/src/test/java/org/apache/falcon/resource/EntityManagerTest.java
index e39947a..1862e39 100644
--- a/prism/src/test/java/org/apache/falcon/resource/EntityManagerTest.java
+++ b/prism/src/test/java/org/apache/falcon/resource/EntityManagerTest.java
@@ -160,6 +160,13 @@ public class EntityManagerTest extends AbstractEntityManager {
         CurrentUser.authenticate(System.getProperty("user.name"));
     }
 
+
+    @Test
+    public void testCapOnNumberOfResults() {
+        Assert.assertNotEquals(getRequiredNumberOfResults(10000, 0, 10000), 10000);
+        Assert.assertEquals(getRequiredNumberOfResults(10000, 0, 10000), MAX_RESULTS);
+    }
+
     @Test
     public void testGetEntityListPagination() throws Exception {
         String user = System.getProperty("user.name");

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/107e804f/src/conf/runtime.properties
----------------------------------------------------------------------
diff --git a/src/conf/runtime.properties b/src/conf/runtime.properties
index d5a8025..0dc43c6 100644
--- a/src/conf/runtime.properties
+++ b/src/conf/runtime.properties
@@ -28,4 +28,4 @@ prism.all.colos=local
 prism.falcon.local.endpoint=https://localhost:15443
 #falcon server should have the following properties
 falcon.current.colo=local
-
+webservices.default.max.results.per.page=100