Skip to content
This repository has been archived by the owner on Jan 6, 2018. It is now read-only.

Commit

Permalink
Closes OOZIE-89 coord job status keep in SUCCEEDED when rerun in back…
Browse files Browse the repository at this point in the history
…ward support state
  • Loading branch information
Angelo Kaichen Huang authored and Mohammad Kamrul Islam committed Apr 30, 2011
1 parent e635b84 commit a75f83d
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
Expand Up @@ -44,7 +44,7 @@ public RerunTransitionXCommand(String name, String type, int priority, boolean d
* @see org.apache.oozie.command.TransitionXCommand#transitToNext()
*/
@Override
public final void transitToNext() {
public void transitToNext() {
if (job == null) {
job = this.getJob();
}
Expand Down
Expand Up @@ -53,6 +53,7 @@
import org.apache.oozie.util.InstrumentUtils;
import org.apache.oozie.util.LogUtils;
import org.apache.oozie.util.ParamChecker;
import org.apache.oozie.util.StatusUtils;
import org.apache.oozie.util.XConfiguration;
import org.apache.oozie.util.XLog;
import org.apache.oozie.util.XmlUtils;
Expand Down Expand Up @@ -525,6 +526,14 @@ public XLog getLog() {
return LOG;
}

@Override
public final void transitToNext() {
prevStatus = coordJob.getStatus();
coordJob.setStatus(Job.Status.RUNNING);
coordJob.setStatus(StatusUtils.getStatus(coordJob));
coordJob.setPending();
}

private final void transitToPrevious() throws CommandException {
coordJob.setStatus(getPrevStatus());
if (!prevPending) {
Expand Down
Expand Up @@ -40,12 +40,16 @@
import org.apache.oozie.client.rest.RestConstants;
import org.apache.oozie.command.CommandException;
import org.apache.oozie.coord.CoordELFunctions;
import org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor;
import org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor;
import org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor;
import org.apache.oozie.executor.jpa.CoordJobUpdateJPAExecutor;
import org.apache.oozie.executor.jpa.JPAExecutorException;
import org.apache.oozie.local.LocalOozie;
import org.apache.oozie.service.JPAService;
import org.apache.oozie.service.SchemaService;
import org.apache.oozie.service.Services;
import org.apache.oozie.service.StatusTransitService;
import org.apache.oozie.service.StoreService;
import org.apache.oozie.store.CoordinatorStore;
import org.apache.oozie.store.StoreException;
Expand Down Expand Up @@ -763,6 +767,54 @@ public void testCoordRerunNeg() throws Exception {
store2.closeTrx();
}

/**
* Tests functionality of the coord rerun for backward support is true. </p> Insert a coordinator job with SUCCEEDED
* and coordinator actions with pending false, but one of action is FAILED.
* Set oozie.service.StatusTransitService.backward.support.for.coord.status=true
* and use uri:oozie:coordinator:0.1 namespace, then, rerun the coord job for action 1 and action 2.
*
* @throws Exception
*/
public void testCoordRerunForBackwardSupport() throws Exception {
Services.get().destroy();
setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_COORD_STATUS, "true");
new Services().init();

Date start = DateUtils.parseDateUTC("2009-02-01T01:00Z");
Date end = DateUtils.parseDateUTC("2009-02-02T23:59Z");
CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, start, end, false,
true, 3);

final JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
coordJob.setAppNamespace(SchemaService.COORDINATOR_NAMESPACE_URI_1);
jpaService.execute(new CoordJobUpdateJPAExecutor(coordJob));

CoordinatorActionBean action1 = addRecordToCoordActionTable(coordJob.getId(), 1,
CoordinatorAction.Status.FAILED, "coord-rerun-action1.xml", 0);
CoordinatorActionBean action2 = addRecordToCoordActionTable(coordJob.getId(), 2,
CoordinatorAction.Status.SUCCEEDED, "coord-rerun-action1.xml", 0);
CoordinatorActionBean action3 = addRecordToCoordActionTable(coordJob.getId(), 3,
CoordinatorAction.Status.SUCCEEDED, "coord-rerun-action1.xml", 0);

String rerunScope = Integer.toString(1) + "-" + Integer.toString(2);

final OozieClient coordClient = LocalOozie.getCoordClient();
coordClient.reRunCoord(coordJob.getId(), RestConstants.JOB_COORD_RERUN_ACTION, rerunScope, false, true);

CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(coordJob.getId());
coordJob = jpaService.execute(coordJobGetCmd);
assertEquals(CoordinatorJob.Status.SUCCEEDED, coordJob.getStatus());

CoordActionGetJPAExecutor coordActionGetCmd = new CoordActionGetJPAExecutor(action1.getId());
action1 = jpaService.execute(coordActionGetCmd);
assertNotSame(action1.getStatus(), CoordinatorAction.Status.FAILED);

coordActionGetCmd = new CoordActionGetJPAExecutor(action2.getId());
action2 = jpaService.execute(coordActionGetCmd);
assertNotSame(action2.getStatus(), CoordinatorAction.Status.SUCCEEDED);
}

protected CoordinatorJobBean addRecordToCoordJobTableWithPausedTime(CoordinatorJob.Status status, boolean pending,
boolean doneMatd, Date pausedTime) throws Exception {
CoordinatorJobBean coordJob = createCoordJob(status, pending, doneMatd);
Expand Down
1 change: 1 addition & 0 deletions release-log.txt
@@ -1,5 +1,6 @@
-- Oozie 3.0.1 release

OOZIE-89 coord job status keep in SUCCEEDED when rerun in backward support state
OOZIE-88 fix the status-transit-service to aggregate coordinator job running state
OOZIE-83 add parameter userName to bundle xml in example
OOZIE-85 kill a SUCCEEDED coordinator job with 0.1 schema and backward compatibility is true
Expand Down

0 comments on commit a75f83d

Please sign in to comment.