From a570c6caace0b750224d12171eaa070b23a0cfcf Mon Sep 17 00:00:00 2001 From: pkuwm Date: Thu, 7 Dec 2017 11:52:52 -0800 Subject: [PATCH] [OOZIE-3141] Expose external child job IDs to EL functions: wf:externalChildIDs(String actionName). --- .../java/org/apache/oozie/DagELFunctions.java | 17 ++++++++++++++--- .../org/apache/oozie/TestDagELFunctions.java | 2 ++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/apache/oozie/DagELFunctions.java b/core/src/main/java/org/apache/oozie/DagELFunctions.java index 22ac624c16..4056c0cde9 100644 --- a/core/src/main/java/org/apache/oozie/DagELFunctions.java +++ b/core/src/main/java/org/apache/oozie/DagELFunctions.java @@ -40,7 +40,6 @@ */ public class DagELFunctions { - public static final String HADOOP_JOBS_PREFIX = "hadoopJobs:"; private static final String WORKFLOW = "oozie.el.workflow.bean"; private static final String ACTION = "oozie.el.action.bean"; private static final String ACTION_PROTO_CONF = "oozie.el.action.proto.conf"; @@ -51,6 +50,7 @@ public class DagELFunctions { private static final String ACTION_ERROR_CODE = "action.error.code"; private static final String ACTION_ERROR_MESSAGE = "action.error.message"; private static final String ACTION_EXTERNAL_ID = "action.external.id"; + private static final String ACTION_EXTERNAL_CHILD_IDS = "action.external.child.ids"; private static final String ACTION_TRACKER_URI = "action.tracker.uri"; private static final String ACTION_EXTERNAL_STATUS = "action.external.status"; @@ -115,8 +115,8 @@ public static void setActionInfo(WorkflowInstance workflowInstance, WorkflowActi .setVar(action.getName() + WorkflowInstance.NODE_VAR_SEPARATOR + ACTION_DATA, action.getData()); } if (action.getExternalChildIDs() != null) { - workflowInstance.setVar(action.getName() + WorkflowInstance.NODE_VAR_SEPARATOR + ACTION_DATA, - HADOOP_JOBS_PREFIX + action.getExternalChildIDs()); + workflowInstance.setVar(action.getName() + WorkflowInstance.NODE_VAR_SEPARATOR + ACTION_EXTERNAL_CHILD_IDS, + action.getExternalChildIDs()); } if (action.getStats() != null) { workflowInstance.setVar(action.getName() + WorkflowInstance.NODE_VAR_SEPARATOR + MapReduceActionExecutor.HADOOP_COUNTERS, @@ -287,6 +287,17 @@ public static String wf_actionExternalId(String actionName) { .getVar(actionName + WorkflowInstance.NODE_VAR_SEPARATOR + ACTION_EXTERNAL_ID); } + /** + * Return the external child IDs of an action. + * + * @param actionName action name. + * @return the external child IDs of an action. + */ + public static String wf_actionExternalChildIDs(String actionName) { + return getWorkflow().getWorkflowInstance() + .getVar(actionName + WorkflowInstance.NODE_VAR_SEPARATOR + ACTION_EXTERNAL_CHILD_IDS); + } + /** * Return the tracker URI of an action. * diff --git a/core/src/test/java/org/apache/oozie/TestDagELFunctions.java b/core/src/test/java/org/apache/oozie/TestDagELFunctions.java index 3fb2029af8..4f0ff8e0d7 100644 --- a/core/src/test/java/org/apache/oozie/TestDagELFunctions.java +++ b/core/src/test/java/org/apache/oozie/TestDagELFunctions.java @@ -82,6 +82,7 @@ public void testFunctions() throws Exception { action.setErrorInfo("ec", "em"); action.setData("b=B"); action.setExternalId("ext"); + action.setExternalChildIDs("extChild"); action.setTrackerUri("tracker"); action.setExternalStatus("externalStatus"); @@ -122,6 +123,7 @@ public void testFunctions() throws Exception { assertTrue(eval.evaluate("${toConfigurationStr(wf:actionData('actionName'))}", String.class).contains(expected)); assertEquals("ext", eval.evaluate("${wf:actionExternalId('actionName')}", String.class)); + assertEquals("extChild", eval.evaluate("${wf:actionExternalChildIDs('actionName')}", String.class)); assertEquals("tracker", eval.evaluate("${wf:actionTrackerUri('actionName')}", String.class)); assertEquals("externalStatus", eval.evaluate("${wf:actionExternalStatus('actionName')}", String.class)); }