Repository: oozie Updated Branches: refs/heads/master c270a20c3 -> 17defc414
OOZIE-1818 CoordMaterializeTransitionXCommand verifyPrecondition doesn't verify current time Project: http://git-wip-us.apache.org/repos/asf/oozie/repo Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/17defc41 Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/17defc41 Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/17defc41 Branch: refs/heads/master Commit: 17defc4148e6945698ae599c38fe4fa48b6ed269 Parents: c270a20 Author: Purshotam Shah <[email protected]> Authored: Mon Sep 8 12:23:39 2014 -0700 Committer: Purshotam Shah <[email protected]> Committed: Mon Sep 8 12:23:39 2014 -0700 ---------------------------------------------------------------------- .../CoordMaterializeTransitionXCommand.java | 9 +++++ .../TestCoordMaterializeTransitionXCommand.java | 37 ++++++++++++++++++-- release-log.txt | 1 + 3 files changed, 45 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/oozie/blob/17defc41/core/src/main/java/org/apache/oozie/command/coord/CoordMaterializeTransitionXCommand.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/command/coord/CoordMaterializeTransitionXCommand.java b/core/src/main/java/org/apache/oozie/command/coord/CoordMaterializeTransitionXCommand.java index a13fe83..05b7a62 100644 --- a/core/src/main/java/org/apache/oozie/command/coord/CoordMaterializeTransitionXCommand.java +++ b/core/src/main/java/org/apache/oozie/command/coord/CoordMaterializeTransitionXCommand.java @@ -313,6 +313,15 @@ public class CoordMaterializeTransitionXCommand extends MaterializeTransitionXCo } } + if (coordJob.getNextMaterializedTimestamp() != null + && coordJob.getNextMaterializedTimestamp().after( + new Timestamp(System.currentTimeMillis() + lookAheadWindow * 1000))) { + throw new PreconditionException(ErrorCode.E1100, "CoordMaterializeTransitionXCommand for jobId=" + jobId + + " Request is for future time. Lookup time is " + + new Timestamp(System.currentTimeMillis() + lookAheadWindow * 1000) + " mat time is " + + coordJob.getNextMaterializedTimestamp()); + } + if (coordJob.getLastActionTime() != null && coordJob.getLastActionTime().compareTo(coordJob.getEndTime()) >= 0) { throw new PreconditionException(ErrorCode.E1100, "ENDED Coordinator materialization for jobId = " + jobId + ", all actions have been materialized from start time = " + coordJob.getStartTime() http://git-wip-us.apache.org/repos/asf/oozie/blob/17defc41/core/src/test/java/org/apache/oozie/command/coord/TestCoordMaterializeTransitionXCommand.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/oozie/command/coord/TestCoordMaterializeTransitionXCommand.java b/core/src/test/java/org/apache/oozie/command/coord/TestCoordMaterializeTransitionXCommand.java index d122944..e09fe32 100644 --- a/core/src/test/java/org/apache/oozie/command/coord/TestCoordMaterializeTransitionXCommand.java +++ b/core/src/test/java/org/apache/oozie/command/coord/TestCoordMaterializeTransitionXCommand.java @@ -606,6 +606,26 @@ public class TestCoordMaterializeTransitionXCommand extends XDataTestCase { checkCoordActionsStatus(job.getId(), expectedStatuses); } + public void testCurrentTimeCheck() throws Exception { + long now = System.currentTimeMillis(); + Date startTime = DateUtils.toDate(new Timestamp(now)); // now + Date endTime = DateUtils.toDate(new Timestamp(now + 3 * 60 * 60 * 1000)); // 3 hours from now + CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, startTime, endTime, null, "5", + 20); + new CoordMaterializeTransitionXCommand(job.getId(), 3600).call(); + checkCoordJobs(job.getId(), CoordinatorJob.Status.RUNNING); + + job = CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, job.getId()); + assertEquals(job.getLastActionNumber(), 12); + new CoordMaterializeTransitionXCommand(job.getId(), 3600).call(); + // unfortunatily XCommand doesn't throw exception on precondition + // assertEquals(e.getErrorCode(), ErrorCode.E1100); + // assertTrue(e.getMessage().contains("Request is for future time. Lookup time is")); + + job = CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, job.getId()); + // getLastActionNumber should 12, last CoordMaterializeTransitionXCommand have failed + assertEquals(job.getLastActionNumber(), 12); + } protected CoordinatorJobBean addRecordToCoordJobTable(CoordinatorJob.Status status, Date startTime, Date endTime, Date pauseTime, String freq) throws Exception { @@ -613,12 +633,25 @@ public class TestCoordMaterializeTransitionXCommand extends XDataTestCase { } protected CoordinatorJobBean addRecordToCoordJobTable(CoordinatorJob.Status status, Date startTime, Date endTime, + Date pauseTime, String freq, int matThrottling) throws Exception { + return addRecordToCoordJobTable(status, startTime, endTime, pauseTime, -1, freq, CoordinatorJob.Execution.FIFO, + matThrottling); + } + + protected CoordinatorJobBean addRecordToCoordJobTable(CoordinatorJob.Status status, Date startTime, Date endTime, Date pauseTime, int timeout, String freq) throws Exception { - return addRecordToCoordJobTable(status, startTime, endTime, pauseTime, timeout, freq, CoordinatorJob.Execution.FIFO); + return addRecordToCoordJobTable(status, startTime, endTime, pauseTime, timeout, freq, + CoordinatorJob.Execution.FIFO, 20); } protected CoordinatorJobBean addRecordToCoordJobTable(CoordinatorJob.Status status, Date startTime, Date endTime, Date pauseTime, int timeout, String freq, CoordinatorJob.Execution execution) throws Exception { + return addRecordToCoordJobTable(status, startTime, endTime, pauseTime, timeout, freq, execution, 20); + } + + protected CoordinatorJobBean addRecordToCoordJobTable(CoordinatorJob.Status status, Date startTime, Date endTime, + Date pauseTime, int timeout, String freq, CoordinatorJob.Execution execution, int matThrottling) + throws Exception { CoordinatorJobBean coordJob = createCoordJob(status, startTime, endTime, false, false, 0); coordJob.setStartTime(startTime); coordJob.setEndTime(endTime); @@ -627,7 +660,7 @@ public class TestCoordMaterializeTransitionXCommand extends XDataTestCase { coordJob.setTimeUnit(Timeunit.MINUTE); coordJob.setTimeout(timeout); coordJob.setConcurrency(3); - coordJob.setMatThrottling(20); + coordJob.setMatThrottling(matThrottling); coordJob.setExecutionOrder(execution); try { http://git-wip-us.apache.org/repos/asf/oozie/blob/17defc41/release-log.txt ---------------------------------------------------------------------- diff --git a/release-log.txt b/release-log.txt index bace76f..dd5131a 100644 --- a/release-log.txt +++ b/release-log.txt @@ -1,5 +1,6 @@ -- Oozie 4.2.0 release (trunk - unreleased) +OOZIE-1818 CoordMaterializeTransitionXCommand verifyPrecondition doesn't verify current time (puru) OOZIE-1653 Support ALL to allowed error code of the user retry (seoeun25 via rkanter) OOZIE-1923 ZKLocksService locks are not re-entrant like MemoryLocks (puru) OOZIE-1843 Bulk update for coord last modified time for CoordMaterializeTriggerService (puru)
