diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java index 4a2dac0..2cf0921 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java @@ -78,8 +78,11 @@ private static final String APP_OWNER_OPTION = "appOwner"; private static final String AM_CONTAINER_OPTION = "am"; private static final String CONTAINER_LOG_FILES = "logFiles"; - private static final String SHOW_META_INFO = "show_meta_info"; private static final String LIST_NODES_OPTION = "list_nodes"; + private static final String SHOW_APPLICATION_LOG_INFO + = "show_application_log_info"; + private static final String SHOW_CONTAINER_LOG_INFO + = "show_container_log_info"; private static final String OUT_OPTION = "out"; private static final String SIZE_OPTION = "size"; public static final String HELP_CMD = "help"; @@ -102,8 +105,9 @@ public int run(String[] args) throws Exception { String nodeAddress = null; String appOwner = null; boolean getAMContainerLogs = false; - boolean showMetaInfo = false; boolean nodesList = false; + boolean showApplicationLogInfo = false; + boolean showContainerLogInfo = false; String[] logFiles = null; List amContainersList = new ArrayList(); String localDir = null; @@ -115,9 +119,11 @@ public int run(String[] args) throws Exception { nodeAddress = commandLine.getOptionValue(NODE_ADDRESS_OPTION); appOwner = commandLine.getOptionValue(APP_OWNER_OPTION); getAMContainerLogs = commandLine.hasOption(AM_CONTAINER_OPTION); - showMetaInfo = commandLine.hasOption(SHOW_META_INFO); nodesList = commandLine.hasOption(LIST_NODES_OPTION); localDir = commandLine.getOptionValue(OUT_OPTION); + showApplicationLogInfo = commandLine.hasOption( + SHOW_APPLICATION_LOG_INFO); + showContainerLogInfo = commandLine.hasOption(SHOW_CONTAINER_LOG_INFO); if (getAMContainerLogs) { try { amContainersList = parseAMContainer(commandLine, printOpts); @@ -215,14 +221,17 @@ public int run(String[] args) throws Exception { isApplicationFinished(appState), appOwner, nodeAddress, null, containerIdStr, localDir, logs, bytes); - if (showMetaInfo) { - return showMetaInfo(request, logCliHelper); + if (showContainerLogInfo) { + return showContainerLogInfo(request, logCliHelper); } if (nodesList) { return showNodeLists(request, logCliHelper); } + if (showApplicationLogInfo) { + return showApplicationLogInfo(request, logCliHelper); + } // To get am logs if (getAMContainerLogs) { return fetchAMContainerLogs(request, amContainersList, @@ -338,7 +347,8 @@ private boolean fetchAllLogFiles(String[] logFiles) { } private List getContainerLogFiles(Configuration conf, - String containerIdStr, String nodeHttpAddress) throws IOException { + String containerIdStr, String nodeHttpAddress, boolean printOut) + throws IOException { List logFiles = new ArrayList<>(); Client webServiceClient = Client.create(); try { @@ -356,7 +366,13 @@ private boolean fetchAllLogFiles(String[] logFiles) { response.getEntity(JSONObject.class); JSONArray array = json.getJSONArray("containerLogInfo"); for (int i = 0; i < array.length(); i++) { - logFiles.add(array.getJSONObject(i).getString("fileName")); + String fileName = array.getJSONObject(i).getString("fileName"); + String fileSize = array.getJSONObject(i).getString("fileSize"); + logFiles.add(fileName); + if (printOut) { + System.out.printf(LogCLIHelpers.CONTAINER_LOG_META_PATTERN, + fileName, fileSize); + } } } catch (Exception e) { System.err.println("Unable to parse json from webservice. Error:"); @@ -387,7 +403,8 @@ public int printContainerLogsFromRunningApplication(Configuration conf, // fetch all the log files for the container // filter the log files based on the given --logFiles pattern List allLogs= - getContainerLogFiles(getConf(), containerIdStr, nodeHttpAddress); + getContainerLogFiles(getConf(), containerIdStr, nodeHttpAddress, + false); List matchedFiles = getMatchedLogFiles(request, allLogs); if (matchedFiles.isEmpty()) { System.err.println("Can not find any log file matching the pattern: " @@ -604,15 +621,12 @@ private void outputAMContainerLogs(ContainerLogsRequest request, } } - private int showMetaInfo(ContainerLogsRequest request, - LogCLIHelpers logCliHelper) throws IOException { + private int showContainerLogInfo(ContainerLogsRequest request, + LogCLIHelpers logCliHelper) throws IOException, YarnException { if (!request.isAppFinished()) { - System.err.println("The -show_meta_info command can be only used " - + "with finished applications"); - return -1; + return printContainerInfoFromRunningApplication(request); } else { - logCliHelper.printLogMetadata(request, System.out, System.err); - return 0; + return logCliHelper.printLogMetadata(request, System.out, System.err); } } @@ -628,6 +642,33 @@ private int showNodeLists(ContainerLogsRequest request, } } + private int showApplicationLogInfo(ContainerLogsRequest request, + LogCLIHelpers logCliHelper) throws IOException, YarnException { + String appState = "Application State: " + + (request.isAppFinished() ? "Completed." : "Running."); + if (!request.isAppFinished()) { + List reports = + getContainerReportsFromRunningApplication(request); + List filterReports = filterContainersInfo( + request, reports); + if (filterReports.isEmpty()) { + System.err.println("Can not find any containers for the application:" + + request.getAppId() + "."); + return -1; + } + System.out.println(appState); + for (ContainerReport report : filterReports) { + System.out.println(report.getContainerId() + + " on " + report.getAssignedNode()); + } + return 0; + } else { + System.out.println(appState); + logCliHelper.printContainersList(request, System.out, System.err); + return 0; + } + } + private Options createCommandOpts() { Options opts = new Options(); opts.addOption(HELP_CMD, false, "Displays help for all commands."); @@ -663,13 +704,16 @@ private Options createCommandOpts() { logFileOpt.setArgs(Option.UNLIMITED_VALUES); logFileOpt.setArgName("Log File Name"); opts.addOption(logFileOpt); - opts.addOption(SHOW_META_INFO, false, "Show the log metadata, " + opts.addOption(SHOW_CONTAINER_LOG_INFO, false, + "Show the container log metadata, " + "including log-file names, the size of the log files. " + "You can combine this with --containerId to get log metadata for " + "the specific container, or with --nodeAddress to get log metadata " - + "for all the containers on the specific NodeManager. " - + "Currently, this option can only be used for finished " - + "applications."); + + "for all the containers on the specific NodeManager."); + opts.addOption(SHOW_APPLICATION_LOG_INFO, false, "Show the " + + "containerIds which belong to the specific Application. " + + "You can combine this with --nodeAddress to get containerIds " + + "for all the containers on the specific NodeManager."); opts.addOption(LIST_NODES_OPTION, false, "Show the list of nodes that successfully aggregated logs. " + "This option can only be used with finished applications."); @@ -697,8 +741,9 @@ private Options createPrintOpts(Options commandOpts) { printOpts.addOption(commandOpts.getOption(APP_OWNER_OPTION)); printOpts.addOption(commandOpts.getOption(AM_CONTAINER_OPTION)); printOpts.addOption(commandOpts.getOption(CONTAINER_LOG_FILES)); - printOpts.addOption(commandOpts.getOption(SHOW_META_INFO)); printOpts.addOption(commandOpts.getOption(LIST_NODES_OPTION)); + printOpts.addOption(commandOpts.getOption(SHOW_APPLICATION_LOG_INFO)); + printOpts.addOption(commandOpts.getOption(SHOW_CONTAINER_LOG_INFO)); printOpts.addOption(commandOpts.getOption(OUT_OPTION)); printOpts.addOption(commandOpts.getOption(SIZE_OPTION)); return printOpts; @@ -944,6 +989,29 @@ private boolean isFileMatching(String fileType, ContainerLogsRequest options) throws YarnException, IOException { List newOptionsList = new ArrayList(); + List reports = + getContainerReportsFromRunningApplication(options); + for (ContainerReport container : reports) { + ContainerLogsRequest newOptions = new ContainerLogsRequest(options); + newOptions.setContainerId(container.getContainerId().toString()); + newOptions.setNodeId(container.getAssignedNode().toString()); + newOptions.setNodeHttpAddress(container.getNodeHttpAddress() + .replaceFirst(WebAppUtils.getHttpSchemePrefix(getConf()), "")); + // if we do not specify the value for CONTAINER_LOG_FILES option, + // we will only output syslog + List logFiles = newOptions.getLogTypes(); + if (logFiles == null || logFiles.isEmpty()) { + logFiles = Arrays.asList("syslog"); + newOptions.setLogTypes(logFiles); + } + newOptionsList.add(newOptions); + } + return newOptionsList; + } + + private List getContainerReportsFromRunningApplication( + ContainerLogsRequest options) throws YarnException, IOException { + List reports = new ArrayList(); YarnClient yarnClient = createYarnClient(); try { List attempts = @@ -951,25 +1019,81 @@ private boolean isFileMatching(String fileType, for (ApplicationAttemptReport attempt : attempts) { List containers = yarnClient.getContainers( attempt.getApplicationAttemptId()); - for (ContainerReport container : containers) { - ContainerLogsRequest newOptions = new ContainerLogsRequest(options); - newOptions.setContainerId(container.getContainerId().toString()); - newOptions.setNodeId(container.getAssignedNode().toString()); - newOptions.setNodeHttpAddress(container.getNodeHttpAddress() - .replaceFirst(WebAppUtils.getHttpSchemePrefix(getConf()), "")); - // if we do not specify the value for CONTAINER_LOG_FILES option, - // we will only output syslog - List logFiles = newOptions.getLogTypes(); - if (logFiles == null || logFiles.isEmpty()) { - logFiles = Arrays.asList("syslog"); - newOptions.setLogTypes(logFiles); - } - newOptionsList.add(newOptions); - } + reports.addAll(containers); } - return newOptionsList; + return reports; } finally { yarnClient.close(); } } + + // filter the containerReports based on the nodeId and ContainerId + private List filterContainersInfo( + ContainerLogsRequest options, List containers) { + List filterReports = new ArrayList( + containers); + String nodeId = options.getNodeId(); + boolean filterBasedonNodeId = (nodeId != null && !nodeId.isEmpty()); + String containerId = options.getContainerId(); + boolean filterBasedonContainerId = (containerId != null + && !containerId.isEmpty()); + + if (filterBasedonNodeId || filterBasedonContainerId) { + // filter the reports based on the containerId and.or nodeId + for(ContainerReport report : containers) { + if (filterBasedonContainerId) { + if (!report.getContainerId().toString() + .equalsIgnoreCase(containerId)) { + filterReports.remove(report); + } + } + + if (filterBasedonNodeId) { + if (!report.getAssignedNode().toString().equalsIgnoreCase(nodeId)) { + filterReports.remove(report); + } + } + } + } + return filterReports; + } + + private int printContainerInfoFromRunningApplication( + ContainerLogsRequest options) throws YarnException, IOException { + String containerIdStr = options.getContainerId(); + String nodeIdStr = options.getNodeId(); + List reports = + getContainerReportsFromRunningApplication(options); + List filteredReports = filterContainersInfo( + options, reports); + if (filteredReports.isEmpty()) { + StringBuilder sb = new StringBuilder(); + if (containerIdStr != null && !containerIdStr.isEmpty()) { + sb.append("Trying to get container with ContainerId: " + + containerIdStr + "\n"); + } + if (nodeIdStr != null && !nodeIdStr.isEmpty()) { + sb.append("Trying to get container from NodeManager: " + + nodeIdStr + "\n"); + } + sb.append("Can not find any matched containers for the application: " + + options.getAppId()); + return -1; + } + for (ContainerReport report : filteredReports) { + String nodeId = report.getAssignedNode().toString(); + String nodeHttpAddress = report.getNodeHttpAddress().replaceFirst( + WebAppUtils.getHttpSchemePrefix(getConf()), ""); + String containerId = report.getContainerId().toString(); + String containerString = + "\n\nContainer: " + containerId + " on " + nodeId; + System.out.println(containerString); + System.out.println(StringUtils.repeat("=", containerString.length())); + System.out.printf(LogCLIHelpers.CONTAINER_LOG_META_PATTERN, + "LogType", "LogLength"); + System.out.println(StringUtils.repeat("=", containerString.length())); + getContainerLogFiles(getConf(), containerId, nodeHttpAddress, true); + } + return 0; + } } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestLogsCLI.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestLogsCLI.java index 34369ef..2114a58 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestLogsCLI.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestLogsCLI.java @@ -217,14 +217,18 @@ public void testHelpMessage() throws Exception { pw.println(" container logs. The container logs will"); pw.println(" be stored based on the node the container"); pw.println(" ran on."); - pw.println(" -show_meta_info Show the log metadata, including log-file"); - pw.println(" names, the size of the log files. You can"); - pw.println(" combine this with --containerId to get"); - pw.println(" log metadata for the specific container,"); - pw.println(" or with --nodeAddress to get log metadata"); - pw.println(" for all the containers on the specific"); - pw.println(" NodeManager. Currently, this option can"); - pw.println(" only be used for finished applications."); + pw.println(" -show_application_log_info Show the containerIds which belong to the"); + pw.println(" specific Application. You can combine"); + pw.println(" this with --nodeAddress to get"); + pw.println(" containerIds for all the containers on"); + pw.println(" the specific NodeManager."); + pw.println(" -show_container_log_info Show the container log metadata,"); + pw.println(" including log-file names, the size of the"); + pw.println(" log files. You can combine this with"); + pw.println(" --containerId to get log metadata for the"); + pw.println(" specific container, or with --nodeAddress"); + pw.println(" to get log metadata for all the"); + pw.println(" containers on the specific NodeManager."); pw.println(" -size Prints the log file's first 'n' bytes or"); pw.println(" the last 'n' bytes. Use negative values"); pw.println(" as bytes to read from the end and"); @@ -698,9 +702,8 @@ public void testFetchApplictionLogsAsAnotherUser() throws Exception { "-applicationId", appTest.toString()}); assertTrue(exitCode == -1); assertTrue(sysErrStream.toString().contains( - "Guessed logs' owner is " + priorityUser + " and current user " - + UserGroupInformation.getCurrentUser().getUserName() - + " does not have permission to access")); + "Can not find the logs for the application: " + + appTest.toString())); sysErrStream.reset(); } finally { fs.delete(new Path(remoteLogRootDir), true); @@ -842,49 +845,70 @@ public void testPrintContainerLogMetadata() throws Exception { LogsCLI cli = new LogsCLIForTest(mockYarnClient); cli.setConf(configuration); - cli.run(new String[] { "-applicationId", appId.toString(), - "-show_meta_info" }); + cli.run(new String[] {"-applicationId", appId.toString(), + "-show_container_log_info" }); assertTrue(sysOutStream.toString().contains( "Container: container_0_0001_01_000001 on localhost_")); assertTrue(sysOutStream.toString().contains( "Container: container_0_0001_01_000002 on localhost_")); assertTrue(sysOutStream.toString().contains( - "LogType:syslog")); + "syslog")); assertTrue(sysOutStream.toString().contains( - "LogLength:43")); + "43")); sysOutStream.reset(); - cli.run(new String[] { "-applicationId", appId.toString(), - "-show_meta_info", "-containerId", "container_0_0001_01_000001" }); + cli.run(new String[] {"-applicationId", appId.toString(), + "-show_container_log_info", "-containerId", + "container_0_0001_01_000001" }); assertTrue(sysOutStream.toString().contains( "Container: container_0_0001_01_000001 on localhost_")); assertFalse(sysOutStream.toString().contains( "Container: container_0_0001_01_000002 on localhost_")); assertTrue(sysOutStream.toString().contains( - "LogType:syslog")); + "syslog")); assertTrue(sysOutStream.toString().contains( - "LogLength:43")); + "43")); sysOutStream.reset(); - cli.run(new String[] { "-applicationId", appId.toString(), - "-show_meta_info", "-nodeAddress", "localhost" }); + cli.run(new String[] {"-applicationId", appId.toString(), + "-show_container_log_info", "-nodeAddress", "localhost" }); assertTrue(sysOutStream.toString().contains( "Container: container_0_0001_01_000001 on localhost_")); assertTrue(sysOutStream.toString().contains( "Container: container_0_0001_01_000002 on localhost_")); assertTrue(sysOutStream.toString().contains( - "LogType:syslog")); + "syslog")); assertTrue(sysOutStream.toString().contains( - "LogLength:43")); + "43")); sysOutStream.reset(); cli.run(new String[] { "-applicationId", appId.toString(), - "-show_meta_info", "-nodeAddress", "localhost", "-containerId", - "container_1234" }); + "-show_container_log_info", "-nodeAddress", "localhost", + "-containerId", "container_1234" }); assertTrue(sysErrStream.toString().contains( "Invalid ContainerId specified")); sysErrStream.reset(); + cli.run(new String[] {"-applicationId", appId.toString(), + "-show_application_log_info" }); + assertTrue(sysOutStream.toString().contains( + "Application State: Completed.")); + assertTrue(sysOutStream.toString().contains( + "container_0_0001_01_000001 on localhost")); + assertTrue(sysOutStream.toString().contains( + "container_0_0001_01_000002 on localhost")); + sysOutStream.reset(); + + cli.run(new String[] {"-applicationId", appId.toString(), + "-show_application_log_info", "-nodeAddress", "localhost" }); + assertTrue(sysOutStream.toString().contains( + "Application State: Completed.")); + assertTrue(sysOutStream.toString().contains( + "container_0_0001_01_000001 on localhost")); + assertTrue(sysOutStream.toString().contains( + "container_0_0001_01_000002 on localhost")); + sysOutStream.reset(); + fs.delete(new Path(remoteLogRootDir), true); fs.delete(new Path(rootLogDir), true); } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/AggregatedLogFormat.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/AggregatedLogFormat.java index 7508dd5..3c4f835 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/AggregatedLogFormat.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/AggregatedLogFormat.java @@ -49,6 +49,7 @@ import org.apache.commons.io.output.WriterOutputStream; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.commons.math3.util.Pair; import org.apache.hadoop.classification.InterfaceAudience.Private; import org.apache.hadoop.classification.InterfaceAudience.Public; import org.apache.hadoop.classification.InterfaceStability.Evolving; @@ -959,25 +960,21 @@ public static int readContainerLogsForALogType( } @Private - public static String readContainerMetaDataAndSkipData( + public static Pair readContainerMetaDataAndSkipData( DataInputStream valueStream, PrintStream out) throws IOException { String fileType = valueStream.readUTF(); String fileLengthStr = valueStream.readUTF(); long fileLength = Long.parseLong(fileLengthStr); - if (out != null) { - out.print("LogType:"); - out.println(fileType); - out.print("LogLength:"); - out.println(fileLengthStr); - } + Pair logMeta = new Pair( + fileType, fileLengthStr); long totalSkipped = 0; long currSkipped = 0; while (currSkipped != -1 && totalSkipped < fileLength) { currSkipped = valueStream.skip(fileLength - totalSkipped); totalSkipped += currSkipped; } - return fileType; + return logMeta; } public void close() { diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/LogCLIHelpers.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/LogCLIHelpers.java index 4de11a5..05e3b99 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/LogCLIHelpers.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/LogCLIHelpers.java @@ -32,6 +32,7 @@ import java.util.Set; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; +import org.apache.commons.math3.util.Pair; import org.apache.hadoop.classification.InterfaceAudience.Private; import org.apache.hadoop.conf.Configurable; import org.apache.hadoop.conf.Configuration; @@ -50,6 +51,9 @@ public class LogCLIHelpers implements Configurable { + public static final String CONTAINER_LOG_META_PATTERN = + "%20s\t%20s" + System.getProperty("line.separator"); + private Configuration conf; @Private @@ -400,7 +404,7 @@ public int dumpAllContainersLogs(ContainerLogsRequest options) } @Private - public void printLogMetadata(ContainerLogsRequest options, + public int printLogMetadata(ContainerLogsRequest options, PrintStream out, PrintStream err) throws IOException { ApplicationId appId = options.getAppId(); @@ -413,7 +417,7 @@ public void printLogMetadata(ContainerLogsRequest options, RemoteIterator nodeFiles = getRemoteNodeFileDir( appId, appOwner); if (nodeFiles == null) { - return; + return -1; } boolean foundAnyLogs = false; while (nodeFiles.hasNext()) { @@ -441,9 +445,15 @@ public void printLogMetadata(ContainerLogsRequest options, out.println("Log Upload Time:" + thisNodeFile.getModificationTime()); out.println(StringUtils.repeat("=", containerString.length())); + out.printf(CONTAINER_LOG_META_PATTERN, "LogType", "LogLength"); + out.println(StringUtils.repeat("=", containerString.length())); while (true) { try { - LogReader.readContainerMetaDataAndSkipData(valueStream, out); + Pair logMeta = + LogReader.readContainerMetaDataAndSkipData( + valueStream, out); + out.printf(CONTAINER_LOG_META_PATTERN, + logMeta.getFirst(), logMeta.getSecond()); } catch (EOFException eof) { break; } @@ -473,7 +483,9 @@ public void printLogMetadata(ContainerLogsRequest options, err.println("Can not find log metadata for container: " + containerIdStr); } + return -1; } + return 0; } @Private @@ -501,6 +513,59 @@ public void printNodesList(ContainerLogsRequest options, } } + @Private + public void printContainersList(ContainerLogsRequest options, + PrintStream out, PrintStream err) throws IOException { + ApplicationId appId = options.getAppId(); + String appOwner = options.getAppOwner(); + String nodeId = options.getNodeId(); + String nodeIdStr = (nodeId == null) ? null + : LogAggregationUtils.getNodeString(nodeId); + RemoteIterator nodeFiles = getRemoteNodeFileDir( + appId, appOwner); + if (nodeFiles == null) { + return; + } + boolean foundAnyLogs = false; + while (nodeFiles.hasNext()) { + FileStatus thisNodeFile = nodeFiles.next(); + if (nodeIdStr != null) { + if (!thisNodeFile.getPath().getName().contains(nodeIdStr)) { + continue; + } + } + if (!thisNodeFile.getPath().getName() + .endsWith(LogAggregationUtils.TMP_FILE_SUFFIX)) { + AggregatedLogFormat.LogReader reader = + new AggregatedLogFormat.LogReader(getConf(), + thisNodeFile.getPath()); + try { + DataInputStream valueStream; + LogKey key = new LogKey(); + valueStream = reader.next(key); + while (valueStream != null) { + out.println(key + " on " + thisNodeFile.getPath().getName()); + foundAnyLogs = true; + // Next container + key = new LogKey(); + valueStream = reader.next(key); + } + } finally { + reader.close(); + } + } + } + if (!foundAnyLogs) { + if (nodeId != null) { + err.println("Can not find information for any containers on " + + nodeId); + } else { + err.println("Can not find any container information for " + + "the application: " + appId); + } + } + } + private RemoteIterator getRemoteNodeFileDir(ApplicationId appId, String appOwner) throws IOException { Path remoteAppLogDir = getRemoteAppLogDir(appId, appOwner); @@ -621,7 +686,7 @@ public void closePrintStream(PrintStream out) { while (true) { try { String logFile = LogReader.readContainerMetaDataAndSkipData( - valueStream, null); + valueStream, null).getFirst(); logTypes.add(logFile); } catch (EOFException eof) { break;