falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajayyad...@apache.org
Subject falcon git commit: FALCON-1674 Fix the mapping of InstanceState status to workflow Status in InstancesResult. Contributed by Pallavi Rao.
Date Tue, 05 Jan 2016 09:19:11 GMT
Repository: falcon
Updated Branches:
  refs/heads/master 1e3dcb73f -> 679167a24


FALCON-1674 Fix the mapping of InstanceState status to workflow Status in InstancesResult.
Contributed by Pallavi Rao.


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

Branch: refs/heads/master
Commit: 679167a24508994c5b4128162f856c2385de0df2
Parents: 1e3dcb7
Author: Ajay Yadava <ajaynsit@gmail.com>
Authored: Tue Jan 5 13:44:03 2016 +0530
Committer: Ajay Yadava <ajaynsit@gmail.com>
Committed: Tue Jan 5 13:44:03 2016 +0530

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 +
 docs/src/site/twiki/restapi/InstanceList.twiki  | 10 ++++
 .../workflow/engine/OozieWorkflowEngine.java    |  5 +-
 .../workflow/engine/FalconWorkflowEngine.java   | 49 ++++++++++++++++----
 4 files changed, 56 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/falcon/blob/679167a2/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 9c59ed6..1d3aa02 100755
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -90,6 +90,8 @@ Proposed Release Version: 0.9
   OPTIMIZATIONS
 
   BUG FIXES
+    FALCON-1674 Fix the mapping of InstanceState status to workflow Status in InstancesResult
(Pallavi Rao via Ajay Yadava)
+
     FALCON-1709 FIFO order is not followed when scheduled using native scheduler (Pallavi
Rao)
 
     FALCON-1711 DependencyInstance twiki does not contain correct documentation	(Praveen
Adlakha via Pallavi Rao)

http://git-wip-us.apache.org/repos/asf/falcon/blob/679167a2/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 229d6f9..5dee8a5 100644
--- a/docs/src/site/twiki/restapi/InstanceList.twiki
+++ b/docs/src/site/twiki/restapi/InstanceList.twiki
@@ -29,6 +29,16 @@ Get list of all instances of a given entity.
 ---++ Results
 List of instances of given entity.
 
+The possible instance status returned and its meaning are as follows:
+   * WAITING - The instance is waiting for the corresponding data(feed) instances to become
available.
+   * READY - The instance is ready to be scheduled. But, is waiting for scheduling conditions
to be met. For example, limitation on number of instances that can be run in parallel.
+   * RUNNING - The instance is running on the workflow engine.
+   * FAILED - The instance has failed during execution.
+   * KILLED - The instance has been killed either manually or by the system.
+   * SUCCEEDED - The instance has executed successfully.
+   * SKIPPED - This instance was not executed, but was skipped. For example, when the execution
order is LAST_ONLY, the older instances are skipped.
+   * ERROR - There was error while executing this instance on the workflow engine.
+   * UNDEFINED - The status of the instance could not be determined.
 ---++ Examples
 ---+++ Rest Call
 <verbatim>

http://git-wip-us.apache.org/repos/asf/falcon/blob/679167a2/oozie/src/main/java/org/apache/falcon/workflow/engine/OozieWorkflowEngine.java
----------------------------------------------------------------------
diff --git a/oozie/src/main/java/org/apache/falcon/workflow/engine/OozieWorkflowEngine.java
b/oozie/src/main/java/org/apache/falcon/workflow/engine/OozieWorkflowEngine.java
index b486357..cf0e30d 100644
--- a/oozie/src/main/java/org/apache/falcon/workflow/engine/OozieWorkflowEngine.java
+++ b/oozie/src/main/java/org/apache/falcon/workflow/engine/OozieWorkflowEngine.java
@@ -953,8 +953,9 @@ public class OozieWorkflowEngine extends AbstractWorkflowEngine {
     }
 
     private String mapActionStatus(String status) {
-        if (CoordinatorAction.Status.READY.toString().equals(status)
-            || CoordinatorAction.Status.WAITING.toString().equals(status)
+        if (CoordinatorAction.Status.READY.toString().equals(status)) {
+            return InstancesResult.WorkflowStatus.READY.name();
+        } else if (CoordinatorAction.Status.WAITING.toString().equals(status)
             || CoordinatorAction.Status.SUBMITTED.toString().equals(status)) {
             return InstancesResult.WorkflowStatus.WAITING.name();
         } else if (CoordinatorAction.Status.IGNORED.toString().equals(status)) {

http://git-wip-us.apache.org/repos/asf/falcon/blob/679167a2/scheduler/src/main/java/org/apache/falcon/workflow/engine/FalconWorkflowEngine.java
----------------------------------------------------------------------
diff --git a/scheduler/src/main/java/org/apache/falcon/workflow/engine/FalconWorkflowEngine.java
b/scheduler/src/main/java/org/apache/falcon/workflow/engine/FalconWorkflowEngine.java
index bceab72..8306b34 100644
--- a/scheduler/src/main/java/org/apache/falcon/workflow/engine/FalconWorkflowEngine.java
+++ b/scheduler/src/main/java/org/apache/falcon/workflow/engine/FalconWorkflowEngine.java
@@ -27,6 +27,7 @@ import org.apache.falcon.entity.v0.Entity;
 import org.apache.falcon.entity.v0.EntityType;
 import org.apache.falcon.entity.v0.SchemaHelper;
 import org.apache.falcon.entity.v0.cluster.Cluster;
+import org.apache.falcon.exception.StateStoreException;
 import org.apache.falcon.execution.EntityExecutor;
 import org.apache.falcon.execution.ExecutionInstance;
 import org.apache.falcon.execution.FalconExecutionService;
@@ -267,23 +268,19 @@ public class FalconWorkflowEngine extends AbstractWorkflowEngine {
         switch(action) {
         case KILL:
             executor.kill(instance);
-            instanceInfo.status = InstancesResult.WorkflowStatus.KILLED;
+            populateInstanceInfo(instanceInfo, instance);
             break;
         case SUSPEND:
             executor.suspend(instance);
-            instanceInfo.status = InstancesResult.WorkflowStatus.SUSPENDED;
+            populateInstanceInfo(instanceInfo, instance);
             break;
         case RESUME:
             executor.resume(instance);
-            instanceInfo.status =
-                    InstancesResult.WorkflowStatus.valueOf(STATE_STORE
-                            .getExecutionInstance(instance.getId()).getCurrentState().name());
+            populateInstanceInfo(instanceInfo, instance);
             break;
         case RERUN:
             executor.rerun(instance, userProps, isForced);
-            instanceInfo.status =
-                    InstancesResult.WorkflowStatus.valueOf(STATE_STORE
-                            .getExecutionInstance(instance.getId()).getCurrentState().name());
+            populateInstanceInfo(instanceInfo, instance);
             break;
         case STATUS:
             // Mask wfParams
@@ -293,6 +290,9 @@ public class FalconWorkflowEngine extends AbstractWorkflowEngine {
                         DAGEngineFactory.getDAGEngine(cluster).getJobDetails(instance.getExternalID());
                 instanceInfo.actions = instanceActions
                         .toArray(new InstancesResult.InstanceAction[instanceActions.size()]);
+            // If not scheduled externally yet, get details from state
+            } else {
+                populateInstanceInfo(instanceInfo, instance);
             }
             break;
 
@@ -313,6 +313,39 @@ public class FalconWorkflowEngine extends AbstractWorkflowEngine {
         return instanceInfo;
     }
 
+    // Populates the InstancesResult.Instance instance using ExecutionInstance
+    private void populateInstanceInfo(InstancesResult.Instance instanceInfo, ExecutionInstance
instance)
+        throws StateStoreException {
+        instanceInfo.cluster = instance.getCluster();
+        InstanceState.STATE state = STATE_STORE.getExecutionInstance(instance.getId()).getCurrentState();
+        switch (state) {
+        case SUCCEEDED:
+            instanceInfo.status = InstancesResult.WorkflowStatus.SUCCEEDED;
+            break;
+        case FAILED:
+            instanceInfo.status = InstancesResult.WorkflowStatus.FAILED;
+            break;
+        case KILLED:
+            instanceInfo.status = InstancesResult.WorkflowStatus.KILLED;
+            break;
+        case READY:
+            instanceInfo.status = InstancesResult.WorkflowStatus.READY;
+            break;
+        case WAITING:
+            instanceInfo.status = InstancesResult.WorkflowStatus.WAITING;
+            break;
+        case SUSPENDED:
+            instanceInfo.status = InstancesResult.WorkflowStatus.SUSPENDED;
+            break;
+        case RUNNING:
+            instanceInfo.status = InstancesResult.WorkflowStatus.RUNNING;
+            break;
+        default:
+            instanceInfo.status = InstancesResult.WorkflowStatus.UNDEFINED;
+            break;
+        }
+    }
+
     @Override
     public InstancesResult killInstances(Entity entity, Date start, Date end,
                                          Properties props, List<LifeCycle> lifeCycles)
throws FalconException {


Mime
View raw message