HDFS-10196. Ozone : Enable better error reporting for failed commands in ozone shell. Contributed by Anu Engineer.
This commit is contained in:
parent
fd2fe47b32
commit
f69ce5f3c6
|
@ -73,6 +73,25 @@ public class Shell extends Configured implements Tool {
|
||||||
public static final String ADD_ACLS = "addAcl";
|
public static final String ADD_ACLS = "addAcl";
|
||||||
public static final String REMOVE_ACLS = "removeAcl";
|
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.
|
* Execute the command with the given arguments.
|
||||||
|
@ -90,12 +109,6 @@ public class Shell extends Configured implements Tool {
|
||||||
return dispatch(cmd, opts);
|
return dispatch(cmd, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an ozShell.
|
|
||||||
*/
|
|
||||||
public Shell() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the Command Line Options.
|
* returns the Command Line 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.
|
* Dispatches calls to the right command Handler classes.
|
||||||
*
|
*
|
||||||
|
@ -285,14 +276,16 @@ public class Shell extends Configured implements Tool {
|
||||||
} else {
|
} else {
|
||||||
HelpFormatter helpFormatter = new HelpFormatter();
|
HelpFormatter helpFormatter = new HelpFormatter();
|
||||||
helpFormatter.printHelp(eightyColumn, "hdfs oz -command uri [args]",
|
helpFormatter.printHelp(eightyColumn, "hdfs oz -command uri [args]",
|
||||||
"Ozone Commands",
|
"Ozone Commands",
|
||||||
opts, "Please correct your command and try again.");
|
opts, "Please correct your command and try again.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} catch (IOException | OzoneException | URISyntaxException ex) {
|
} catch (IOException | URISyntaxException ex) {
|
||||||
System.err.printf("Command Failed : %s%n", ex.getMessage());
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue