Repository: oozie Updated Branches: refs/heads/master ecedf6dc6 -> 11c665998
OOZIE-1703 User should be able to set coord end-time before start time (puru via rohini) Project: http://git-wip-us.apache.org/repos/asf/oozie/repo Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/11c66599 Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/11c66599 Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/11c66599 Branch: refs/heads/master Commit: 11c665998f0ae665cddd24cf0fb3bde4d2080d94 Parents: ecedf6d Author: Rohini Palaniswamy <[email protected]> Authored: Wed Jun 11 06:27:29 2014 -0700 Committer: Rohini Palaniswamy <[email protected]> Committed: Wed Jun 11 06:27:29 2014 -0700 ---------------------------------------------------------------------- .../command/coord/CoordChangeXCommand.java | 58 +++++++++++--------- .../command/coord/TestCoordChangeXCommand.java | 57 +++++++++---------- docs/src/site/twiki/DG_CommandLineTool.twiki | 17 ++++++ release-log.txt | 1 + 4 files changed, 80 insertions(+), 53 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/oozie/blob/11c66599/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 ea7df17..436b999 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 @@ -186,10 +186,7 @@ public class CoordChangeXCommand extends CoordinatorXCommand<Void> { */ private void checkPauseTime(CoordinatorJobBean coordJob, Date newPauseTime) throws CommandException { - // New pauseTime has to be a non-past time. - if (newPauseTime.before(coordJob.getStartTime())) { - throw new CommandException(ErrorCode.E1015, newPauseTime, "must be a non-past time"); - } + //no check. } /** @@ -349,33 +346,44 @@ public class CoordChangeXCommand extends CoordinatorXCommand<Void> { if (!dontChange) { coordJob.setEndTime(newEndTime); // OOZIE-1703, we should SUCCEEDED the coord, if it's in PREP and new endtime is before start time - if (coordJob.getStatus() == CoordinatorJob.Status.PREP && coordJob.getStartTime().after(newEndTime)) { - LOG.info("Changing coord status to SUCCEEDED, because it's in PREP and new end time is before start time. " - + "Startime is " + coordJob.getStartTime() + " and new end time is " + newEndTime); - coordJob.setStatus(CoordinatorJob.Status.SUCCEEDED); + if (coordJob.getStartTime().compareTo(newEndTime) >= 0) { + if (coordJob.getStatus() != CoordinatorJob.Status.PREP) { + processLookaheadActions(coordJob, newEndTime); + } + if (coordJob.getStatus() == CoordinatorJob.Status.PREP + || coordJob.getStatus() == CoordinatorJob.Status.RUNNING) { + LOG.info("Changing coord status to SUCCEEDED, because it's in " + coordJob.getStatus() + + " and new end time is before start time. Startime is " + coordJob.getStartTime() + + " and new end time is " + newEndTime); + coordJob.setStatus(CoordinatorJob.Status.SUCCEEDED); + coordJob.resetPending(); + } coordJob.setDoneMaterialization(); - coordJob.resetPending(); } else { - //move it to running iff neendtime is after starttime. - if (newEndTime.after(coordJob.getStartTime())) { - if (coordJob.getStatus() == CoordinatorJob.Status.SUCCEEDED) { - coordJob.setStatus(CoordinatorJob.Status.RUNNING); - } - if (coordJob.getStatus() == CoordinatorJob.Status.DONEWITHERROR - || coordJob.getStatus() == CoordinatorJob.Status.FAILED) { - // Check for backward compatibility for Oozie versions (3.2 and before) - // when RUNNINGWITHERROR, SUSPENDEDWITHERROR and - // PAUSEDWITHERROR is not supported - coordJob.setStatus(StatusUtils - .getStatusIfBackwardSupportTrue(CoordinatorJob.Status.RUNNINGWITHERROR)); - } - coordJob.setPending(); - coordJob.resetDoneMaterialization(); - processLookaheadActions(coordJob, newEndTime); + // move it to running iff newdtime is after starttime. + if (coordJob.getStatus() == CoordinatorJob.Status.SUCCEEDED) { + coordJob.setStatus(CoordinatorJob.Status.RUNNING); } + if (coordJob.getStatus() == CoordinatorJob.Status.DONEWITHERROR + || coordJob.getStatus() == CoordinatorJob.Status.FAILED) { + // Check for backward compatibility for Oozie versions (3.2 and before) + // when RUNNINGWITHERROR, SUSPENDEDWITHERROR and + // PAUSEDWITHERROR is not supported + coordJob.setStatus(StatusUtils + .getStatusIfBackwardSupportTrue(CoordinatorJob.Status.RUNNINGWITHERROR)); + } + coordJob.setPending(); + coordJob.resetDoneMaterialization(); + processLookaheadActions(coordJob, newEndTime); } } + else { + LOG.info("Didn't change endtime. Endtime is in between coord end time and next materialization time." + + "Coord endTime = " + DateUtils.formatDateOozieTZ(newEndTime) + + " next materialization time =" + + DateUtils.formatDateOozieTZ(coordJob.getNextMaterializedTime())); + } } if (newConcurrency != null) { http://git-wip-us.apache.org/repos/asf/oozie/blob/11c66599/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 bc24235..86c2d32 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 @@ -202,26 +202,6 @@ public class TestCoordChangeXCommand extends XDataTestCase { } try { - new CoordChangeXCommand(jobId, "pausetime=1900-12-20T05:00Z").call(); - fail("Should not reach here."); - } - catch (CommandException ex) { - if (ex.getErrorCode() != ErrorCode.E1015) { - fail("Error code should be E1015."); - } - } - - try { - new CoordChangeXCommand(jobId, "pausetime=2009-02-01T00:00Z").call(); - fail("Should not reach here."); - } - catch (CommandException ex) { - if (ex.getErrorCode() != ErrorCode.E1015) { - fail("Error code should be E1015."); - } - } - - try { new CoordChangeXCommand(jobId, "pausetime=null").call(); fail("Should not reach here."); } @@ -232,13 +212,10 @@ public class TestCoordChangeXCommand extends XDataTestCase { } try { - new CoordChangeXCommand(jobId, "pausetime=2009-02-01T00:08Z").call(); - fail("Should not reach here."); + new CoordChangeXCommand(jobId, "pausetime=" + pauseTime).call(); } catch (CommandException ex) { - if (ex.getErrorCode() != ErrorCode.E1015) { - fail("Error code should be E1015."); - } + fail("Should not throw exception"); } } @@ -395,7 +372,12 @@ public class TestCoordChangeXCommand extends XDataTestCase { assertTrue(coordJob.isDoneMaterialization()); String newEndTime = convertDateToString(startTime.getTime() + 20 * 60 * 1000); + try{ new CoordChangeXCommand(coordJob.getId(), "endtime=" + newEndTime).call(); + } catch(Exception e){ + assertTrue(e.getMessage().contains( + "Didn't change endtime. Endtime is in between coord end time and next materialization time")); + } coordJob = jpaService.execute(coordGetCmd); assertFalse(Job.Status.RUNNING == coordJob.getStatus()); assertFalse(coordJob.isPending()); @@ -498,13 +480,12 @@ public class TestCoordChangeXCommand extends XDataTestCase { assertEquals(Job.Status.PREP, coordJob.getStatus()); assertEquals(0, coordJob.getLastActionNumber()); - new CoordChangeXCommand(job.getId(), endTimeChangeStr).call(); - coordGetCmd = new CoordJobGetJPAExecutor(job.getId()); coordJob = jpaService.execute(coordGetCmd); assertEquals(DateUtils.formatDateOozieTZ(coordJob.getEndTime()), DateUtils.formatDateOozieTZ(endTime)); assertEquals(Job.Status.SUCCEEDED, coordJob.getStatus()); + Date newEndTime = new Date(start.getTime() - 2000); endTimeChangeStr = "endtime=" + DateUtils.formatDateOozieTZ(newEndTime); new CoordChangeXCommand(job.getId(), endTimeChangeStr).call(); @@ -512,6 +493,26 @@ public class TestCoordChangeXCommand extends XDataTestCase { coordJob = jpaService.execute(coordGetCmd); assertEquals(DateUtils.formatDateOozieTZ(coordJob.getEndTime()), DateUtils.formatDateOozieTZ(newEndTime)); assertEquals(Job.Status.SUCCEEDED, coordJob.getStatus()); + + // setting end date after startdate should make coord in running state + newEndTime = new Date(start.getTime() + (4 * 60 * 60 * 1000)); + endTimeChangeStr = "endtime=" + DateUtils.formatDateOozieTZ(newEndTime); + new CoordChangeXCommand(job.getId(), endTimeChangeStr).call(); + coordGetCmd = new CoordJobGetJPAExecutor(job.getId()); + coordJob = jpaService.execute(coordGetCmd); + assertEquals(DateUtils.formatDateOozieTZ(coordJob.getEndTime()), DateUtils.formatDateOozieTZ(newEndTime)); + assertEquals(Job.Status.RUNNING, coordJob.getStatus()); + + // setting end date before startdate should make coord in SUCCEEDED state + newEndTime = new Date(start.getTime() - 1000); + endTimeChangeStr = "endtime=" + DateUtils.formatDateOozieTZ(newEndTime); + new CoordChangeXCommand(job.getId(), endTimeChangeStr).call(); + coordGetCmd = new CoordJobGetJPAExecutor(job.getId()); + coordJob = jpaService.execute(coordGetCmd); + assertEquals(DateUtils.formatDateOozieTZ(coordJob.getEndTime()), DateUtils.formatDateOozieTZ(newEndTime)); + assertEquals(Job.Status.SUCCEEDED, coordJob.getStatus()); + + } /** @@ -958,4 +959,4 @@ public class TestCoordChangeXCommand extends XDataTestCase { } } -} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/oozie/blob/11c66599/docs/src/site/twiki/DG_CommandLineTool.twiki ---------------------------------------------------------------------- diff --git a/docs/src/site/twiki/DG_CommandLineTool.twiki b/docs/src/site/twiki/DG_CommandLineTool.twiki index 03a36eb..4a07711 100644 --- a/docs/src/site/twiki/DG_CommandLineTool.twiki +++ b/docs/src/site/twiki/DG_CommandLineTool.twiki @@ -378,7 +378,24 @@ Valid value names are: Repeated value names are not allowed. An empty string "" can be used to reset pause time to none. New end time should not be before job's kickoff time. +---+++ Changing endtime/pausetime of a Bundle Job + +Example: + +<verbatim> +$ oozie job -oozie http://localhost:11000/oozie -change 14-20090525161321-oozie-joe -value pausetime=2011-12-01T05:00Z +</verbatim> + +The =change= option changes a bundle job that is not in =KILLED= status. + +Valid value names are: + * pausetime: the pause time of the bundle job. + * endtime: the end time of the bundle job. + +Repeated value names are not allowed. An empty string "" can be used to reset pause time to none. New end time should not be before job's kickoff time. + Bundle will execute pause/end date change command on each coordinator job. Refer conditions and usage section of coordinator change command for more details [[DG_CommandLineTool#Changing_endtimeconcurrencypausetimestatus_of_a_Coordinator_Job][Coordinator job change command]]. + ---+++ Rerunning a Workflow Job Example: http://git-wip-us.apache.org/repos/asf/oozie/blob/11c66599/release-log.txt ---------------------------------------------------------------------- diff --git a/release-log.txt b/release-log.txt index 74b5dfd..5090b5d 100644 --- a/release-log.txt +++ b/release-log.txt @@ -1,5 +1,6 @@ -- Oozie 4.1.0 release (trunk - unreleased) +OOZIE-1703 User should be able to set coord end-time before start time (puru via rohini) OOZIE-1715 Distributed ID sequence for HA (puru via rkanter) OOZIE-1870 Workflow action doen't resolve retry-max and retry-interval (puru via rohini) OOZIE-1686 Typo in DG_CommandLineTool (anbu78 via ryota)
