diff --git a/core/src/main/java/org/apache/oozie/CoordinatorEngine.java b/core/src/main/java/org/apache/oozie/CoordinatorEngine.java index 07bab122e..8f6a1c1dc 100644 --- a/core/src/main/java/org/apache/oozie/CoordinatorEngine.java +++ b/core/src/main/java/org/apache/oozie/CoordinatorEngine.java @@ -316,13 +316,14 @@ public void streamLog(String jobId, String logRetrievalScope, String logRetrieva // Use set implementation that maintains order or elements to achieve reproducibility: Set actionSet = new LinkedHashSet(); String[] list = logRetrievalScope.split(","); + LOG.debug("Value for the retrieval type of JobId : " + jobId); + int continuousRangeSum = 0; 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 - + "'"); + 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; @@ -341,7 +342,15 @@ public void streamLog(String jobId, String logRetrievalScope, String logRetrieva if (start > end) { throw new CommandException(ErrorCode.E0302, "format is wrong for action's range '" + s + "'"); } + + LOG.debug("Start and end actionIds are : " + start + " to " + end); + continuousRangeSum = continuousRangeSum + (end - start + 1); + if (continuousRangeSum > maxNumActionsForLog) { + throw new CommandException(ErrorCode.E0302, "action's range: " + continuousRangeSum + " is too large than allowed: " + maxNumActionsForLog); + } + for (int i = start; i <= end; i++) { + LOG.debug("Adding to actionSet."); actionSet.add(jobId + "@" + i); } } diff --git a/core/src/main/java/org/apache/oozie/coord/CoordUtils.java b/core/src/main/java/org/apache/oozie/coord/CoordUtils.java index 5c0821062..140388618 100644 --- a/core/src/main/java/org/apache/oozie/coord/CoordUtils.java +++ b/core/src/main/java/org/apache/oozie/coord/CoordUtils.java @@ -63,8 +63,17 @@ public class CoordUtils { + private static final XLog LOG = XLog.getLog(CoordUtils.class); public static final String HADOOP_USER = "user.name"; + public final static String COORD_ACTIONS_LOG_MAX_COUNT = "oozie.coord.actions.log.max.count"; + private final static int COORD_ACTIONS_LOG_MAX_COUNT_DEFAULT = 50; + private static int maxNumActionsForLog; + static { + maxNumActionsForLog = Services.get().getConf().getInt(COORD_ACTIONS_LOG_MAX_COUNT, COORD_ACTIONS_LOG_MAX_COUNT_DEFAULT); + LOG.info("maxNumActionsForLog set to = " + maxNumActionsForLog); + } + public static String getDoneFlag(Element doneFlagElement) { if (doneFlagElement != null) { return doneFlagElement.getTextTrim(); @@ -198,6 +207,8 @@ public static Set getActionsIds(String jobId, String scope) throws Comma Set actions = new LinkedHashSet(); String[] list = scope.split(","); + LOG.debug("Value for the retrieval type of JobId : " + jobId); + int continuousRangeSum = 0; for (String s : list) { s = s.trim(); // An action range is specified with two actions separated by '-' @@ -221,11 +232,19 @@ public static Set getActionsIds(String jobId, String scope) throws Comma } catch (NumberFormatException ne) { throw new CommandException(ErrorCode.E0302, "could not parse " + range[1].trim() + "into an integer", ne); } + LOG.debug("Start and end actionIds are : " + start + " to " + end); + continuousRangeSum = continuousRangeSum + (end - start + 1); + LOG.debug("continuousRangeSum = " + continuousRangeSum); + LOG.debug("maxNumActionsForLog = " + maxNumActionsForLog); + if (continuousRangeSum > maxNumActionsForLog) { + throw new CommandException(ErrorCode.E0302, "action's range: " + continuousRangeSum + " is too large than allowed: " + maxNumActionsForLog); + } 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"); } // Add the actionIds + LOG.debug("Adding to actionSet."); for (int i = start; i <= end; i++) { actions.add(jobId + "@" + i); }