From a756de93effb8c4c041e79a72b6542d2e88b253f Mon Sep 17 00:00:00 2001 From: Jason Darrell Lowe Date: Mon, 3 Mar 2014 22:02:18 +0000 Subject: [PATCH] MAPREDUCE-5773. Provide dedicated MRAppMaster syslog length limit. Contributed by Gera Shegalov git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1573775 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-mapreduce-project/CHANGES.txt | 3 ++ .../apache/hadoop/mapreduce/MRJobConfig.java | 6 +++- .../src/main/resources/mapred-default.xml | 8 ++++++ .../org/apache/hadoop/mapred/YARNRunner.java | 3 +- .../hadoop/mapreduce/v2/TestMRJobs.java | 28 ++++++++++++++----- 5 files changed, 39 insertions(+), 9 deletions(-) diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index 25444e482a..117780d8bc 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -185,6 +185,9 @@ Release 2.4.0 - UNRELEASED MAPREDUCE-5766. Moved ping messages from TaskAttempts to be at DEBUG level inside the ApplicationMaster log. (Jian He via vinodkv) + MAPREDUCE-5773. Provide dedicated MRAppMaster syslog length limit (Gera + Shegalov via jlowe) + OPTIMIZATIONS BUG FIXES diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/MRJobConfig.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/MRJobConfig.java index ffb9543351..2e40562fd6 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/MRJobConfig.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/MRJobConfig.java @@ -414,9 +414,13 @@ public interface MRJobConfig { MR_AM_PREFIX+"log.level"; public static final String DEFAULT_MR_AM_LOG_LEVEL = "INFO"; + public static final String MR_AM_LOG_KB = + MR_AM_PREFIX + "container.log.limit.kb"; + public static final int DEFAULT_MR_AM_LOG_KB = 0; // don't roll + public static final String MR_AM_LOG_BACKUPS = MR_AM_PREFIX + "container.log.backups"; - public static final int DEFAULT_MR_AM_LOG_BACKUPS = 0; // don't roll + public static final int DEFAULT_MR_AM_LOG_BACKUPS = 0; /**The number of splits when reporting progress in MR*/ public static final String MR_AM_NUM_PROGRESS_SPLITS = diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/resources/mapred-default.xml b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/resources/mapred-default.xml index cc663923ea..f4a3193b3d 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/resources/mapred-default.xml +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/resources/mapred-default.xml @@ -510,6 +510,14 @@ + + yarn.app.mapreduce.am.container.log.limit.kb + 0 + The maximum size of the MRAppMaster attempt container logs in KB. + 0 disables the cap. + + + yarn.app.mapreduce.task.container.log.backups 0 diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/YARNRunner.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/YARNRunner.java index ce475c197c..0258f161df 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/YARNRunner.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/YARNRunner.java @@ -391,7 +391,8 @@ public ApplicationSubmissionContext createApplicationSubmissionContext( vargs.add(Environment.JAVA_HOME.$() + "/bin/java"); // TODO: why do we use 'conf' some places and 'jobConf' others? - long logSize = TaskLog.getTaskLogLength(new JobConf(conf)); + long logSize = jobConf.getLong(MRJobConfig.MR_AM_LOG_KB, + MRJobConfig.DEFAULT_MR_AM_LOG_KB) << 10; String logLevel = jobConf.get( MRJobConfig.MR_AM_LOG_LEVEL, MRJobConfig.DEFAULT_MR_AM_LOG_LEVEL); int numBackups = jobConf.getInt(MRJobConfig.MR_AM_LOG_BACKUPS, diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/TestMRJobs.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/TestMRJobs.java index 441fd98cb0..2d8972bfc9 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/TestMRJobs.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/TestMRJobs.java @@ -27,6 +27,7 @@ import java.io.StringReader; import java.net.URI; import java.security.PrivilegedExceptionAction; +import java.util.Arrays; import java.util.EnumSet; import java.util.HashMap; import java.util.Map; @@ -442,9 +443,12 @@ public void testContainerRollingLog() throws IOException, final SleepJob sleepJob = new SleepJob(); final JobConf sleepConf = new JobConf(mrCluster.getConfig()); sleepConf.set(MRJobConfig.MAP_LOG_LEVEL, Level.ALL.toString()); - sleepConf.set(MRJobConfig.MR_AM_LOG_LEVEL, Level.ALL.toString()); - sleepConf.setLong(MRJobConfig.TASK_USERLOG_LIMIT, 1); + final long userLogKb = 4; + sleepConf.setLong(MRJobConfig.TASK_USERLOG_LIMIT, userLogKb); sleepConf.setInt(MRJobConfig.TASK_LOG_BACKUPS, 3); + sleepConf.set(MRJobConfig.MR_AM_LOG_LEVEL, Level.ALL.toString()); + final long amLogKb = 7; + sleepConf.setLong(MRJobConfig.MR_AM_LOG_KB, amLogKb); sleepConf.setInt(MRJobConfig.MR_AM_LOG_BACKUPS, 7); sleepJob.setConf(sleepConf); @@ -503,6 +507,8 @@ public void testContainerRollingLog() throws IOException, final FileStatus[] sysSiblings = localFs.globStatus(new Path( containerPathComponent, TaskLog.LogName.SYSLOG + "*")); + // sort to ensure for i > 0 sysSiblings[i] == "syslog.i" + Arrays.sort(sysSiblings); if (foundAppMaster) { numAppMasters++; @@ -510,11 +516,19 @@ public void testContainerRollingLog() throws IOException, numMapTasks++; } - Assert.assertSame("Number of sylog* files", - foundAppMaster - ? sleepConf.getInt(MRJobConfig.MR_AM_LOG_BACKUPS, 0) + 1 - : sleepConf.getInt(MRJobConfig.TASK_LOG_BACKUPS, 0) + 1, - sysSiblings.length); + if (foundAppMaster) { + Assert.assertSame("Unexpected number of AM sylog* files", + sleepConf.getInt(MRJobConfig.MR_AM_LOG_BACKUPS, 0) + 1, + sysSiblings.length); + Assert.assertTrue("AM syslog.1 length kb should be >= " + amLogKb, + sysSiblings[1].getLen() >= amLogKb * 1024); + } else { + Assert.assertSame("Unexpected number of MR task sylog* files", + sleepConf.getInt(MRJobConfig.TASK_LOG_BACKUPS, 0) + 1, + sysSiblings.length); + Assert.assertTrue("MR syslog.1 length kb should be >= " + userLogKb, + sysSiblings[1].getLen() >= userLogKb * 1024); + } } } }