Repository: hadoop Updated Branches: refs/heads/YARN-2915 6f9133893 -> f43ad972e (forced update)
HADOOP-13599. s3a close() to be non-synchronized, so avoid risk of deadlock on shutdown. 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/47f80922 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/47f80922 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/47f80922 Branch: refs/heads/YARN-2915 Commit: 47f80922dc7cb2fa6d084e6fb1f354c4ec1d4c69 Parents: 84c6264 Author: Chris Nauroth <cnaur...@apache.org> Authored: Wed Sep 28 15:53:17 2016 -0700 Committer: Chris Nauroth <cnaur...@apache.org> Committed: Wed Sep 28 16:19:32 2016 -0700 ---------------------------------------------------------------------- .../main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java | 8 +++++++- .../java/org/apache/hadoop/fs/s3a/ITestS3AConfiguration.java | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/47f80922/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 6a6c26b..dffef15 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 @@ -31,6 +31,7 @@ import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.Objects; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import com.amazonaws.AmazonClientException; import com.amazonaws.AmazonServiceException; @@ -121,6 +122,7 @@ public class S3AFileSystem extends FileSystem { private S3AStorageStatistics storageStatistics; private long readAhead; private S3AInputPolicy inputPolicy; + private final AtomicBoolean closed = new AtomicBoolean(false); // The maximum number of entries that can be deleted in any call to s3 private static final int MAX_ENTRIES_TO_DELETE = 1000; @@ -1414,7 +1416,11 @@ public class S3AFileSystem extends FileSystem { * @throws IOException IO problem */ @Override - public synchronized void close() throws IOException { + public void close() throws IOException { + if (closed.getAndSet(true)) { + // already closed + return; + } try { super.close(); } finally { http://git-wip-us.apache.org/repos/asf/hadoop/blob/47f80922/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AConfiguration.java ---------------------------------------------------------------------- diff --git a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AConfiguration.java b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AConfiguration.java index fca8e49..b08bfe9 100644 --- a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AConfiguration.java +++ b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AConfiguration.java @@ -409,6 +409,14 @@ public class ITestS3AConfiguration { awsConf.getUserAgent()); } + @Test + public void testCloseIdempotent() throws Throwable { + conf = new Configuration(); + fs = S3ATestUtils.createTestFileSystem(conf); + fs.close(); + fs.close(); + } + /** * Reads and returns a field from an object using reflection. If the field * cannot be found, is null, or is not the expected type, then this method --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org