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/11/30 05:39:12 UTC
svn commit: r1415496 - in /oozie/branches/branch-3.3: ./
core/src/main/java/org/apache/oozie/command/bundle/
core/src/main/java/org/apache/oozie/service/
core/src/test/java/org/apache/oozie/service/
Author: virag
Date: Fri Nov 30 04:39:11 2012
New Revision: 1415496
URL: http://svn.apache.org/viewvc?rev=1415496&view=rev
Log:
OOZIE-1064 Status value of coordinator job not reflected in bundle action and invalid transition of coordinator job (virag)
Modified:
oozie/branches/branch-3.3/core/src/main/java/org/apache/oozie/command/bundle/BundleStatusUpdateXCommand.java
oozie/branches/branch-3.3/core/src/main/java/org/apache/oozie/service/StatusTransitService.java
oozie/branches/branch-3.3/core/src/test/java/org/apache/oozie/service/TestStatusTransitService.java
oozie/branches/branch-3.3/release-log.txt
Modified: oozie/branches/branch-3.3/core/src/main/java/org/apache/oozie/command/bundle/BundleStatusUpdateXCommand.java
URL: http://svn.apache.org/viewvc/oozie/branches/branch-3.3/core/src/main/java/org/apache/oozie/command/bundle/BundleStatusUpdateXCommand.java?rev=1415496&r1=1415495&r2=1415496&view=diff
==============================================================================
--- oozie/branches/branch-3.3/core/src/main/java/org/apache/oozie/command/bundle/BundleStatusUpdateXCommand.java (original)
+++ oozie/branches/branch-3.3/core/src/main/java/org/apache/oozie/command/bundle/BundleStatusUpdateXCommand.java Fri Nov 30 04:39:11 2012
@@ -65,8 +65,9 @@ public class BundleStatusUpdateXCommand
+ " coord job ID: " + coordjob.getId() + " coord Status " + coordjob.getStatus());
Job.Status coordCurrentStatus = coordjob.getStatus();
// The status of bundle action should not be updated if the bundle action is in terminal state
- // TODO - change this once bottom up rerun is allowed to change the bundle action state
- if (!bundleaction.isTerminalStatus()) {
+ // and coord Id is null. For e.g if Bundleaction is killed and coord Id is null, then the status of bundle
+ // should not be changed.
+ if (bundleaction.getCoordId() != null || !bundleaction.isTerminalStatus()) {
bundleaction.setStatus(coordCurrentStatus);
}
if (bundleaction.isPending()) {
Modified: oozie/branches/branch-3.3/core/src/main/java/org/apache/oozie/service/StatusTransitService.java
URL: http://svn.apache.org/viewvc/oozie/branches/branch-3.3/core/src/main/java/org/apache/oozie/service/StatusTransitService.java?rev=1415496&r1=1415495&r2=1415496&view=diff
==============================================================================
--- oozie/branches/branch-3.3/core/src/main/java/org/apache/oozie/service/StatusTransitService.java (original)
+++ oozie/branches/branch-3.3/core/src/main/java/org/apache/oozie/service/StatusTransitService.java Fri Nov 30 04:39:11 2012
@@ -286,9 +286,10 @@ public class StatusTransitService implem
}
int nonPendingCoordActionsCount = coordActionStatusList.size();
-
- if ((coordJob.isDoneMaterialization() || coordStatus[0] == Job.Status.FAILED || coordStatus[0] == Job.Status.KILLED)
- && checkCoordTerminalStatus(coordActionStatus, nonPendingCoordActionsCount, coordStatus)) {
+ boolean isDoneMaterialization = coordJob.isDoneMaterialization();
+ if ((isDoneMaterialization || coordStatus[0] == Job.Status.FAILED || coordStatus[0] == Job.Status.KILLED)
+ && checkCoordTerminalStatus(coordActionStatus, nonPendingCoordActionsCount,
+ coordStatus, isDoneMaterialization)) {
LOG.info("Set coordinator job [" + jobId + "] status to '" + coordStatus[0].toString()
+ "' from '" + coordJob.getStatus() + "'");
updateCoordJob(isPending, coordJob, coordStatus[0]);
@@ -367,7 +368,7 @@ public class StatusTransitService implem
}
private boolean checkCoordTerminalStatus(HashMap<CoordinatorAction.Status, Integer> coordActionStatus,
- int coordActionsCount, Job.Status[] coordStatus) {
+ int coordActionsCount, Job.Status[] coordStatus, boolean isDoneMaterialization) {
boolean ret = false;
int totalValuesSucceed = 0;
if (coordActionStatus.containsKey(CoordinatorAction.Status.SUCCEEDED)) {
@@ -389,7 +390,7 @@ public class StatusTransitService implem
if (coordActionsCount == (totalValuesSucceed + totalValuesFailed + totalValuesKilled + totalValuesTimeOut)) {
// If all the coordinator actions are succeeded then coordinator job should be succeeded.
- if (coordActionsCount == totalValuesSucceed) {
+ if (coordActionsCount == totalValuesSucceed && isDoneMaterialization) {
coordStatus[0] = Job.Status.SUCCEEDED;
ret = true;
}
Modified: oozie/branches/branch-3.3/core/src/test/java/org/apache/oozie/service/TestStatusTransitService.java
URL: http://svn.apache.org/viewvc/oozie/branches/branch-3.3/core/src/test/java/org/apache/oozie/service/TestStatusTransitService.java?rev=1415496&r1=1415495&r2=1415496&view=diff
==============================================================================
--- oozie/branches/branch-3.3/core/src/test/java/org/apache/oozie/service/TestStatusTransitService.java (original)
+++ oozie/branches/branch-3.3/core/src/test/java/org/apache/oozie/service/TestStatusTransitService.java Fri Nov 30 04:39:11 2012
@@ -695,6 +695,27 @@ public class TestStatusTransitService ex
assertEquals(CoordinatorJob.Status.DONEWITHERROR, coordJob.getStatus());
}
+ /**
+ * Inserts a coordinator job in KILLED state with pending materialization.
+ * Make sure the status changes to DONEWITHERROR if there is at least one
+ * coordinator action in NON-KILLED state
+ *
+ * @throws Exception
+ */
+ public void testCoordStatusTransitServiceTransitionToDoneWithError() throws Exception {
+ CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.KILLED, true, false);
+ addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
+ Runnable runnable = new StatusTransitRunnable();
+ runnable.run();
+ sleep(1000);
+
+ JPAService jpaService = Services.get().get(JPAService.class);
+ CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(job.getId());
+ CoordinatorJobBean coordJob = jpaService.execute(coordGetCmd);
+ assertEquals(CoordinatorJob.Status.DONEWITHERROR, coordJob.getStatus());
+
+ }
+
@Override
protected CoordinatorActionBean addRecordToCoordActionTable(String jobId, int actionNum,
CoordinatorAction.Status status, String resourceXmlName, int pending) throws Exception {
@@ -785,6 +806,51 @@ public class TestStatusTransitService ex
}
/**
+ * Insert a coordinator job in KILLED state with one coordinator action as
+ * SUCCEEDED. Make sure the status of the job changes to DONEWITHERROR.
+ * Also, the status of bundle action and bundle job should change to
+ * DONEWITHERROR
+ *
+ * @throws Exception
+ */
+ public void testBundleStatusTransitServiceForTerminalStates() throws Exception {
+ BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
+ final JPAService jpaService = Services.get().get(JPAService.class);
+ assertNotNull(jpaService);
+
+ final String bundleId = job.getId();
+ addRecordToBundleActionTable(bundleId, "action1", 0, Job.Status.KILLED);
+
+ String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
+ Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
+ Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
+
+ addRecordToCoordJobTableWithBundle(bundleId, "action1", CoordinatorJob.Status.KILLED, start, end, true, true, 2);
+
+ addRecordToCoordActionTable("action1", 1, CoordinatorAction.Status.KILLED, "coord-action-get.xml", 0);
+ addRecordToCoordActionTable("action1", 2, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
+
+ Runnable runnable = new StatusTransitRunnable();
+ runnable.run();
+
+ waitFor(15 * 1000, new Predicate() {
+ public boolean evaluate() throws Exception {
+ CoordinatorJobBean coordJob = jpaService.execute(new CoordJobGetJPAExecutor("action1"));
+ return coordJob.getStatus().equals(Job.Status.DONEWITHERROR);
+ }
+ });
+
+ CoordinatorJobBean coordJob = jpaService.execute(new CoordJobGetJPAExecutor("action1"));
+ assertEquals(Job.Status.DONEWITHERROR, coordJob.getStatus());
+
+ BundleActionBean bab = jpaService.execute(new BundleActionGetJPAExecutor(bundleId, "action1"));
+ assertEquals(Job.Status.DONEWITHERROR, bab.getStatus());
+
+ job = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
+ assertEquals(Job.Status.DONEWITHERROR, job.getStatus());
+ }
+
+ /**
* Test : all coord jobs are succeeded - bundle job's status will be updated to succeeded after suspend and resume.
* coordinator action -> coordinator job -> bundle action -> bundle job
*
Modified: oozie/branches/branch-3.3/release-log.txt
URL: http://svn.apache.org/viewvc/oozie/branches/branch-3.3/release-log.txt?rev=1415496&r1=1415495&r2=1415496&view=diff
==============================================================================
--- oozie/branches/branch-3.3/release-log.txt (original)
+++ oozie/branches/branch-3.3/release-log.txt Fri Nov 30 04:39:11 2012
@@ -1,5 +1,6 @@
-- Oozie 3.3.0 release
+OOZIE-1064 Status value of coordinator job not reflected in bundle action and invalid transition of coordinator job (virag)
OOZIE-1089 DistributedCache workaround for Hadoop 2.0.2-alpha (tucu)
OOZIE-1005 Tests from OOZIE-994 use wrong condition in waitFor (rkanter via virag)
OOZIE-994 ActionCheckXCommand does not handle failures properly(rkanter via mohammad)