falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From suh...@apache.org
Subject incubator-falcon git commit: FALCON-869. Clean up required in the instance API calls. Contributed by Suhas Vasu
Date Tue, 11 Nov 2014 08:43:07 GMT
Repository: incubator-falcon
Updated Branches:
  refs/heads/master 6f28481c4 -> 38f545000


FALCON-869. Clean up required in the instance API calls. Contributed by Suhas Vasu


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

Branch: refs/heads/master
Commit: 38f5450008571c6aac3bcbe2c8b0da2123c0d99f
Parents: 6f28481
Author: Suhas V <suhas.v@inmobi.com>
Authored: Tue Nov 11 14:12:51 2014 +0530
Committer: Suhas V <suhas.v@inmobi.com>
Committed: Tue Nov 11 14:12:51 2014 +0530

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 +
 .../workflow/engine/OozieWorkflowEngine.java    | 44 ++++++++++----------
 2 files changed, 23 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/38f54500/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 90360af..7eb4b70 100755
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -41,6 +41,8 @@ Trunk (Unreleased)
    FALCON-263 API to get workflow parameters. (pavan kumar kolamuri via Shwetha GS)
 
   IMPROVEMENTS
+   FALCON-869 Clean up required in the instance API calls. (Suhas Vasu)
+
    FALCON-878 Move falcon html files to HTML5. (Ajay Yadav via Srikanth Sundarrajan)
 
    FALCON-145 Feed eviction be implemented in appropriate Storage 

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/38f54500/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 771839a..8bde7e3 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
@@ -569,32 +569,20 @@ public class OozieWorkflowEngine extends AbstractWorkflowEngine {
                         continue;
                     }
                 }
-                String status;
                 instanceCount++;
+                String nominalTimeStr = SchemaHelper.formatDateUTC(coordinatorAction.getNominalTime());
+
+                InstancesResult.Instance instance =
+                        new InstancesResult.Instance(cluster, nominalTimeStr, null);
+                instance.sourceCluster = sourceCluster;
                 try {
-                    status = performAction(cluster, action, coordinatorAction, props);
+                    performAction(cluster, action, coordinatorAction, props, instance);
                 } catch (FalconException e) {
                     LOG.warn("Unable to perform action {} on cluster", action, e);
-                    status = WorkflowStatus.ERROR.name();
+                    instance.status = WorkflowStatus.ERROR;
                     overallStatus = APIResult.Status.PARTIAL;
                 }
 
-                String nominalTimeStr = SchemaHelper.formatDateUTC(coordinatorAction.getNominalTime());
-                InstancesResult.Instance instance =
-                    new InstancesResult.Instance(cluster, nominalTimeStr, WorkflowStatus.valueOf(status));
-                if (StringUtils.isNotEmpty(coordinatorAction.getExternalId())) {
-                    WorkflowJob jobInfo = getWorkflowInfo(cluster, coordinatorAction.getExternalId());
-                    instance.startTime = jobInfo.getStartTime();
-                    instance.endTime = jobInfo.getEndTime();
-                    instance.logFile = jobInfo.getConsoleUrl();
-                    instance.sourceCluster = sourceCluster;
-                    if (action == JobAction.PARAMS) {
-                        instance.wfParams = getWFParams(jobInfo);
-                    }
-                    if (action == JobAction.STATUS) {
-                        populateInstanceActions(cluster, jobInfo, instance);
-                    }
-                }
                 instance.details = coordinatorAction.getMissingDependencies();
                 instances.add(instance);
             }
@@ -627,9 +615,9 @@ public class OozieWorkflowEngine extends AbstractWorkflowEngine {
             List<CoordinatorJob> applicableCoords = getApplicableCoords(client, start,
end,
                     bundles, lifeCycles);
             long unscheduledInstances = 0;
-            boolean isLastCoord = false;
 
             for (int i = 0; i < applicableCoords.size(); i++) {
+                boolean isLastCoord = false;
                 CoordinatorJob coord = applicableCoords.get(i);
                 Frequency freq = createFrequency(String.valueOf(coord.getFrequency()), coord.getTimeUnit());
                 TimeZone tz = EntityUtil.getTimeZone(coord.getTimeZone());
@@ -740,14 +728,18 @@ public class OozieWorkflowEngine extends AbstractWorkflowEngine {
         }
     }
 
-    private String performAction(String cluster, JobAction action, CoordinatorAction coordinatorAction,
-        Properties props) throws FalconException {
+    private void performAction(String cluster, JobAction action, CoordinatorAction coordinatorAction,
+        Properties props, InstancesResult.Instance instance) throws FalconException {
         WorkflowJob jobInfo = null;
         String status = coordinatorAction.getStatus().name();
         if (StringUtils.isNotEmpty(coordinatorAction.getExternalId())) {
             jobInfo = getWorkflowInfo(cluster, coordinatorAction.getExternalId());
             status = jobInfo.getStatus().name();
+            instance.startTime = jobInfo.getStartTime();
+            instance.endTime = jobInfo.getEndTime();
+            instance.logFile = jobInfo.getConsoleUrl();
         }
+
         switch (action) {
         case KILL:
             if (jobInfo == null || !WF_KILL_PRECOND.contains(jobInfo.getStatus())) {
@@ -790,16 +782,22 @@ public class OozieWorkflowEngine extends AbstractWorkflowEngine {
 
 
         case STATUS:
+            if (StringUtils.isNotEmpty(coordinatorAction.getExternalId())) {
+                populateInstanceActions(cluster, jobInfo, instance);
+            }
             break;
 
         case PARAMS:
+            if (StringUtils.isNotEmpty(coordinatorAction.getExternalId())) {
+                instance.wfParams = getWFParams(jobInfo);
+            }
             break;
 
         default:
             throw new IllegalArgumentException("Unhandled action " + action);
         }
 
-        return mapActionStatus(status);
+        instance.status = WorkflowStatus.valueOf(mapActionStatus(status));
     }
 
     private void reRunCoordAction(String cluster, CoordinatorAction coordinatorAction) throws
FalconException {


Mime
View raw message