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 2014/05/28 00:19:04 UTC
[3/3] git commit: OOZIE-1834 sla should-start is supposed to be
optional but it is not (rkanter)
OOZIE-1834 sla should-start is supposed to be optional but it is not (rkanter)
Project: http://git-wip-us.apache.org/repos/asf/oozie/repo
Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/373a52ff
Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/373a52ff
Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/373a52ff
Branch: refs/heads/master
Commit: 373a52ff28a2b41aed9a8950f24f974523fc19e9
Parents: 2a85bfe
Author: Robert Kanter <rk...@cloudera.com>
Authored: Tue May 27 15:15:39 2014 -0700
Committer: Robert Kanter <rk...@cloudera.com>
Committed: Tue May 27 15:15:39 2014 -0700
----------------------------------------------------------------------
.../apache/oozie/util/db/SLADbOperations.java | 39 +++++++-------
.../apache/oozie/util/db/SLADbXOperations.java | 21 ++++----
.../oozie/util/db/TestSLADbOperations.java | 55 ++++++++++++++++++++
.../oozie/util/db/TestSLADbXOperations.java | 47 +++++++++++++++++
release-log.txt | 1 +
5 files changed, 134 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/oozie/blob/373a52ff/core/src/main/java/org/apache/oozie/util/db/SLADbOperations.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/util/db/SLADbOperations.java b/core/src/main/java/org/apache/oozie/util/db/SLADbOperations.java
index 155434b..15a37cf 100644
--- a/core/src/main/java/org/apache/oozie/util/db/SLADbOperations.java
+++ b/core/src/main/java/org/apache/oozie/util/db/SLADbOperations.java
@@ -53,17 +53,18 @@ public class SLADbOperations {
Date nominalTime = DateUtils.parseDateOozieTZ(strNominalTime);
// Setting expected start time
String strRelExpectedStart = getTagElement(eSla, "should-start");
- if (strRelExpectedStart == null || strRelExpectedStart.length() == 0) {
- throw new RuntimeException("should-start can't be empty");
- }
- int relExpectedStart = Integer.parseInt(strRelExpectedStart);
- if (relExpectedStart < 0) {
+ if (strRelExpectedStart != null && strRelExpectedStart.length() > 0) {
+ int relExpectedStart = Integer.parseInt(strRelExpectedStart);
+ if (relExpectedStart < 0) {
+ sla.setExpectedStart(null);
+ }
+ else {
+ Date expectedStart = new Date(nominalTime.getTime() + relExpectedStart * 60 * 1000);
+ sla.setExpectedStart(expectedStart);
+ }
+ } else {
sla.setExpectedStart(null);
}
- else {
- Date expectedStart = new Date(nominalTime.getTime() + relExpectedStart * 60 * 1000);
- sla.setExpectedStart(expectedStart);
- }
// Setting expected end time
String strRelExpectedEnd = getTagElement(eSla, "should-end");
@@ -120,18 +121,18 @@ public class SLADbOperations {
Date nominalTime = DateUtils.parseDateOozieTZ(strNominalTime);
// Setting expected start time
String strRelExpectedStart = getTagElement(eSla, "should-start");
- if (strRelExpectedStart == null || strRelExpectedStart.length() == 0) {
- throw new RuntimeException("should-start can't be empty");
- }
- int relExpectedStart = Integer.parseInt(strRelExpectedStart);
- if (relExpectedStart < 0) {
+ if (strRelExpectedStart != null && strRelExpectedStart.length() > 0) {
+ int relExpectedStart = Integer.parseInt(strRelExpectedStart);
+ if (relExpectedStart < 0) {
+ sla.setExpectedStart(null);
+ }
+ else {
+ Date expectedStart = new Date(nominalTime.getTime() + relExpectedStart * 60 * 1000);
+ sla.setExpectedStart(expectedStart);
+ }
+ } else {
sla.setExpectedStart(null);
}
- else {
- Date expectedStart = new Date(nominalTime.getTime()
- + relExpectedStart * 60 * 1000);
- sla.setExpectedStart(expectedStart);
- }
// Setting expected end time
String strRelExpectedEnd = getTagElement(eSla, "should-end");
http://git-wip-us.apache.org/repos/asf/oozie/blob/373a52ff/core/src/main/java/org/apache/oozie/util/db/SLADbXOperations.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/util/db/SLADbXOperations.java b/core/src/main/java/org/apache/oozie/util/db/SLADbXOperations.java
index 1474f1f..f313a4a 100644
--- a/core/src/main/java/org/apache/oozie/util/db/SLADbXOperations.java
+++ b/core/src/main/java/org/apache/oozie/util/db/SLADbXOperations.java
@@ -61,18 +61,19 @@ public class SLADbXOperations {
Date nominalTime = DateUtils.parseDateOozieTZ(strNominalTime);
// Setting expected start time
String strRelExpectedStart = getTagElement(eSla, "should-start");
- if (strRelExpectedStart == null || strRelExpectedStart.length() == 0) {
- throw new CommandException(ErrorCode.E1101);
- }
- int relExpectedStart = Integer.parseInt(strRelExpectedStart);
- if (relExpectedStart < 0) {
+ if (strRelExpectedStart != null && strRelExpectedStart.length() > 0) {
+ int relExpectedStart = Integer.parseInt(strRelExpectedStart);
+ if (relExpectedStart < 0) {
+ sla.setExpectedStart(null);
+ }
+ else {
+ Date expectedStart = new Date(nominalTime.getTime()
+ + relExpectedStart * 60 * 1000);
+ sla.setExpectedStart(expectedStart);
+ }
+ } else {
sla.setExpectedStart(null);
}
- else {
- Date expectedStart = new Date(nominalTime.getTime()
- + relExpectedStart * 60 * 1000);
- sla.setExpectedStart(expectedStart);
- }
// Setting expected end time
String strRelExpectedEnd = getTagElement(eSla, "should-end");
http://git-wip-us.apache.org/repos/asf/oozie/blob/373a52ff/core/src/test/java/org/apache/oozie/util/db/TestSLADbOperations.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/oozie/util/db/TestSLADbOperations.java b/core/src/test/java/org/apache/oozie/util/db/TestSLADbOperations.java
new file mode 100644
index 0000000..3e9452e
--- /dev/null
+++ b/core/src/test/java/org/apache/oozie/util/db/TestSLADbOperations.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oozie.util.db;
+
+import java.util.Date;
+import org.apache.oozie.SLAEventBean;
+import org.apache.oozie.client.SLAEvent;
+import org.apache.oozie.test.XTestCase;
+import org.apache.oozie.util.DateUtils;
+import org.apache.oozie.util.XmlUtils;
+import org.jdom.Element;
+
+public class TestSLADbOperations extends XTestCase {
+
+ @SuppressWarnings("deprecation")
+ public void testCreateSlaRegistrationEventMinReqFields() throws Exception {
+ Date nomDate = DateUtils.parseDateOozieTZ("2014-01-01T01:01Z");
+ String slaXML = " <sla:info xmlns:sla='uri:oozie:sla:0.2'>"
+ + " <sla:nominal-time>" + DateUtils.formatDateOozieTZ(nomDate) + "</sla:nominal-time>"
+ + " <sla:should-end>5</sla:should-end>"
+ + "</sla:info>";
+ Element eSla = XmlUtils.parseXml(slaXML);
+
+ SLAEventBean regEvent =
+ SLADbOperations.createSlaRegistrationEvent(eSla, null, "id1", SLAEvent.SlaAppType.WORKFLOW_JOB, "user1", "group1");
+ assertEquals(SLAEvent.SlaAppType.WORKFLOW_JOB, regEvent.getAppType());
+ assertEquals(new Date(nomDate.getTime() + 5 * 60 * 1000), regEvent.getExpectedEnd());
+ assertEquals("group1", regEvent.getGroupName());
+ assertEquals("id1", regEvent.getSlaId());
+ assertEquals("user1", regEvent.getUser());
+
+ regEvent =
+ SLADbOperations.createSlaRegistrationEvent(eSla, "id1", SLAEvent.SlaAppType.WORKFLOW_JOB, "user1", "group1", null);
+ assertEquals(SLAEvent.SlaAppType.WORKFLOW_JOB, regEvent.getAppType());
+ assertEquals(new Date(nomDate.getTime() + 5 * 60 * 1000), regEvent.getExpectedEnd());
+ assertEquals("group1", regEvent.getGroupName());
+ assertEquals("id1", regEvent.getSlaId());
+ assertEquals("user1", regEvent.getUser());
+ }
+}
http://git-wip-us.apache.org/repos/asf/oozie/blob/373a52ff/core/src/test/java/org/apache/oozie/util/db/TestSLADbXOperations.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/oozie/util/db/TestSLADbXOperations.java b/core/src/test/java/org/apache/oozie/util/db/TestSLADbXOperations.java
new file mode 100644
index 0000000..2ab609f
--- /dev/null
+++ b/core/src/test/java/org/apache/oozie/util/db/TestSLADbXOperations.java
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oozie.util.db;
+
+import java.util.Date;
+import org.apache.oozie.SLAEventBean;
+import org.apache.oozie.client.SLAEvent;
+import org.apache.oozie.test.XTestCase;
+import org.apache.oozie.util.DateUtils;
+import org.apache.oozie.util.XmlUtils;
+import org.jdom.Element;
+
+public class TestSLADbXOperations extends XTestCase {
+
+ @SuppressWarnings("deprecation")
+ public void testCreateSlaRegistrationEventMinReqFields() throws Exception {
+ Date nomDate = DateUtils.parseDateOozieTZ("2014-01-01T01:01Z");
+ String slaXML = " <sla:info xmlns:sla='uri:oozie:sla:0.2'>"
+ + " <sla:nominal-time>" + DateUtils.formatDateOozieTZ(nomDate) + "</sla:nominal-time>"
+ + " <sla:should-end>5</sla:should-end>"
+ + "</sla:info>";
+ Element eSla = XmlUtils.parseXml(slaXML);
+
+ SLAEventBean regEvent =
+ SLADbXOperations.createSlaRegistrationEvent(eSla, "id1", SLAEvent.SlaAppType.WORKFLOW_JOB, "user1", "group1");
+ assertEquals(SLAEvent.SlaAppType.WORKFLOW_JOB, regEvent.getAppType());
+ assertEquals(new Date(nomDate.getTime() + 5 * 60 * 1000), regEvent.getExpectedEnd());
+ assertEquals("group1", regEvent.getGroupName());
+ assertEquals("id1", regEvent.getSlaId());
+ assertEquals("user1", regEvent.getUser());
+ }
+}
http://git-wip-us.apache.org/repos/asf/oozie/blob/373a52ff/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 008c089..7d1d339 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -1,5 +1,6 @@
-- Oozie 4.1.0 release (trunk - unreleased)
+OOZIE-1834 sla should-start is supposed to be optional but it is not (rkanter)
OOZIE-1838 jdbc.connections.active sampler does not show up (rkanter)
OOZIE-1801 ZKLocksService instrumentation should say how many locks this server has (rkanter)
OOZIE-1819 Avoid early queueing of CoordActionInputCheckXCommand (shwethags via rohini)