From 77910d4fe3f7415fe8a604c4ac6522f7f7d3529f Mon Sep 17 00:00:00 2001 From: Jason Darrell Lowe Date: Fri, 28 Feb 2014 19:22:01 +0000 Subject: [PATCH] MAPREDUCE-5768. TestMRJobs.testContainerRollingLog fails on trunk. Contributed by Gera Shegalov git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1573035 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-mapreduce-project/CHANGES.txt | 3 ++ .../hadoop/mapreduce/v2/TestMRJobs.java | 32 +++++++------------ 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index e843f1d483..25444e482a 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -202,6 +202,9 @@ Release 2.4.0 - UNRELEASED to the YARN's web-app proxy with the correct scheme prefix. (Jian He via vinodkv) + MAPREDUCE-5768. TestMRJobs.testContainerRollingLog fails on trunk (Gera + Shegalov via jlowe) + Release 2.3.1 - UNRELEASED INCOMPATIBLE CHANGES 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 5601c7f84c..441fd98cb0 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 @@ -23,7 +23,6 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; -import java.io.InputStreamReader; import java.io.IOException; import java.io.StringReader; import java.net.URI; @@ -82,8 +81,10 @@ import org.apache.hadoop.util.JarFinder; import org.apache.hadoop.util.Shell; import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState; +import org.apache.hadoop.yarn.util.ConverterUtils; import org.apache.log4j.Level; import org.junit.AfterClass; import org.junit.Assert; @@ -492,28 +493,17 @@ public void testContainerRollingLog() throws IOException, LOG.info("Checking for glob: " + absSyslogGlob); final FileStatus[] syslogs = localFs.globStatus(absSyslogGlob); for (FileStatus slog : syslogs) { - // check all syslogs for the container - // - final FileStatus[] sysSiblings = localFs.globStatus(new Path( - slog.getPath().getParent(), TaskLog.LogName.SYSLOG + "*")); - boolean foundAppMaster = false; - floop: - for (FileStatus f : sysSiblings) { - final BufferedReader reader = new BufferedReader( - new InputStreamReader(localFs.open(f.getPath()))); - String line; - try { - while ((line = reader.readLine()) != null) { - if (line.contains(MRJobConfig.APPLICATION_MASTER_CLASS)) { - foundAppMaster = true; - break floop; - } - } - } finally { - reader.close(); - } + boolean foundAppMaster = job.isUber(); + final Path containerPathComponent = slog.getPath().getParent(); + if (!foundAppMaster) { + final ContainerId cid = ConverterUtils.toContainerId( + containerPathComponent.getName()); + foundAppMaster = (cid.getId() == 1); } + final FileStatus[] sysSiblings = localFs.globStatus(new Path( + containerPathComponent, TaskLog.LogName.SYSLOG + "*")); + if (foundAppMaster) { numAppMasters++; } else {