Repository: oozie Updated Branches: refs/heads/master bac6d005e -> 1c6680541
OOZIE-2028 Coord action rerun with -failed option should rerun existing workflow with RERUN_FAIL_NODES=true (jaydeepvishwakarma via shwethags) Project: http://git-wip-us.apache.org/repos/asf/oozie/repo Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/1c668054 Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/1c668054 Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/1c668054 Branch: refs/heads/master Commit: 1c668054190aee9991b2ea20cf48e1f5b494806f Parents: bac6d00 Author: shwethags <[email protected]> Authored: Thu Dec 11 10:57:35 2014 +0530 Committer: shwethags <[email protected]> Committed: Thu Dec 11 10:57:35 2014 +0530 ---------------------------------------------------------------------- .../java/org/apache/oozie/cli/OozieCLI.java | 10 ++- .../org/apache/oozie/client/OozieClient.java | 22 ++++++- .../apache/oozie/client/rest/RestConstants.java | 1 + .../org/apache/oozie/CoordinatorActionBean.java | 2 +- .../org/apache/oozie/CoordinatorEngine.java | 5 +- .../org/apache/oozie/LocalOozieClientCoord.java | 5 +- .../command/bundle/BundleRerunXCommand.java | 4 +- .../command/coord/CoordActionStartXCommand.java | 13 ++-- .../oozie/command/coord/CoordRerunXCommand.java | 9 ++- .../CoordActionGetForInputCheckJPAExecutor.java | 3 + .../org/apache/oozie/servlet/V1JobServlet.java | 3 +- .../command/coord/TestCoordRerunXCommand.java | 69 ++++++++++++++++++-- .../command/coord/TestCoordUpdateXCommand.java | 3 +- .../apache/oozie/event/TestEventGeneration.java | 2 +- .../servlet/MockCoordinatorEngineService.java | 2 +- .../oozie/sla/TestSLAEventGeneration.java | 4 +- .../site/twiki/CoordinatorFunctionalSpec.twiki | 2 +- docs/src/site/twiki/DG_CommandLineTool.twiki | 3 +- docs/src/site/twiki/DG_CoordinatorRerun.twiki | 3 +- release-log.txt | 1 + 20 files changed, 136 insertions(+), 30 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/oozie/blob/1c668054/client/src/main/java/org/apache/oozie/cli/OozieCLI.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/oozie/cli/OozieCLI.java b/client/src/main/java/org/apache/oozie/cli/OozieCLI.java index 1265fad..0d3b758 100644 --- a/client/src/main/java/org/apache/oozie/cli/OozieCLI.java +++ b/client/src/main/java/org/apache/oozie/cli/OozieCLI.java @@ -137,6 +137,7 @@ public class OozieCLI { public static final String DATE_OPTION = "date"; public static final String RERUN_REFRESH_OPTION = "refresh"; public static final String RERUN_NOCLEANUP_OPTION = "nocleanup"; + public static final String RERUN_FAILED_OPTION = "failed"; public static final String ORDER_OPTION = "order"; public static final String UPDATE_SHARELIB_OPTION = "sharelibupdate"; @@ -328,6 +329,8 @@ public class OozieCLI { "re-materialize the coordinator rerun actions (requires -rerun)"); Option rerun_nocleanup = new Option(RERUN_NOCLEANUP_OPTION, false, "do not clean up output-events of the coordiantor rerun actions (requires -rerun)"); + Option rerun_failed = new Option(RERUN_FAILED_OPTION, false, + "runs the failed workflow actions of the coordinator actions (requires -rerun)"); Option property = OptionBuilder.withArgName("property=value").hasArgs(2).withValueSeparator().withDescription( "set/override value for given property").create("D"); Option getAllWorkflows = new Option(ALL_WORKFLOWS_FOR_COORD_ACTION, false, @@ -380,6 +383,7 @@ public class OozieCLI { jobOptions.addOption(rerun_coord); jobOptions.addOption(rerun_refresh); jobOptions.addOption(rerun_nocleanup); + jobOptions.addOption(rerun_failed); jobOptions.addOption(getAllWorkflows); jobOptions.addOptionGroup(actions); jobOptions.addOption(logFilter); @@ -1050,7 +1054,11 @@ public class OozieCLI { if (options.contains(RERUN_NOCLEANUP_OPTION)) { noCleanup = true; } - printCoordActions(wc.reRunCoord(coordJobId, rerunType, scope, refresh, noCleanup)); + if (options.contains(RERUN_FAILED_OPTION)) { + printCoordActions(wc.reRunCoord(coordJobId, rerunType, scope, refresh, noCleanup, true)); + } else { + printCoordActions(wc.reRunCoord(coordJobId, rerunType, scope, refresh, noCleanup)); + } } } else if (options.contains(INFO_OPTION)) { http://git-wip-us.apache.org/repos/asf/oozie/blob/1c668054/client/src/main/java/org/apache/oozie/client/OozieClient.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/oozie/client/OozieClient.java b/client/src/main/java/org/apache/oozie/client/OozieClient.java index 23a8f21..b1bedc6 100644 --- a/client/src/main/java/org/apache/oozie/client/OozieClient.java +++ b/client/src/main/java/org/apache/oozie/client/OozieClient.java @@ -1476,12 +1476,12 @@ public class OozieClient { } private class CoordRerun extends ClientCallable<List<CoordinatorAction>> { - CoordRerun(String jobId, String rerunType, String scope, boolean refresh, boolean noCleanup) { + CoordRerun(String jobId, String rerunType, String scope, boolean refresh, boolean noCleanup, boolean failed) { super("PUT", RestConstants.JOB, notEmpty(jobId, "jobId"), prepareParams(RestConstants.ACTION_PARAM, RestConstants.JOB_COORD_ACTION_RERUN, RestConstants.JOB_COORD_RANGE_TYPE_PARAM, rerunType, RestConstants.JOB_COORD_SCOPE_PARAM, scope, RestConstants.JOB_COORD_RERUN_REFRESH_PARAM, Boolean.toString(refresh), RestConstants.JOB_COORD_RERUN_NOCLEANUP_PARAM, Boolean - .toString(noCleanup))); + .toString(noCleanup), RestConstants.JOB_COORD_RERUN_FAILED_PARAM, Boolean.toString(failed))); } @Override @@ -1535,7 +1535,23 @@ public class OozieClient { */ public List<CoordinatorAction> reRunCoord(String jobId, String rerunType, String scope, boolean refresh, boolean noCleanup) throws OozieClientException { - return new CoordRerun(jobId, rerunType, scope, refresh, noCleanup).call(); + return new CoordRerun(jobId, rerunType, scope, refresh, noCleanup, false).call(); + } + + /** + * Rerun coordinator actions with failed option. + * + * @param jobId coordinator jobId + * @param rerunType rerun type 'date' if -date is used, 'action-id' if -action is used + * @param scope rerun scope for date or actionIds + * @param refresh true if -refresh is given in command option + * @param noCleanup true if -nocleanup is given in command option + * @param failed true if -failed is given in command option + * @throws OozieClientException + */ + public List<CoordinatorAction> reRunCoord(String jobId, String rerunType, String scope, boolean refresh, + boolean noCleanup, boolean failed) throws OozieClientException { + return new CoordRerun(jobId, rerunType, scope, refresh, noCleanup, failed).call(); } /** http://git-wip-us.apache.org/repos/asf/oozie/blob/1c668054/client/src/main/java/org/apache/oozie/client/rest/RestConstants.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/oozie/client/rest/RestConstants.java b/client/src/main/java/org/apache/oozie/client/rest/RestConstants.java index 4cc6606..85efecf 100644 --- a/client/src/main/java/org/apache/oozie/client/rest/RestConstants.java +++ b/client/src/main/java/org/apache/oozie/client/rest/RestConstants.java @@ -183,4 +183,5 @@ public interface RestConstants { public static final String LOG_FILTER_OPTION = "logfilter"; + public static final String JOB_COORD_RERUN_FAILED_PARAM = "failed"; } http://git-wip-us.apache.org/repos/asf/oozie/blob/1c668054/core/src/main/java/org/apache/oozie/CoordinatorActionBean.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/CoordinatorActionBean.java b/core/src/main/java/org/apache/oozie/CoordinatorActionBean.java index 188b70e..25859dd 100644 --- a/core/src/main/java/org/apache/oozie/CoordinatorActionBean.java +++ b/core/src/main/java/org/apache/oozie/CoordinatorActionBean.java @@ -96,7 +96,7 @@ import java.util.List; // Select Query used by Timeout and skip commands @NamedQuery(name = "GET_COORD_ACTION_FOR_TIMEOUT", query = "select a.id, a.jobId, a.statusStr, a.runConf, a.pending, a.nominalTimestamp, a.createdTimestamp from CoordinatorActionBean a where a.id = :id"), // Select query used by InputCheck command - @NamedQuery(name = "GET_COORD_ACTION_FOR_INPUTCHECK", query = "select a.id, a.jobId, a.statusStr, a.runConf, a.nominalTimestamp, a.createdTimestamp, a.actionXml, a.missingDependencies, a.pushMissingDependencies, a.timeOut from CoordinatorActionBean a where a.id = :id"), + @NamedQuery(name = "GET_COORD_ACTION_FOR_INPUTCHECK", query = "select a.id, a.jobId, a.statusStr, a.runConf, a.nominalTimestamp, a.createdTimestamp, a.actionXml, a.missingDependencies, a.pushMissingDependencies, a.timeOut, a.externalId from CoordinatorActionBean a where a.id = :id"), // Select query used by CoordActionUpdate command @NamedQuery(name = "GET_COORD_ACTION_FOR_EXTERNALID", query = "select a.id, a.jobId, a.statusStr, a.pending, a.externalId, a.lastModifiedTimestamp, a.slaXml, a.nominalTimestamp, a.createdTimestamp from CoordinatorActionBean a where a.externalId = :externalId"), // Select query used by Check command http://git-wip-us.apache.org/repos/asf/oozie/blob/1c668054/core/src/main/java/org/apache/oozie/CoordinatorEngine.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/CoordinatorEngine.java b/core/src/main/java/org/apache/oozie/CoordinatorEngine.java index a893e0c..cce3f84 100644 --- a/core/src/main/java/org/apache/oozie/CoordinatorEngine.java +++ b/core/src/main/java/org/apache/oozie/CoordinatorEngine.java @@ -260,11 +260,12 @@ public class CoordinatorEngine extends BaseEngine { * @param noCleanup * @throws BaseEngineException */ - public CoordinatorActionInfo reRun(String jobId, String rerunType, String scope, boolean refresh, boolean noCleanup) + public CoordinatorActionInfo reRun(String jobId, String rerunType, String scope, boolean refresh, boolean noCleanup, + boolean failed) throws BaseEngineException { try { return new CoordRerunXCommand(jobId, rerunType, scope, refresh, - noCleanup).call(); + noCleanup, failed).call(); } catch (CommandException ex) { throw new BaseEngineException(ex); http://git-wip-us.apache.org/repos/asf/oozie/blob/1c668054/core/src/main/java/org/apache/oozie/LocalOozieClientCoord.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/LocalOozieClientCoord.java b/core/src/main/java/org/apache/oozie/LocalOozieClientCoord.java index 0ec2bff..34ab1e1 100644 --- a/core/src/main/java/org/apache/oozie/LocalOozieClientCoord.java +++ b/core/src/main/java/org/apache/oozie/LocalOozieClientCoord.java @@ -248,18 +248,19 @@ public class LocalOozieClientCoord extends OozieClient { * @param scope rerun scope for date or actionIds * @param refresh true if -refresh is given in command option * @param noCleanup true if -nocleanup is given in command option + * @param failed true if -failed is given in command option * @throws OozieClientException */ @Override public List<CoordinatorAction> reRunCoord(String jobId, String rerunType, String scope, boolean refresh, - boolean noCleanup) throws OozieClientException { + boolean noCleanup, boolean failed) throws OozieClientException { try { if (!(rerunType.equals(RestConstants.JOB_COORD_SCOPE_DATE) || rerunType .equals(RestConstants.JOB_COORD_SCOPE_ACTION))) { throw new CommandException(ErrorCode.E1018, "date or action expected."); } CoordinatorActionInfo coordInfo = coordEngine.reRun(jobId, rerunType, scope, Boolean.valueOf(refresh), - Boolean.valueOf(noCleanup)); + Boolean.valueOf(noCleanup), Boolean.valueOf(failed)); List<CoordinatorActionBean> actionBeans; if (coordInfo != null) { actionBeans = coordInfo.getCoordActions(); http://git-wip-us.apache.org/repos/asf/oozie/blob/1c668054/core/src/main/java/org/apache/oozie/command/bundle/BundleRerunXCommand.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/command/bundle/BundleRerunXCommand.java b/core/src/main/java/org/apache/oozie/command/bundle/BundleRerunXCommand.java index a75b951..8de2c70 100644 --- a/core/src/main/java/org/apache/oozie/command/bundle/BundleRerunXCommand.java +++ b/core/src/main/java/org/apache/oozie/command/bundle/BundleRerunXCommand.java @@ -139,7 +139,7 @@ public class BundleRerunXCommand extends RerunTransitionXCommand<Void> { LOG.debug("Queuing rerun range [" + rerunDateScope + "] for coord id " + coordId + " of bundle " + bundleJob.getId()); queue(new CoordRerunXCommand(coordId, RestConstants.JOB_COORD_SCOPE_DATE, rerunDateScope, refresh, - noCleanup)); + noCleanup, false)); updateBundleAction(coordNameToBAMapping.get(coordName)); isUpdateActionDone = true; } @@ -159,7 +159,7 @@ public class BundleRerunXCommand extends RerunTransitionXCommand<Void> { LOG.debug("Queuing rerun range [" + dateScope + "] for coord id " + action.getCoordId() + " of bundle " + bundleJob.getId()); queue(new CoordRerunXCommand(action.getCoordId(), RestConstants.JOB_COORD_SCOPE_DATE, dateScope, - refresh, noCleanup)); + refresh, noCleanup, false)); updateBundleAction(action); isUpdateActionDone = true; } http://git-wip-us.apache.org/repos/asf/oozie/blob/1c668054/core/src/main/java/org/apache/oozie/command/coord/CoordActionStartXCommand.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/command/coord/CoordActionStartXCommand.java b/core/src/main/java/org/apache/oozie/command/coord/CoordActionStartXCommand.java index f003790..1dd8272 100644 --- a/core/src/main/java/org/apache/oozie/command/coord/CoordActionStartXCommand.java +++ b/core/src/main/java/org/apache/oozie/command/coord/CoordActionStartXCommand.java @@ -186,16 +186,21 @@ public class CoordActionStartXCommand extends CoordinatorXCommand<Void> { } // Normalize workflow appPath here; JobUtils.normalizeAppPath(conf.get(OozieClient.USER_NAME), conf.get(OozieClient.GROUP_NAME), conf); - String wfId = dagEngine.submitJobFromCoordinator(conf, actionId); + if (coordAction.getExternalId() != null) { + conf.setBoolean(OozieClient.RERUN_FAIL_NODES, true); + dagEngine.reRun(coordAction.getExternalId(), conf); + } else { + String wfId = dagEngine.submitJobFromCoordinator(conf, actionId); + coordAction.setExternalId(wfId); + } coordAction.setStatus(CoordinatorAction.Status.RUNNING); - coordAction.setExternalId(wfId); coordAction.incrementAndGetPending(); //store.updateCoordinatorAction(coordAction); JPAService jpaService = Services.get().get(JPAService.class); if (jpaService != null) { - log.debug("Updating WF record for WFID :" + wfId + " with parent id: " + actionId); - WorkflowJobBean wfJob = WorkflowJobQueryExecutor.getInstance().get(WorkflowJobQuery.GET_WORKFLOW_STARTTIME, wfId); + log.debug("Updating WF record for WFID :" + coordAction.getExternalId() + " with parent id: " + actionId); + WorkflowJobBean wfJob = WorkflowJobQueryExecutor.getInstance().get(WorkflowJobQuery.GET_WORKFLOW_STARTTIME, coordAction.getExternalId()); wfJob.setParentId(actionId); wfJob.setLastModifiedTime(new Date()); BatchQueryExecutor executor = BatchQueryExecutor.getInstance(); http://git-wip-us.apache.org/repos/asf/oozie/blob/1c668054/core/src/main/java/org/apache/oozie/command/coord/CoordRerunXCommand.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/command/coord/CoordRerunXCommand.java b/core/src/main/java/org/apache/oozie/command/coord/CoordRerunXCommand.java index 2eefdb8..cbace93 100644 --- a/core/src/main/java/org/apache/oozie/command/coord/CoordRerunXCommand.java +++ b/core/src/main/java/org/apache/oozie/command/coord/CoordRerunXCommand.java @@ -90,6 +90,7 @@ public class CoordRerunXCommand extends RerunTransitionXCommand<CoordinatorActio private boolean noCleanup; private CoordinatorJobBean coordJob = null; protected boolean prevPending; + private boolean failed; /** * The constructor for class {@link CoordRerunXCommand} @@ -100,13 +101,15 @@ public class CoordRerunXCommand extends RerunTransitionXCommand<CoordinatorActio * @param refresh true if user wants to refresh input/output dataset urls * @param noCleanup false if user wants to cleanup output events for given rerun actions */ - public CoordRerunXCommand(String jobId, String rerunType, String scope, boolean refresh, boolean noCleanup) { + public CoordRerunXCommand(String jobId, String rerunType, String scope, boolean refresh, boolean noCleanup, + boolean failed) { super("coord_rerun", "coord_rerun", 1); this.jobId = ParamChecker.notEmpty(jobId, "jobId"); this.rerunType = ParamChecker.notEmpty(rerunType, "rerunType"); this.scope = ParamChecker.notEmpty(scope, "scope"); this.refresh = refresh; this.noCleanup = noCleanup; + this.failed = failed; } /** @@ -232,7 +235,9 @@ public class CoordRerunXCommand extends RerunTransitionXCommand<CoordinatorActio coordAction.setCreatedTime(new Date()); } coordAction.setStatus(CoordinatorAction.Status.WAITING); - coordAction.setExternalId(null); + if(!failed) { + coordAction.setExternalId(null); + } coordAction.setExternalStatus(null); coordAction.setRerunTime(new Date()); coordAction.setLastModifiedTime(new Date()); http://git-wip-us.apache.org/repos/asf/oozie/blob/1c668054/core/src/main/java/org/apache/oozie/executor/jpa/CoordActionGetForInputCheckJPAExecutor.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/executor/jpa/CoordActionGetForInputCheckJPAExecutor.java b/core/src/main/java/org/apache/oozie/executor/jpa/CoordActionGetForInputCheckJPAExecutor.java index 9d44cf1..e58646b 100644 --- a/core/src/main/java/org/apache/oozie/executor/jpa/CoordActionGetForInputCheckJPAExecutor.java +++ b/core/src/main/java/org/apache/oozie/executor/jpa/CoordActionGetForInputCheckJPAExecutor.java @@ -99,6 +99,9 @@ public class CoordActionGetForInputCheckJPAExecutor implements JPAExecutor<Coord if (arr[9] != null) { bean.setTimeOut((Integer) arr[9]); } + if (arr[10] != null) { + bean.setExternalId((String)arr[10]); + } return bean; } } http://git-wip-us.apache.org/repos/asf/oozie/blob/1c668054/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java b/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java index 2ca3ce5..6506028 100644 --- a/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java +++ b/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java @@ -663,6 +663,7 @@ public class V1JobServlet extends BaseJobServlet { String scope = request.getParameter(RestConstants.JOB_COORD_SCOPE_PARAM); String refresh = request.getParameter(RestConstants.JOB_COORD_RERUN_REFRESH_PARAM); String noCleanup = request.getParameter(RestConstants.JOB_COORD_RERUN_NOCLEANUP_PARAM); + String failed = request.getParameter(RestConstants.JOB_COORD_RERUN_FAILED_PARAM); XLog.getLog(getClass()).info( "Rerun coordinator for jobId=" + jobId + ", rerunType=" + rerunType + ",scope=" + scope + ",refresh=" @@ -674,7 +675,7 @@ public class V1JobServlet extends BaseJobServlet { throw new CommandException(ErrorCode.E1018, "date or action expected."); } CoordinatorActionInfo coordInfo = coordEngine.reRun(jobId, rerunType, scope, Boolean.valueOf(refresh), - Boolean.valueOf(noCleanup)); + Boolean.valueOf(noCleanup), Boolean.valueOf(failed)); List<CoordinatorActionBean> coordActions; if (coordInfo != null) { coordActions = coordInfo.getCoordActions(); http://git-wip-us.apache.org/repos/asf/oozie/blob/1c668054/core/src/test/java/org/apache/oozie/command/coord/TestCoordRerunXCommand.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/oozie/command/coord/TestCoordRerunXCommand.java b/core/src/test/java/org/apache/oozie/command/coord/TestCoordRerunXCommand.java index 2730aa6..ae7cdba 100644 --- a/core/src/test/java/org/apache/oozie/command/coord/TestCoordRerunXCommand.java +++ b/core/src/test/java/org/apache/oozie/command/coord/TestCoordRerunXCommand.java @@ -764,7 +764,7 @@ public class TestCoordRerunXCommand extends XDataTestCase { assertEquals(Job.Status.FAILED, job.getStatus()); try { - new CoordRerunXCommand(job.getId(), RestConstants.JOB_COORD_SCOPE_DATE, "2009-12-15T01:00Z", false, true) + new CoordRerunXCommand(job.getId(), RestConstants.JOB_COORD_SCOPE_DATE, "2009-12-15T01:00Z", false, true, false) .call(); fail("Coordinator job is FAILED, rerun should throw exception"); } @@ -792,7 +792,7 @@ public class TestCoordRerunXCommand extends XDataTestCase { job = jpaService.execute(coordJobGetExecutor); assertEquals(Job.Status.DONEWITHERROR, job.getStatus()); - new CoordRerunXCommand(job.getId(), RestConstants.JOB_COORD_SCOPE_DATE, "2009-12-15T01:00Z", false, true) + new CoordRerunXCommand(job.getId(), RestConstants.JOB_COORD_SCOPE_DATE, "2009-12-15T01:00Z", false, true, false) .call(); job = jpaService.execute(coordJobGetExecutor); assertEquals(Job.Status.RUNNINGWITHERROR, job.getStatus()); @@ -815,7 +815,7 @@ public class TestCoordRerunXCommand extends XDataTestCase { job = jpaService.execute(coordJobGetExecutor); assertEquals(Job.Status.PAUSED, job.getStatus()); - new CoordRerunXCommand(job.getId(), RestConstants.JOB_COORD_SCOPE_DATE, "2009-12-15T01:00Z", false, true) + new CoordRerunXCommand(job.getId(), RestConstants.JOB_COORD_SCOPE_DATE, "2009-12-15T01:00Z", false, true, false) .call(); job = jpaService.execute(coordJobGetExecutor); @@ -840,7 +840,7 @@ public class TestCoordRerunXCommand extends XDataTestCase { job = jpaService.execute(coordJobGetExecutor); assertEquals(Job.Status.PAUSEDWITHERROR, job.getStatus()); - new CoordRerunXCommand(job.getId(), RestConstants.JOB_COORD_SCOPE_DATE, "2009-12-15T01:00Z", false, true) + new CoordRerunXCommand(job.getId(), RestConstants.JOB_COORD_SCOPE_DATE, "2009-12-15T01:00Z", false, true, false) .call(); job = jpaService.execute(coordJobGetExecutor); @@ -1446,4 +1446,65 @@ public class TestCoordRerunXCommand extends XDataTestCase { + "<end name='end' />" + "</workflow-app>"; } + + /** + * Tests -failed option of rerun. If failed option is provided it should rerun the old workflow of an action + * otherwise it should run the new workflow. + * @throws Exception + */ + public void testCoordRerunWithFailedOption() throws Exception { + Date start = DateUtils.parseDateOozieTZ("2009-02-01T01:00Z"); + Date end = DateUtils.parseDateOozieTZ("2009-02-01T23:59Z"); + CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, + false, 1); + + CoordinatorActionBean action = addRecordToWithLazyAction(coordJob.getId(), 1, + CoordinatorAction.Status.SUBMITTED, "coord-rerun-action1.xml"); + final String actionId = action.getId(); + new CoordActionStartXCommand(actionId, getTestUser(), "myapp", "myjob").call(); + + final JPAService jpaService = Services.get().get(JPAService.class); + action = jpaService.execute(new CoordActionGetJPAExecutor(actionId)); + + if (action.getStatus() == CoordinatorAction.Status.SUBMITTED) { + fail("CoordActionStartCommand didn't work because the status for action id" + actionId + " is :" + + action.getStatus() + " expected to be NOT SUBMITTED (i.e. RUNNING)"); + } + + final OozieClient coordClient = LocalOozie.getCoordClient(); + final OozieClient wclient = LocalOozie.getClient(); + waitFor(15*1000, new Predicate() { + public boolean evaluate() throws Exception { + return (coordClient.getCoordActionInfo(actionId).getStatus() == CoordinatorAction.Status.RUNNING); + } + }); + + wclient.kill(coordClient.getCoordActionInfo(actionId).getExternalId()); + + waitFor(150*1000, new Predicate() { + public boolean evaluate() throws Exception { + return (coordClient.getCoordActionInfo(actionId).getStatus() == CoordinatorAction.Status.KILLED); + } + }); + + String externalId = coordClient.getCoordActionInfo(actionId).getExternalId(); + + coordClient.reRunCoord(coordJob.getId(), RestConstants.JOB_COORD_SCOPE_ACTION, "1", false, true, true); + + waitFor(150*1000, new Predicate() { + public boolean evaluate() throws Exception { + return (coordClient.getCoordActionInfo(actionId).getStatus() == CoordinatorAction.Status.SUCCEEDED); + } + }); + assertEquals(externalId,coordClient.getCoordActionInfo(actionId).getExternalId()); + + coordClient.reRunCoord(coordJob.getId(), RestConstants.JOB_COORD_SCOPE_ACTION, "1", false, true, false); + + waitFor(150*1000, new Predicate() { + public boolean evaluate() throws Exception { + return (coordClient.getCoordActionInfo(actionId).getStatus() == CoordinatorAction.Status.SUCCEEDED); + } + }); + assertNotSame(externalId,coordClient.getCoordActionInfo(actionId).getExternalId()); + } } http://git-wip-us.apache.org/repos/asf/oozie/blob/1c668054/core/src/test/java/org/apache/oozie/command/coord/TestCoordUpdateXCommand.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/oozie/command/coord/TestCoordUpdateXCommand.java b/core/src/test/java/org/apache/oozie/command/coord/TestCoordUpdateXCommand.java index 9d66c2c..89b81d5 100644 --- a/core/src/test/java/org/apache/oozie/command/coord/TestCoordUpdateXCommand.java +++ b/core/src/test/java/org/apache/oozie/command/coord/TestCoordUpdateXCommand.java @@ -278,7 +278,8 @@ public class TestCoordUpdateXCommand extends XDataTestCase { .getChildren("instance", namespace).get(0)).getText(); assertEquals(text, "${coord:future(0, 1)}"); new CoordActionsKillXCommand(jobId, RestConstants.JOB_COORD_SCOPE_ACTION, Integer.toString(actionNum)).call(); - coordClient.reRunCoord(jobId, RestConstants.JOB_COORD_SCOPE_ACTION, Integer.toString(actionNum), true, true); + coordClient.reRunCoord(jobId, RestConstants.JOB_COORD_SCOPE_ACTION, Integer.toString(actionNum), true, + true); bean = coordClient.getCoordActionInfo(actionId); sleep(1000); assertEquals(bean.getMissingDependencies(), "!!${coord:future(0, 1)}"); http://git-wip-us.apache.org/repos/asf/oozie/blob/1c668054/core/src/test/java/org/apache/oozie/event/TestEventGeneration.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/oozie/event/TestEventGeneration.java b/core/src/test/java/org/apache/oozie/event/TestEventGeneration.java index b8d34c4..bdfaf7f 100644 --- a/core/src/test/java/org/apache/oozie/event/TestEventGeneration.java +++ b/core/src/test/java/org/apache/oozie/event/TestEventGeneration.java @@ -337,7 +337,7 @@ public class TestEventGeneration extends XDataTestCase { action.setStatus(CoordinatorAction.Status.KILLED); CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION_STATUS_PENDING_TIME, action); queue.clear(); - new CoordRerunXCommand(coord.getId(), RestConstants.JOB_COORD_SCOPE_ACTION, "1", false, true) + new CoordRerunXCommand(coord.getId(), RestConstants.JOB_COORD_SCOPE_ACTION, "1", false, true, false) .call(); waitFor(3 * 100, new Predicate() { @Override http://git-wip-us.apache.org/repos/asf/oozie/blob/1c668054/core/src/test/java/org/apache/oozie/servlet/MockCoordinatorEngineService.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/oozie/servlet/MockCoordinatorEngineService.java b/core/src/test/java/org/apache/oozie/servlet/MockCoordinatorEngineService.java index 07c1f19..01097d3 100644 --- a/core/src/test/java/org/apache/oozie/servlet/MockCoordinatorEngineService.java +++ b/core/src/test/java/org/apache/oozie/servlet/MockCoordinatorEngineService.java @@ -177,7 +177,7 @@ public class MockCoordinatorEngineService extends CoordinatorEngineService { } @Override public CoordinatorActionInfo reRun(String jobId, String rerunType, String scope, boolean refresh, - boolean noCleanup) throws BaseEngineException { + boolean noCleanup, boolean failed) throws BaseEngineException { did = RestConstants.JOB_COORD_ACTION_RERUN; int idx = validateCoordinatorIdx(jobId); started.set(idx, true); http://git-wip-us.apache.org/repos/asf/oozie/blob/1c668054/core/src/test/java/org/apache/oozie/sla/TestSLAEventGeneration.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/oozie/sla/TestSLAEventGeneration.java b/core/src/test/java/org/apache/oozie/sla/TestSLAEventGeneration.java index e47e17f..10a8311 100644 --- a/core/src/test/java/org/apache/oozie/sla/TestSLAEventGeneration.java +++ b/core/src/test/java/org/apache/oozie/sla/TestSLAEventGeneration.java @@ -332,8 +332,8 @@ public class TestSLAEventGeneration extends XDataTestCase { addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.FAILED, "coord-rerun-action1.xml", 0); try { - new CoordRerunXCommand(job.getId(), RestConstants.JOB_COORD_SCOPE_DATE, "2009-12-15T01:00Z", false, true) - .call(); + new CoordRerunXCommand(job.getId(), RestConstants.JOB_COORD_SCOPE_DATE, "2009-12-15T01:00Z", false, + true, false).call(); } catch (CommandException ce) { if (ce.getErrorCode() == ErrorCode.E0604) { http://git-wip-us.apache.org/repos/asf/oozie/blob/1c668054/docs/src/site/twiki/CoordinatorFunctionalSpec.twiki ---------------------------------------------------------------------- diff --git a/docs/src/site/twiki/CoordinatorFunctionalSpec.twiki b/docs/src/site/twiki/CoordinatorFunctionalSpec.twiki index 8894649..15568a0 100644 --- a/docs/src/site/twiki/CoordinatorFunctionalSpec.twiki +++ b/docs/src/site/twiki/CoordinatorFunctionalSpec.twiki @@ -3498,7 +3498,7 @@ See the [[WebServicesAPI][Web Services API]] page. Example: <verbatim> -$oozie job -rerun <coord_Job_id> [-nocleanup] [-refresh] +$oozie job -rerun <coord_Job_id> [-nocleanup] [-refresh] [-failed] [-action 1, 3-4, 7-40] (-action or -date is required to rerun.) [-date 2009-01-01T01:00Z::2009-05-31T23:59Z, 2009-11-10T01:00Z, 2009-12-31T22:00Z] (if neither -action nor -date is given, the exception will be thrown.) http://git-wip-us.apache.org/repos/asf/oozie/blob/1c668054/docs/src/site/twiki/DG_CommandLineTool.twiki ---------------------------------------------------------------------- diff --git a/docs/src/site/twiki/DG_CommandLineTool.twiki b/docs/src/site/twiki/DG_CommandLineTool.twiki index b37e947..5d4132f 100644 --- a/docs/src/site/twiki/DG_CommandLineTool.twiki +++ b/docs/src/site/twiki/DG_CommandLineTool.twiki @@ -46,6 +46,7 @@ usage: -doas <arg> doAs user, impersonates as the specified user -dryrun Dryrun a workflow (since 3.3.2) or coordinator (since 2.0) job without actually executing it + -failed re-runs the failed workflow actions of the coordinator actions (requires -rerun) -filter <arg> <key><comparator><value>[;<key><comparator><value>]* (All Coordinator actions satisfying the filters will be retreived). key: status or nominaltime @@ -450,7 +451,7 @@ Refer to the [[DG_WorkflowReRun][Rerunning Workflow Jobs]] for details on rerun. Example: <verbatim> -$oozie job -rerun <coord_Job_id> [-nocleanup] [-refresh] +$oozie job -rerun <coord_Job_id> [-nocleanup] [-refresh] [-failed] [-action 1, 3-4, 7-40] (-action or -date is required to rerun.) [-date 2009-01-01T01:00Z::2009-05-31T23:59Z, 2009-11-10T01:00Z, 2009-12-31T22:00Z] (if neither -action nor -date is given, the exception will be thrown.) http://git-wip-us.apache.org/repos/asf/oozie/blob/1c668054/docs/src/site/twiki/DG_CoordinatorRerun.twiki ---------------------------------------------------------------------- diff --git a/docs/src/site/twiki/DG_CoordinatorRerun.twiki b/docs/src/site/twiki/DG_CoordinatorRerun.twiki index cd593d1..12a757c 100644 --- a/docs/src/site/twiki/DG_CoordinatorRerun.twiki +++ b/docs/src/site/twiki/DG_CoordinatorRerun.twiki @@ -19,7 +19,7 @@ ---++ Rerun Arguments <verbatim> -$oozie job -rerun <coord_Job_id> [-nocleanup] [-refresh] +$oozie job -rerun <coord_Job_id> [-nocleanup] [-refresh] [-failed] [-action 1, 3-4, 7-40] (-action or -date is required to rerun.) [-date 2009-01-01T01:00Z::2009-05-31T23:59Z, 2009-11-10T01:00Z, 2009-12-31T22:00Z] (if neither -action nor -date is given, the exception will be thrown.) @@ -34,6 +34,7 @@ $oozie job -rerun <coord_Job_id> [-nocleanup] [-refresh] * If -nocleanup is given, coordinator directories will not be removed; otherwise the 'output-event' will be deleted. * If -refresh is set, new dataset is re-evaluated for latest() and future(). * If -refresh is set, all dependencies will be re-checked; otherwise only missed dependencies will be checked. + * If -failed is set, re-runs the failed workflow actions of the coordinator actions. ---++ Rerun coordinator actions http://git-wip-us.apache.org/repos/asf/oozie/blob/1c668054/release-log.txt ---------------------------------------------------------------------- diff --git a/release-log.txt b/release-log.txt index 2aab6a9..86301d0 100644 --- a/release-log.txt +++ b/release-log.txt @@ -1,5 +1,6 @@ -- Oozie 4.2.0 release (trunk - unreleased) +OOZIE-2028 Coord action rerun with -failed option should rerun existing workflow with RERUN_FAIL_NODES=true (jaydeepvishwakarma via shwethags) OOZIE-2029 Workflow re-run with RERUN_FAIL_NODES=true should re-run only the failed nodes of the sub-workflow (jaydeepvishwakarma via shwethags) OOZIE-2035 NotificationXCommand should support proxy (puru) OOZIE-2065 Oozie returns incorrect total action for coord dryrun (puru)
