Repository: oozie
Updated Branches:
  refs/heads/master 53ad77290 -> 681c907ab


OOZIE-2063 Cron syntax creates duplicate actions (bzhang)


Project: http://git-wip-us.apache.org/repos/asf/oozie/repo
Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/681c907a
Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/681c907a
Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/681c907a

Branch: refs/heads/master
Commit: 681c907ab090809aa1a70b9930cf0407fd14251d
Parents: 53ad772
Author: Bowen Zhang <[email protected]>
Authored: Wed Nov 12 14:15:24 2014 -0800
Committer: Bowen Zhang <[email protected]>
Committed: Wed Nov 12 14:15:24 2014 -0800

----------------------------------------------------------------------
 .../CoordMaterializeTransitionXCommand.java     | 10 ++++++++
 .../TestCoordMaterializeTransitionXCommand.java | 26 ++++++++++++++++++++
 release-log.txt                                 |  1 +
 3 files changed, 37 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/oozie/blob/681c907a/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 e2d63bb..4c86f9e 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
@@ -500,6 +500,16 @@ public class CoordMaterializeTransitionXCommand extends 
MaterializeTransitionXCo
             }
         }
 
+        if (isCronFrequency) {
+            if (start.compareTo(end) < 0 && !(ignoreMaxActions || 
maxActionToBeCreated-- > 0)) {
+                //Since we exceed the throttle, we need to move the 
nextMadtime forward
+                //to avoid creating duplicate actions
+                if (!firstMater) {
+                    
start.setTime(CoordCommandUtils.getNextValidActionTimeForCronFrequency(start.getTime(),
 coordJob));
+                }
+            }
+        }
+
         endMatdTime = start.getTime();
 
         if (!dryrun) {

http://git-wip-us.apache.org/repos/asf/oozie/blob/681c907a/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 e09fe32..cf11ae0 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
@@ -293,6 +293,32 @@ public class TestCoordMaterializeTransitionXCommand 
extends XDataTestCase {
         }
     }
 
+    public void testActionMaterwithCronFrequencyWithThrottle() throws 
Exception {
+        Date startTime = DateUtils.parseDateOozieTZ("2013-07-18T00:00Z");
+        Date endTime = DateUtils.parseDateOozieTZ("2013-07-18T01:00Z");
+        CoordinatorJobBean job = 
addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, startTime, endTime, 
null,
+                "0/10 * * * *");
+        job.setMatThrottling(3);
+        
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB,
 job);
+
+        new CoordMaterializeTransitionXCommand(job.getId(), 3600).call();
+        Date[] nominalTimes = new Date[] 
{DateUtils.parseDateOozieTZ("2013-07-18T00:00Z"),
+                DateUtils.parseDateOozieTZ("2013-07-18T00:10Z"),
+                DateUtils.parseDateOozieTZ("2013-07-18T00:20Z")};
+        checkCoordActionsNominalTime(job.getId(), 3, nominalTimes);
+
+        try {
+            JPAService jpaService = Services.get().get(JPAService.class);
+            job =  jpaService.execute(new CoordJobGetJPAExecutor(job.getId()));
+            assertFalse(job.isDoneMaterialization());
+            assertEquals(3, job.getLastActionNumber());
+            assertEquals(DateUtils.parseDateOozieTZ("2013-07-18T00:30Z"), 
job.getNextMaterializedTime());
+        }
+        catch (JPAExecutorException se) {
+            se.printStackTrace();
+            fail("Job ID " + job.getId() + " was not stored properly in db");
+        }
+    }
     public void testActionMaterWithDST1() throws Exception {
         Date startTime = DateUtils.parseDateOozieTZ("2013-03-10T08:00Z");
         Date endTime = DateUtils.parseDateOozieTZ("2013-03-10T12:00Z");

http://git-wip-us.apache.org/repos/asf/oozie/blob/681c907a/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 3196a63..99a2f45 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -1,5 +1,6 @@
 -- Oozie 4.2.0 release (trunk - unreleased)
 
+OOZIE-2063 Cron syntax creates duplicate actions (bzhang)
 OOZIE-1803 Improvement in Purge service (jaydeepvishwakarma via shwethags)
 OOZIE-2043 Misc test failures against JDK8 (rkanter)
 OOZIE-2045 Symlink support for sharelib (puru)

Reply via email to