From 5a06792648d7f03aeeaf78a3bec296f040e45cba Mon Sep 17 00:00:00 2001 From: Pranav Saxena Date: Tue, 26 Mar 2024 22:34:45 -0700 Subject: [PATCH] removed ITestAbfsInputStream inheritence from ITestAbfsInputStreamSmallFileReads; fixed futureAwait API use; javadocs --- .../ITestAbfsInputStreamReadFooter.java | 28 ++++++++++++++----- .../ITestAbfsInputStreamSmallFileReads.java | 4 ++- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/services/ITestAbfsInputStreamReadFooter.java b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/services/ITestAbfsInputStreamReadFooter.java index 7b5fe2af8407b..924f28862027c 100644 --- a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/services/ITestAbfsInputStreamReadFooter.java +++ b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/services/ITestAbfsInputStreamReadFooter.java @@ -25,7 +25,6 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FutureDataInputStreamBuilder; @@ -91,8 +90,6 @@ public class ITestAbfsInputStreamReadFooter extends AbstractAbfsScaleTest { ONE_MB }; - private static final long FUTURE_AWAIT_TIMEOUT_SEC = 60L; - private final AbfsInputStreamTestUtils abfsInputStreamTestUtils; public ITestAbfsInputStreamReadFooter() throws Exception { @@ -121,6 +118,18 @@ public void testMultipleServerCallsAreMadeWhenTheConfIsFalse() validateNumBackendCalls(false); } + + /** + * For different combination of file sizes, read buffer sizes and footer read + * buffer size, assert the number of server calls made when the optimization + * is enabled and disabled. + *

+ * If the footer optimization is on, if the first read on the file is within the + * footer range (given by {@link AbfsInputStream#FOOTER_SIZE}, then the last block + * of size footerReadBufferSize is read from the server, and then subsequent + * inputStream reads from that block is returned from the buffer maintained by the + * AbfsInputStream. So, those reads will not result in server calls. + */ private void validateNumBackendCalls(boolean optimizeFooterRead) throws Exception { int fileIdx = 0; @@ -141,7 +150,7 @@ private void validateNumBackendCalls(boolean optimizeFooterRead) }); futureList.add(future); } - FutureIO.awaitFuture(futureList, FUTURE_AWAIT_TIMEOUT_SEC, TimeUnit.SECONDS); + FutureIO.awaitFuture(futureList); } private void validateNumBackendCalls(final AzureBlobFileSystem spiedFs, @@ -236,6 +245,11 @@ public void testSeekToEndAndReadWithConfFalse() throws Exception { validateSeekAndReadWithConf(false, SeekTo.END); } + /** + * For different combination of file sizes, read buffer sizes and footer read + * buffer size, and read from different seek positions, validate the internal + * state of AbfsInputStream. + */ private void validateSeekAndReadWithConf(boolean optimizeFooterRead, SeekTo seekTo) throws Exception { int fileIdx = 0; @@ -259,7 +273,7 @@ private void validateSeekAndReadWithConf(boolean optimizeFooterRead, } })); } - FutureIO.awaitFuture(futureList, FUTURE_AWAIT_TIMEOUT_SEC, TimeUnit.SECONDS); + FutureIO.awaitFuture(futureList); } private void validateSeekAndReadWithConf(final AzureBlobFileSystem spiedFs, @@ -387,7 +401,7 @@ public void testPartialReadWithNoData() throws Exception { throw new RuntimeException(ex); } })); - FutureIO.awaitFuture(futureList, FUTURE_AWAIT_TIMEOUT_SEC, TimeUnit.SECONDS); + FutureIO.awaitFuture(futureList); } } @@ -460,7 +474,7 @@ public void testPartialReadWithSomeData() throws Exception { } })); } - FutureIO.awaitFuture(futureList, FUTURE_AWAIT_TIMEOUT_SEC, TimeUnit.SECONDS); + FutureIO.awaitFuture(futureList); } private void validatePartialReadWithSomeData(final AzureBlobFileSystem spiedFs, diff --git a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/services/ITestAbfsInputStreamSmallFileReads.java b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/services/ITestAbfsInputStreamSmallFileReads.java index 3967829ee77e5..d0d5d187e4a6e 100644 --- a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/services/ITestAbfsInputStreamSmallFileReads.java +++ b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/services/ITestAbfsInputStreamSmallFileReads.java @@ -27,6 +27,7 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.fs.azurebfs.AbstractAbfsIntegrationTest; import org.apache.hadoop.fs.azurebfs.AzureBlobFileSystem; import org.apache.hadoop.fs.azurebfs.utils.TracingContext; @@ -40,7 +41,8 @@ import static org.apache.hadoop.fs.azurebfs.constants.FileSystemConfigurations.ONE_KB; import static org.apache.hadoop.fs.azurebfs.constants.FileSystemConfigurations.ONE_MB; -public class ITestAbfsInputStreamSmallFileReads extends ITestAbfsInputStream { +public class ITestAbfsInputStreamSmallFileReads extends + AbstractAbfsIntegrationTest { private final AbfsInputStreamTestUtils abfsInputStreamTestUtils; public ITestAbfsInputStreamSmallFileReads() throws Exception {