You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by rk...@apache.org on 2016/08/17 05:05:22 UTC
oozie git commit: OOZIE-2081 WorkflowJob notification to include
coordinator action id (seoeun25 via rkanter)
Repository: oozie
Updated Branches:
refs/heads/master c0cc536a5 -> 568041dc8
OOZIE-2081 WorkflowJob notification to include coordinator action id (seoeun25 via rkanter)
Project: http://git-wip-us.apache.org/repos/asf/oozie/repo
Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/568041dc
Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/568041dc
Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/568041dc
Branch: refs/heads/master
Commit: 568041dc878683f33e916fbf0f4ccb5811640b61
Parents: c0cc536
Author: Robert Kanter <rk...@cloudera.com>
Authored: Tue Aug 16 22:05:15 2016 -0700
Committer: Robert Kanter <rk...@cloudera.com>
Committed: Tue Aug 16 22:05:15 2016 -0700
----------------------------------------------------------------------
.../wf/WorkflowNotificationXCommand.java | 6 ++
.../wf/TestWorkflowNotificationXCommand.java | 67 ++++++++++++++++++++
.../src/site/twiki/WorkflowFunctionalSpec.twiki | 1 +
release-log.txt | 1 +
4 files changed, 75 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/oozie/blob/568041dc/core/src/main/java/org/apache/oozie/command/wf/WorkflowNotificationXCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/command/wf/WorkflowNotificationXCommand.java b/core/src/main/java/org/apache/oozie/command/wf/WorkflowNotificationXCommand.java
index d973def..62bf9b5 100644
--- a/core/src/main/java/org/apache/oozie/command/wf/WorkflowNotificationXCommand.java
+++ b/core/src/main/java/org/apache/oozie/command/wf/WorkflowNotificationXCommand.java
@@ -31,6 +31,7 @@ public class WorkflowNotificationXCommand extends NotificationXCommand {
private static final String STATUS_PATTERN = "\\$status";
private static final String JOB_ID_PATTERN = "\\$jobId";
+ private static final String PARENT_ID_PATTERN = "\\$parentId";
private static final String NODE_NAME_PATTERN = "\\$nodeName";
public WorkflowNotificationXCommand(WorkflowJobBean workflow) {
@@ -41,6 +42,11 @@ public class WorkflowNotificationXCommand extends NotificationXCommand {
if (url != null) {
url = url.replaceAll(JOB_ID_PATTERN, workflow.getId());
url = url.replaceAll(STATUS_PATTERN, workflow.getStatus().toString());
+ if (workflow.getParentId() == null) {
+ url = url.replaceAll(PARENT_ID_PATTERN, "");
+ } else {
+ url = url.replaceAll(PARENT_ID_PATTERN, workflow.getParentId());
+ }
proxyConf = workflow.getWorkflowInstance().getConf()
.get(OozieClient.WORKFLOW_NOTIFICATION_PROXY, ConfigurationService.get(NOTIFICATION_PROXY_KEY));
LOG.debug("Proxy :" + proxyConf);
http://git-wip-us.apache.org/repos/asf/oozie/blob/568041dc/core/src/test/java/org/apache/oozie/command/wf/TestWorkflowNotificationXCommand.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/oozie/command/wf/TestWorkflowNotificationXCommand.java b/core/src/test/java/org/apache/oozie/command/wf/TestWorkflowNotificationXCommand.java
index 4d2df21..ef342a4 100644
--- a/core/src/test/java/org/apache/oozie/command/wf/TestWorkflowNotificationXCommand.java
+++ b/core/src/test/java/org/apache/oozie/command/wf/TestWorkflowNotificationXCommand.java
@@ -30,9 +30,39 @@ import org.apache.oozie.workflow.WorkflowInstance;
import org.junit.Assert;
import org.mockito.Mockito;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
public class TestWorkflowNotificationXCommand extends XTestCase {
private EmbeddedServletContainer container;
+ public static class CallbackServlet extends HttpServlet {
+ public static volatile String JOB_ID = null;
+ public static String NODE_NAME = null;
+ public static String STATUS = null;
+ public static String PARENT_ID = null;
+
+ public static void reset() {
+ JOB_ID = null;
+ NODE_NAME = null;
+ STATUS = null;
+ PARENT_ID = null;
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ JOB_ID = req.getParameter("jobId");
+ NODE_NAME = req.getParameter("nodeName");
+ STATUS = req.getParameter("status");
+ PARENT_ID = req.getParameter("parentId");
+ resp.setStatus(HttpServletResponse.SC_OK);
+ }
+
+ }
+
@Override
public void setUp() throws Exception {
super.setUp();
@@ -41,6 +71,8 @@ public class TestWorkflowNotificationXCommand extends XTestCase {
services.init();
container = new EmbeddedServletContainer("blah");
container.addServletEndpoint("/hang/*", HangServlet.class);
+ CallbackServlet.reset();
+ container.addServletEndpoint("/callback/*", CallbackServlet.class);
container.start();
}
@@ -76,4 +108,39 @@ public class TestWorkflowNotificationXCommand extends XTestCase {
Assert.assertTrue(end - start >= 50);
Assert.assertTrue(end - start < 10000);
}
+
+ public void testWFNotification() throws Exception {
+
+ String notificationUrl = "/callback/wf?jobId=$jobId&parentId=$parentId";
+ _testNotificationParentId(notificationUrl, "1", null, "");
+
+ notificationUrl = "/callback/wf?jobId=$jobId";
+ _testNotificationParentId(notificationUrl, "1", null, null);
+
+ notificationUrl = "/callback/wf?jobId=$jobId&parentId=$parentId";
+ _testNotificationParentId(notificationUrl, "1", "0000000-111111-oozie-XXX-C@1", "0000000-111111-oozie-XXX-C@1");
+
+ notificationUrl = "/callback/wf?jobId=$jobId";
+ _testNotificationParentId(notificationUrl, "1", "0000000-111111-oozie-XXX-C@1", null);
+
+ }
+
+ private void _testNotificationParentId(String notificationUrl, String jobId, String parentId, String expectedParentId)
+ throws Exception{
+ XConfiguration conf = new XConfiguration();
+ conf.set(OozieClient.WORKFLOW_NOTIFICATION_URL, container.getServletURL(notificationUrl));
+ WorkflowInstance wfi = Mockito.mock(WorkflowInstance.class);
+ Mockito.when(wfi.getConf()).thenReturn(conf);
+ WorkflowJobBean workflow = Mockito.mock(WorkflowJobBean.class);
+ Mockito.when(workflow.getId()).thenReturn(jobId);
+ Mockito.when(workflow.getStatus()).thenReturn(WorkflowJob.Status.SUCCEEDED);
+ Mockito.when(workflow.getParentId()).thenReturn(parentId);
+ Mockito.when(workflow.getWorkflowInstance()).thenReturn(wfi);
+ WorkflowNotificationXCommand command = new WorkflowNotificationXCommand(workflow);
+ command.setRetry(3);
+ command.call();
+
+ Assert.assertEquals(jobId, CallbackServlet.JOB_ID);
+ Assert.assertEquals(expectedParentId, CallbackServlet.PARENT_ID);
+ }
}
http://git-wip-us.apache.org/repos/asf/oozie/blob/568041dc/docs/src/site/twiki/WorkflowFunctionalSpec.twiki
----------------------------------------------------------------------
diff --git a/docs/src/site/twiki/WorkflowFunctionalSpec.twiki b/docs/src/site/twiki/WorkflowFunctionalSpec.twiki
index 8b1bc19..7474ea5 100644
--- a/docs/src/site/twiki/WorkflowFunctionalSpec.twiki
+++ b/docs/src/site/twiki/WorkflowFunctionalSpec.twiki
@@ -2275,6 +2275,7 @@ the notification:
* =$jobId= : The workflow job ID
* =$status= : the workflow current state
+ * =$parentId= : The parent ID of the workflow job. If there is no parent ID, it will be replaced with an empty string.
---+++ 5.2 Node Start and End Notifications
http://git-wip-us.apache.org/repos/asf/oozie/blob/568041dc/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index fc2854b..b222fc0 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -1,5 +1,6 @@
-- Oozie 4.3.0 release (trunk - unreleased)
+OOZIE-2081 WorkflowJob notification to include coordinator action id (seoeun25 via rkanter)
OOZIE-2036 Drop support for Java 1.6 (gezapeti via jaydeepvishwakarma)
OOZIE-2512 ShareLibservice returns incorrect path for jar (satishsaley via puru)
OOZIE-2508 Documentation change for Coord action rerun [OOZIE-1735] (satishsaley via puru)