浏览代码

YARN-5223. Container line in yarn logs output for a live application should include the hostname for the container. Contributed by Xuan Gong.

Varun Vasudev 9 年之前
父节点
当前提交
25064fb2fb

+ 2 - 1
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java

@@ -393,7 +393,8 @@ public class LogsCLI extends Configured implements Tool {
       newOptions.setLogTypes(matchedFiles);
       newOptions.setLogTypes(matchedFiles);
 
 
       Client webServiceClient = Client.create();
       Client webServiceClient = Client.create();
-      String containerString = "\n\nContainer: " + containerIdStr;
+      String containerString = "\n\nContainer: " + containerIdStr + " on "
+          + nodeId;
       out.println(containerString);
       out.println(containerString);
       out.println(StringUtils.repeat("=", containerString.length()));
       out.println(StringUtils.repeat("=", containerString.length()));
 
 

+ 2 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestLogsCLI.java

@@ -463,6 +463,8 @@ public class TestLogsCLI {
         "Hello container_0_0001_01_000003 in syslog!"));
         "Hello container_0_0001_01_000003 in syslog!"));
     assertTrue(sysOutStream.toString().contains(
     assertTrue(sysOutStream.toString().contains(
         "Hello container_0_0001_01_000003 in stdout!"));
         "Hello container_0_0001_01_000003 in stdout!"));
+    assertTrue(sysOutStream.toString().contains(
+        containerId3 + " on " + LogAggregationUtils.getNodeString(nodeId)));
     sysOutStream.reset();
     sysOutStream.reset();
 
 
     fs.delete(new Path(remoteLogRootDir), true);
     fs.delete(new Path(remoteLogRootDir), true);

+ 3 - 2
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/LogCLIHelpers.java

@@ -153,7 +153,8 @@ public class LogCLIHelpers implements Configurable {
         AggregatedLogFormat.LogReader reader = null;
         AggregatedLogFormat.LogReader reader = null;
         PrintStream out = createPrintStream(localDir, fileName, containerId);
         PrintStream out = createPrintStream(localDir, fileName, containerId);
         try {
         try {
-          String containerString = "\n\nContainer: " + containerId;
+          String containerString = "\n\nContainer: " + containerId + " on "
+              + thisNodeFile.getPath().getName();
           out.println(containerString);
           out.println(containerString);
           out.println(StringUtils.repeat("=", containerString.length()));
           out.println(StringUtils.repeat("=", containerString.length()));
           reader =
           reader =
@@ -220,7 +221,7 @@ public class LogCLIHelpers implements Configurable {
               thisNodeFile.getPath());
               thisNodeFile.getPath());
           out = createPrintStream(localDir, thisNodeFile.getPath().getName(),
           out = createPrintStream(localDir, thisNodeFile.getPath().getName(),
               containerId);
               containerId);
-          out.println(containerId);
+          out.println(containerId + " on " + thisNodeFile.getPath().getName());
           out.println(StringUtils.repeat("=", containerId.length()));
           out.println(StringUtils.repeat("=", containerId.length()));
           if (logType == null || logType.isEmpty()) {
           if (logType == null || logType.isEmpty()) {
             if (dumpAContainerLogs(containerId, reader, out,
             if (dumpAContainerLogs(containerId, reader, out,