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.Tool;
|
import org.apache.hadoop.util.Tool;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
|
import org.apache.hadoop.util.ToolRunner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class implements command-line operations on the HDFS Cache.
|
* This class implements command-line operations on the HDFS Cache.
|
||||||
@ -64,6 +65,7 @@ public CacheAdmin(Configuration conf) {
|
|||||||
public int run(String[] args) throws IOException {
|
public int run(String[] args) throws IOException {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
AdminHelper.printUsage(false, "cacheadmin", COMMANDS);
|
AdminHelper.printUsage(false, "cacheadmin", COMMANDS);
|
||||||
|
ToolRunner.printGenericCommandUsage(System.err);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
AdminHelper.Command command = AdminHelper.determineCommand(args[0],
|
AdminHelper.Command command = AdminHelper.determineCommand(args[0],
|
||||||
@ -74,6 +76,7 @@ public int run(String[] args) throws IOException {
|
|||||||
System.err.println("Command names must start with dashes.");
|
System.err.println("Command names must start with dashes.");
|
||||||
}
|
}
|
||||||
AdminHelper.printUsage(false, "cacheadmin", COMMANDS);
|
AdminHelper.printUsage(false, "cacheadmin", COMMANDS);
|
||||||
|
ToolRunner.printGenericCommandUsage(System.err);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
List<String> argsList = new LinkedList<String>();
|
List<String> argsList = new LinkedList<String>();
|
||||||
@ -88,9 +91,10 @@ public int run(String[] args) throws IOException {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] argsArray) throws IOException {
|
public static void main(String[] argsArray) throws Exception {
|
||||||
CacheAdmin cacheAdmin = new CacheAdmin(new Configuration());
|
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)
|
private static CacheDirectiveInfo.Expiration parseExpirationString(String ttlString)
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
import org.apache.hadoop.tools.TableListing;
|
import org.apache.hadoop.tools.TableListing;
|
||||||
import org.apache.hadoop.util.StringUtils;
|
import org.apache.hadoop.util.StringUtils;
|
||||||
import org.apache.hadoop.util.Tool;
|
import org.apache.hadoop.util.Tool;
|
||||||
|
import org.apache.hadoop.util.ToolRunner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class implements crypto command-line operations.
|
* This class implements crypto command-line operations.
|
||||||
@ -54,6 +55,7 @@ public CryptoAdmin(Configuration conf) {
|
|||||||
public int run(String[] args) throws IOException {
|
public int run(String[] args) throws IOException {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
AdminHelper.printUsage(false, "crypto", COMMANDS);
|
AdminHelper.printUsage(false, "crypto", COMMANDS);
|
||||||
|
ToolRunner.printGenericCommandUsage(System.err);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
final AdminHelper.Command command = AdminHelper.determineCommand(args[0],
|
final AdminHelper.Command command = AdminHelper.determineCommand(args[0],
|
||||||
@ -64,6 +66,7 @@ public int run(String[] args) throws IOException {
|
|||||||
System.err.println("Command names must start with dashes.");
|
System.err.println("Command names must start with dashes.");
|
||||||
}
|
}
|
||||||
AdminHelper.printUsage(false, "crypto", COMMANDS);
|
AdminHelper.printUsage(false, "crypto", COMMANDS);
|
||||||
|
ToolRunner.printGenericCommandUsage(System.err);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
final List<String> argsList = new LinkedList<String>();
|
final List<String> argsList = new LinkedList<String>();
|
||||||
@ -78,9 +81,10 @@ public int run(String[] args) throws IOException {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] argsArray) throws IOException {
|
public static void main(String[] argsArray) throws Exception {
|
||||||
final CryptoAdmin cryptoAdmin = new CryptoAdmin(new Configuration());
|
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.tools.TableListing;
|
import org.apache.hadoop.tools.TableListing;
|
||||||
import org.apache.hadoop.util.StringUtils;
|
import org.apache.hadoop.util.StringUtils;
|
||||||
import org.apache.hadoop.util.Tool;
|
import org.apache.hadoop.util.Tool;
|
||||||
|
import org.apache.hadoop.util.ToolRunner;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -42,7 +43,8 @@ public class StoragePolicyAdmin extends Configured implements Tool {
|
|||||||
public static void main(String[] argsArray) throws Exception {
|
public static void main(String[] argsArray) throws Exception {
|
||||||
final StoragePolicyAdmin admin = new StoragePolicyAdmin(new
|
final StoragePolicyAdmin admin = new StoragePolicyAdmin(new
|
||||||
Configuration());
|
Configuration());
|
||||||
System.exit(admin.run(argsArray));
|
int res = ToolRunner.run(admin, argsArray);
|
||||||
|
System.exit(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StoragePolicyAdmin(Configuration conf) {
|
public StoragePolicyAdmin(Configuration conf) {
|
||||||
@ -53,6 +55,7 @@ public StoragePolicyAdmin(Configuration conf) {
|
|||||||
public int run(String[] args) throws Exception {
|
public int run(String[] args) throws Exception {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
AdminHelper.printUsage(false, "storagepolicies", COMMANDS);
|
AdminHelper.printUsage(false, "storagepolicies", COMMANDS);
|
||||||
|
ToolRunner.printGenericCommandUsage(System.err);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
final AdminHelper.Command command = AdminHelper.determineCommand(args[0],
|
final AdminHelper.Command command = AdminHelper.determineCommand(args[0],
|
||||||
@ -63,6 +66,7 @@ public int run(String[] args) throws Exception {
|
|||||||
System.err.println("Command names must start with dashes.");
|
System.err.println("Command names must start with dashes.");
|
||||||
}
|
}
|
||||||
AdminHelper.printUsage(false, "storagepolicies", COMMANDS);
|
AdminHelper.printUsage(false, "storagepolicies", COMMANDS);
|
||||||
|
ToolRunner.printGenericCommandUsage(System.err);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
final List<String> argsList = new LinkedList<>();
|
final List<String> argsList = new LinkedList<>();
|
||||||
|
Loading…
Reference in New Issue
Block a user