Author: kamrul
Date: Tue Jan 24 08:43:34 2012
New Revision: 1235163
URL: http://svn.apache.org/viewvc?rev=1235163&view=rev
Log:
OOZIE-651: Coordinator rerun fails due to NPE in some cases.(Virag via
Mohammad).OOZIE-655: Information added to Oozie help.(Virag via Mohammad)
Modified:
incubator/oozie/trunk/client/src/main/java/org/apache/oozie/cli/OozieCLI.java
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/LocalOozieClientCoord.java
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordRerunXCommand.java
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/coord/CoordUtils.java
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/servlet/JobServlet.java
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/util/CoordActionsInDateRange.java
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/util/DateUtils.java
incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordRerunXCommand.java
incubator/oozie/trunk/docs/src/site/twiki/DG_CommandLineTool.twiki
incubator/oozie/trunk/docs/src/site/twiki/DG_CoordinatorRerun.twiki
incubator/oozie/trunk/release-log.txt
Modified:
incubator/oozie/trunk/client/src/main/java/org/apache/oozie/cli/OozieCLI.java
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/client/src/main/java/org/apache/oozie/cli/OozieCLI.java?rev=1235163&r1=1235162&r2=1235163&view=diff
==============================================================================
---
incubator/oozie/trunk/client/src/main/java/org/apache/oozie/cli/OozieCLI.java
(original)
+++
incubator/oozie/trunk/client/src/main/java/org/apache/oozie/cli/OozieCLI.java
Tue Jan 24 08:43:34 2012
@@ -269,7 +269,8 @@ public class OozieCLI {
Option jobtype = new Option(JOBTYPE_OPTION, true,
"job type ('Supported in Oozie-2.0 or later versions ONLY -
'coordinator' or 'bundle' or 'wf'(default))");
Option len = new Option(LEN_OPTION, true, "number of jobs (default
'100')");
- Option filter = new Option(FILTER_OPTION, true,
"user=<U>;name=<N>;group=<G>;status=<S>;...");
+ Option filter = new Option(FILTER_OPTION, true,
"user=<U>;name=<N>;group=<G>;status=<S>;frequency=<F>;unit=<M> " +
+ "(Valid unit values are 'months', 'days', 'hours' or
'minutes'.)");
Option localtime = new Option(LOCAL_TIME_OPTION, false, "use local
time (default GMT)");
Option verbose = new Option(VERBOSE_OPTION, false, "verbose mode");
Option doAs = new Option(DO_AS_OPTION, true, "doAs user, impersonates
as the specified user");
Modified:
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/LocalOozieClientCoord.java
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/java/org/apache/oozie/LocalOozieClientCoord.java?rev=1235163&r1=1235162&r2=1235163&view=diff
==============================================================================
---
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/LocalOozieClientCoord.java
(original)
+++
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/LocalOozieClientCoord.java
Tue Jan 24 08:43:34 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.
@@ -30,6 +30,9 @@ import org.apache.oozie.client.OozieClie
import org.apache.oozie.client.WorkflowJob;
import org.apache.oozie.client.rest.JsonCoordinatorAction;
import org.apache.oozie.client.rest.JsonCoordinatorJob;
+import org.apache.oozie.client.rest.RestConstants;
+import org.apache.oozie.command.CommandException;
+import org.apache.oozie.command.coord.CoordRerunXCommand;
import org.apache.oozie.util.XConfiguration;
/**
@@ -252,15 +255,28 @@ public class LocalOozieClientCoord exten
public List<CoordinatorAction> reRunCoord(String jobId, String rerunType,
String scope, boolean refresh,
boolean noCleanup) throws OozieClientException {
try {
+ if (!(rerunType.equals(RestConstants.JOB_COORD_RERUN_DATE) ||
rerunType
+ .equals(RestConstants.JOB_COORD_RERUN_ACTION))) {
+ throw new CommandException(ErrorCode.E1018, "date or action
expected.");
+ }
CoordinatorActionInfo coordInfo = coordEngine.reRun(jobId,
rerunType, scope, Boolean.valueOf(refresh),
Boolean.valueOf(noCleanup));
- List<CoordinatorActionBean> actionBeans =
coordInfo.getCoordActions();
+ List<CoordinatorActionBean> actionBeans;
+ if (coordInfo != null) {
+ actionBeans = coordInfo.getCoordActions();
+ }
+ else {
+ actionBeans = CoordRerunXCommand.getCoordActions(rerunType,
jobId, scope);
+ }
List<CoordinatorAction> actions = new
ArrayList<CoordinatorAction>();
for (CoordinatorActionBean actionBean : actionBeans) {
actions.add(actionBean);
}
return actions;
}
+ catch(CommandException ce){
+ throw new OozieClientException(ce.getErrorCode().toString(), ce);
+ }
catch (BaseEngineException ex) {
throw new OozieClientException(ex.getErrorCode().toString(), ex);
}
@@ -354,7 +370,7 @@ public class LocalOozieClientCoord exten
/**
* Get the info of a coordinator action.
- *
+ *
* @param actionId Id.
* @return the coordinator action info.
* @throws OozieClientException thrown if the job info could not be
Modified:
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordRerunXCommand.java
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordRerunXCommand.java?rev=1235163&r1=1235162&r2=1235163&view=diff
==============================================================================
---
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordRerunXCommand.java
(original)
+++
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordRerunXCommand.java
Tue Jan 24 08:43:34 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.
@@ -44,6 +44,7 @@ import org.apache.oozie.command.Precondi
import org.apache.oozie.command.RerunTransitionXCommand;
import org.apache.oozie.command.bundle.BundleStatusUpdateXCommand;
import org.apache.oozie.coord.CoordELFunctions;
+import org.apache.oozie.coord.CoordUtils;
import org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor;
import
org.apache.oozie.executor.jpa.CoordJobGetActionForNominalTimeJPAExecutor;
import org.apache.oozie.executor.jpa.CoordJobGetActionsForDatesJPAExecutor;
@@ -103,158 +104,13 @@ public class CoordRerunXCommand extends
}
/**
- * Get the list of actions for given id ranges
- *
- * @param jobId coordinator job id
- * @param scope the id range to rerun separated by ","
- * @return the list of all actions to rerun
- * @throws CommandException thrown if failed to get coordinator actions by
given id range
- */
- private List<CoordinatorActionBean> getCoordActionsFromIds(String jobId,
String scope) throws CommandException {
- ParamChecker.notEmpty(jobId, "jobId");
- ParamChecker.notEmpty(scope, "scope");
-
- Set<String> actions = new HashSet<String>();
- String[] list = scope.split(",");
- for (String s : list) {
- s = s.trim();
- if (s.contains("-")) {
- String[] range = s.split("-");
- if (range.length != 2) {
- throw new CommandException(ErrorCode.E0302, "format is
wrong for action's range '" + s + "'");
- }
- int start;
- int end;
- try {
- start = Integer.parseInt(range[0].trim());
- end = Integer.parseInt(range[1].trim());
- if (start > end) {
- throw new CommandException(ErrorCode.E0302, "format is
wrong for action's range '" + s + "'");
- }
- }
- catch (NumberFormatException ne) {
- throw new CommandException(ErrorCode.E0302, ne);
- }
- for (int i = start; i <= end; i++) {
- actions.add(jobId + "@" + i);
- }
- }
- else {
- try {
- Integer.parseInt(s);
- }
- catch (NumberFormatException ne) {
- throw new CommandException(ErrorCode.E0302, "format is
wrong for action id'" + s
- + "'. Integer only.");
- }
- actions.add(jobId + "@" + s);
- }
- }
-
- List<CoordinatorActionBean> coordActions = new
ArrayList<CoordinatorActionBean>();
- for (String id : actions) {
- CoordinatorActionBean coordAction;
- try {
- coordAction = jpaService.execute(new
CoordActionGetJPAExecutor(id));
- }
- catch (JPAExecutorException je) {
- throw new CommandException(je);
- }
- coordActions.add(coordAction);
- LOG.debug("Rerun coordinator for actionId='" + id + "'");
- }
- return coordActions;
- }
-
- /**
- * Get the list of actions for given date ranges
- *
- * @param jobId coordinator job id
- * @param scope the date range to rerun separated by ","
- * @return the list of dates to rerun
- * @throws CommandException thrown if failed to get coordinator actions by
given date range
- */
- private List<CoordinatorActionBean> getCoordActionsFromDates(String jobId,
String scope) throws CommandException {
- ParamChecker.notEmpty(jobId, "jobId");
- ParamChecker.notEmpty(scope, "scope");
-
- Set<CoordinatorActionBean> actionSet = new
HashSet<CoordinatorActionBean>();
- String[] list = scope.split(",");
- for (String s : list) {
- s = s.trim();
- if (s.contains("::")) {
- String[] dateRange = s.split("::");
- if (dateRange.length != 2) {
- throw new CommandException(ErrorCode.E0302, "format is
wrong for date's range '" + s + "'");
- }
- Date start;
- Date end;
- try {
- start = DateUtils.parseDateUTC(dateRange[0].trim());
- end = DateUtils.parseDateUTC(dateRange[1].trim());
- if (start.after(end)) {
- throw new CommandException(ErrorCode.E0302, "start
date is older than end date: '" + s + "'");
- }
- }
- catch (Exception e) {
- throw new CommandException(ErrorCode.E0302, e);
- }
-
- List<CoordinatorActionBean> listOfActions =
getActionIdsFromDateRange(jobId, start, end);
- actionSet.addAll(listOfActions);
- }
- else {
- try {
- Date date = DateUtils.parseDateUTC(s.trim());
- CoordinatorActionBean coordAction = jpaService
- .execute(new
CoordJobGetActionForNominalTimeJPAExecutor(jobId, date));
- actionSet.add(coordAction);
- }
- catch (JPAExecutorException e) {
- throw new CommandException(e);
- }
- catch (Exception e) {
- throw new CommandException(ErrorCode.E0302, e);
- }
- }
- }
-
- List<CoordinatorActionBean> coordActions = new
ArrayList<CoordinatorActionBean>();
- for (CoordinatorActionBean coordAction : actionSet) {
- coordActions.add(coordAction);
- LOG.debug("Rerun coordinator for actionId='" + coordAction.getId()
+ "'");
- }
- return coordActions;
- }
-
- /**
- * Get coordinator action ids between given start and end time
- *
- * @param jobId coordinator job id
- * @param start start time
- * @param end end time
- * @return a list of coordinator actions belong to the range of start and
end time
- * @throws CommandException thrown if failed to get coordinator actions
- */
- private List<CoordinatorActionBean> getActionIdsFromDateRange(String
jobId, Date start, Date end)
- throws CommandException {
- List<CoordinatorActionBean> list;
- try {
- list = jpaService.execute(new
CoordJobGetActionsForDatesJPAExecutor(jobId, start, end));
- }
- catch (JPAExecutorException je) {
- throw new CommandException(je);
- }
- return list;
- }
-
- /**
* Check if all given actions are eligible to rerun.
*
* @param actions list of CoordinatorActionBean
* @return true if all actions are eligible to rerun
*/
- private boolean checkAllActionsRunnable(List<CoordinatorActionBean>
coordActions) {
+ private static boolean checkAllActionsRunnable(List<CoordinatorActionBean>
coordActions) {
+ ParamChecker.notNull(coordActions, "Coord actions to be rerun");
boolean ret = false;
for (CoordinatorActionBean coordAction : coordActions) {
ret = true;
@@ -267,6 +123,25 @@ public class CoordRerunXCommand extends
}
/**
+ * Get the list of actions for a given coordinator job
+ * @param rerunType the rerun type (date, action)
+ * @param jobId the coordinator job id
+ * @param scope the date scope or action id scope
+ * @return the list of Coordinator actions
+ * @throws CommandException
+ */
+ public static List<CoordinatorActionBean> getCoordActions(String
rerunType, String jobId, String scope) throws CommandException{
+ List<CoordinatorActionBean> coordActions = null;
+ if (rerunType.equals(RestConstants.JOB_COORD_RERUN_DATE)) {
+ coordActions = CoordUtils.getCoordActionsFromDates(jobId, scope);
+ }
+ else if (rerunType.equals(RestConstants.JOB_COORD_RERUN_ACTION)) {
+ coordActions = CoordUtils.getCoordActionsFromIds(jobId, scope);
+ }
+ return coordActions;
+ }
+
+ /**
* Cleanup output-events directories
*
* @param eAction coordinator action xml
@@ -436,17 +311,7 @@ public class CoordRerunXCommand extends
try {
CoordinatorActionInfo coordInfo = null;
InstrumentUtils.incrJobCounter(getName(), 1, getInstrumentation());
- List<CoordinatorActionBean> coordActions;
- if (rerunType.equals(RestConstants.JOB_COORD_RERUN_DATE)) {
- coordActions = getCoordActionsFromDates(jobId, scope);
- }
- else if (rerunType.equals(RestConstants.JOB_COORD_RERUN_ACTION)) {
- coordActions = getCoordActionsFromIds(jobId, scope);
- }
- else {
- isError = true;
- throw new CommandException(ErrorCode.E1018, "date or action
expected.");
- }
+ List<CoordinatorActionBean> coordActions =
getCoordActions(rerunType, jobId, scope);
if (checkAllActionsRunnable(coordActions)) {
for (CoordinatorActionBean coordAction : coordActions) {
String actionXml = coordAction.getActionXml();
Modified:
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/coord/CoordUtils.java
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/java/org/apache/oozie/coord/CoordUtils.java?rev=1235163&r1=1235162&r2=1235163&view=diff
==============================================================================
---
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/coord/CoordUtils.java
(original)
+++
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/coord/CoordUtils.java
Tue Jan 24 08:43:34 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.
@@ -17,8 +17,26 @@
*/
package org.apache.oozie.coord;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
import org.apache.hadoop.conf.Configuration;
+import org.apache.oozie.CoordinatorActionBean;
+import org.apache.oozie.ErrorCode;
+import org.apache.oozie.XException;
import org.apache.oozie.client.OozieClient;
+import org.apache.oozie.command.CommandException;
+import org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor;
+import
org.apache.oozie.executor.jpa.CoordJobGetActionForNominalTimeJPAExecutor;
+import org.apache.oozie.executor.jpa.JPAExecutorException;
+import org.apache.oozie.service.JPAService;
+import org.apache.oozie.service.Services;
+import org.apache.oozie.util.CoordActionsInDateRange;
+import org.apache.oozie.util.DateUtils;
import org.apache.oozie.util.ParamChecker;
import org.jdom.Element;
@@ -45,4 +63,134 @@ public class CoordUtils {
conf.set(HADOOP_UGI, user + "," + group);
return conf;
}
+
+ /**
+ * Get the list of actions for given date ranges
+ *
+ * @param jobId coordinator job id
+ * @param scope a comma-separated list of date ranges. Each date range
element is specified with two dates separated by '::'
+ * @return the list of Coordinator actions for the date range
+ * @throws CommandException thrown if failed to get coordinator actions by
given date range
+ */
+ public static List<CoordinatorActionBean> getCoordActionsFromDates(String
jobId, String scope) throws CommandException {
+ JPAService jpaService = Services.get().get(JPAService.class);
+ ParamChecker.notEmpty(jobId, "jobId");
+ ParamChecker.notEmpty(scope, "scope");
+
+ Set<CoordinatorActionBean> actionSet = new
HashSet<CoordinatorActionBean>();
+ String[] list = scope.split(",");
+ for (String s : list) {
+ s = s.trim();
+ // A date range is specified with two dates separated by '::'
+ if (s.contains("::")) {
+ List<CoordinatorActionBean> listOfActions;
+ try {
+ // Get list of actions within the range of date
+ listOfActions =
CoordActionsInDateRange.getCoordActionsFromDateRange(jobId, s);
+ }
+ catch (XException e) {
+ throw new CommandException(e);
+ }
+ actionSet.addAll(listOfActions);
+ }
+ else {
+ try {
+ // Get action for the nominal time
+ Date date = DateUtils.parseDateUTC(s.trim());
+ CoordinatorActionBean coordAction = jpaService
+ .execute(new
CoordJobGetActionForNominalTimeJPAExecutor(jobId, date));
+
+ if (coordAction != null) {
+ actionSet.add(coordAction);
+ }
+ else {
+ throw new RuntimeException("This should never happen,
Coordinator Action shouldn't be null");
+ }
+ }
+ catch (ParseException e) {
+ throw new CommandException(ErrorCode.E0302, e);
+ }
+ catch (JPAExecutorException e) {
+ throw new CommandException(e);
+ }
+
+ }
+ }
+
+ List<CoordinatorActionBean> coordActions = new
ArrayList<CoordinatorActionBean>();
+ for (CoordinatorActionBean coordAction : actionSet) {
+ coordActions.add(coordAction);
+ }
+ return coordActions;
+ }
+
+ /**
+ * Get the list of actions for given id ranges
+ *
+ * @param jobId coordinator job id
+ * @param scope a comma-separated list of action ranges. The action range
is specified with two action numbers separated by '-'
+ * @return the list of all Coordinator actions for action range
+ * @throws CommandException thrown if failed to get coordinator actions by
given id range
+ */
+ public static List<CoordinatorActionBean> getCoordActionsFromIds(String
jobId, String scope) throws CommandException {
+ JPAService jpaService = Services.get().get(JPAService.class);
+ ParamChecker.notEmpty(jobId, "jobId");
+ ParamChecker.notEmpty(scope, "scope");
+
+ Set<String> actions = new HashSet<String>();
+ String[] list = scope.split(",");
+ for (String s : list) {
+ s = s.trim();
+ // An action range is specified with two actions separated by '-'
+ if (s.contains("-")) {
+ String[] range = s.split("-");
+ // Check the format for action's range
+ if (range.length != 2) {
+ throw new CommandException(ErrorCode.E0302, "format is
wrong for action's range '" + s + "', an example of correct format is 1-5");
+ }
+ int start;
+ int end;
+ try {
+ //Get the starting and ending action numbers
+ start = Integer.parseInt(range[0].trim());
+ end = Integer.parseInt(range[1].trim());
+ if (start > end) {
+ throw new CommandException(ErrorCode.E0302, "format is
wrong for action's range '" + s
+ + "', starting action number of the range
should be less than ending action number, an example will be 1-4");
+ }
+ }
+ catch (NumberFormatException ne) {
+ throw new CommandException(ErrorCode.E0302, ne);
+ }
+ // Add the actionIds
+ for (int i = start; i <= end; i++) {
+ actions.add(jobId + "@" + i);
+ }
+ }
+ else {
+ try {
+ Integer.parseInt(s);
+ }
+ catch (NumberFormatException ne) {
+ throw new CommandException(ErrorCode.E0302, "format is
wrong for action id'" + s
+ + "'. Integer only.");
+ }
+ actions.add(jobId + "@" + s);
+ }
+ }
+ // Retrieve the actions using the corresponding actionIds
+ List<CoordinatorActionBean> coordActions = new
ArrayList<CoordinatorActionBean>();
+ for (String id : actions) {
+ CoordinatorActionBean coordAction;
+ try {
+ coordAction = jpaService.execute(new
CoordActionGetJPAExecutor(id));
+ }
+ catch (JPAExecutorException je) {
+ throw new CommandException(je);
+ }
+ coordActions.add(coordAction);
+ }
+ return coordActions;
+ }
+
}
Modified:
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/servlet/JobServlet.java
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/java/org/apache/oozie/servlet/JobServlet.java?rev=1235163&r1=1235162&r2=1235163&view=diff
==============================================================================
---
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/servlet/JobServlet.java
(original)
+++
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/servlet/JobServlet.java
Tue Jan 24 08:43:34 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.
@@ -37,6 +37,8 @@ import org.apache.oozie.client.OozieClie
import org.apache.oozie.client.rest.JsonTags;
import org.apache.oozie.client.rest.JsonWorkflowJob;
import org.apache.oozie.client.rest.RestConstants;
+import org.apache.oozie.command.CommandException;
+import org.apache.oozie.command.coord.CoordRerunXCommand;
import org.apache.oozie.service.AuthorizationException;
import org.apache.oozie.service.AuthorizationService;
import org.apache.oozie.service.CoordinatorEngineService;
@@ -128,9 +130,19 @@ public class JobServlet extends JsonRest
String scope =
request.getParameter(RestConstants.JOB_COORD_RERUN_SCOPE_PARAM);
String refresh =
request.getParameter(RestConstants.JOB_COORD_RERUN_REFRESH_PARAM);
String noCleanup =
request.getParameter(RestConstants.JOB_COORD_RERUN_NOCLEANUP_PARAM);
+ if (!(rerunType.equals(RestConstants.JOB_COORD_RERUN_DATE) ||
rerunType
+ .equals(RestConstants.JOB_COORD_RERUN_ACTION))) {
+ throw new CommandException(ErrorCode.E1018, "date or
action expected.");
+ }
CoordinatorActionInfo coordInfo = coordEngine.reRun(jobId,
rerunType, scope, Boolean.valueOf(refresh),
Boolean.valueOf(noCleanup));
- List<CoordinatorActionBean> actions =
coordInfo.getCoordActions();
+ List<CoordinatorActionBean> actions;
+ if (coordInfo != null) {
+ actions = coordInfo.getCoordActions();
+ }
+ else {
+ actions = CoordRerunXCommand.getCoordActions(rerunType,
jobId, scope);
+ }
JSONObject json = new JSONObject();
json.put(JsonTags.COORDINATOR_ACTIONS,
CoordinatorActionBean.toJSONArray(actions));
startCron();
@@ -141,6 +153,9 @@ public class JobServlet extends JsonRest
RestConstants.ACTION_PARAM, action);
}
}
+ catch (CommandException ex) {
+ throw new XServletException(HttpServletResponse.SC_BAD_REQUEST,
ex);
+ }
catch (DagEngineException ex) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST,
ex);
}
Modified:
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java?rev=1235163&r1=1235162&r2=1235163&view=diff
==============================================================================
---
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java
(original)
+++
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/servlet/V1JobServlet.java
Tue Jan 24 08:43:34 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.
@@ -33,6 +33,8 @@ import org.apache.oozie.CoordinatorActio
import org.apache.oozie.CoordinatorEngine;
import org.apache.oozie.CoordinatorEngineException;
import org.apache.oozie.command.CommandException;
+import org.apache.oozie.command.coord.CoordRerunXCommand;
+import org.apache.oozie.coord.CoordUtils;
import org.apache.oozie.DagEngine;
import org.apache.oozie.DagEngineException;
import org.apache.oozie.ErrorCode;
@@ -614,18 +616,33 @@ public class V1JobServlet extends BaseJo
+ refresh + ", noCleanup=" + noCleanup);
try {
+ if (!(rerunType.equals(RestConstants.JOB_COORD_RERUN_DATE) ||
rerunType
+ .equals(RestConstants.JOB_COORD_RERUN_ACTION))) {
+ throw new CommandException(ErrorCode.E1018, "date or action
expected.");
+ }
CoordinatorActionInfo coordInfo = coordEngine.reRun(jobId,
rerunType, scope, Boolean.valueOf(refresh),
Boolean.valueOf(noCleanup));
- List<CoordinatorActionBean> actions = coordInfo.getCoordActions();
- json.put(JsonTags.COORDINATOR_ACTIONS,
CoordinatorActionBean.toJSONArray(actions));
+ List<CoordinatorActionBean> coordActions;
+ if (coordInfo != null) {
+ coordActions = coordInfo.getCoordActions();
+ }
+ else {
+ coordActions = CoordRerunXCommand.getCoordActions(rerunType,
jobId, scope);
+ }
+ json.put(JsonTags.COORDINATOR_ACTIONS,
CoordinatorActionBean.toJSONArray(coordActions));
}
catch (BaseEngineException ex) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST,
ex);
}
+ catch (CommandException ex) {
+ throw new XServletException(HttpServletResponse.SC_BAD_REQUEST,
ex);
+ }
return json;
}
+
+
/**
* Get workflow job
*
Modified:
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/util/CoordActionsInDateRange.java
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/java/org/apache/oozie/util/CoordActionsInDateRange.java?rev=1235163&r1=1235162&r2=1235163&view=diff
==============================================================================
---
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/util/CoordActionsInDateRange.java
(original)
+++
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/util/CoordActionsInDateRange.java
Tue Jan 24 08:43:34 2012
@@ -18,6 +18,7 @@
package org.apache.oozie.util;
+import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
@@ -59,25 +60,8 @@ public class CoordActionsInDateRange {
String[] list = scope.split(",");
for (String s : list) {
s = s.trim();
- // This block checks for errors in the format of specifying date
range
if (s.contains("::")) {
- String[] dateRange = s.split("::");
- if (dateRange.length != 2) {
- throw new XException(ErrorCode.E0308, "'" + s + "'. Date
value expected on both sides of the scope resolution operator '::' to signify
start and end of range");
- }
- Date start;
- Date end;
- try {
- start = DateUtils.parseDateUTC(dateRange[0].trim());
- end = DateUtils.parseDateUTC(dateRange[1].trim());
- }
- catch (Exception dx) {
- throw new XException(ErrorCode.E0308, "Error in parsing
start or end date");
- }
- if (start.after(end)) {
- throw new XException(ErrorCode.E0308, "'" + s + "'. Start
date '" + start + "' is older than end date: '" + end + "'");
- }
- List<CoordinatorActionBean> listOfActions =
getActionIdsFromDateRange(jobId, start, end);
+ List<CoordinatorActionBean> listOfActions =
getCoordActionsFromDateRange(jobId, s);
actionSet.addAll(listOfActions);
}
else {
@@ -91,6 +75,36 @@ public class CoordActionsInDateRange {
return coordActions;
}
+ /**
+ * Get the coordinator actions for a given date range
+ * @param jobId the coordinator job id
+ * @param range the date range separated by '::'
+ * @return the list of Coordinator actions for the date range
+ * @throws XException
+ */
+ public static List<CoordinatorActionBean>
getCoordActionsFromDateRange(String jobId, String range) throws XException{
+ String[] dateRange = range.split("::");
+ // This block checks for errors in the format of specifying date
range
+ if (dateRange.length != 2) {
+ throw new XException(ErrorCode.E0308, "'" + range + "'. Date
value expected on both sides of the scope resolution operator '::' to signify
start and end of range");
+ }
+ Date start;
+ Date end;
+ try {
+ // Get the start and end dates for the range
+ start = DateUtils.parseDateUTC(dateRange[0].trim());
+ end = DateUtils.parseDateUTC(dateRange[1].trim());
+ }
+ catch (ParseException dx) {
+ throw new XException(ErrorCode.E0308, "Error in parsing start
or end date. " + dx);
+ }
+ if (start.after(end)) {
+ throw new XException(ErrorCode.E0308, "'" + range + "'. Start
date '" + start + "' is older than end date: '" + end + "'");
+ }
+ List<CoordinatorActionBean> listOfActions =
getActionIdsFromDateRange(jobId, start, end);
+ return listOfActions;
+ }
+
/*
* Get coordinator action ids between given start and end time
*
Modified:
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/util/DateUtils.java
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/java/org/apache/oozie/util/DateUtils.java?rev=1235163&r1=1235162&r2=1235163&view=diff
==============================================================================
---
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/util/DateUtils.java
(original)
+++
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/util/DateUtils.java
Tue Jan 24 08:43:34 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.
@@ -19,6 +19,7 @@ package org.apache.oozie.util;
import java.sql.Timestamp;
import java.text.DateFormat;
+import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@@ -101,7 +102,7 @@ public class DateUtils {
dateFormat.setTimeZone(UTC);
return dateFormat;
}
-
+
private static DateFormat getSpecificDateFormat(String format) {
DateFormat dateFormat = new SimpleDateFormat(format);
dateFormat.setTimeZone(UTC);
@@ -119,7 +120,7 @@ public class DateUtils {
return tz;
}
- public static Date parseDateUTC(String s) throws Exception {
+ public static Date parseDateUTC(String s) throws ParseException {
return getISO8601DateFormat().parse(s);
}
Modified:
incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordRerunXCommand.java
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordRerunXCommand.java?rev=1235163&r1=1235162&r2=1235163&view=diff
==============================================================================
---
incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordRerunXCommand.java
(original)
+++
incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordRerunXCommand.java
Tue Jan 24 08:43:34 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.
@@ -554,6 +554,7 @@ public class TestCoordRerunXCommand exte
store2.closeTrx();
waitFor(120 * 1000, new Predicate() {
+ @Override
public boolean evaluate() throws Exception {
CoordinatorAction bean =
coordClient.getCoordActionInfo(actionId);
return (bean.getStatus() == CoordinatorAction.Status.READY ||
bean.getStatus() == CoordinatorAction.Status.SUBMITTED);
@@ -623,6 +624,7 @@ public class TestCoordRerunXCommand exte
store2.closeTrx();
waitFor(120 * 1000, new Predicate() {
+ @Override
public boolean evaluate() throws Exception {
CoordinatorAction bean =
coordClient.getCoordActionInfo(actionId);
return (bean.getStatus() == CoordinatorAction.Status.WAITING
|| bean.getStatus() == CoordinatorAction.Status.READY);
@@ -667,6 +669,7 @@ public class TestCoordRerunXCommand exte
store2.commitTrx();
store2.closeTrx();
waitFor(120 * 1000, new Predicate() {
+ @Override
public boolean evaluate() throws Exception {
CoordinatorAction bean =
coordClient.getCoordActionInfo(actionId);
return (bean.getStatus() == CoordinatorAction.Status.WAITING
|| bean.getStatus() == CoordinatorAction.Status.READY);
Modified: incubator/oozie/trunk/docs/src/site/twiki/DG_CommandLineTool.twiki
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/docs/src/site/twiki/DG_CommandLineTool.twiki?rev=1235163&r1=1235162&r2=1235163&view=diff
==============================================================================
--- incubator/oozie/trunk/docs/src/site/twiki/DG_CommandLineTool.twiki
(original)
+++ incubator/oozie/trunk/docs/src/site/twiki/DG_CommandLineTool.twiki Tue Jan
24 08:43:34 2012
@@ -491,9 +491,11 @@ Valid filter names are:
* user: the user that submitted the job.
* group: the group for the job.
* status: the status of the job.
+ * frequency: the frequency of the Coordinator job.
+ * unit: the time unit. It can take one of the following four values:
months, days, hours or minutes. Time unit should be added only when frequency
is specified.
The query will do an AND among all the filter names. The query will do an OR
among all the filter values for the same
-name. Multiple values must be specified as different name value pairs.
+name. Multiple values must be specified as different name value pairs.
---+++ Checking the Status of multiple Coordinator Jobs
Modified: incubator/oozie/trunk/docs/src/site/twiki/DG_CoordinatorRerun.twiki
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/docs/src/site/twiki/DG_CoordinatorRerun.twiki?rev=1235163&r1=1235162&r2=1235163&view=diff
==============================================================================
--- incubator/oozie/trunk/docs/src/site/twiki/DG_CoordinatorRerun.twiki
(original)
+++ incubator/oozie/trunk/docs/src/site/twiki/DG_CoordinatorRerun.twiki Tue Jan
24 08:43:34 2012
@@ -43,7 +43,7 @@ $oozie job -rerun <coord_Job_id> [-nocle
* Rerun for job, user should use job's start date and end date in -date.
* If the user specifies a date range (say Jan 1 to May 1), the actions that
will be re-run are the existing actions
within that range. If the existing actions are action #5....#40, which
map to Jan 15 to Feb 15, then only those actions will run.
- * When rerun succeeds, the rerun action_id and nominal_time will be return.
+ * The rerun action_id and nominal_time of the actions which are eligible to
rerun will be returned.
[[index][::Go back to Oozie Documentation Index::]]
Modified: incubator/oozie/trunk/release-log.txt
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/release-log.txt?rev=1235163&r1=1235162&r2=1235163&view=diff
==============================================================================
--- incubator/oozie/trunk/release-log.txt (original)
+++ incubator/oozie/trunk/release-log.txt Tue Jan 24 08:43:34 2012
@@ -1,5 +1,7 @@
-- Oozie 3.2.0 release
+OOZIE-651: Coordinator rerun fails due to NPE in some cases.(Virag via
Mohammad)
+OOZIE-655: Information added to Oozie help.(Virag via Mohammad)
OOZIE-642: Year support in dateOffset() El function.(Virag via Mohammad)
OOZIE-652 Add proxyuser capabilities to Oozie HTTP API. (tucu)
OOZIE-591: Oozie continues to materialize new actions after end date
modification (Mohamed Battisha vis Angelo)