falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From suh...@apache.org
Subject falcon git commit: FALCON-555 API response from instance 'params' having multiple 'entry' key. Contributed by Pallavi Rao
Date Tue, 03 Mar 2015 14:55:59 GMT
Repository: falcon
Updated Branches:
  refs/heads/master 591c2fe88 -> 45808eff7


FALCON-555 API response from instance 'params' having multiple 'entry' key. 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/45808eff
Tree: http://git-wip-us.apache.org/repos/asf/falcon/tree/45808eff
Diff: http://git-wip-us.apache.org/repos/asf/falcon/diff/45808eff

Branch: refs/heads/master
Commit: 45808eff7c42b097a2bfc434f46812319091d105
Parents: 591c2fe
Author: Suhas Vasu <suhas.v@inmobi.com>
Authored: Tue Mar 3 20:25:27 2015 +0530
Committer: Suhas Vasu <suhas.v@inmobi.com>
Committed: Tue Mar 3 20:25:27 2015 +0530

----------------------------------------------------------------------
 CHANGES.txt                                     |  3 ++
 .../java/org/apache/falcon/ResponseHelper.java  |  4 +-
 .../apache/falcon/resource/InstancesResult.java | 40 +++++++++++++++++---
 .../workflow/engine/OozieWorkflowEngine.java    |  7 ++--
 4 files changed, 43 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/falcon/blob/45808eff/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index a081a00..d88e256 100755
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -8,6 +8,9 @@ Trunk (Unreleased)
    FALCON-949 Force update feature (pavan kumar kolamuri via Suhas Vasu)
 
   IMPROVEMENTS
+   FALCON-555 API response from instance "params" having multiple "entry" key
+   (Pallavi Rao via Suhas Vasu)
+
    FALCON-1003 Update checkstyle to remove DoubleCheckedLocking
    (Pallavi Rao via Suhas Vasu)
 

http://git-wip-us.apache.org/repos/asf/falcon/blob/45808eff/client/src/main/java/org/apache/falcon/ResponseHelper.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/ResponseHelper.java b/client/src/main/java/org/apache/falcon/ResponseHelper.java
index 5f36e3a..7d5cbe5 100644
--- a/client/src/main/java/org/apache/falcon/ResponseHelper.java
+++ b/client/src/main/java/org/apache/falcon/ResponseHelper.java
@@ -207,9 +207,9 @@ public final class ResponseHelper {
                 sb.append(toAppend).append("\n");
 
                 if (instance.getWfParams() != null) {
-                    Map<String, String> props = instance.getWfParams();
+                    InstancesResult.KeyValuePair[] props = instance.getWfParams();
                     sb.append("Workflow params").append("\n");
-                    for (Map.Entry<String, String> entry : props.entrySet()) {
+                    for (InstancesResult.KeyValuePair entry : props) {
                         sb.append(entry.getKey()).append("=")
                             .append(entry.getValue()).append("\n");
                     }

http://git-wip-us.apache.org/repos/asf/falcon/blob/45808eff/client/src/main/java/org/apache/falcon/resource/InstancesResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/resource/InstancesResult.java b/client/src/main/java/org/apache/falcon/resource/InstancesResult.java
index 65355f0..bde5767 100644
--- a/client/src/main/java/org/apache/falcon/resource/InstancesResult.java
+++ b/client/src/main/java/org/apache/falcon/resource/InstancesResult.java
@@ -19,10 +19,8 @@
 package org.apache.falcon.resource;
 
 import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementWrapper;
 import javax.xml.bind.annotation.XmlRootElement;
 import java.util.Date;
-import java.util.Map;
 
 /**
  * Pojo for JAXB marshalling / unmarshalling.
@@ -116,8 +114,8 @@ public class InstancesResult extends APIResult {
         @XmlElement
         public InstanceAction[] actions;
 
-        @XmlElementWrapper(name="params")
-        public Map<String, String> wfParams;
+        @XmlElement(name="params")
+        public KeyValuePair[] wfParams;
 
         public Instance() {
         }
@@ -164,8 +162,7 @@ public class InstancesResult extends APIResult {
             return details;
         }
 
-        public Map<String, String> getWfParams() { return wfParams; }
-
+        public KeyValuePair[] getWfParams() { return wfParams; }
 
         @Override
         public String toString() {
@@ -221,5 +218,36 @@ public class InstancesResult extends APIResult {
                     + "}";
         }
     }
+
+    /**
+     * POJO for key value parameters.
+     */
+    @XmlRootElement(name = "params")
+    public static class KeyValuePair {
+        @XmlElement
+        public String key;
+        @XmlElement
+        public String value;
+
+        public KeyValuePair(String key, String value) {
+            this.key = key;
+            this.value = value;
+        }
+
+        public KeyValuePair() { }
+
+        public String getKey() {
+            return key;
+        }
+
+        public String getValue() {
+            return value;
+        }
+
+        @Override
+        public String toString() {
+            return "{key:" + this.key + ", value:" + this.value + "}";
+        }
+    }
 }
 //RESUME CHECKSTYLE CHECK VisibilityModifierCheck

http://git-wip-us.apache.org/repos/asf/falcon/blob/45808eff/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 169856c..2733cca 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
@@ -711,12 +711,13 @@ public class OozieWorkflowEngine extends AbstractWorkflowEngine {
         instance.actions = instanceActions.toArray(new InstancesResult.InstanceAction[instanceActions.size()]);
     }
 
-    private Map<String, String> getWFParams(WorkflowJob jobInfo) {
-        Map<String, String> wfParams = new HashMap<String, String>();
+    private InstancesResult.KeyValuePair[] getWFParams(WorkflowJob jobInfo) {
         Configuration conf = new Configuration(false);
         conf.addResource(new ByteArrayInputStream(jobInfo.getConf().getBytes()));
+        InstancesResult.KeyValuePair[] wfParams = new InstancesResult.KeyValuePair[conf.size()];
+        int i = 0;
         for (Map.Entry<String, String> entry : conf) {
-            wfParams.put(entry.getKey(), entry.getValue());
+            wfParams[i++] = new InstancesResult.KeyValuePair(entry.getKey(), entry.getValue());
         }
         return wfParams;
     }


Mime
View raw message