Repository: hadoop Updated Branches: refs/heads/HDFS-7240 3f708bf71 -> 58cdb715f
HDFS-10196. Ozone : Enable better error reporting for failed commands in ozone shell. Contributed by Anu Engineer. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/58cdb715 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/58cdb715 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/58cdb715 Branch: refs/heads/HDFS-7240 Commit: 58cdb715fb2b2b60d7cc8339e99e0fb5fd54541a Parents: 3f708bf Author: Chris Nauroth <[email protected]> Authored: Thu Mar 24 09:27:10 2016 -0700 Committer: Chris Nauroth <[email protected]> Committed: Thu Mar 24 09:27:10 2016 -0700 ---------------------------------------------------------------------- .../apache/hadoop/ozone/web/ozShell/Shell.java | 57 +++++++++----------- 1 file changed, 25 insertions(+), 32 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/58cdb715/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/ozShell/Shell.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/ozShell/Shell.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/ozShell/Shell.java index a0d3d23..6fc42a0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/ozShell/Shell.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/web/ozShell/Shell.java @@ -73,6 +73,25 @@ public class Shell extends Configured implements Tool { public static final String ADD_ACLS = "addAcl"; public static final String REMOVE_ACLS = "removeAcl"; + /** + * Main for the ozShell Command handling. + * + * @param argv - System Args Strings[] + * @throws Exception + */ + public static void main(String[] argv) throws Exception { + Shell shell = new Shell(); + Configuration conf = new Configuration(); + conf.setQuietMode(false); + shell.setConf(conf); + int res = 0; + try { + res = ToolRunner.run(shell, argv); + } catch (Exception ex) { + System.exit(1); + } + System.exit(res); + } /** * Execute the command with the given arguments. @@ -91,12 +110,6 @@ public class Shell extends Configured implements Tool { } /** - * Construct an ozShell. - */ - public Shell() { - } - - /** * returns the Command Line Options. * * @return Options @@ -202,28 +215,6 @@ public class Shell extends Configured implements Tool { } - - /** - * Main for the ozShell Command handling. - * - * @param argv - System Args Strings[] - * - * @throws Exception - */ - public static void main(String[] argv) throws Exception { - Shell shell = new Shell(); - Configuration conf = new Configuration(); - conf.setQuietMode(false); - shell.setConf(conf); - int res = 0; - try { - res = ToolRunner.run(shell, argv); - } catch (Exception ex) { - System.exit(1); - } - System.exit(res); - } - /** * Dispatches calls to the right command Handler classes. * @@ -285,14 +276,16 @@ public class Shell extends Configured implements Tool { } else { HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.printHelp(eightyColumn, "hdfs oz -command uri [args]", - "Ozone Commands", - opts, "Please correct your command and try again."); + "Ozone Commands", + opts, "Please correct your command and try again."); return 1; } - } catch (IOException | OzoneException | URISyntaxException ex) { + } catch (IOException | URISyntaxException ex) { System.err.printf("Command Failed : %s%n", ex.getMessage()); - return 1; + } catch (OzoneException ex) { + System.err.printf("Command Failed : %s%n", ex.toJsonString()); } + return 1; } }
