Author: angeloh
Date: Fri Jan 6 21:58:23 2012
New Revision: 1228450
URL: http://svn.apache.org/viewvc?rev=1228450&view=rev
Log:
OOZIE-553 Ability to view log for coordinator actions that ran in a date
range.(Kiran via Mona via Mohammad)
Modified:
incubator/oozie/branches/3.1/client/src/main/java/org/apache/oozie/cli/OozieCLI.java
incubator/oozie/branches/3.1/client/src/main/java/org/apache/oozie/client/rest/RestConstants.java
incubator/oozie/branches/3.1/core/src/main/java/org/apache/oozie/CoordinatorEngine.java
incubator/oozie/branches/3.1/release-log.txt
Modified:
incubator/oozie/branches/3.1/client/src/main/java/org/apache/oozie/cli/OozieCLI.java
URL:
http://svn.apache.org/viewvc/incubator/oozie/branches/3.1/client/src/main/java/org/apache/oozie/cli/OozieCLI.java?rev=1228450&r1=1228449&r2=1228450&view=diff
==============================================================================
---
incubator/oozie/branches/3.1/client/src/main/java/org/apache/oozie/cli/OozieCLI.java
(original)
+++
incubator/oozie/branches/3.1/client/src/main/java/org/apache/oozie/cli/OozieCLI.java
Fri Jan 6 21:58:23 2012
@@ -111,7 +111,7 @@ public class OozieCLI {
public static final String LOCAL_TIME_OPTION = "localtime";
public static final String QUEUE_DUMP_OPTION = "queuedump";
public static final String RERUN_COORD_OPTION = "coordinator";
- public static final String RERUN_DATE_OPTION = "date";
+ public static final String DATE_OPTION = "date";
public static final String RERUN_REFRESH_OPTION = "refresh";
public static final String RERUN_NOCLEANUP_OPTION = "nocleanup";
@@ -208,8 +208,8 @@ public class OozieCLI {
Option verbose = new Option(VERBOSE_OPTION, false, "verbose mode");
Option action = new Option(ACTION_OPTION, true,
"coordinator rerun on action ids (requires -rerun);
coordinator log retrieval on action ids (requires -log)");
- Option rerun_date = new Option(RERUN_DATE_OPTION, true,
- "coordinator/bundle rerun on action dates (requires -rerun)");
+ Option date = new Option(DATE_OPTION, true,
+ "coordinator/bundle rerun on action dates (requires -rerun);
coordinator log retrieval on action dates (requires -log)");
Option rerun_coord = new Option(RERUN_COORD_OPTION, true, "bundle
rerun on coordinator names (requires -rerun)");
Option rerun_refresh = new Option(RERUN_REFRESH_OPTION, false,
"re-materialize the coordinator rerun actions (requires
-rerun)");
@@ -243,7 +243,7 @@ public class OozieCLI {
jobOptions.addOption(offset);
jobOptions.addOption(len);
jobOptions.addOption(action);
- jobOptions.addOption(rerun_date);
+ jobOptions.addOption(date);
jobOptions.addOption(rerun_coord);
jobOptions.addOption(rerun_refresh);
jobOptions.addOption(rerun_nocleanup);
@@ -612,8 +612,8 @@ public class OozieCLI {
throw new OozieCLIException("Invalid options provided
for bundle rerun. " + ACTION_OPTION
+ " is not valid for bundle rerun");
}
- if (options.contains(RERUN_DATE_OPTION)) {
- dateScope =
commandLine.getOptionValue(RERUN_DATE_OPTION);
+ if (options.contains(DATE_OPTION)) {
+ dateScope = commandLine.getOptionValue(DATE_OPTION);
}
if (options.contains(RERUN_COORD_OPTION)) {
@@ -642,20 +642,20 @@ public class OozieCLI {
String rerunType = null;
boolean refresh = false;
boolean noCleanup = false;
- if (options.contains(RERUN_DATE_OPTION) &&
options.contains(ACTION_OPTION)) {
- throw new OozieCLIException("Invalid options provided
for rerun: either" + RERUN_DATE_OPTION
- + " or " + ACTION_OPTION + " expected. Don't
use both at the same time.");
+ if (options.contains(DATE_OPTION) &&
options.contains(ACTION_OPTION)) {
+ throw new OozieCLIException("Invalid options provided
for rerun: either" + DATE_OPTION + " or "
+ + ACTION_OPTION + " expected. Don't use both
at the same time.");
}
- if (options.contains(RERUN_DATE_OPTION)) {
+ if (options.contains(DATE_OPTION)) {
rerunType = RestConstants.JOB_COORD_RERUN_DATE;
- scope = commandLine.getOptionValue(RERUN_DATE_OPTION);
+ scope = commandLine.getOptionValue(DATE_OPTION);
}
else if (options.contains(ACTION_OPTION)) {
rerunType = RestConstants.JOB_COORD_RERUN_ACTION;
scope = commandLine.getOptionValue(ACTION_OPTION);
}
else {
- throw new OozieCLIException("Invalid options provided
for rerun: " + RERUN_DATE_OPTION + " or "
+ throw new OozieCLIException("Invalid options provided
for rerun: " + DATE_OPTION + " or "
+ ACTION_OPTION + " expected.");
}
if (options.contains(RERUN_REFRESH_OPTION)) {
@@ -708,6 +708,10 @@ public class OozieCLI {
logRetrievalType = RestConstants.JOB_LOG_ACTION;
logRetrievalScope =
commandLine.getOptionValue(ACTION_OPTION);
}
+ if (options.contains(DATE_OPTION)) {
+ logRetrievalType = RestConstants.JOB_LOG_DATE;
+ logRetrievalScope =
commandLine.getOptionValue(DATE_OPTION);
+ }
try {
wc.getJobLog(commandLine.getOptionValue(LOG_OPTION),
logRetrievalType, logRetrievalScope, ps);
}
@@ -716,12 +720,12 @@ public class OozieCLI {
}
}
else {
- if (!options.contains(ACTION_OPTION)) {
+ if (!options.contains(ACTION_OPTION) &&
!options.contains(DATE_OPTION)) {
wc.getJobLog(commandLine.getOptionValue(LOG_OPTION),
null, null, ps);
}
else {
throw new OozieCLIException("Invalid options provided
for log retrieval. " + ACTION_OPTION
- + " is valid only for coordinator job log
retrieval");
+ + " and " + DATE_OPTION + " are valid only for
coordinator job log retrieval");
}
}
}
Modified:
incubator/oozie/branches/3.1/client/src/main/java/org/apache/oozie/client/rest/RestConstants.java
URL:
http://svn.apache.org/viewvc/incubator/oozie/branches/3.1/client/src/main/java/org/apache/oozie/client/rest/RestConstants.java?rev=1228450&r1=1228449&r2=1228450&view=diff
==============================================================================
---
incubator/oozie/branches/3.1/client/src/main/java/org/apache/oozie/client/rest/RestConstants.java
(original)
+++
incubator/oozie/branches/3.1/client/src/main/java/org/apache/oozie/client/rest/RestConstants.java
Fri Jan 6 21:58:23 2012
@@ -93,6 +93,8 @@ public interface RestConstants {
public static final String JOB_LOG_ACTION = "action";
+ public static final String JOB_LOG_DATE = "date";
+
public static final String JOB_LOG_SCOPE_PARAM = "scope";
public static final String JOB_LOG_TYPE_PARAM = "type";
Modified:
incubator/oozie/branches/3.1/core/src/main/java/org/apache/oozie/CoordinatorEngine.java
URL:
http://svn.apache.org/viewvc/incubator/oozie/branches/3.1/core/src/main/java/org/apache/oozie/CoordinatorEngine.java?rev=1228450&r1=1228449&r2=1228450&view=diff
==============================================================================
---
incubator/oozie/branches/3.1/core/src/main/java/org/apache/oozie/CoordinatorEngine.java
(original)
+++
incubator/oozie/branches/3.1/core/src/main/java/org/apache/oozie/CoordinatorEngine.java
Fri Jan 6 21:58:23 2012
@@ -36,6 +36,7 @@ import org.apache.oozie.client.rest.Rest
import org.apache.oozie.command.CommandException;
import org.apache.oozie.command.coord.CoordActionInfoCommand;
import org.apache.oozie.command.coord.CoordActionInfoXCommand;
+import org.apache.oozie.util.CoordActionsInDateRange;
import org.apache.oozie.command.coord.CoordChangeCommand;
import org.apache.oozie.command.coord.CoordChangeXCommand;
import org.apache.oozie.command.coord.CoordJobCommand;
@@ -315,6 +316,7 @@ public class CoordinatorEngine extends B
XLogStreamer.Filter filter = new XLogStreamer.Filter();
filter.setParameter(DagXLogInfoService.JOB, jobId);
if (logRetrievalScope != null && logRetrievalType != null) {
+ // if coordinator action logs are to be retrieved based on action
id range
if (logRetrievalType.equals(RestConstants.JOB_LOG_ACTION)) {
Set<String> actions = new HashSet<String>();
String[] list = logRetrievalScope.split(",");
@@ -368,6 +370,21 @@ public class CoordinatorEngine extends B
}
filter.setParameter(DagXLogInfoService.ACTION,
commaSeparatedActions.toString());
}
+ // if coordinator action logs are to be retrieved based on date
range
+ // this block gets the corresponding list of coordinator actions
to be used by the log filter
+ if (logRetrievalType.equalsIgnoreCase(RestConstants.JOB_LOG_DATE))
{
+ List<CoordinatorActionBean> actionsList =
CoordActionsInDateRange.getCoordActionsFromDates(jobId, logRetrievalScope);
+ StringBuilder commaSeparatedActions = new StringBuilder("");
+ boolean commaRequired = false;
+ for (CoordinatorActionBean coordAction : actionsList) {
+ if (commaRequired) {
+ commaSeparatedActions.append(",");
+ }
+ commaSeparatedActions.append(coordAction.getId());
+ commaRequired = true;
+ }
+ filter.setParameter(DagXLogInfoService.ACTION,
commaSeparatedActions.toString());
+ }
CoordinatorJobBean job = getCoordJobWithNoActionInfo(jobId);
Services.get().get(XLogService.class).streamLog(filter,
job.getCreatedTime(), new Date(), writer);
}
Modified: incubator/oozie/branches/3.1/release-log.txt
URL:
http://svn.apache.org/viewvc/incubator/oozie/branches/3.1/release-log.txt?rev=1228450&r1=1228449&r2=1228450&view=diff
==============================================================================
--- incubator/oozie/branches/3.1/release-log.txt (original)
+++ incubator/oozie/branches/3.1/release-log.txt Fri Jan 6 21:58:23 2012
@@ -1,4 +1,6 @@
-- Oozie 3.1.1 release
+
+OOZIE-553 Ability to view log for coordinator actions that ran in a date range.
OOZIE-581 Fix unit test failure in TestStatusTransitService.java.
OOZIE-579 POM file changes for oozie version 3.1.2
OOZIE-26 Ability to get the log content from Archived file(.gz format)