You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by pb...@apache.org on 2017/05/08 10:40:32 UTC
[26/37] oozie git commit: OOZIE-2862 Coord change command doesn't
change job to running if job was killed without creating any actions
OOZIE-2862 Coord change command doesn't change job to running if job was killed without creating any actions
Project: http://git-wip-us.apache.org/repos/asf/oozie/repo
Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/cf3b400a
Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/cf3b400a
Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/cf3b400a
Branch: refs/heads/oya
Commit: cf3b400a2a8e66f8689856bfb16b2547526a012a
Parents: 993f06d
Author: puru <pu...@gmail.com>
Authored: Wed Apr 12 14:17:13 2017 -0700
Committer: puru <pu...@gmail.com>
Committed: Wed Apr 12 14:17:13 2017 -0700
----------------------------------------------------------------------
.../command/coord/CoordChangeXCommand.java | 4 +-
.../command/coord/TestCoordChangeXCommand.java | 40 ++++++++++++++++----
release-log.txt | 1 +
3 files changed, 35 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/oozie/blob/cf3b400a/core/src/main/java/org/apache/oozie/command/coord/CoordChangeXCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/command/coord/CoordChangeXCommand.java b/core/src/main/java/org/apache/oozie/command/coord/CoordChangeXCommand.java
index e65b74f..ff7bf8a 100644
--- a/core/src/main/java/org/apache/oozie/command/coord/CoordChangeXCommand.java
+++ b/core/src/main/java/org/apache/oozie/command/coord/CoordChangeXCommand.java
@@ -436,8 +436,8 @@ public class CoordChangeXCommand extends CoordinatorXCommand<Void> {
LOG.info("Coord status is changed to " + jobStatus + " from " + prevStatus);
if (jobStatus.equals(CoordinatorJob.Status.RUNNING)) {
coordJob.setPending();
- if (coordJob.getNextMaterializedTime() != null
- && coordJob.getEndTime().after(coordJob.getNextMaterializedTime())) {
+ if (coordJob.getNextMaterializedTime() == null
+ || coordJob.getEndTime().after(coordJob.getNextMaterializedTime())) {
coordJob.resetDoneMaterialization();
}
} else if (jobStatus.equals(CoordinatorJob.Status.IGNORED)) {
http://git-wip-us.apache.org/repos/asf/oozie/blob/cf3b400a/core/src/test/java/org/apache/oozie/command/coord/TestCoordChangeXCommand.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/oozie/command/coord/TestCoordChangeXCommand.java b/core/src/test/java/org/apache/oozie/command/coord/TestCoordChangeXCommand.java
index 8034bbe..c071000 100644
--- a/core/src/test/java/org/apache/oozie/command/coord/TestCoordChangeXCommand.java
+++ b/core/src/test/java/org/apache/oozie/command/coord/TestCoordChangeXCommand.java
@@ -59,6 +59,7 @@ import org.apache.oozie.util.XCallable;
public class TestCoordChangeXCommand extends XDataTestCase {
private Services services;
+ public static final int HOURS_IN_MS = 60 * 60 * 1000;
/**
* Return the UTC date and time in W3C format down to second
@@ -538,7 +539,7 @@ public class TestCoordChangeXCommand extends XDataTestCase {
// Testcase to check status for coord whose enddate is set before startdate.
public void testCoordChangeEndTimeBeforeStart() throws Exception {
Date start = new Date();
- Date end = new Date(start.getTime() + (4 * 60 * 60 * 1000)); // 4 hrs
+ Date end = new Date(start.getTime() + (4 * HOURS_IN_MS)); // 4 hrs
Date endTime = new Date(start.getTime() - 3000);
String endTimeChangeStr = "endtime=" + DateUtils.formatDateOozieTZ(endTime);
@@ -624,7 +625,7 @@ public class TestCoordChangeXCommand extends XDataTestCase {
Date startTime = DateUtils.parseDateOozieTZ("2013-08-01T00:00Z");
Date endTime = DateUtils.parseDateOozieTZ("2013-08-01T04:59Z");
- Date pauseTime = new Date(startTime.getTime() + (3 * 60 * 60 * 1000)); //2 hrs
+ Date pauseTime = new Date(startTime.getTime() + (3 * HOURS_IN_MS)); //2 hrs
String pauseTimeChangeStr = "pausetime=" + DateUtils.formatDateOozieTZ(pauseTime);
final CoordinatorJobBean job = addRecordToCoordJobTableForPauseTimeTest(CoordinatorJob.Status.RUNNING, startTime,
endTime, endTime, true, false, 4);
@@ -729,7 +730,7 @@ public class TestCoordChangeXCommand extends XDataTestCase {
public void testChangeTimeDeleteRunning() throws Exception {
Date startTime = DateUtils.parseDateOozieTZ("2013-08-01T00:00Z");
Date endTime = DateUtils.parseDateOozieTZ("2013-08-01T04:59Z");
- Date pauseTime = new Date(startTime.getTime() + (2 * 60 * 60 * 1000)); // 2 hrs
+ Date pauseTime = new Date(startTime.getTime() + (2 * HOURS_IN_MS)); // 2 hrs
String pauseTimeChangeStr = "pausetime=" + DateUtils.formatDateOozieTZ(pauseTime);
final CoordinatorJobBean job = addRecordToCoordJobTableForPauseTimeTest(CoordinatorJob.Status.RUNNING,
startTime, endTime, endTime, true, false, 4);
@@ -763,7 +764,7 @@ public class TestCoordChangeXCommand extends XDataTestCase {
public void testCoordStatus_Ignored() throws Exception {
Date start = new Date();
- Date end = new Date(start.getTime() + (5 * 60 * 60 * 1000)); // 5 hrs
+ Date end = new Date(start.getTime() + (5 * HOURS_IN_MS)); // 5 hrs
String statusToRUNNING = "status=RUNNING";
String statusToIGNORED = "status=IGNORED";
final CoordinatorJobBean job1 = addRecordToCoordJobTableForPauseTimeTest(CoordinatorJob.Status.IGNORED, start,
@@ -808,7 +809,7 @@ public class TestCoordChangeXCommand extends XDataTestCase {
// Status change from failed- successful
public void testCoordStatus_Failed() throws Exception {
Date start = new Date();
- Date end = new Date(start.getTime() + (5 * 60 * 60 * 1000)); // 5 hrs
+ Date end = new Date(start.getTime() + (5 * HOURS_IN_MS)); // 5 hrs
String status = "status=RUNNING";
final CoordinatorJobBean job = addRecordToCoordJobTableForPauseTimeTest(CoordinatorJob.Status.FAILED, start,
end, end, true, false, 4);
@@ -837,7 +838,7 @@ public class TestCoordChangeXCommand extends XDataTestCase {
// Status change from Killed- successful
public void testCoordStatus_Killed() throws Exception {
Date start = new Date();
- Date end = new Date(start.getTime() + (5 * 60 * 60 * 1000)); // 5 hrs
+ Date end = new Date(start.getTime() + (5 * HOURS_IN_MS)); // 5 hrs
String status = "status=RUNNING";
final CoordinatorJobBean job = addRecordToCoordJobTableForPauseTimeTest(CoordinatorJob.Status.KILLED, start,
end, end, true, false, 4);
@@ -866,7 +867,7 @@ public class TestCoordChangeXCommand extends XDataTestCase {
// Check status change from Succeeded- exception
public void testCoordStatus_Changefailed() throws Exception {
Date start = new Date();
- Date end = new Date(start.getTime() + (4 * 60 * 60 * 1000)); // 5 hrs
+ Date end = new Date(start.getTime() + (4 * HOURS_IN_MS)); // 5 hrs
String status = "status=RUNNING";
final CoordinatorJobBean job = addRecordToCoordJobTableForPauseTimeTest(CoordinatorJob.Status.SUCCEEDED, start,
end, end, true, false, 4);
@@ -886,7 +887,7 @@ public class TestCoordChangeXCommand extends XDataTestCase {
// Check status change - with multiple option. Pause can't be applied to killed job, old behavior.
public void testCoord_throwException() throws Exception {
Date start = new Date();
- Date end = new Date(start.getTime() + (4 * 60 * 60 * 1000)); // 4 hrs
+ Date end = new Date(start.getTime() + (4 * HOURS_IN_MS)); // 4 hrs
String status = "status=RUNNING;pausetime=" + DateUtils.formatDateOozieTZ(end);
final CoordinatorJobBean job = addRecordToCoordJobTableForPauseTimeTest(CoordinatorJob.Status.KILLED, start,
end, end, true, false, 4);
@@ -903,6 +904,29 @@ public class TestCoordChangeXCommand extends XDataTestCase {
assertTrue(e.getMessage().contains("Cannot change a killed coordinator job"));
}
}
+
+ // Check status change - when job is killed with no action created
+ public void testRunningStatusWithNoAction() throws Exception {
+ Date now = new Date();
+ Date start = new Date(now.getTime() - (4 * HOURS_IN_MS)); // 4 hrs
+ Date end = new Date(now.getTime() + (4 * HOURS_IN_MS)); // 4 hrs
+
+ String status = "status=RUNNING";
+ CoordinatorJobBean job = addRecordToCoordJobTableForPauseTimeTest(CoordinatorJob.Status.KILLED, start, end,
+ null, true, false, 0);
+ job = CoordJobQueryExecutor.getInstance().get(CoordJobQueryExecutor.CoordJobQuery.GET_COORD_JOB, job.getId());
+ assertEquals("KILLED", job.getStatusStr());
+ assertNull(job.getNextMaterializedTime());
+ new CoordChangeXCommand(job.getId(), status).call();
+ job = CoordJobQueryExecutor.getInstance().get(CoordJobQueryExecutor.CoordJobQuery.GET_COORD_JOB, job.getId());
+ assertEquals("RUNNING", job.getStatusStr());
+ // make sure that action is created
+ new CoordMaterializeTransitionXCommand(job.getId(), 3600).call();
+ job = CoordJobQueryExecutor.getInstance().get(CoordJobQueryExecutor.CoordJobQuery.GET_COORD_JOB, job.getId());
+ assertNotNull(job.getNextMaterializedTime());
+ assertEquals(1, job.getLastActionNumber());
+ }
+
protected CoordinatorJobBean addRecordToCoordJobTableForPauseTimeTest(CoordinatorJob.Status status, Date start,
Date end, Date lastActionTime, boolean pending, boolean doneMatd, int lastActionNum) throws Exception {
CoordinatorJobBean coordJob = createCoordJob(status, start, end, pending, doneMatd, lastActionNum);
http://git-wip-us.apache.org/repos/asf/oozie/blob/cf3b400a/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index e141d0e..6fb121e 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -1,5 +1,6 @@
-- Oozie 4.4.0 release (trunk - unreleased)
+OOZIE-2862 Coord change command doesn't change job to running if job was killed without creating any actions (puru)
OOZIE-2815 Oozie not always display job log (puru)
OOZIE-2860 Improve Jetty logging (andras.piros via pbacsko)
OOZIE-2457 Oozie log parsing regex consume more than 90% cpu (satishsaley)