HDFS-11226. cacheadmin, cryptoadmin and storagepolicyadmin should support generic options. Contributed by Brahma Reddy Battula
This commit is contained in:
parent
2d4731c067
commit
754f15bae6
|
@ -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<String> argsList = new LinkedList<String>();
|
||||
|
@ -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)
|
||||
|
|
|
@ -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<String> argsList = new LinkedList<String>();
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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<String> argsList = new LinkedList<>();
|
||||
|
|
Loading…
Reference in New Issue