diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java index 270a662a9f4..522f701bd96 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CacheAdmin.java @@ -45,6 +45,7 @@ import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.util.Tool; import com.google.common.base.Joiner; +import org.apache.hadoop.util.ToolRunner; /** * This class implements command-line operations on the HDFS Cache. @@ -64,6 +65,7 @@ public class CacheAdmin extends Configured implements Tool { public int run(String[] args) throws IOException { if (args.length == 0) { AdminHelper.printUsage(false, "cacheadmin", COMMANDS); + ToolRunner.printGenericCommandUsage(System.err); return 1; } AdminHelper.Command command = AdminHelper.determineCommand(args[0], @@ -74,6 +76,7 @@ public class CacheAdmin extends Configured implements Tool { System.err.println("Command names must start with dashes."); } AdminHelper.printUsage(false, "cacheadmin", COMMANDS); + ToolRunner.printGenericCommandUsage(System.err); return 1; } List argsList = new LinkedList(); @@ -88,9 +91,10 @@ public class CacheAdmin extends Configured implements Tool { } } - public static void main(String[] argsArray) throws IOException { + public static void main(String[] argsArray) throws Exception { CacheAdmin cacheAdmin = new CacheAdmin(new Configuration()); - System.exit(cacheAdmin.run(argsArray)); + int res = ToolRunner.run(cacheAdmin, argsArray); + System.exit(res); } private static CacheDirectiveInfo.Expiration parseExpirationString(String ttlString) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CryptoAdmin.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CryptoAdmin.java index b78da31e78f..225f11a2d13 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CryptoAdmin.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/CryptoAdmin.java @@ -35,6 +35,7 @@ import org.apache.hadoop.hdfs.protocol.EncryptionZone; import org.apache.hadoop.tools.TableListing; import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.util.Tool; +import org.apache.hadoop.util.ToolRunner; /** * This class implements crypto command-line operations. @@ -54,6 +55,7 @@ public class CryptoAdmin extends Configured implements Tool { public int run(String[] args) throws IOException { if (args.length == 0) { AdminHelper.printUsage(false, "crypto", COMMANDS); + ToolRunner.printGenericCommandUsage(System.err); return 1; } final AdminHelper.Command command = AdminHelper.determineCommand(args[0], @@ -64,6 +66,7 @@ public class CryptoAdmin extends Configured implements Tool { System.err.println("Command names must start with dashes."); } AdminHelper.printUsage(false, "crypto", COMMANDS); + ToolRunner.printGenericCommandUsage(System.err); return 1; } final List argsList = new LinkedList(); @@ -78,9 +81,10 @@ public class CryptoAdmin extends Configured implements Tool { } } - public static void main(String[] argsArray) throws IOException { + public static void main(String[] argsArray) throws Exception { final CryptoAdmin cryptoAdmin = new CryptoAdmin(new Configuration()); - System.exit(cryptoAdmin.run(argsArray)); + int res = ToolRunner.run(cryptoAdmin, argsArray); + System.exit(res); } /** diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/StoragePolicyAdmin.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/StoragePolicyAdmin.java index 24079b3c25d..d99b88a0b31 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/StoragePolicyAdmin.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/StoragePolicyAdmin.java @@ -27,6 +27,7 @@ import org.apache.hadoop.hdfs.protocol.HdfsFileStatus; import org.apache.hadoop.tools.TableListing; import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.util.Tool; +import org.apache.hadoop.util.ToolRunner; import java.io.IOException; import java.util.Arrays; @@ -42,7 +43,8 @@ public class StoragePolicyAdmin extends Configured implements Tool { public static void main(String[] argsArray) throws Exception { final StoragePolicyAdmin admin = new StoragePolicyAdmin(new Configuration()); - System.exit(admin.run(argsArray)); + int res = ToolRunner.run(admin, argsArray); + System.exit(res); } public StoragePolicyAdmin(Configuration conf) { @@ -53,6 +55,7 @@ public class StoragePolicyAdmin extends Configured implements Tool { public int run(String[] args) throws Exception { if (args.length == 0) { AdminHelper.printUsage(false, "storagepolicies", COMMANDS); + ToolRunner.printGenericCommandUsage(System.err); return 1; } final AdminHelper.Command command = AdminHelper.determineCommand(args[0], @@ -63,6 +66,7 @@ public class StoragePolicyAdmin extends Configured implements Tool { System.err.println("Command names must start with dashes."); } AdminHelper.printUsage(false, "storagepolicies", COMMANDS); + ToolRunner.printGenericCommandUsage(System.err); return 1; } final List argsList = new LinkedList<>();