HADOOP-14927. ITestS3GuardTool failures in testDestroyNoBucket(). Contributed by Gabor Bota.
This commit is contained in:
parent
184cced513
commit
7eb0d3a324
@ -218,6 +218,27 @@ protected void addAgeOptions() {
|
||||
format.addOptionWithValue(SECONDS_FLAG);
|
||||
}
|
||||
|
||||
protected void checkMetadataStoreUri(List<String> paths) throws IOException {
|
||||
// be sure that path is provided in params, so there's no IOoBE
|
||||
String s3Path = "";
|
||||
if(!paths.isEmpty()) {
|
||||
s3Path = paths.get(0);
|
||||
}
|
||||
|
||||
// Check if DynamoDB url is set from arguments.
|
||||
String metadataStoreUri = getCommandFormat().getOptValue(META_FLAG);
|
||||
if(metadataStoreUri == null || metadataStoreUri.isEmpty()) {
|
||||
// If not set, check if filesystem is guarded by creating an
|
||||
// S3AFileSystem and check if hasMetadataStore is true
|
||||
try (S3AFileSystem s3AFileSystem = (S3AFileSystem)
|
||||
S3AFileSystem.newInstance(toUri(s3Path), getConf())){
|
||||
Preconditions.checkState(s3AFileSystem.hasMetadataStore(),
|
||||
"The S3 bucket is unguarded. " + getName()
|
||||
+ " can not be used on an unguarded bucket.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse metadata store from command line option or HDFS configuration.
|
||||
*
|
||||
@ -500,20 +521,7 @@ public String getUsage() {
|
||||
public int run(String[] args, PrintStream out) throws Exception {
|
||||
List<String> paths = parseArgs(args);
|
||||
Map<String, String> options = new HashMap<>();
|
||||
String s3Path = paths.get(0);
|
||||
|
||||
// Check if DynamoDB url is set from arguments.
|
||||
String metadataStoreUri = getCommandFormat().getOptValue(META_FLAG);
|
||||
if(metadataStoreUri == null || metadataStoreUri.isEmpty()) {
|
||||
// If not set, check if filesystem is guarded by creating an
|
||||
// S3AFileSystem and check if hasMetadataStore is true
|
||||
try (S3AFileSystem s3AFileSystem = (S3AFileSystem)
|
||||
S3AFileSystem.newInstance(toUri(s3Path), getConf())){
|
||||
Preconditions.checkState(s3AFileSystem.hasMetadataStore(),
|
||||
"The S3 bucket is unguarded. " + getName()
|
||||
+ " can not be used on an unguarded bucket.");
|
||||
}
|
||||
}
|
||||
checkMetadataStoreUri(paths);
|
||||
|
||||
String readCap = getCommandFormat().getOptValue(READ_FLAG);
|
||||
if (StringUtils.isNotEmpty(readCap)) {
|
||||
@ -590,6 +598,8 @@ public int run(String[] args, PrintStream out) throws Exception {
|
||||
throw e;
|
||||
}
|
||||
|
||||
checkMetadataStoreUri(paths);
|
||||
|
||||
try {
|
||||
initMetadataStore(false);
|
||||
} catch (FileNotFoundException e) {
|
||||
|
Loading…
Reference in New Issue
Block a user