You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by eb...@apache.org on 2020/06/11 21:11:49 UTC
[hadoop] branch branch-3.3 updated: YARN-10312. Add support for
yarn logs -logFile to retain backward compatibility. Contributed by Jim
Brennan.
This is an automated email from the ASF dual-hosted git repository.
ebadger pushed a commit to branch branch-3.3
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-3.3 by this push:
new fcd7ce5 YARN-10312. Add support for yarn logs -logFile to retain backward compatibility. Contributed by Jim Brennan.
fcd7ce5 is described below
commit fcd7ce53b5598d0b64e82d42fa5ca6d4ba9648b2
Author: Eric Badger <eb...@verizonmedia.com>
AuthorDate: Thu Jun 11 21:11:20 2020 +0000
YARN-10312. Add support for yarn logs -logFile to retain backward compatibility.
Contributed by Jim Brennan.
(cherry picked from commit fed6fecd3a9e24efc20f9221505da35a7e1949c7)
---
.../org/apache/hadoop/yarn/client/cli/LogsCLI.java | 13 +++++++
.../apache/hadoop/yarn/client/cli/TestLogsCLI.java | 42 ++++++++++++++++++++++
2 files changed, 55 insertions(+)
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java
index 343dfc7..1a158e0 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java
@@ -105,6 +105,7 @@ public class LogsCLI extends Configured implements Tool {
private static final String APP_OWNER_OPTION = "appOwner";
private static final String AM_CONTAINER_OPTION = "am";
private static final String PER_CONTAINER_LOG_FILES_OPTION = "log_files";
+ private static final String PER_CONTAINER_LOG_FILES_OLD_OPTION = "logFiles";
private static final String PER_CONTAINER_LOG_FILES_REGEX_OPTION
= "log_files_pattern";
private static final String LIST_NODES_OPTION = "list_nodes";
@@ -221,6 +222,12 @@ public class LogsCLI extends Configured implements Tool {
}
if (commandLine.hasOption(PER_CONTAINER_LOG_FILES_OPTION)) {
logFiles = commandLine.getOptionValues(PER_CONTAINER_LOG_FILES_OPTION);
+ } else {
+ // For backward compatibility, we need to check for the old form of this
+ // command line option as well. New form takes precedent.
+ if (commandLine.hasOption(PER_CONTAINER_LOG_FILES_OLD_OPTION)) {
+ logFiles = commandLine.getOptionValues(PER_CONTAINER_LOG_FILES_OLD_OPTION);
+ }
}
if (commandLine.hasOption(PER_CONTAINER_LOG_FILES_REGEX_OPTION)) {
logFilesRegex = commandLine.getOptionValues(
@@ -954,6 +961,12 @@ public class LogsCLI extends Configured implements Tool {
logFileOpt.setArgs(Option.UNLIMITED_VALUES);
logFileOpt.setArgName("Log File Name");
opts.addOption(logFileOpt);
+ Option oldLogFileOpt = new Option(PER_CONTAINER_LOG_FILES_OLD_OPTION, true,
+ "Deprecated name for log_files, please use log_files option instead");
+ oldLogFileOpt.setValueSeparator(',');
+ oldLogFileOpt.setArgs(Option.UNLIMITED_VALUES);
+ oldLogFileOpt.setArgName("Log File Name");
+ opts.addOption(oldLogFileOpt);
Option logFileRegexOpt = new Option(PER_CONTAINER_LOG_FILES_REGEX_OPTION,
true, "Specify comma-separated value "
+ "to get matched log files by using java regex. Use \".*\" to "
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestLogsCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestLogsCLI.java
index 7966313..9555b0a 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestLogsCLI.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestLogsCLI.java
@@ -526,6 +526,48 @@ public class TestLogsCLI {
createEmptyLog("empty")));
sysOutStream.reset();
+ // Check backward compatibility for -logFiles
+ exitCode = cli.run(new String[] {"-applicationId", appId.toString(),
+ "-logFiles", "stdout"});
+ assertTrue("Failed with -logFiles", exitCode == 0);
+ assertFalse("Failed with -logFiles", sysOutStream.toString().contains(
+ logMessage(containerId1, "syslog")));
+ assertFalse("Failed with -logFiles", sysOutStream.toString().contains(
+ logMessage(containerId2, "syslog")));
+ assertFalse("Failed with -logFiles", sysOutStream.toString().contains(
+ logMessage(containerId3, "syslog")));
+ assertTrue("Failed with -logFiles", sysOutStream.toString().contains(
+ logMessage(containerId3, "stdout")));
+ assertFalse("Failed with -logFiles", sysOutStream.toString().contains(
+ logMessage(containerId3, "stdout1234")));
+ assertFalse("Failed with -logFiles", sysOutStream.toString().contains(
+ createEmptyLog("empty")));
+ sysOutStream.reset();
+
+ // Check -log_files supercedes -logFiles
+ exitCode = cli.run(new String[] {"-applicationId", appId.toString(),
+ "-log_files", "stdout", "-logFiles", "syslog"});
+ assertTrue("Failed with -logFiles and -log_files", exitCode == 0);
+ assertFalse("Failed with -logFiles and -log_files",
+ sysOutStream.toString().contains(
+ logMessage(containerId1, "syslog")));
+ assertFalse("Failed with -logFiles and -log_files",
+ sysOutStream.toString().contains(
+ logMessage(containerId2, "syslog")));
+ assertFalse("Failed with -logFiles and -log_files",
+ sysOutStream.toString().contains(
+ logMessage(containerId3, "syslog")));
+ assertTrue("Failed with -logFiles and -log_files",
+ sysOutStream.toString().contains(
+ logMessage(containerId3, "stdout")));
+ assertFalse("Failed with -logFiles and -log_files",
+ sysOutStream.toString().contains(
+ logMessage(containerId3, "stdout1234")));
+ assertFalse("Failed with -logFiles and -log_files",
+ sysOutStream.toString().contains(
+ createEmptyLog("empty")));
+ sysOutStream.reset();
+
exitCode = cli.run(new String[] {"-applicationId", appId.toString(),
"-log_files_pattern", "std*"});
assertTrue(exitCode == 0);
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org