Repository: oozie
Updated Branches:
  refs/heads/branch-4.1 1505bf00e -> 3a93f8435


OOZIE-2017 On startup, StatusTransitService can transition Coordinators that 
were in PREPSUSPENDED to RUNNING (rkanter)


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

Branch: refs/heads/branch-4.1
Commit: 3a93f84350487cfc4f9130d37397bc92d6118854
Parents: 1505bf0
Author: Robert Kanter <[email protected]>
Authored: Thu Oct 9 15:39:05 2014 -0700
Committer: Robert Kanter <[email protected]>
Committed: Thu Oct 9 15:39:05 2014 -0700

----------------------------------------------------------------------
 .../oozie/service/StatusTransitService.java     |  4 +-
 .../oozie/service/TestStatusTransitService.java | 49 ++++++++++++++++++++
 release-log.txt                                 |  2 +
 3 files changed, 54 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/oozie/blob/3a93f843/core/src/main/java/org/apache/oozie/service/StatusTransitService.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/oozie/service/StatusTransitService.java 
b/core/src/main/java/org/apache/oozie/service/StatusTransitService.java
index 21ac25f..39d3d16 100644
--- a/core/src/main/java/org/apache/oozie/service/StatusTransitService.java
+++ b/core/src/main/java/org/apache/oozie/service/StatusTransitService.java
@@ -600,7 +600,9 @@ public class StatusTransitService implements Service {
         private boolean 
checkCoordRunningStatus(HashMap<CoordinatorAction.Status, Integer> 
coordActionStatus,
                 int coordActionsCount, Job.Status[] coordStatus) {
             boolean ret = false;
-            if (coordStatus[0] != Job.Status.PREP) {
+            if (coordStatus[0] != Job.Status.PREP
+                    && coordStatus[0] != Job.Status.PREPSUSPENDED
+                    && coordStatus[0] !=  Job.Status.PREPPAUSED) {
                 if 
(coordActionStatus.containsKey(CoordinatorAction.Status.KILLED)
                         || 
coordActionStatus.containsKey(CoordinatorAction.Status.FAILED)
                         || 
coordActionStatus.containsKey(CoordinatorAction.Status.TIMEDOUT)) {

http://git-wip-us.apache.org/repos/asf/oozie/blob/3a93f843/core/src/test/java/org/apache/oozie/service/TestStatusTransitService.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/oozie/service/TestStatusTransitService.java 
b/core/src/test/java/org/apache/oozie/service/TestStatusTransitService.java
index bb99138..bcb4ee7 100644
--- a/core/src/test/java/org/apache/oozie/service/TestStatusTransitService.java
+++ b/core/src/test/java/org/apache/oozie/service/TestStatusTransitService.java
@@ -437,6 +437,55 @@ public class TestStatusTransitService extends 
XDataTestCase {
         assertEquals(Job.Status.SUCCEEDED, coordJob1.getStatus());
     }
 
+    /**
+     * If you have a PREP coordinator job (with no actions) and you suspend 
it, it goes into PREPSUSPENDED.
+     * The StatusTransitService should not transition it to RUNNING 
automatically.  This test verifies that the job remains in
+     * PREPSUSPENDED; and transitions back to PREP after a resume command.
+     *
+     * @throws Exception
+     */
+    public void CoordStatusTransitServicePrepSuspendedPrep() throws Exception {
+        final JPAService jpaService = Services.get().get(JPAService.class);
+        assertNotNull(jpaService);
+        String currentDatePlusMonth = 
XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
+        Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
+        Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
+
+        CoordinatorJobBean coordJob = 
addRecordToCoordJobTable(CoordinatorJob.Status.PREP, start, end, true, false, 
0);
+        final String coordJobId = coordJob.getId();
+
+        new CoordSuspendXCommand(coordJobId).call();
+
+        CoordJobGetJPAExecutor coordJobGetCmd = new 
CoordJobGetJPAExecutor(coordJobId);
+        coordJob = jpaService.execute(coordJobGetCmd);
+
+        assertEquals(Job.Status.PREPSUSPENDED, coordJob.getStatus());
+
+        new StatusTransitRunnable().run();
+
+        CoordinatorJobBean coordJob1 = jpaService.execute(new 
CoordJobGetJPAExecutor(coordJobId));
+        assertEquals(Job.Status.PREPSUSPENDED, coordJob1.getStatus());
+
+        new CoordResumeXCommand(coordJobId).call();
+
+        coordJob = jpaService.execute(coordJobGetCmd);
+
+        assertEquals(Job.Status.PREP, coordJob.getStatus());
+
+        new StatusTransitRunnable().run();
+
+        waitFor(20 * 1000, new Predicate() {
+            @Override
+            public boolean evaluate() throws Exception {
+                CoordinatorJobBean job = jpaService.execute(new 
CoordJobGetJPAExecutor(coordJobId));
+                return job.getStatus().equals(Job.Status.PREP);
+            }
+        });
+
+        coordJob1 = jpaService.execute(new CoordJobGetJPAExecutor(coordJobId));
+        assertEquals(Job.Status.PREP, coordJob1.getStatus());
+    }
+
 
     /**
      * Test : all coord actions are running, job pending is reset

http://git-wip-us.apache.org/repos/asf/oozie/blob/3a93f843/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index a36de24..f6684f8 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -1,4 +1,6 @@
 -- Oozie 4.1.0 release (4.1 - unreleased)
+
+OOZIE-2017 On startup, StatusTransitService can transition Coordinators that 
were in PREPSUSPENDED to RUNNING (rkanter)
 OOZIE-2023 Job rerun can stuck in prep (puru)
 OOZIE-1932 Services should load CallableQueueService after MemoryLocksService 
(mona)
 OOZIE-1950 Coordinator job info should support timestamp (nominal time) 
(shwethags)

Reply via email to