Repository: falcon
Updated Branches:
  refs/heads/master efa9b1441 -> e270b5c70


FALCON-1811 Status API does not honour start option

$ bin/falcon instance -type process -name process1 -start 2015-10-09T14:00Z 
-status -numResults 2
Consolidated Status: SUCCEEDED

Instances:
Instance                Cluster         SourceCluster           Status          
Start           End             Details                                 Log
-----------------------------------------------------------------------------------------------
2015-12-31T01:00Z       local   -       SUSPENDED       2016-02-11T09:34Z       
-       -       
http://blr-test-129.corp.inmobi.com:11000/oozie?job=0000028-151229192519233-oozie-oozi-W
actions:
 mr-node        null    null
 failed-post-processing null    null
2016-01-01T01:00Z       local   -       SUSPENDED       2016-02-11T10:18Z       
-       -       
http://blr-test-129.corp.inmobi.com:11000/oozie?job=0000030-151229192519233-oozie-oozi-W
actions:
 mr-node        null    null
 failed-post-processing null    null

Additional Information:
Response: default/STATUS
Request Id: default/124451500qtp-822600088-12 - 
2ca2d36d-6e03-4e14-9e97-1448aed90084

Note we will not get the same result when status is waiting as at that time 
start time is null.

Author: Praveen Adlakha <[email protected]>

Reviewers: Pallavi Rao <[email protected]>

Closes #40 from PraveenAdlakha/1811 and squashes the following commits:

d9925d0 [Praveen Adlakha] pallavi's comments addressed
7784468 [Praveen Adlakha] checkstyle voilation issue solved
4530233 [Praveen Adlakha] changes done as per pallavi's comment
3c3da61 [Praveen Adlakha] Deepak's comments addressed
de08573 [Praveen Adlakha] FALCON-1811 Status API does not honour start option


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

Branch: refs/heads/master
Commit: e270b5c7058c7672eb3b2b5cd0253c4301426463
Parents: efa9b14
Author: Praveen Adlakha <[email protected]>
Authored: Wed Feb 24 16:30:46 2016 +0530
Committer: Pallavi Rao <[email protected]>
Committed: Wed Feb 24 16:30:46 2016 +0530

----------------------------------------------------------------------
 .../resource/AbstractInstanceManager.java       | 22 ++++++++++++--------
 1 file changed, 13 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/falcon/blob/e270b5c7/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 b35ae9a..1895ba5 100644
--- 
a/prism/src/main/java/org/apache/falcon/resource/AbstractInstanceManager.java
+++ 
b/prism/src/main/java/org/apache/falcon/resource/AbstractInstanceManager.java
@@ -125,7 +125,7 @@ public abstract class AbstractInstanceManager extends 
AbstractEntityManager {
             Entity entityObject = EntityUtil.getEntity(type, entity);
             AbstractWorkflowEngine wfEngine = getWorkflowEngine(entityObject);
             return 
getInstanceResultSubset(wfEngine.getRunningInstances(entityObject, lifeCycles),
-                    filterBy, orderBy, sortOrder, offset, numResults);
+                    filterBy, orderBy, sortOrder, offset, numResults, "");
         } catch (Throwable e) {
             LOG.error("Failed to get running instances", e);
             throw FalconWebException.newAPIException(e);
@@ -174,8 +174,8 @@ public abstract class AbstractInstanceManager extends 
AbstractEntityManager {
             // LifeCycle lifeCycleObject = EntityUtil.getLifeCycle(lifeCycle);
             AbstractWorkflowEngine wfEngine = getWorkflowEngine(entityObject);
             return getInstanceResultSubset(wfEngine.getStatus(entityObject,
-                            startAndEndDate.first, startAndEndDate.second, 
lifeCycles, allAttempts),
-                    filterBy, orderBy, sortOrder, offset, numResults);
+                    startAndEndDate.first, startAndEndDate.second, lifeCycles, 
allAttempts),
+                    filterBy, orderBy, sortOrder, offset, numResults, 
startStr);
         } catch (FalconException e) {
             LOG.error("Failed to get instances status", e);
             throw FalconWebException.newAPIException(e.getMessage());
@@ -284,10 +284,9 @@ public abstract class AbstractInstanceManager extends 
AbstractEntityManager {
     }
 
     //RESUME CHECKSTYLE CHECK ParameterNumberCheck
-
     private InstancesResult getInstanceResultSubset(InstancesResult resultSet, 
String filterBy,
                                                     String orderBy, String 
sortOrder, Integer offset,
-                                                    Integer numResults) throws 
FalconException {
+                                                    Integer numResults, String 
startStr) throws FalconException {
         if (resultSet.getInstances() == null) {
             // return the empty resultSet
             resultSet.setInstances(new Instance[0]);
@@ -305,8 +304,13 @@ public abstract class AbstractInstanceManager extends 
AbstractEntityManager {
             result.setInstances(new Instance[0]);
             return result;
         }
-        // Sort the ArrayList using orderBy
-        instanceSet = sortInstances(instanceSet, orderBy.toLowerCase(), 
sortOrder);
+        if (StringUtils.isNotEmpty(startStr) && 
StringUtils.isEmpty(sortOrder)) {
+            Collections.reverse(instanceSet);
+        }
+        if (StringUtils.isNoneEmpty(sortOrder)) {
+            // Sort the ArrayList using orderBy
+            instanceSet = sortInstances(instanceSet, orderBy.toLowerCase(), 
sortOrder);
+        }
         result.setCollection(instanceSet.subList(
                 offset, (offset + pageCount)).toArray(new 
Instance[pageCount]));
         return result;
@@ -485,8 +489,8 @@ public abstract class AbstractInstanceManager extends 
AbstractEntityManager {
                             : end2.compareTo(end1);
                 }
             });
-        }//Default : no sort
-
+        }
+        //Default : no sort
         return instanceSet;
     }
 

Reply via email to