HADOOP-13697. LogLevel#main should not throw exception if no arguments. Contributed by Mingliang Liu
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/2fb392a5 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/2fb392a5 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/2fb392a5 Branch: refs/heads/HADOOP-13037 Commit: 2fb392a587d288b628936ca6d18fabad04afc585 Parents: 809cfd2 Author: Mingliang Liu <lium...@apache.org> Authored: Fri Oct 7 14:05:40 2016 -0700 Committer: Mingliang Liu <lium...@apache.org> Committed: Tue Oct 11 10:57:08 2016 -0700 ---------------------------------------------------------------------- .../src/main/java/org/apache/hadoop/log/LogLevel.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/2fb392a5/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java index 4fa839f..79eae12 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java @@ -47,15 +47,17 @@ import org.apache.hadoop.http.HttpServer2; import org.apache.hadoop.security.authentication.client.AuthenticatedURL; import org.apache.hadoop.security.authentication.client.KerberosAuthenticator; import org.apache.hadoop.security.ssl.SSLFactory; +import org.apache.hadoop.util.GenericOptionsParser; import org.apache.hadoop.util.ServletUtil; import org.apache.hadoop.util.Tool; +import org.apache.hadoop.util.ToolRunner; /** * Change log level in runtime. */ @InterfaceStability.Evolving public class LogLevel { - public static final String USAGES = "\nUsage: General options are:\n" + public static final String USAGES = "\nUsage: Command options are:\n" + "\t[-getlevel <host:port> <classname> [-protocol (http|https)]\n" + "\t[-setlevel <host:port> <classname> <level> " + "[-protocol (http|https)]\n"; @@ -67,7 +69,7 @@ public class LogLevel { */ public static void main(String[] args) throws Exception { CLI cli = new CLI(new Configuration()); - System.exit(cli.run(args)); + System.exit(ToolRunner.run(cli, args)); } /** @@ -81,6 +83,7 @@ public class LogLevel { private static void printUsage() { System.err.println(USAGES); + GenericOptionsParser.printGenericCommandUsage(System.err); } public static boolean isValidProtocol(String protocol) { @@ -107,7 +110,7 @@ public class LogLevel { sendLogLevelRequest(); } catch (HadoopIllegalArgumentException e) { printUsage(); - throw e; + return -1; } return 0; } --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org