HDFS-10196. Ozone : Enable better error reporting for failed commands in ozone shell. Contributed by Anu Engineer.

This commit is contained in:
Chris Nauroth 2016-03-24 09:27:10 -07:00 committed by Owen O'Malley
parent fd2fe47b32
commit f69ce5f3c6

View File

@ -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.
@ -90,12 +109,6 @@ public int run(String[] args) throws Exception {
return dispatch(cmd, opts);
}
/**
* Construct an ozShell.
*/
public Shell() {
}
/**
* returns the Command Line Options.
*
@ -202,28 +215,6 @@ private void addBucketCommands(Options opts) {
}
/**
* 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 @@ private int dispatch(CommandLine cmd, Options opts)
} 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;
}
}