hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lium...@apache.org
Subject hadoop git commit: HADOOP-14110. In S3AFileSystem, make getAmazonClient() package private; export getBucketLocation(). Contributed by Steve Loughran
Date Fri, 24 Feb 2017 19:19:59 GMT
Repository: hadoop
Updated Branches:
  refs/heads/HADOOP-13345 4f7f2baf6 -> dd2a9cfc3


HADOOP-14110. In S3AFileSystem, make getAmazonClient() package private; export getBucketLocation().
Contributed by Steve Loughran


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/dd2a9cfc
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/dd2a9cfc
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/dd2a9cfc

Branch: refs/heads/HADOOP-13345
Commit: dd2a9cfc3e8245be47c3f1f751caa77d623656a0
Parents: 4f7f2ba
Author: Mingliang Liu <liuml07@apache.org>
Authored: Fri Feb 24 11:15:59 2017 -0800
Committer: Mingliang Liu <liuml07@apache.org>
Committed: Fri Feb 24 11:15:59 2017 -0800

----------------------------------------------------------------------
 .../org/apache/hadoop/fs/s3a/S3AFileSystem.java | 26 +++++++++++++++++++-
 .../fs/s3a/s3guard/DynamoDBMetadataStore.java   | 17 ++-----------
 .../s3a/s3guard/TestDynamoDBMetadataStore.java  |  2 +-
 3 files changed, 28 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/dd2a9cfc/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java
b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java
index c3f7a87..68e0795 100644
--- a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java
+++ b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java
@@ -390,11 +390,35 @@ public class S3AFileSystem extends FileSystem {
    * Returns the S3 client used by this filesystem.
    * @return AmazonS3Client
    */
-  public AmazonS3 getAmazonS3Client() {
+  AmazonS3 getAmazonS3Client() {
     return s3;
   }
 
   /**
+   * Get the region of a bucket.
+   * @return the region in which a bucket is located
+   * @throws IOException on any failure.
+   */
+  public String getBucketLocation() throws IOException {
+    return getBucketLocation(bucket);
+  }
+
+  /**
+   * Get the region of a bucket.
+   * @param bucketName the name of the bucket
+   * @return the region in which a bucket is located
+   * @throws IOException on any failure.
+   */
+  public String getBucketLocation(String bucketName) throws IOException {
+    try {
+      return s3.getBucketLocation(bucketName);
+    } catch (AmazonClientException e) {
+      throw translateException("getBucketLocation()",
+          bucketName, e);
+    }
+  }
+
+  /**
    * Returns the read ahead range value used by this filesystem
    * @return
    */

http://git-wip-us.apache.org/repos/asf/hadoop/blob/dd2a9cfc/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/DynamoDBMetadataStore.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/DynamoDBMetadataStore.java
b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/DynamoDBMetadataStore.java
index c7d7ac3..19018e3 100644
--- a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/DynamoDBMetadataStore.java
+++ b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/DynamoDBMetadataStore.java
@@ -199,14 +199,7 @@ public class DynamoDBMetadataStore implements MetadataStore {
   @VisibleForTesting
   static DynamoDB createDynamoDB(S3AFileSystem fs) throws IOException {
     Preconditions.checkNotNull(fs);
-    String region;
-    try {
-      region = fs.getAmazonS3Client().getBucketLocation(fs.getBucket());
-    } catch (AmazonClientException e) {
-      throw translateException("Determining bucket location",
-          fs.getUri().toString(), e);
-    }
-    return createDynamoDB(fs, region);
+    return createDynamoDB(fs, fs.getBucketLocation());
   }
 
   /**
@@ -236,13 +229,7 @@ public class DynamoDBMetadataStore implements MetadataStore {
         "DynamoDBMetadataStore only supports S3A filesystem.");
     final S3AFileSystem s3afs = (S3AFileSystem) fs;
     final String bucket = s3afs.getBucket();
-    try {
-      region = s3afs.getAmazonS3Client().getBucketLocation(bucket);
-    } catch (AmazonClientException e) {
-      throw translateException("Determining bucket location",
-          fs.getUri().toString(), e);
-    }
-
+    region = s3afs.getBucketLocation();
     username = s3afs.getUsername();
     conf = s3afs.getConf();
     Class<? extends DynamoDBClientFactory> cls = conf.getClass(

http://git-wip-us.apache.org/repos/asf/hadoop/blob/dd2a9cfc/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/s3guard/TestDynamoDBMetadataStore.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/s3guard/TestDynamoDBMetadataStore.java
b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/s3guard/TestDynamoDBMetadataStore.java
index f642abd..b76dedf 100644
--- a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/s3guard/TestDynamoDBMetadataStore.java
+++ b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/s3guard/TestDynamoDBMetadataStore.java
@@ -216,7 +216,7 @@ public class TestDynamoDBMetadataStore extends MetadataStoreTestBase {
       assertNotNull(ddbms.getTable());
       assertEquals(tableName, ddbms.getTable().getTableName());
       assertEquals("DynamoDB table should be in the same region as S3 bucket",
-          s3afs.getAmazonS3Client().getBucketLocation(tableName),
+          s3afs.getBucketLocation(tableName),
           ddbms.getRegion());
     }
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message