You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by vi...@apache.org on 2012/09/04 21:24:14 UTC
svn commit: r1380821 - in /incubator/oozie/trunk: ./
core/src/main/java/org/apache/oozie/command/bundle/
core/src/test/java/org/apache/oozie/service/
Author: virag
Date: Tue Sep 4 19:24:13 2012
New Revision: 1380821
URL: http://svn.apache.org/viewvc?rev=1380821&view=rev
Log:
OOZIE-978 Bundle status doesn't transit to KILLED after a coordinator job fails submission (virag)
Modified:
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/bundle/BundleJobSuspendXCommand.java
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/bundle/BundleKillXCommand.java
incubator/oozie/trunk/core/src/test/java/org/apache/oozie/service/TestStatusTransitService.java
incubator/oozie/trunk/release-log.txt
Modified: incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/bundle/BundleJobSuspendXCommand.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/bundle/BundleJobSuspendXCommand.java?rev=1380821&r1=1380820&r2=1380821&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/bundle/BundleJobSuspendXCommand.java (original)
+++ incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/bundle/BundleJobSuspendXCommand.java Tue Sep 4 19:24:13 2012
@@ -133,8 +133,8 @@ public class BundleJobSuspendXCommand ex
@Override
protected void verifyPrecondition() throws CommandException, PreconditionException {
if (bundleJob.getStatus() == Job.Status.SUCCEEDED || bundleJob.getStatus() == Job.Status.FAILED
- || bundleJob.getStatus() == Job.Status.KILLED) {
- LOG.info("BundleJobSuspendXCommand is not going to execute because job finished or failed or killed, id = "
+ || bundleJob.getStatus() == Job.Status.KILLED || bundleJob.getStatus() == Job.Status.DONEWITHERROR) {
+ LOG.info("BundleJobSuspendXCommand is not going to execute because job either succeeded, failed, killed, or donewitherror; id = "
+ jobId + ", status = " + bundleJob.getStatus());
throw new PreconditionException(ErrorCode.E1312, jobId, bundleJob.getStatus().toString());
}
Modified: incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/bundle/BundleKillXCommand.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/bundle/BundleKillXCommand.java?rev=1380821&r1=1380820&r2=1380821&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/bundle/BundleKillXCommand.java (original)
+++ incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/bundle/BundleKillXCommand.java Tue Sep 4 19:24:13 2012
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -95,11 +95,12 @@ public class BundleKillXCommand extends
*/
@Override
protected void verifyPrecondition() throws CommandException, PreconditionException {
- if (bundleJob.getStatus() == CoordinatorJob.Status.SUCCEEDED
- || bundleJob.getStatus() == CoordinatorJob.Status.FAILED
- || bundleJob.getStatus() == CoordinatorJob.Status.DONEWITHERROR) {
- LOG.info("BundleKillXCommand not killed - job either finished SUCCEEDED, FAILED or DONEWITHERROR, job id = "
- + jobId + ", status = " + bundleJob.getStatus());
+ if (bundleJob.getStatus() == Job.Status.SUCCEEDED
+ || bundleJob.getStatus() == Job.Status.FAILED
+ || bundleJob.getStatus() == Job.Status.DONEWITHERROR
+ || bundleJob.getStatus() == Job.Status.KILLED) {
+ LOG.info("Bundle job cannot be killed - job already SUCCEEDED, FAILED, KILLED or DONEWITHERROR, job id = "
+ + jobId + ", status = " + bundleJob.getStatus());
throw new PreconditionException(ErrorCode.E1020, jobId);
}
}
@@ -134,9 +135,11 @@ public class BundleKillXCommand extends
* @throws CommandException
*/
private void updateBundleAction(BundleActionBean action) {
- action.incrementAndGetPending();
action.setLastModifiedTime(new Date());
- action.setStatus(Job.Status.KILLED);
+ if (!action.isTerminalStatus()) {
+ action.incrementAndGetPending();
+ action.setStatus(Job.Status.KILLED);
+ }
updateList.add(action);
}
Modified: incubator/oozie/trunk/core/src/test/java/org/apache/oozie/service/TestStatusTransitService.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/service/TestStatusTransitService.java?rev=1380821&r1=1380820&r2=1380821&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/test/java/org/apache/oozie/service/TestStatusTransitService.java (original)
+++ incubator/oozie/trunk/core/src/test/java/org/apache/oozie/service/TestStatusTransitService.java Tue Sep 4 19:24:13 2012
@@ -33,6 +33,7 @@ import org.apache.oozie.client.OozieClie
import org.apache.oozie.client.WorkflowJob;
import org.apache.oozie.command.bundle.BundleJobResumeXCommand;
import org.apache.oozie.command.bundle.BundleJobSuspendXCommand;
+import org.apache.oozie.command.bundle.BundleKillXCommand;
import org.apache.oozie.command.coord.CoordKillXCommand;
import org.apache.oozie.command.coord.CoordResumeXCommand;
import org.apache.oozie.command.coord.CoordSuspendXCommand;
@@ -74,7 +75,9 @@ public class TestStatusTransitService ex
super.tearDown();
}
- // Exclude some of the services classes from loading so they dont interfere while the test case is running
+
+ // Exclude some of the services classes from loading so they dont interfere
+ // while the test case is running
private void setClassesToBeExcluded(Configuration conf) {
String classes = conf.get(Services.CONF_SERVICE_CLASSES);
StringBuilder builder = new StringBuilder(classes);
@@ -890,6 +893,87 @@ public class TestStatusTransitService ex
}
/**
+ * Test : kill a bundle job with coord jobs as DONEWITHERROR
+ * <p/>
+ * Initially the bundle job should be KILLED and then DONEWITHERROR
+ *
+ * @throws Exception
+ */
+ public void testBundleStatusTransitServiceKilled1() throws Exception {
+ BundleJobBean bundleJob = this.addRecordToBundleJobTable(Job.Status.RUNNING, true);
+ final JPAService jpaService = Services.get().get(JPAService.class);
+ assertNotNull(jpaService);
+
+ final String bundleId = bundleJob.getId();
+ addRecordToBundleActionTable(bundleId, "action1", 0, Job.Status.DONEWITHERROR);
+ addRecordToBundleActionTable(bundleId, "action2", 0, Job.Status.DONEWITHERROR);
+
+ addRecordToCoordJobTableWithBundle(bundleId, "action1", CoordinatorJob.Status.DONEWITHERROR, false, true, 2);
+ addRecordToCoordJobTableWithBundle(bundleId, "action2", CoordinatorJob.Status.DONEWITHERROR, false, true, 2);
+
+ new BundleKillXCommand(bundleId).call();
+ waitFor(5 * 1000, new Predicate() {
+ public boolean evaluate() throws Exception {
+ BundleJobBean bundle = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
+ return bundle.getStatus() == Job.Status.KILLED;
+ }
+ });
+
+ bundleJob = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
+ assertEquals(Job.Status.KILLED, bundleJob.getStatus());
+
+ Runnable runnable = new StatusTransitRunnable();
+ runnable.run();
+
+ waitFor(15 * 1000, new Predicate() {
+ public boolean evaluate() throws Exception {
+ BundleJobBean bundle = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
+ return bundle.getStatus() == Job.Status.DONEWITHERROR;
+ }
+ });
+
+ bundleJob = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
+ assertEquals(Job.Status.DONEWITHERROR, bundleJob.getStatus());
+
+ }
+
+
+ /**
+ * Test : Make the bundle kill itself by having one of the coord job fail preparation.
+ *
+ * @throws Exception
+ */
+ public void testBundleStatusTransitServiceKilled2() throws Exception {
+ BundleJobBean bundleJob = this.addRecordToBundleJobTable(Job.Status.RUNNING, true);
+ final JPAService jpaService = Services.get().get(JPAService.class);
+ assertNotNull(jpaService);
+
+ final String bundleId = bundleJob.getId();
+ // Add a bundle action with no coordinator to make it fail
+ addRecordToBundleActionTable(bundleId, null, 0, Job.Status.KILLED);
+ addRecordToBundleActionTable(bundleId, "action2", 0, Job.Status.RUNNING);
+ addRecordToCoordJobTableWithBundle(bundleId, "action2", CoordinatorJob.Status.RUNNING, true, true, 2);
+ addRecordToCoordActionTable("action2", 1, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
+
+ Runnable runnable = new StatusTransitRunnable();
+ // first time, service will call bundle kill
+ runnable.run();
+ sleep(10000);
+ runnable.run();
+
+ waitFor(25 * 1000, new Predicate() {
+ public boolean evaluate() throws Exception {
+ BundleJobBean bundle = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
+ return bundle.getStatus() == Job.Status.KILLED;
+ }
+ });
+
+ bundleJob = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
+ assertEquals(Job.Status.KILLED, bundleJob.getStatus());
+ }
+
+
+ /**
* Test : kill one coord job and keep the other running. Check whether the bundle job's status
* is updated to RUNNINGWITHERROR
* @throws Exception
Modified: incubator/oozie/trunk/release-log.txt
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/release-log.txt?rev=1380821&r1=1380820&r2=1380821&view=diff
==============================================================================
--- incubator/oozie/trunk/release-log.txt (original)
+++ incubator/oozie/trunk/release-log.txt Tue Sep 4 19:24:13 2012
@@ -7,6 +7,7 @@ OOZIE-979 bump up trunk version to 3.4.0
-- Oozie 3.3.0 release (unreleased)
+OOZIE-978 Bundle status doesn't transit to KILLED after a coordinator job fails submission (virag)
OOZIE-971 TestRecoveryService failing very often in pre-commit builds (mona via virag)
OOZIE-966 Fix formatting in CLI output when GMT-#### and GMT-##:## formatted timezones are used (rkanter via tucu)
OOZIE-960 TestStatusTransitService failing intermittently (virag)