HADOOP-14927. ITestS3GuardTool failures in testDestroyNoBucket(). Contributed by Gabor Bota.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/7eb0d3a3 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/7eb0d3a3 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/7eb0d3a3 Branch: refs/heads/HDDS-4 Commit: 7eb0d3a32435da110dc9e6004dba8c5c9b082c35 Parents: 184cced Author: Sean Mackrory <mackror...@apache.org> Authored: Wed Nov 28 16:57:12 2018 -0700 Committer: Sean Mackrory <mackror...@apache.org> Committed: Thu Nov 29 09:36:39 2018 -0700 ---------------------------------------------------------------------- .../hadoop/fs/s3a/s3guard/S3GuardTool.java | 38 ++++++++++++-------- 1 file changed, 24 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/7eb0d3a3/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/S3GuardTool.java ---------------------------------------------------------------------- diff --git a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/S3GuardTool.java b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/S3GuardTool.java index 1316121..aea57a6 100644 --- a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/S3GuardTool.java +++ b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/S3GuardTool.java @@ -218,6 +218,27 @@ public abstract class S3GuardTool extends Configured implements Tool { 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 abstract class S3GuardTool extends Configured implements Tool { 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 abstract class S3GuardTool extends Configured implements Tool { throw e; } + checkMetadataStoreUri(paths); + try { initMetadataStore(false); } catch (FileNotFoundException e) { --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org