falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From venkat...@apache.org
Subject [3/3] git commit: FALCON-640 Add ability to specify sort order for orderBy param in RestAPI. Contributed by Balu Vellanki
Date Tue, 02 Sep 2014 20:43:15 GMT
FALCON-640 Add ability to specify sort order for orderBy param in RestAPI. Contributed by Balu Vellanki


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

Branch: refs/heads/master
Commit: 2ed0112e0e2379ff95968dd33b86ebe261cf208b
Parents: 7cfa00d
Author: Venkatesh Seetharam <venkatesh@apache.org>
Authored: Tue Sep 2 13:42:38 2014 -0700
Committer: Venkatesh Seetharam <venkatesh@apache.org>
Committed: Tue Sep 2 13:42:38 2014 -0700

----------------------------------------------------------------------
 CHANGES.txt                                     |   3 +
 .../java/org/apache/falcon/cli/FalconCLI.java   |  29 +++-
 .../org/apache/falcon/client/FalconClient.java  | 133 ++++++++++---------
 docs/src/site/twiki/FalconCLI.twiki             |  12 +-
 docs/src/site/twiki/restapi/EntityList.twiki    |   1 +
 docs/src/site/twiki/restapi/EntitySummary.twiki |   1 +
 docs/src/site/twiki/restapi/InstanceList.twiki  |   1 +
 docs/src/site/twiki/restapi/InstanceLogs.twiki  |   1 +
 .../site/twiki/restapi/InstanceRunning.twiki    |   1 +
 .../src/site/twiki/restapi/InstanceStatus.twiki |   1 +
 .../falcon/resource/AbstractEntityManager.java  |  39 +++---
 .../resource/AbstractInstanceManager.java       |  49 ++++---
 .../AbstractSchedulableEntityManager.java       |   6 +-
 .../resource/proxy/InstanceManagerProxy.java    |  12 +-
 .../proxy/SchedulableEntityManagerProxy.java    |  36 ++---
 .../falcon/resource/EntityManagerTest.java      |  29 ++--
 .../apache/falcon/resource/InstanceManager.java |  13 +-
 .../resource/SchedulableEntityManager.java      |   8 +-
 .../java/org/apache/falcon/cli/FalconCLIIT.java |  62 +++++++--
 .../falcon/resource/EntityManagerJerseyIT.java  |   5 +-
 20 files changed, 277 insertions(+), 165 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2ed0112e/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 085fa8e..f554236 100755
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -27,6 +27,9 @@ Trunk (Unreleased)
    FALCON-263 API to get workflow parameters. (pavan kumar kolamuri via Shwetha GS)
 
   IMPROVEMENTS
+   FALCON-640 Add ability to specify sort order for orderBy param in RestAPI
+   (Balu Vellanki via Venkatesh Seetharam)
+
    FALCON-594 Process lineage information for Retention policies
    (Sowmya Ramesh via Venkatesh Seetharam)
 

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2ed0112e/client/src/main/java/org/apache/falcon/cli/FalconCLI.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/cli/FalconCLI.java b/client/src/main/java/org/apache/falcon/cli/FalconCLI.java
index a42da13..d6e3598 100644
--- a/client/src/main/java/org/apache/falcon/cli/FalconCLI.java
+++ b/client/src/main/java/org/apache/falcon/cli/FalconCLI.java
@@ -86,6 +86,7 @@ public class FalconCLI {
     public static final String FILTER_BY_OPT = "filterBy";
     public static final String TAGS_OPT = "tags";
     public static final String ORDER_BY_OPT = "orderBy";
+    public static final String SORT_ORDER_OPT = "sortOrder";
     public static final String OFFSET_OPT = "offset";
     public static final String NUM_RESULTS_OPT = "numResults";
     public static final String NUM_INSTANCES_OPT = "numInstances";
@@ -229,24 +230,27 @@ public class FalconCLI {
         List<LifeCycle> lifeCycles = getLifeCycle(commandLine.getOptionValue(LIFECYCLE_OPT));
         String filterBy = commandLine.getOptionValue(FILTER_BY_OPT);
         String orderBy = commandLine.getOptionValue(ORDER_BY_OPT);
+        String sortOrder = commandLine.getOptionValue(SORT_ORDER_OPT);
         Integer offset = parseIntegerInput(commandLine.getOptionValue(OFFSET_OPT), 0, "offset");
         Integer numResults = parseIntegerInput(commandLine.getOptionValue(NUM_RESULTS_OPT),
                 FalconClient.DEFAULT_NUM_RESULTS, "numResults");
 
         colo = getColo(colo);
         String instanceAction = "instance";
+        validateSortOrder(sortOrder);
         validateInstanceCommands(optionsList, entity, type, colo);
 
 
         if (optionsList.contains(RUNNING_OPT)) {
             validateOrderBy(orderBy, instanceAction);
             validateFilterBy(filterBy, instanceAction);
-            result = client.getRunningInstances(type, entity, colo, lifeCycles, filterBy, orderBy, offset, numResults);
+            result = client.getRunningInstances(type, entity, colo, lifeCycles, filterBy, orderBy, sortOrder,
+                    offset, numResults);
         } else if (optionsList.contains(STATUS_OPT) || optionsList.contains(LIST_OPT)) {
             validateOrderBy(orderBy, instanceAction);
             validateFilterBy(filterBy, instanceAction);
             result = client.getStatusOfInstances(type, entity, start, end, colo, lifeCycles,
-                    filterBy, orderBy, offset, numResults);
+                    filterBy, orderBy, sortOrder, offset, numResults);
         } else if (optionsList.contains(SUMMARY_OPT)) {
             result = client.getSummaryOfInstances(type, entity, start, end, colo, lifeCycles);
         } else if (optionsList.contains(KILL_OPT)) {
@@ -264,7 +268,7 @@ public class FalconCLI {
             validateOrderBy(orderBy, instanceAction);
             validateFilterBy(filterBy, instanceAction);
             result = client.getLogsOfInstances(type, entity, start, end, colo, runId, lifeCycles,
-                    filterBy, orderBy, offset, numResults);
+                    filterBy, orderBy, sortOrder, offset, numResults);
         } else if (optionsList.contains(PARARMS_OPT)) {
             // start time is the nominal time of instance
             result = client.getParamsOfInstance(type, entity, start, colo, clusters, sourceClusters, lifeCycles);
@@ -340,6 +344,7 @@ public class FalconCLI {
         String end = commandLine.getOptionValue(END_OPT);
         String time = commandLine.getOptionValue(EFFECTIVE_OPT);
         String orderBy = commandLine.getOptionValue(ORDER_BY_OPT);
+        String sortOrder = commandLine.getOptionValue(SORT_ORDER_OPT);
         String filterBy = commandLine.getOptionValue(FILTER_BY_OPT);
         String filterTags = commandLine.getOptionValue(TAGS_OPT);
         String fields = commandLine.getOptionValue(FIELDS_OPT);
@@ -348,6 +353,7 @@ public class FalconCLI {
                 FalconClient.DEFAULT_NUM_RESULTS, "numResults");
         Integer numInstances = parseIntegerInput(commandLine.getOptionValue(NUM_INSTANCES_OPT), 7, "numInstances");
         validateEntityType(entityType);
+        validateSortOrder(sortOrder);
         String entityAction = "entity";
 
         if (optionsList.contains(SUBMIT_OPT)) {
@@ -402,7 +408,7 @@ public class FalconCLI {
             validateOrderBy(orderBy, entityAction);
             validateFilterBy(filterBy, entityAction);
             EntityList entityList = client.getEntityList(entityType, fields, filterBy,
-                    filterTags, orderBy, offset, numResults);
+                    filterTags, orderBy, sortOrder, offset, numResults);
             result = entityList != null ? entityList.toString() : "No entity of type (" + entityType + ") found.";
         }  else if (optionsList.contains(SUMMARY_OPT)) {
             validateCluster(cluster);
@@ -410,7 +416,7 @@ public class FalconCLI {
             validateFilterBy(filterBy, entityAction);
             validateOrderBy(orderBy, entityAction);
             result = client.getEntitySummary(entityType, cluster, start, end, fields, filterBy, filterTags,
-                    orderBy, offset, numResults, numInstances);
+                    orderBy, sortOrder, offset, numResults, numInstances);
         } else if (optionsList.contains(HELP_CMD)) {
             OUT.get().println("Falcon Help");
         } else {
@@ -419,6 +425,15 @@ public class FalconCLI {
         OUT.get().println(result);
     }
 
+    private void validateSortOrder(String sortOrder) throws FalconCLIException {
+        if (!StringUtils.isEmpty(sortOrder)) {
+            if (!sortOrder.equalsIgnoreCase("asc") && !sortOrder.equalsIgnoreCase("desc")) {
+                throw new FalconCLIException("Value for param sortOrder should be \"asc\" or \"desc\". It is  : "
+                        + sortOrder);
+            }
+        }
+    }
+
     private void validateCluster(String cluster) throws FalconCLIException {
         if (StringUtils.isEmpty(cluster)) {
             throw new FalconCLIException("Missing argument: cluster");
@@ -617,6 +632,7 @@ public class FalconCLI {
         Option filterTags = new Option(TAGS_OPT, true, "Filter returned entities by the specified tags");
         Option orderBy = new Option(ORDER_BY_OPT, true,
                 "Order returned entities by this field");
+        Option sortOrder = new Option(SORT_ORDER_OPT, true, "asc or desc order for results");
         Option offset = new Option(OFFSET_OPT, true,
                 "Start returning entities from this offset");
         Option numResults = new Option(NUM_RESULTS_OPT, true,
@@ -638,6 +654,7 @@ public class FalconCLI {
         entityOptions.addOption(filterBy);
         entityOptions.addOption(filterTags);
         entityOptions.addOption(orderBy);
+        entityOptions.addOption(sortOrder);
         entityOptions.addOption(offset);
         entityOptions.addOption(numResults);
         entityOptions.addOption(numInstances);
@@ -747,6 +764,7 @@ public class FalconCLI {
                 "Filter returned instances by the specified fields");
         Option orderBy = new Option(ORDER_BY_OPT, true,
                 "Order returned instances by this field");
+        Option sortOrder = new Option(SORT_ORDER_OPT, true, "asc or desc order for results");
         Option offset = new Option(OFFSET_OPT, true,
                 "Start returning instances from this offset");
         Option numResults = new Option(NUM_RESULTS_OPT, true,
@@ -767,6 +785,7 @@ public class FalconCLI {
         instanceOptions.addOption(filterBy);
         instanceOptions.addOption(offset);
         instanceOptions.addOption(orderBy);
+        instanceOptions.addOption(sortOrder);
         instanceOptions.addOption(numResults);
 
         return instanceOptions;

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2ed0112e/client/src/main/java/org/apache/falcon/client/FalconClient.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/client/FalconClient.java b/client/src/main/java/org/apache/falcon/client/FalconClient.java
index 619955b..73635fa 100644
--- a/client/src/main/java/org/apache/falcon/client/FalconClient.java
+++ b/client/src/main/java/org/apache/falcon/client/FalconClient.java
@@ -338,34 +338,37 @@ public class FalconClient {
     //SUSPEND CHECKSTYLE CHECK ParameterNumberCheck
 
     public EntityList getEntityList(String entityType, String fields, String filterBy, String filterTags,
-                                    String orderBy, Integer offset, Integer numResults) throws FalconCLIException {
+                                    String orderBy, String sortOrder,
+                                    Integer offset, Integer numResults) throws FalconCLIException {
         return sendListRequest(Entities.LIST, entityType, fields, filterBy,
-                filterTags, orderBy, offset, numResults);
+                filterTags, orderBy, sortOrder, offset, numResults);
     }
 
     public String getEntitySummary(String entityType, String cluster, String start, String end,
                                    String fields, String filterBy, String filterTags,
-                                   String orderBy, Integer offset, Integer numResults, Integer numInstances)
+                                   String orderBy, String sortOrder,
+                                   Integer offset, Integer numResults, Integer numInstances)
         throws FalconCLIException {
         return sendEntitySummaryRequest(Entities.SUMMARY, entityType, cluster, start, end, fields, filterBy, filterTags,
-                orderBy, offset, numResults, numInstances);
+                orderBy, sortOrder, offset, numResults, numInstances);
     }
 
     public String getRunningInstances(String type, String entity, String colo, List<LifeCycle> lifeCycles,
-                                      String filterBy, String orderBy, Integer offset, Integer numResults)
-        throws FalconCLIException {
+                                      String filterBy, String orderBy, String sortOrder,
+                                      Integer offset, Integer numResults) throws FalconCLIException {
 
         return sendInstanceRequest(Instances.RUNNING, type, entity, null, null,
-                null, null, colo, lifeCycles, filterBy, orderBy, offset, numResults);
+                null, null, colo, lifeCycles, filterBy, orderBy, sortOrder, offset, numResults);
     }
 
     public String getStatusOfInstances(String type, String entity,
                                        String start, String end,
                                        String colo, List<LifeCycle> lifeCycles, String filterBy,
-                                       String orderBy, Integer offset, Integer numResults) throws FalconCLIException {
+                                       String orderBy, String sortOrder,
+                                       Integer offset, Integer numResults) throws FalconCLIException {
 
         return sendInstanceRequest(Instances.STATUS, type, entity, start, end,
-                null, null, colo, lifeCycles, filterBy, orderBy, offset, numResults);
+                null, null, colo, lifeCycles, filterBy, orderBy, sortOrder, offset, numResults);
     }
 
     public String getSummaryOfInstances(String type, String entity,
@@ -440,11 +443,11 @@ public class FalconClient {
     public String getLogsOfInstances(String type, String entity, String start,
                                      String end, String colo, String runId,
                                      List<LifeCycle> lifeCycles, String filterBy,
-                                     String orderBy, Integer offset, Integer numResults)
+                                     String orderBy, String sortOrder, Integer offset, Integer numResults)
         throws FalconCLIException {
 
         return sendInstanceRequest(Instances.LOG, type, entity, start, end,
-                null, runId, colo, lifeCycles, filterBy, orderBy, offset, numResults);
+                null, runId, colo, lifeCycles, filterBy, orderBy, sortOrder, offset, numResults);
     }
 
     public String getParamsOfInstance(String type, String entity,
@@ -533,23 +536,17 @@ public class FalconClient {
         return parseAPIResult(clientResponse);
     }
 
-    private String sendEntitySummaryRequest(Entities entities, String entityType, String cluster,
-                                            String start, String end,
-                                            String fields, String filterBy, String filterTags,
-                                            String orderBy, Integer offset, Integer numResults,
-                                            Integer numInstances) throws FalconCLIException {
-        WebResource resource;
-        if (StringUtils.isEmpty(cluster)) {
-            resource = service.path(entities.path).path(entityType);
-        } else {
-            resource = service.path(entities.path).path(entityType).path(cluster);
-        }
+    private WebResource addParamsToResource(WebResource resource,
+                                            String start, String end, String runId, String colo,
+                                            String fields, String filterBy, String tags,
+                                            String orderBy, String sortOrder,
+                                            Integer offset, Integer numResults, Integer numInstances) {
 
         if (!StringUtils.isEmpty(fields)) {
             resource = resource.queryParam("fields", fields);
         }
-        if (!StringUtils.isEmpty(filterTags)) {
-            resource = resource.queryParam("tags", filterTags);
+        if (!StringUtils.isEmpty(tags)) {
+            resource = resource.queryParam("tags", tags);
         }
         if (!StringUtils.isEmpty(filterBy)) {
             resource = resource.queryParam("filterBy", filterBy);
@@ -557,16 +554,50 @@ public class FalconClient {
         if (!StringUtils.isEmpty(orderBy)) {
             resource = resource.queryParam("orderBy", orderBy);
         }
+        if (!StringUtils.isEmpty(sortOrder)) {
+            resource = resource.queryParam("sortOrder", sortOrder);
+        }
         if (!StringUtils.isEmpty(start)) {
             resource = resource.queryParam("start", start);
         }
         if (!StringUtils.isEmpty(end)) {
             resource = resource.queryParam("end", end);
         }
+        if (runId != null) {
+            resource = resource.queryParam("runid", runId);
+        }
+        if (colo != null) {
+            resource = resource.queryParam("colo", colo);
+        }
+        if (offset != null) {
+            resource = resource.queryParam("offset", offset.toString());
+        }
+        if (numResults != null) {
+            resource = resource.queryParam("numResults", numResults.toString());
+        }
+        if (numInstances != null) {
+            resource = resource.queryParam("numInstances", numInstances.toString());
+        }
+        return resource;
+
+    }
+
+    private String sendEntitySummaryRequest(Entities entities, String entityType, String cluster,
+                                            String start, String end,
+                                            String fields, String filterBy, String filterTags,
+                                            String orderBy, String sortOrder, Integer offset, Integer numResults,
+                                            Integer numInstances) throws FalconCLIException {
+        WebResource resource;
+        if (StringUtils.isEmpty(cluster)) {
+            resource = service.path(entities.path).path(entityType);
+        } else {
+            resource = service.path(entities.path).path(entityType).path(cluster);
+        }
 
-        resource = resource.queryParam("offset", offset.toString());
-        resource = resource.queryParam("numResults", numResults.toString());
-        resource = resource.queryParam("numInstances", numInstances.toString());
+        resource = addParamsToResource(resource, start, end, null, null,
+                fields, filterBy, filterTags,
+                orderBy, sortOrder,
+                offset, numResults, numInstances);
 
         ClientResponse clientResponse = resource
                 .header("Cookie", AUTH_COOKIE_EQ + authenticationToken)
@@ -628,36 +659,19 @@ public class FalconClient {
                                        String runid, String colo,
                                        List<LifeCycle> lifeCycles) throws FalconCLIException {
         return sendInstanceRequest(instances, type, entity, start, end, props,
-                runid, colo, lifeCycles, "", "", 0, DEFAULT_NUM_RESULTS);
+                runid, colo, lifeCycles, "", "", "", 0, DEFAULT_NUM_RESULTS);
     }
 
     private String sendInstanceRequest(Instances instances, String type, String entity,
                                        String start, String end, InputStream props, String runid, String colo,
-                                       List<LifeCycle> lifeCycles, String filterBy,
-                                       String orderBy, Integer offset, Integer numResults) throws FalconCLIException {
+                                       List<LifeCycle> lifeCycles, String filterBy, String orderBy, String sortOrder,
+                                       Integer offset, Integer numResults) throws FalconCLIException {
         checkType(type);
         WebResource resource = service.path(instances.path).path(type)
                 .path(entity);
-        if (start != null) {
-            resource = resource.queryParam("start", start);
-        }
-        if (end != null) {
-            resource = resource.queryParam("end", end);
-        }
-        if (runid != null) {
-            resource = resource.queryParam("runid", runid);
-        }
-        if (colo != null) {
-            resource = resource.queryParam("colo", colo);
-        }
-        if (!StringUtils.isEmpty(filterBy)) {
-            resource = resource.queryParam("filterBy", filterBy);
-        }
-        if (!StringUtils.isEmpty(orderBy)) {
-            resource = resource.queryParam("orderBy", orderBy);
-        }
-        resource = resource.queryParam("offset", offset.toString());
-        resource = resource.queryParam("numResults", numResults.toString());
+
+        resource = addParamsToResource(resource, start, end, runid, colo,
+                null, filterBy, null, orderBy, sortOrder, offset, numResults, null);
 
         if (lifeCycles != null) {
             checkLifeCycleOption(lifeCycles, type);
@@ -717,24 +731,13 @@ public class FalconClient {
 
     //SUSPEND CHECKSTYLE CHECK ParameterNumberCheck
     private EntityList sendListRequest(Entities entities, String entityType, String fields, String filterBy,
-                                       String filterTags, String orderBy, Integer offset,
+                                       String filterTags, String orderBy, String sortOrder, Integer offset,
                                        Integer numResults) throws FalconCLIException {
         WebResource resource = service.path(entities.path)
                 .path(entityType);
-        if (!StringUtils.isEmpty(filterBy)) {
-            resource = resource.queryParam("filterBy", filterBy);
-        }
-        if (!StringUtils.isEmpty(orderBy)) {
-            resource = resource.queryParam("orderBy", orderBy);
-        }
-        if (!StringUtils.isEmpty(fields)) {
-            resource = resource.queryParam("fields", fields);
-        }
-        if (!StringUtils.isEmpty(filterTags)) {
-            resource = resource.queryParam("tags", filterTags);
-        }
-        resource = resource.queryParam("offset", offset.toString());
-        resource = resource.queryParam("numResults", numResults.toString());
+        resource = addParamsToResource(resource, null, null, null, null, fields, filterBy, filterTags,
+                orderBy, sortOrder, offset, numResults, null);
+
         ClientResponse clientResponse = resource
                 .header("Cookie", AUTH_COOKIE_EQ + authenticationToken)
                 .accept(entities.mimeType).type(MediaType.TEXT_XML)

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2ed0112e/docs/src/site/twiki/FalconCLI.twiki
----------------------------------------------------------------------
diff --git a/docs/src/site/twiki/FalconCLI.twiki b/docs/src/site/twiki/FalconCLI.twiki
index 4ea80c1..3b945e9 100644
--- a/docs/src/site/twiki/FalconCLI.twiki
+++ b/docs/src/site/twiki/FalconCLI.twiki
@@ -52,7 +52,7 @@ Usage:
 $FALCON_HOME/bin/falcon entity -type [cluster|feed|process] -list
 
 Optional Args : -fields <<field1,field2>> -filterBy <<field1:value1,field2:value2>> -tags <<tagkey=tagvalue,tagkey=tagvalue>>
--orderBy <<field>> -offset 0 -numResults 10
+-orderBy <<field>> -sortOrder <<sortOrder>> -offset 0 -numResults 10
 
 <a href="./Restapi/EntityList.html">Optional params described here.</a>
 
@@ -65,7 +65,7 @@ $FALCON_HOME/bin/falcon entity -type [cluster|feed|process] -summary
 
 Optional Args : -start "yyyy-MM-dd'T'HH:mm'Z'" -end "yyyy-MM-dd'T'HH:mm'Z'" -fields <<field1,field2>>
 -filterBy <<field1:value1,field2:value2>> -tags <<tagkey=tagvalue,tagkey=tagvalue>>
--orderBy <<field>> -offset 0 -numResults 10 -numInstances 7
+-orderBy <<field>> -sortOrder <<sortOrder>> -offset 0 -numResults 10 -numInstances 7
 
 <a href="./Restapi/EntitySummary.html">Optional params described here.</a>
 
@@ -157,7 +157,7 @@ $FALCON_HOME/bin/falcon instance -type <<feed/process>> -name <<name>> -status
 
 Optional Args : -start "yyyy-MM-dd'T'HH:mm'Z'" -end "yyyy-MM-dd'T'HH:mm'Z'" -colo <<colo>>
 -filterBy <<field1:value1,field2:value2>> -lifecycle <<lifecycles>>
--orderBy field -offset 0 -numResults 10
+-orderBy field -sortOrder <<sortOrder>> -offset 0 -numResults 10
 
 <a href="./Restapi/InstanceStatus.html"> Optional params described here.</a>
 
@@ -175,7 +175,7 @@ $FALCON_HOME/bin/falcon instance -type <<feed/process>> -name <<name>> -list
 
 Optional Args : -start "yyyy-MM-dd'T'HH:mm'Z'" -end "yyyy-MM-dd'T'HH:mm'Z'"
 -colo <<colo>> -lifecycle <<lifecycles>>
--filterBy <<field1:value1,field2:value2>> -orderBy field -offset 0 -numResults 10
+-filterBy <<field1:value1,field2:value2>> -orderBy field -sortOrder <<sortOrder>> -offset 0 -numResults 10
 
 <a href="./Restapi/InstanceList.html">Optional params described here.</a>
 
@@ -205,7 +205,7 @@ Usage:
 $FALCON_HOME/bin/falcon instance -type <<feed/process>> -name <<name>> -running
 
 Optional Args : -colo <<colo>> -lifecycle <<lifecycles>>
--filterBy <<field1:value1,field2:value2>> -orderBy <<field>> -offset 0 -numResults 10
+-filterBy <<field1:value1,field2:value2>> -orderBy <<field>> -sortOrder <<sortOrder>> -offset 0 -numResults 10
 
 <a href="./Restapi/InstanceRunning.html">Optional params described here.</a>
 
@@ -218,7 +218,7 @@ $FALCON_HOME/bin/falcon instance -type <<feed/process>> -name <<name>> -logs
 
 Optional Args : -start "yyyy-MM-dd'T'HH:mm'Z'" -end "yyyy-MM-dd'T'HH:mm'Z'" -runid <<runid>>
 -colo <<colo>> -lifecycle <<lifecycles>>
--filterBy <<field1:value1,field2:value2>> -orderBy field -offset 0 -numResults 10
+-filterBy <<field1:value1,field2:value2>> -orderBy field -sortOrder <<sortOrder>> -offset 0 -numResults 10
 
 <a href="./Restapi/InstanceLogs.html">Optional params described here.</a>
 

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2ed0112e/docs/src/site/twiki/restapi/EntityList.twiki
----------------------------------------------------------------------
diff --git a/docs/src/site/twiki/restapi/EntityList.twiki b/docs/src/site/twiki/restapi/EntityList.twiki
index 353007c..b569ade 100644
--- a/docs/src/site/twiki/restapi/EntityList.twiki
+++ b/docs/src/site/twiki/restapi/EntityList.twiki
@@ -18,6 +18,7 @@ Get list of the entities.
       * Example: tags=consumer=consumer@xyz.com,owner=producer@xyz.com
    * orderBy <optional param> Field by which results should be ordered.
       * Supports ordering by "name".
+   * sortOrder <optional param> Valid options are "asc" and "desc"
    * offset <optional param> Show results from the offset, used for pagination. Defaults to 0.
    * numResults <optional param> Number of results to show per request, used for pagination. Only integers > 0 are valid, Default is 10.
 

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2ed0112e/docs/src/site/twiki/restapi/EntitySummary.twiki
----------------------------------------------------------------------
diff --git a/docs/src/site/twiki/restapi/EntitySummary.twiki b/docs/src/site/twiki/restapi/EntitySummary.twiki
index 6e6ddf4..f002d81 100644
--- a/docs/src/site/twiki/restapi/EntitySummary.twiki
+++ b/docs/src/site/twiki/restapi/EntitySummary.twiki
@@ -23,6 +23,7 @@ Given an EntityType and cluster, get list of entities along with summary of N re
       * Example: tags=consumer=consumer@xyz.com,owner=producer@xyz.com
    * orderBy <optional param> Field by which results should be ordered.
       * Supports ordering by "name".
+   * sortOrder <optional param> Valid options are "asc" and "desc"
    * offset <optional param> Show results from the offset, used for pagination. Defaults to 0.
    * numResults <optional param> Number of results to show per request, used for pagination. Only integers > 0 are valid, Default is 10.
    * numInstances <optional param> Number of recent instances to show per entity. Only integers > 0 are valid, Default is 7.

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2ed0112e/docs/src/site/twiki/restapi/InstanceList.twiki
----------------------------------------------------------------------
diff --git a/docs/src/site/twiki/restapi/InstanceList.twiki b/docs/src/site/twiki/restapi/InstanceList.twiki
index 76eaa33..2cd9b1c 100644
--- a/docs/src/site/twiki/restapi/InstanceList.twiki
+++ b/docs/src/site/twiki/restapi/InstanceList.twiki
@@ -21,6 +21,7 @@ Get list of all instances of a given entity.
       * Query will do an AND among filterBy fields.
    * orderBy <optional param> Field by which results should be ordered.
       * Supports ordering by  "status","startTime","endTime","cluster".
+   * sortOrder <optional param> Valid options are "asc" and "desc"
    * offset <optional param> Show results from the offset, used for pagination. Defaults to 0.
    * numResults <optional param> Number of results to show per request, used for pagination. Only integers > 0 are valid, Default is 10.
    

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2ed0112e/docs/src/site/twiki/restapi/InstanceLogs.twiki
----------------------------------------------------------------------
diff --git a/docs/src/site/twiki/restapi/InstanceLogs.twiki b/docs/src/site/twiki/restapi/InstanceLogs.twiki
index 354eed4..c1103b7 100644
--- a/docs/src/site/twiki/restapi/InstanceLogs.twiki
+++ b/docs/src/site/twiki/restapi/InstanceLogs.twiki
@@ -22,6 +22,7 @@ Get log of a specific instance of an entity.
       * Query will do an AND among filterBy fields.
    * orderBy <optional param> Field by which results should be ordered.
       * Supports ordering by "status","startTime","endTime","cluster".
+   * sortOrder <optional param> Valid options are "asc" and "desc"
    * offset <optional param> Show results from the offset, used for pagination. Defaults to 0.
    * numResults <optional param> Number of results to show per request, used for pagination. Only integers > 0 are valid, Default is 10.
 

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2ed0112e/docs/src/site/twiki/restapi/InstanceRunning.twiki
----------------------------------------------------------------------
diff --git a/docs/src/site/twiki/restapi/InstanceRunning.twiki b/docs/src/site/twiki/restapi/InstanceRunning.twiki
index 47037d6..dcd2230 100644
--- a/docs/src/site/twiki/restapi/InstanceRunning.twiki
+++ b/docs/src/site/twiki/restapi/InstanceRunning.twiki
@@ -17,6 +17,7 @@ Get a list of instances currently running for a given entity.
       * Query will do an AND among filterBy fields.
    * orderBy <optional param> Field by which results should be ordered.
       * Supports ordering by "status","startTime","endTime","cluster".
+   * sortOrder <optional param> Valid options are "asc" and "desc"
    * offset <optional param> Show results from the offset, used for pagination. Defaults to 0.
    * numResults <optional param> Number of results to show per request, used for pagination. Only integers > 0 are valid, Default is 10.
 

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2ed0112e/docs/src/site/twiki/restapi/InstanceStatus.twiki
----------------------------------------------------------------------
diff --git a/docs/src/site/twiki/restapi/InstanceStatus.twiki b/docs/src/site/twiki/restapi/InstanceStatus.twiki
index 69634de..ece8c3f 100644
--- a/docs/src/site/twiki/restapi/InstanceStatus.twiki
+++ b/docs/src/site/twiki/restapi/InstanceStatus.twiki
@@ -21,6 +21,7 @@ Get status of a specific instance of an entity.
       * Query will do an AND among filterBy fields.
    * orderBy <optional param> Field by which results should be ordered.
       * Supports ordering by "status","startTime","endTime","cluster".
+   * sortOrder <optional param> Valid options are "asc" and "desc"
    * offset <optional param> Show results from the offset, used for pagination. Defaults to 0.
    * numResults <optional param> Number of results to show per request, used for pagination. Only integers > 0 are valid, Default is 10.
 

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2ed0112e/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 d12dede..fcd7b29 100644
--- a/prism/src/main/java/org/apache/falcon/resource/AbstractEntityManager.java
+++ b/prism/src/main/java/org/apache/falcon/resource/AbstractEntityManager.java
@@ -473,12 +473,12 @@ public abstract class AbstractEntityManager {
      * @return EntityList
      */
     public EntityList getEntityList(String type, String fieldStr, String filterBy, String filterTags,
-                                    String orderBy, Integer offset, Integer resultsPerPage) {
+                                    String orderBy, String sortOrder, Integer offset, Integer resultsPerPage) {
 
         HashSet<String> fields = new HashSet<String>(Arrays.asList(fieldStr.toLowerCase().split(",")));
         List<Entity> entities;
         try {
-            entities = getEntities(type, "", "", "", filterBy, filterTags, orderBy, offset, resultsPerPage);
+            entities = getEntities(type, "", "", "", filterBy, filterTags, orderBy, sortOrder, offset, resultsPerPage);
         } catch (Exception e) {
             LOG.error("Failed to get entity list", e);
             throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
@@ -490,7 +490,7 @@ public abstract class AbstractEntityManager {
     }
 
     protected List<Entity> getEntities(String type, String startDate, String endDate, String cluster,
-                                       String filterBy, String filterTags, String orderBy,
+                                       String filterBy, String filterTags, String orderBy, String sortOrder,
                                        int offset, int resultsPerPage) throws FalconException {
         final HashMap<String, String> filterByFieldsValues = getFilterByFieldsValues(filterBy);
         final ArrayList<String> filterByTags = getFilterByTags(filterTags);
@@ -529,7 +529,7 @@ public abstract class AbstractEntityManager {
             entities.add(entity);
         }
         // Sort entities before returning a subset of entity elements.
-        entities = sortEntities(entities, orderBy);
+        entities = sortEntities(entities, orderBy, sortOrder);
 
         int pageCount = getRequiredNumberOfResults(entities.size(), offset, resultsPerPage);
         if (pageCount == 0) {  // handle pagination
@@ -702,27 +702,19 @@ public abstract class AbstractEntityManager {
         return filterEntity;
     }
 
-    private ArrayList<Entity> sortEntities(ArrayList<Entity> entities, String orderBy) {
+    private ArrayList<Entity> sortEntities(ArrayList<Entity> entities, String orderBy, String sortOrder) {
         // Sort the ArrayList using orderBy param
         if (!StringUtils.isEmpty(orderBy)) {
             EntityList.EntityFieldList orderByField = EntityList.EntityFieldList.valueOf(orderBy.toUpperCase());
-
+            final String order = getValidSortOrder(sortOrder, orderBy);
             switch (orderByField) {
 
-            case TYPE:
-                Collections.sort(entities, new Comparator<Entity>() {
-                    @Override
-                    public int compare(Entity e1, Entity e2) {
-                        return e1.getEntityType().compareTo(e2.getEntityType());
-                    }
-                });
-                break;
-
             case NAME:
                 Collections.sort(entities, new Comparator<Entity>() {
                     @Override
                     public int compare(Entity e1, Entity e2) {
-                        return e1.getName().compareTo(e2.getName());
+                        return (order.equalsIgnoreCase("asc")) ? e1.getName().compareTo(e2.getName())
+                                : e2.getName().compareTo(e1.getName());
                     }
                 });
                 break;
@@ -735,6 +727,21 @@ public abstract class AbstractEntityManager {
         return entities;
     }
 
+    protected String getValidSortOrder(String sortOrder, String orderBy) {
+        if (StringUtils.isEmpty(sortOrder)) {
+            return (orderBy.equalsIgnoreCase("starttime")
+                    || orderBy.equalsIgnoreCase("endtime")) ? "desc" : "asc";
+        }
+
+        if (sortOrder.equalsIgnoreCase("asc") || sortOrder.equalsIgnoreCase("desc")) {
+            return sortOrder;
+        }
+
+        String err = "Value for param sortOrder should be \"asc\" or \"desc\". It is  : " + sortOrder;
+        LOG.error(err);
+        throw FalconWebException.newException(err, Response.Status.BAD_REQUEST);
+    }
+
     protected int getRequiredNumberOfResults(int arraySize, int offset, int numresults) {
         /* Get a subset of elements based on offset and count. When returning subset of elements,
               elements[offset] is included. Size 10, offset 10, return empty list.

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2ed0112e/prism/src/main/java/org/apache/falcon/resource/AbstractInstanceManager.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/resource/AbstractInstanceManager.java b/prism/src/main/java/org/apache/falcon/resource/AbstractInstanceManager.java
index e2c465a..5e351f6 100644
--- a/prism/src/main/java/org/apache/falcon/resource/AbstractInstanceManager.java
+++ b/prism/src/main/java/org/apache/falcon/resource/AbstractInstanceManager.java
@@ -86,7 +86,7 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
     //SUSPEND CHECKSTYLE CHECK ParameterNumberCheck
     public InstancesResult getRunningInstances(String type, String entity,
                                                String colo, List<LifeCycle> lifeCycles, String filterBy,
-                                               String orderBy, Integer offset, Integer numResults) {
+                                               String orderBy, String sortOrder, Integer offset, Integer numResults) {
         checkColo(colo);
         checkType(type);
         try {
@@ -95,7 +95,7 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
             AbstractWorkflowEngine wfEngine = getWorkflowEngine();
             Entity entityObject = EntityUtil.getEntity(type, entity);
             return getInstanceResultSubset(wfEngine.getRunningInstances(entityObject, lifeCycles),
-                    filterBy, orderBy, offset, numResults);
+                    filterBy, orderBy, sortOrder, offset, numResults);
         } catch (Throwable e) {
             LOG.error("Failed to get running instances", e);
             throw FalconWebException.newInstanceException(e, Response.Status.BAD_REQUEST);
@@ -105,14 +105,16 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
     //SUSPEND CHECKSTYLE CHECK ParameterNumberCheck
     public InstancesResult getInstances(String type, String entity, String startStr, String endStr,
                                         String colo, List<LifeCycle> lifeCycles,
-                                        String filterBy, String orderBy, Integer offset, Integer numResults) {
+                                        String filterBy, String orderBy, String sortOrder,
+                                        Integer offset, Integer numResults) {
         return getStatus(type, entity, startStr, endStr, colo, lifeCycles,
-                filterBy, orderBy, offset, numResults);
+                filterBy, orderBy, sortOrder, offset, numResults);
     }
 
     public InstancesResult getStatus(String type, String entity, String startStr, String endStr,
                                      String colo, List<LifeCycle> lifeCycles,
-                                     String filterBy, String orderBy, Integer offset, Integer numResults) {
+                                     String filterBy, String orderBy, String sortOrder,
+                                     Integer offset, Integer numResults) {
         checkColo(colo);
         checkType(type);
         try {
@@ -125,7 +127,7 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
             AbstractWorkflowEngine wfEngine = getWorkflowEngine();
             return getInstanceResultSubset(wfEngine.getStatus(entityObject,
                             startAndEndDate.first, startAndEndDate.second, lifeCycles),
-                    filterBy, orderBy, offset, numResults);
+                    filterBy, orderBy, sortOrder, offset, numResults);
         } catch (Throwable e) {
             LOG.error("Failed to get instances status", e);
             throw FalconWebException
@@ -151,16 +153,15 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
         }
     }
 
-    public InstancesResult getLogs(String type, String entity, String startStr,
-                                   String endStr, String colo, String runId,
-                                   List<LifeCycle> lifeCycles,
-                                   String filterBy, String orderBy, Integer offset, Integer numResults) {
-
+    public InstancesResult getLogs(String type, String entity, String startStr, String endStr,
+                                   String colo, String runId, List<LifeCycle> lifeCycles,
+                                   String filterBy, String orderBy, String sortOrder,
+                                   Integer offset, Integer numResults) {
         try {
             lifeCycles = checkAndUpdateLifeCycle(lifeCycles, type);
             // getStatus does all validations and filters clusters
             InstancesResult result = getStatus(type, entity, startStr, endStr,
-                    colo, lifeCycles, filterBy, orderBy, offset, numResults);
+                    colo, lifeCycles, filterBy, orderBy, sortOrder, offset, numResults);
             LogProvider logProvider = new LogProvider();
             Entity entityObject = EntityUtil.getEntity(type, entity);
             for (Instance instance : result.getInstances()) {
@@ -174,7 +175,8 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
         }
     }
 
-    private InstancesResult getInstanceResultSubset(InstancesResult resultSet, String filterBy, String orderBy,
+    private InstancesResult getInstanceResultSubset(InstancesResult resultSet, String filterBy,
+                                                    String orderBy, String sortOrder,
                                                     Integer offset, Integer numResults) {
 
         ArrayList<Instance> instanceSet = new ArrayList<Instance>();
@@ -193,7 +195,7 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
             return new InstancesResult(resultSet.getMessage(), new Instance[0]);
         }
         // Sort the ArrayList using orderBy
-        instanceSet = sortInstances(instanceSet, orderBy);
+        instanceSet = sortInstances(instanceSet, orderBy, sortOrder);
         return new InstancesResult(resultSet.getMessage(),
                 instanceSet.subList(offset, (offset+pageCount)).toArray(new Instance[pageCount]));
     }
@@ -256,7 +258,9 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
         return instanceSet;
     }
 
-    private ArrayList<Instance> sortInstances(ArrayList<Instance> instanceSet, String orderBy) {
+    private ArrayList<Instance> sortInstances(ArrayList<Instance> instanceSet,
+                                              String orderBy, String sortOrder) {
+        final String order = getValidSortOrder(sortOrder, orderBy);
         if (orderBy.equals("status")) {
             Collections.sort(instanceSet, new Comparator<Instance>() {
                 @Override
@@ -267,14 +271,16 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
                     if (i2.getStatus() == null) {
                         i2.status = InstancesResult.WorkflowStatus.ERROR;
                     }
-                    return i1.getStatus().name().compareTo(i2.getStatus().name());
+                    return (order.equalsIgnoreCase("asc")) ? i1.getStatus().name().compareTo(i2.getStatus().name())
+                            : i2.getStatus().name().compareTo(i1.getStatus().name());
                 }
             });
         } else if (orderBy.equals("cluster")) {
             Collections.sort(instanceSet, new Comparator<Instance>() {
                 @Override
                 public int compare(Instance i1, Instance i2) {
-                    return i1.getCluster().compareTo(i2.getCluster());
+                    return (order.equalsIgnoreCase("asc")) ? i1.getCluster().compareTo(i2.getCluster())
+                            : i2.getCluster().compareTo(i1.getCluster());
                 }
             });
         } else if (orderBy.equals("startTime")){
@@ -283,7 +289,8 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
                 public int compare(Instance i1, Instance i2) {
                     Date start1 = (i1.getStartTime() == null) ? new Date(0) : i1.getStartTime();
                     Date start2 = (i2.getStartTime() == null) ? new Date(0) : i2.getStartTime();
-                    return start2.compareTo(start1); //default desc
+                    return (order.equalsIgnoreCase("asc")) ? start1.compareTo(start2)
+                            : start2.compareTo(start1);
                 }
             });
         } else if (orderBy.equals("endTime")) {
@@ -292,10 +299,12 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
                 public int compare(Instance i1, Instance i2) {
                     Date end1 = (i1.getEndTime() == null) ? new Date(0) : i1.getEndTime();
                     Date end2 = (i2.getEndTime() == null) ? new Date(0) : i2.getEndTime();
-                    return end2.compareTo(end1); //default desc
+                    return (order.equalsIgnoreCase("asc")) ? end1.compareTo(end2)
+                            : end2.compareTo(end1);
                 }
             });
         }//Default : no sort
+
         return instanceSet;
     }
 
@@ -328,7 +337,6 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
                                         String type, String entity, String startStr,
                                         String endStr, String colo,
                                         List<LifeCycle> lifeCycles) {
-
         checkColo(colo);
         checkType(type);
         try {
@@ -352,7 +360,6 @@ public abstract class AbstractInstanceManager extends AbstractEntityManager {
                                            String type, String entity, String startStr,
                                            String endStr, String colo,
                                            List<LifeCycle> lifeCycles) {
-
         checkColo(colo);
         checkType(type);
         try {

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2ed0112e/prism/src/main/java/org/apache/falcon/resource/AbstractSchedulableEntityManager.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/resource/AbstractSchedulableEntityManager.java b/prism/src/main/java/org/apache/falcon/resource/AbstractSchedulableEntityManager.java
index 6fba6df..b3151b9 100644
--- a/prism/src/main/java/org/apache/falcon/resource/AbstractSchedulableEntityManager.java
+++ b/prism/src/main/java/org/apache/falcon/resource/AbstractSchedulableEntityManager.java
@@ -176,7 +176,7 @@ public abstract class AbstractSchedulableEntityManager extends AbstractInstanceM
      */
     public EntitySummaryResult getEntitySummary(String type, String cluster, String startDate, String endDate,
                                                 String fields, String filterBy, String filterTags,
-                                                String orderBy, Integer offset,
+                                                String orderBy, String sortOrder, Integer offset,
                                                 Integer resultsPerPage, Integer numInstances) {
         HashSet<String> fieldSet = new HashSet<String>(Arrays.asList(fields.toLowerCase().split(",")));
         Pair<Date, Date> startAndEndDates = getStartEndDatesForSummary(startDate, endDate);
@@ -187,7 +187,7 @@ public abstract class AbstractSchedulableEntityManager extends AbstractInstanceM
             entities = getEntities(type,
                     SchemaHelper.getDateFormat().format(startAndEndDates.first),
                     SchemaHelper.getDateFormat().format(startAndEndDates.second),
-                    cluster, filterBy, filterTags, orderBy, offset, resultsPerPage);
+                    cluster, filterBy, filterTags, orderBy, sortOrder, offset, resultsPerPage);
             colo = ((Cluster) configStore.get(EntityType.CLUSTER, cluster)).getColo();
         } catch (Exception e) {
             LOG.error("Failed to get entities", e);
@@ -199,7 +199,7 @@ public abstract class AbstractSchedulableEntityManager extends AbstractInstanceM
             InstancesResult instancesResult = getInstances(entity.getEntityType().name(), entity.getName(),
                     SchemaHelper.getDateFormat().format(startAndEndDates.first),
                     SchemaHelper.getDateFormat().format(startAndEndDates.second),
-                    colo, null, "", "", 0, numInstances);
+                    colo, null, "", "", "", 0, numInstances);
 
             /* ToDo - Use oozie bulk API after FALCON-591 is implemented
              *       getBulkInstances(entity, cluster,

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2ed0112e/prism/src/main/java/org/apache/falcon/resource/proxy/InstanceManagerProxy.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/resource/proxy/InstanceManagerProxy.java b/prism/src/main/java/org/apache/falcon/resource/proxy/InstanceManagerProxy.java
index bfce5f9..d172c3e 100644
--- a/prism/src/main/java/org/apache/falcon/resource/proxy/InstanceManagerProxy.java
+++ b/prism/src/main/java/org/apache/falcon/resource/proxy/InstanceManagerProxy.java
@@ -84,6 +84,7 @@ public class InstanceManagerProxy extends AbstractInstanceManager {
             @Dimension("lifecycle") @QueryParam("lifecycle") final List<LifeCycle> lifeCycles,
             @DefaultValue("") @QueryParam("filterBy") final String filterBy,
             @DefaultValue("") @QueryParam("orderBy") final String orderBy,
+            @DefaultValue("") @QueryParam("sortOrder") final String sortOrder,
             @DefaultValue("0") @QueryParam("offset") final Integer offset,
             @DefaultValue(DEFAULT_NUM_RESULTS) @QueryParam("numResults") final Integer resultsPerPage) {
         return new InstanceProxy() {
@@ -91,7 +92,7 @@ public class InstanceManagerProxy extends AbstractInstanceManager {
             protected InstancesResult doExecute(String colo) throws FalconException {
                 return getInstanceManager(colo).
                         invoke("getRunningInstances", type, entity, colo, lifeCycles,
-                                filterBy, orderBy, offset, resultsPerPage);
+                                filterBy, orderBy, sortOrder, offset, resultsPerPage);
             }
         }.execute(colo, type, entity);
     }
@@ -114,6 +115,7 @@ public class InstanceManagerProxy extends AbstractInstanceManager {
             @Dimension("lifecycle") @QueryParam("lifecycle") final List<LifeCycle> lifeCycles,
             @DefaultValue("") @QueryParam("filterBy") final String filterBy,
             @DefaultValue("") @QueryParam("orderBy") final String orderBy,
+            @DefaultValue("") @QueryParam("sortOrder") final String sortOrder,
             @DefaultValue("0") @QueryParam("offset") final Integer offset,
             @DefaultValue(DEFAULT_NUM_RESULTS) @QueryParam("numResults") final Integer resultsPerPage) {
         return new InstanceProxy() {
@@ -121,7 +123,7 @@ public class InstanceManagerProxy extends AbstractInstanceManager {
             protected InstancesResult doExecute(String colo) throws FalconException {
                 return getInstanceManager(colo).invoke("getInstances",
                         type, entity, startStr, endStr, colo, lifeCycles,
-                        filterBy, orderBy, offset, resultsPerPage);
+                        filterBy, orderBy, sortOrder, offset, resultsPerPage);
             }
         }.execute(colo, type, entity);
     }
@@ -140,6 +142,7 @@ public class InstanceManagerProxy extends AbstractInstanceManager {
             @Dimension("lifecycle") @QueryParam("lifecycle") final List<LifeCycle> lifeCycles,
             @DefaultValue("") @QueryParam("filterBy") final String filterBy,
             @DefaultValue("") @QueryParam("orderBy") final String orderBy,
+            @DefaultValue("") @QueryParam("sortOrder") final String sortOrder,
             @DefaultValue("0") @QueryParam("offset") final Integer offset,
             @DefaultValue(DEFAULT_NUM_RESULTS) @QueryParam("numResults") final Integer resultsPerPage) {
         return new InstanceProxy() {
@@ -147,7 +150,7 @@ public class InstanceManagerProxy extends AbstractInstanceManager {
             protected InstancesResult doExecute(String colo) throws FalconException {
                 return getInstanceManager(colo).invoke("getStatus",
                         type, entity, startStr, endStr, colo, lifeCycles,
-                        filterBy, orderBy, offset, resultsPerPage);
+                        filterBy, orderBy, sortOrder, offset, resultsPerPage);
             }
         }.execute(colo, type, entity);
     }
@@ -209,6 +212,7 @@ public class InstanceManagerProxy extends AbstractInstanceManager {
             @Dimension("lifecycle") @QueryParam("lifecycle") final List<LifeCycle> lifeCycles,
             @DefaultValue("") @QueryParam("filterBy") final String filterBy,
             @DefaultValue("") @QueryParam("orderBy") final String orderBy,
+            @DefaultValue("") @QueryParam("sortOrder") final String sortOrder,
             @DefaultValue("0") @QueryParam("offset") final Integer offset,
             @DefaultValue(DEFAULT_NUM_RESULTS) @QueryParam("numResults") final Integer resultsPerPage) {
         return new InstanceProxy() {
@@ -216,7 +220,7 @@ public class InstanceManagerProxy extends AbstractInstanceManager {
             protected InstancesResult doExecute(String colo) throws FalconException {
                 return getInstanceManager(colo).invoke("getLogs",
                         type, entity, startStr, endStr, colo, runId, lifeCycles,
-                        filterBy, orderBy, offset, resultsPerPage);
+                        filterBy, orderBy, sortOrder, offset, resultsPerPage);
             }
         }.execute(colo, type, entity);
     }

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2ed0112e/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 e69e531..fbccd6b 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
@@ -293,21 +293,6 @@ public class SchedulableEntityManagerProxy extends AbstractSchedulableEntityMana
     }
 
     @GET
-    @Path("list/{type}")
-    @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_JSON})
-    @Override
-    public EntityList getEntityList(@PathParam("type") String type,
-                                    @DefaultValue("") @QueryParam("fields") String fields,
-                                    @DefaultValue("") @QueryParam("filterBy") String filterBy,
-                                    @DefaultValue("") @QueryParam("tags") String tags,
-                                    @DefaultValue("") @QueryParam("orderBy") String orderBy,
-                                    @DefaultValue("0") @QueryParam("offset") Integer offset,
-                                    @DefaultValue(DEFAULT_NUM_RESULTS)
-                                    @QueryParam("numResults") Integer resultsPerPage) {
-        return super.getEntityList(type, fields, filterBy, tags, orderBy, offset, resultsPerPage);
-    }
-
-    @GET
     @Path("definition/{type}/{entity}")
     @Produces({MediaType.TEXT_XML, MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON})
     @Override
@@ -406,6 +391,22 @@ public class SchedulableEntityManagerProxy extends AbstractSchedulableEntityMana
 
     //SUSPEND CHECKSTYLE CHECK ParameterNumberCheck
     @GET
+    @Path("list/{type}")
+    @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_JSON})
+    @Override
+    public EntityList getEntityList(@PathParam("type") String type,
+                                    @DefaultValue("") @QueryParam("fields") String fields,
+                                    @DefaultValue("") @QueryParam("filterBy") String filterBy,
+                                    @DefaultValue("") @QueryParam("tags") String tags,
+                                    @DefaultValue("") @QueryParam("orderBy") String orderBy,
+                                    @DefaultValue("asc") @QueryParam("sortOrder") String sortOrder,
+                                    @DefaultValue("0") @QueryParam("offset") Integer offset,
+                                    @DefaultValue(DEFAULT_NUM_RESULTS)
+                                    @QueryParam("numResults") Integer resultsPerPage) {
+        return super.getEntityList(type, fields, filterBy, tags, orderBy, sortOrder, offset, resultsPerPage);
+    }
+
+    @GET
     @Path("summary/{type}/{cluster}")
     @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_JSON})
     @Monitored(event = "summary")
@@ -419,11 +420,12 @@ public class SchedulableEntityManagerProxy extends AbstractSchedulableEntityMana
             @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("0") @QueryParam("offset") final Integer entityOffset,
             @DefaultValue("10") @QueryParam("numResults") final Integer numEntities,
             @DefaultValue("7") @QueryParam("numInstances") final Integer numInstanceResults) {
-        return super.getEntitySummary(type, cluster, startStr, endStr, entityFields, entityFilter, entityTags,
-                entityOrderBy, entityOffset, numEntities, numInstanceResults);
+        return super.getEntitySummary(type, cluster, startStr, endStr, entityFields, entityFilter,
+                entityTags, entityOrderBy, entitySortOrder, entityOffset, numEntities, numInstanceResults);
     }
     //RESUME CHECKSTYLE CHECK ParameterNumberCheck
 

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2ed0112e/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 0b55eb3..f7b4f45 100644
--- a/prism/src/test/java/org/apache/falcon/resource/EntityManagerTest.java
+++ b/prism/src/test/java/org/apache/falcon/resource/EntityManagerTest.java
@@ -118,7 +118,7 @@ public class EntityManagerTest extends AbstractEntityManager {
         Entity process2 = buildProcess("processAuthUser", System.getProperty("user.name"), "", "");
         configStore.publish(EntityType.PROCESS, process2);
 
-        EntityList entityList = this.getEntityList("process", "", "", "", "", 0, 10);
+        EntityList entityList = this.getEntityList("process", "", "", "", "", "asc", 0, 10);
         Assert.assertNotNull(entityList.getElements());
         Assert.assertEquals(entityList.getElements().length, 2);
 
@@ -127,7 +127,7 @@ public class EntityManagerTest extends AbstractEntityManager {
          */
         StartupProperties.get().setProperty("falcon.security.authorization.enabled", "true");
         CurrentUser.authenticate(System.getProperty("user.name"));
-        entityList = this.getEntityList("process", "", "", "", "", 0, 10);
+        entityList = this.getEntityList("process", "", "", "", "", "desc", 0, 10);
         Assert.assertNotNull(entityList.getElements());
         Assert.assertEquals(entityList.getElements().length, 2);
 
@@ -135,7 +135,7 @@ public class EntityManagerTest extends AbstractEntityManager {
          * Only one entity should be returned when the auth is enabled.
          */
         CurrentUser.authenticate("fakeUser");
-        entityList = this.getEntityList("process", "", "", "", "", 0, 10);
+        entityList = this.getEntityList("process", "", "", "", "", "", 0, 10);
         Assert.assertNotNull(entityList.getElements());
         Assert.assertEquals(entityList.getElements().length, 1);
 
@@ -165,17 +165,17 @@ public class EntityManagerTest extends AbstractEntityManager {
         configStore.publish(EntityType.PROCESS, process4);
 
         EntityList entityList = this.getEntityList("process", "tags", "PIPELINES:dataReplicationPipeline",
-                "", "name", 1, 2);
+                "", "name", "desc", 1, 2);
         Assert.assertNotNull(entityList.getElements());
         Assert.assertEquals(entityList.getElements().length, 2);
-        Assert.assertEquals(entityList.getElements()[1].name, "process4");
-        Assert.assertEquals(entityList.getElements()[1].tag.size(), 1);
-        Assert.assertEquals(entityList.getElements()[1].tag.get(0), "owner=producer@xyz.com");
+        Assert.assertEquals(entityList.getElements()[1].name, "process1");
+        Assert.assertEquals(entityList.getElements()[1].tag.size(), 2);
+        Assert.assertEquals(entityList.getElements()[1].tag.get(0), "consumer=consumer@xyz.com");
         Assert.assertEquals(entityList.getElements()[0].status, null);
 
 
         entityList = this.getEntityList("process", "pipelines", "",
-                "consumer=consumer@xyz.com, owner=producer@xyz.com", "name", 0, 2);
+                "consumer=consumer@xyz.com, owner=producer@xyz.com", "name", "", 0, 2);
         Assert.assertNotNull(entityList.getElements());
         Assert.assertEquals(entityList.getElements().length, 2);
         Assert.assertEquals(entityList.getElements()[1].name, "process2");
@@ -184,13 +184,22 @@ public class EntityManagerTest extends AbstractEntityManager {
         Assert.assertEquals(entityList.getElements()[0].tag, null);
 
         entityList = this.getEntityList("process", "pipelines", "",
-                "consumer=consumer@xyz.com, owner=producer@xyz.com", "name", 10, 2);
+                "consumer=consumer@xyz.com, owner=producer@xyz.com", "name", "", 10, 2);
         Assert.assertEquals(entityList.getElements().length, 0);
 
         // Test negative value for numResults, should throw an exception.
         try {
             this.getEntityList("process", "pipelines", "",
-                    "consumer=consumer@xyz.com, owner=producer@xyz.com", "name", 10, -1);
+                    "consumer=consumer@xyz.com, owner=producer@xyz.com", "name", "", 10, -1);
+            Assert.assertTrue(false);
+        } catch (Throwable e) {
+            Assert.assertTrue(true);
+        }
+
+        // Test invalid entry for sortOrder
+        try {
+            this.getEntityList("process", "pipelines", "",
+                    "consumer=consumer@xyz.com, owner=producer@xyz.com", "name", "invalid", 10, 2);
             Assert.assertTrue(false);
         } catch (Throwable e) {
             Assert.assertTrue(true);

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2ed0112e/webapp/src/main/java/org/apache/falcon/resource/InstanceManager.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/falcon/resource/InstanceManager.java b/webapp/src/main/java/org/apache/falcon/resource/InstanceManager.java
index a2aaac2..7a7d993 100644
--- a/webapp/src/main/java/org/apache/falcon/resource/InstanceManager.java
+++ b/webapp/src/main/java/org/apache/falcon/resource/InstanceManager.java
@@ -47,9 +47,11 @@ public class InstanceManager extends AbstractInstanceManager {
             @Dimension("lifecycle") @QueryParam("lifecycle") List<LifeCycle> lifeCycles,
             @DefaultValue("") @QueryParam("filterBy") String filterBy,
             @DefaultValue("") @QueryParam("orderBy") String orderBy,
+            @DefaultValue("") @QueryParam("sortOrder") String sortOrder,
             @DefaultValue("0") @QueryParam("offset") Integer offset,
             @DefaultValue(DEFAULT_NUM_RESULTS) @QueryParam("numResults") Integer resultsPerPage) {
-        return super.getRunningInstances(type, entity, colo, lifeCycles, filterBy, orderBy, offset, resultsPerPage);
+        return super.getRunningInstances(type, entity, colo, lifeCycles, filterBy,
+                orderBy, sortOrder, offset, resultsPerPage);
     }
 
     /*
@@ -70,10 +72,11 @@ public class InstanceManager extends AbstractInstanceManager {
             @Dimension("lifecycle") @QueryParam("lifecycle") List<LifeCycle> lifeCycles,
             @DefaultValue("") @QueryParam("filterBy") String filterBy,
             @DefaultValue("") @QueryParam("orderBy") String orderBy,
+            @DefaultValue("") @QueryParam("sortOrder") String sortOrder,
             @DefaultValue("0") @QueryParam("offset") Integer offset,
             @DefaultValue(DEFAULT_NUM_RESULTS) @QueryParam("numResults") Integer resultsPerPage) {
         return super.getInstances(type, entity, startStr, endStr, colo, lifeCycles,
-                filterBy, orderBy, offset, resultsPerPage);
+                filterBy, orderBy, sortOrder, offset, resultsPerPage);
     }
 
     @GET
@@ -90,10 +93,11 @@ public class InstanceManager extends AbstractInstanceManager {
             @Dimension("lifecycle") @QueryParam("lifecycle") List<LifeCycle> lifeCycles,
             @DefaultValue("") @QueryParam("filterBy") String filterBy,
             @DefaultValue("") @QueryParam("orderBy") String orderBy,
+            @DefaultValue("") @QueryParam("sortOrder") String sortOrder,
             @DefaultValue("0") @QueryParam("offset") Integer offset,
             @DefaultValue(DEFAULT_NUM_RESULTS) @QueryParam("numResults") Integer resultsPerPage) {
         return super.getStatus(type, entity, startStr, endStr, colo, lifeCycles,
-                filterBy, orderBy, offset, resultsPerPage);
+                filterBy, orderBy, sortOrder, offset, resultsPerPage);
     }
 
     @GET
@@ -125,10 +129,11 @@ public class InstanceManager extends AbstractInstanceManager {
             @Dimension("lifecycle") @QueryParam("lifecycle") List<LifeCycle> lifeCycles,
             @DefaultValue("") @QueryParam("filterBy") String filterBy,
             @DefaultValue("") @QueryParam("orderBy") String orderBy,
+            @DefaultValue("") @QueryParam("sortOrder") String sortOrder,
             @DefaultValue("0") @QueryParam("offset") Integer offset,
             @DefaultValue(DEFAULT_NUM_RESULTS) @QueryParam("numResults") Integer resultsPerPage) {
         return super.getLogs(type, entity, startStr, endStr, colo, runId, lifeCycles,
-                filterBy, orderBy, offset, resultsPerPage);
+                filterBy, orderBy, sortOrder, offset, resultsPerPage);
     }
 
     @GET

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2ed0112e/webapp/src/main/java/org/apache/falcon/resource/SchedulableEntityManager.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/falcon/resource/SchedulableEntityManager.java b/webapp/src/main/java/org/apache/falcon/resource/SchedulableEntityManager.java
index c10301b..c318bfb 100644
--- a/webapp/src/main/java/org/apache/falcon/resource/SchedulableEntityManager.java
+++ b/webapp/src/main/java/org/apache/falcon/resource/SchedulableEntityManager.java
@@ -53,6 +53,7 @@ public class SchedulableEntityManager extends AbstractSchedulableEntityManager {
         return super.getDependencies(type, entity);
     }
 
+    //SUSPEND CHECKSTYLE CHECK ParameterNumberCheck
     @GET
     @Path("list/{type}")
     @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_JSON})
@@ -63,13 +64,13 @@ public class SchedulableEntityManager extends AbstractSchedulableEntityManager {
                                     @DefaultValue("") @QueryParam("filterBy") String filterBy,
                                     @DefaultValue("") @QueryParam("tags") String tags,
                                     @DefaultValue("") @QueryParam("orderBy") String orderBy,
+                                    @DefaultValue("asc") @QueryParam("sortOrder") String sortOrder,
                                     @DefaultValue("0") @QueryParam("offset") Integer offset,
                                     @DefaultValue(DEFAULT_NUM_RESULTS)
                                     @QueryParam("numResults") Integer resultsPerPage) {
-        return super.getEntityList(type, fields, filterBy, tags, orderBy, offset, resultsPerPage);
+        return super.getEntityList(type, fields, filterBy, tags, orderBy, sortOrder, offset, resultsPerPage);
     }
 
-    //SUSPEND CHECKSTYLE CHECK ParameterNumberCheck
     @GET
     @Path("summary/{type}/{cluster}")
     @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_JSON})
@@ -84,11 +85,12 @@ public class SchedulableEntityManager extends AbstractSchedulableEntityManager {
             @DefaultValue("") @QueryParam("filterBy") String entityFilter,
             @DefaultValue("") @QueryParam("tags")  String entityTags,
             @DefaultValue("") @QueryParam("orderBy") String entityOrderBy,
+            @DefaultValue("asc") @QueryParam("sortOrder") String entitySortOrder,
             @DefaultValue("0") @QueryParam("offset") Integer entityOffset,
             @DefaultValue("10") @QueryParam("numResults") Integer numEntities,
             @DefaultValue("7") @QueryParam("numInstances") Integer numInstanceResults) {
         return super.getEntitySummary(type, cluster, startStr, endStr, fields, entityFilter, entityTags,
-                entityOrderBy, entityOffset, numEntities, numInstanceResults);
+                entityOrderBy, entitySortOrder, entityOffset, numEntities, numInstanceResults);
     }
     //RESUME CHECKSTYLE CHECK ParameterNumberCheck
 

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2ed0112e/webapp/src/test/java/org/apache/falcon/cli/FalconCLIIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/falcon/cli/FalconCLIIT.java b/webapp/src/test/java/org/apache/falcon/cli/FalconCLIIT.java
index 1612abb..82208b0 100644
--- a/webapp/src/test/java/org/apache/falcon/cli/FalconCLIIT.java
+++ b/webapp/src/test/java/org/apache/falcon/cli/FalconCLIIT.java
@@ -288,15 +288,24 @@ public class FalconCLIIT {
         Assert.assertEquals(0,
                 executeWithURL("entity -summary -type feed -cluster "+ overlay.get("cluster")
                         + " -fields status,tags -start " + START_INSTANCE
-                        + " -filterBy TYPE:FEED -orderBy name "
+                        + " -filterBy TYPE:FEED -orderBy name -sortOrder asc "
                         + " -offset 0 -numResults 1 -numInstances 5"));
         Assert.assertEquals(0,
                 executeWithURL("entity -summary -type process -fields status,pipelines"
                         + " -cluster " + overlay.get("cluster")
                         + " -start " + SchemaHelper.getDateFormat().format(new Date(0))
                         + " -end " + SchemaHelper.getDateFormat().format(new Date())
-                        + " -filterBy TYPE:PROCESS -orderBy name "
+                        + " -filterBy TYPE:PROCESS -orderBy name -sortOrder desc "
+                        + " -offset 0 -numResults 1 -numInstances 7"));
+
+        Assert.assertEquals(-1,
+                executeWithURL("entity -summary -type process -fields status,pipelines"
+                        + " -cluster " + overlay.get("cluster")
+                        + " -start " + SchemaHelper.getDateFormat().format(new Date(0))
+                        + " -end " + SchemaHelper.getDateFormat().format(new Date())
+                        + " -filterBy TYPE:PROCESS -orderBy name -sortOrder invalid "
                         + " -offset 0 -numResults 1 -numInstances 7"));
+
         // No start or end date
         Assert.assertEquals(0,
                 executeWithURL("entity -summary -type process -fields status,pipelines"
@@ -413,12 +422,23 @@ public class FalconCLIIT {
                 executeWithURL("instance -running -type feed -lifecycle eviction -name "
                         + overlay.get("outputFeedName")
                         + " -start " + startTimeString
-                        + " -orderBy startTime -offset 0 -numResults 1"));
+                        + " -orderBy startTime -sortOrder asc -offset 0 -numResults 1"));
         Assert.assertEquals(-1,
                 executeWithURL("instance -running -type feed -lifecycle eviction -name "
                         + overlay.get("outputFeedName")
                         + " -start " + SchemaHelper.getDateFormat().format(new Date())
                         + " -orderBy INVALID -offset 0 -numResults 1"));
+        Assert.assertEquals(0,
+                executeWithURL("instance -running -type feed -lifecycle eviction -name "
+                        + overlay.get("outputFeedName")
+                        + " -start " + startTimeString
+                        + " -orderBy startTime -sortOrder desc -offset 0 -numResults 1"));
+        Assert.assertEquals(-1,
+                executeWithURL("instance -running -type feed -lifecycle eviction -name "
+                        + overlay.get("outputFeedName")
+                        + " -start " + startTimeString
+                        + " -orderBy startTime -sortOrder invalid -offset 0 -numResults 1"));
+
         Assert.assertEquals(-1,
                 executeWithURL("instance -running -type feed -lifecycle eviction -name "
                         + overlay.get("outputFeedName")
@@ -430,7 +450,7 @@ public class FalconCLIIT {
                 executeWithURL("instance -running -type feed -lifecycle eviction -name "
                         + overlay.get("outputFeedName")
                         + " -start " + SchemaHelper.getDateFormat().format(new Date(10000))
-                        + " -orderBy startTime -offset 0 -numResults 1"));
+                        + " -orderBy startTime -sortOrder asc -offset 0 -numResults 1"));
         // testcase : end str is in future
         long futureTimeinMilliSecs = (new Date()).getTime()+ 86400000;
         Assert.assertEquals(0,
@@ -450,7 +470,7 @@ public class FalconCLIIT {
                         + overlay.get("processName")
                         + " -start "+ START_INSTANCE
                         + " -filterBy STATUS:SUCCEEDED,STARTEDAFTER:"+START_INSTANCE
-                        + " -orderBy startTime -offset 0 -numResults 1"));
+                        + " -orderBy startTime -sortOrder desc -offset 0 -numResults 1"));
         Assert.assertEquals(0,
                 executeWithURL("instance -list -type feed -lifecycle eviction -name "
                         + overlay.get("outputFeedName")
@@ -647,14 +667,15 @@ public class FalconCLIIT {
                         + " -offset 0 -numResults 1"));
         Assert.assertEquals(0,
                 executeWithURL("entity -list -type process -fields status "
-                        + " -filterBy STATUS:SUBMITTED,TYPE:process -orderBy name -offset 1 -numResults 1"));
+                        + " -filterBy STATUS:SUBMITTED,TYPE:process -orderBy name "
+                        + " -sortOrder asc -offset 1 -numResults 1"));
         Assert.assertEquals(0,
                 executeWithURL("entity -list -type process -fields status,pipelines "
                         + " -filterBy STATUS:SUBMITTED,type:process -orderBy name -offset 1 -numResults 1"));
         Assert.assertEquals(0,
                 executeWithURL("entity -list -type process -fields status,pipelines "
                         + " -filterBy STATUS:SUBMITTED,pipelines:testPipeline "
-                        + " -orderBy name -offset 1 -numResults 1"));
+                        + " -orderBy name -sortOrder desc -offset 1 -numResults 1"));
         Assert.assertEquals(0,
                 executeWithURL("entity -list -type process -fields status,tags "
                         + " -tags owner=producer@xyz.com,department=forecasting "
@@ -670,7 +691,11 @@ public class FalconCLIIT {
                         + " -filterBy INVALID:FILTER,TYPE:process -orderBy name -offset 1 -numResults 1"));
         Assert.assertEquals(0,
                 executeWithURL("entity -definition -type cluster -name " + overlay.get("cluster")));
-
+        Assert.assertEquals(-1,
+                executeWithURL("entity -list -type process -fields status,tags "
+                        + " -tags owner=producer@xyz.com,department=forecasting "
+                        + " -filterBy STATUS:SUBMITTED,type:process "
+                        + " -orderBy name -sortOrder invalid -offset 1 -numResults 1"));
         Assert.assertEquals(0,
                 executeWithURL("instance -status -type feed -name "
                         + overlay.get("outputFeedName") + " -start " + START_INSTANCE));
@@ -808,12 +833,31 @@ public class FalconCLIIT {
                 executeWithURL("instance -logs -type process -name "
                         + overlay.get("processName")
                         + " -start " + START_INSTANCE + " -end " + START_INSTANCE
-                        + " -filterBy STATUS:SUCCEEDED -orderBy startTime -offset 0 -numResults 1"));
+                        + " -filterBy STATUS:SUCCEEDED -orderBy endtime "
+                        + " -sortOrder asc -offset 0 -numResults 1"));
+        Assert.assertEquals(0,
+                executeWithURL("instance -logs -type process -name "
+                        + overlay.get("processName")
+                        + " -start " + START_INSTANCE + " -end " + START_INSTANCE
+                        + " -filterBy STATUS:SUCCEEDED -orderBy starttime "
+                        + " -sortOrder asc -offset 0 -numResults 1"));
+        Assert.assertEquals(0,
+                executeWithURL("instance -logs -type process -name "
+                        + overlay.get("processName")
+                        + " -start " + START_INSTANCE + " -end " + START_INSTANCE
+                        + " -filterBy STATUS:SUCCEEDED -orderBy cluster "
+                        + " -sortOrder asc -offset 0 -numResults 1"));
         Assert.assertEquals(0,
                 executeWithURL("instance -logs -type process -name "
                         + overlay.get("processName")
                         + " -start " + START_INSTANCE + " -end " + START_INSTANCE
                         + " -filterBy STATUS:WAITING -orderBy startTime -offset 0 -numResults 1"));
+        Assert.assertEquals(-1,
+                executeWithURL("instance -logs -type process -name "
+                        + overlay.get("processName")
+                        + " -start " + START_INSTANCE + " -end " + START_INSTANCE
+                        + " -filterBy STATUS:SUCCEEDED -orderBy endtime "
+                        + " -sortOrder invalid -offset 0 -numResults 1"));
         Assert.assertEquals(0,
                 executeWithURL("instance -logs -type process -name "
                         + overlay.get("processName")

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/2ed0112e/webapp/src/test/java/org/apache/falcon/resource/EntityManagerJerseyIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/falcon/resource/EntityManagerJerseyIT.java b/webapp/src/test/java/org/apache/falcon/resource/EntityManagerJerseyIT.java
index 4755c30..cfcc14f 100644
--- a/webapp/src/test/java/org/apache/falcon/resource/EntityManagerJerseyIT.java
+++ b/webapp/src/test/java/org/apache/falcon/resource/EntityManagerJerseyIT.java
@@ -749,7 +749,7 @@ public class EntityManagerJerseyIT {
                 .path("api/entities/list/process/")
                 .queryParam("filterBy", "TYPE:PROCESS,STATUS:RUNNING")
                 .queryParam("tags", "owner=producer@xyz.com, department=forecasting")
-                .queryParam("orderBy", "name").queryParam("offset", "2")
+                .queryParam("orderBy", "name").queryParam("sortOrder", "desc").queryParam("offset", "2")
                 .queryParam("numResults", "2").queryParam("fields", "status,tags")
                 .header("Cookie", context.getAuthenticationToken())
                 .type(MediaType.TEXT_XML)
@@ -762,7 +762,8 @@ public class EntityManagerJerseyIT {
 
         response = context.service
                 .path("api/entities/list/process/")
-                .queryParam("orderBy", "name").queryParam("offset", "50").queryParam("numResults", "2")
+                .queryParam("orderBy", "name").queryParam("sortOrder", "asc")
+                .queryParam("offset", "50").queryParam("numResults", "2")
                 .header("Cookie", context.getAuthenticationToken())
                 .type(MediaType.TEXT_XML)
                 .accept(MediaType.TEXT_XML)


Mime
View raw message