-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HADOOP-18189 S3APrefetchingInputStream to support status probes when closed #5036
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,8 @@ | |
| import org.apache.hadoop.fs.Path; | ||
| import org.apache.hadoop.fs.contract.ContractTestUtils; | ||
| import org.apache.hadoop.fs.s3a.performance.AbstractS3ACostTest; | ||
| import org.apache.hadoop.fs.s3a.prefetch.S3APrefetchingInputStream; | ||
| import org.apache.hadoop.fs.s3a.statistics.S3AInputStreamStatistics; | ||
| import org.apache.hadoop.fs.statistics.IOStatistics; | ||
|
|
||
| import static org.apache.hadoop.fs.s3a.Constants.PREFETCH_BLOCK_DEFAULT_SIZE; | ||
|
|
@@ -240,4 +242,56 @@ public void testRandomReadSmallFile() throws Throwable { | |
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testStatusProbesAfterClosingStream() throws Throwable { | ||
| describe("When the underlying input stream is closed, the prefetch input stream" | ||
| + " should still support some status probes"); | ||
|
|
||
| byte[] data = ContractTestUtils.dataset(SMALL_FILE_SIZE, 'a', 26); | ||
| Path smallFile = path("testStatusProbesAfterClosingStream"); | ||
| ContractTestUtils.writeDataset(getFileSystem(), smallFile, data, data.length, 16, true); | ||
|
|
||
| FSDataInputStream in = getFileSystem().open(smallFile); | ||
|
|
||
| byte[] buffer = new byte[SMALL_FILE_SIZE]; | ||
| in.read(buffer, 0, S_1K * 4); | ||
| in.seek(S_1K * 12); | ||
| in.read(buffer, 0, S_1K * 4); | ||
|
|
||
| long pos = in.getPos(); | ||
| IOStatistics ioStats = in.getIOStatistics(); | ||
| S3AInputStreamStatistics inputStreamStatistics = | ||
| ((S3APrefetchingInputStream) (in.getWrappedStream())).getS3AStreamStatistics(); | ||
|
|
||
| assertNotNull("Prefetching input IO stats should not be null", ioStats); | ||
| assertNotNull("Prefetching input stream stats should not be null", inputStreamStatistics); | ||
| assertNotEquals("Position retrieved from prefetching input stream should be greater than 0", 0, | ||
| pos); | ||
|
|
||
| in.close(); | ||
|
|
||
| // status probes after closing the input stream | ||
| long newPos = in.getPos(); | ||
| IOStatistics newIoStats = in.getIOStatistics(); | ||
| S3AInputStreamStatistics newInputStreamStatistics = | ||
| ((S3APrefetchingInputStream) (in.getWrappedStream())).getS3AStreamStatistics(); | ||
|
|
||
| assertNotNull("Prefetching input IO stats should not be null", newIoStats); | ||
| assertNotNull("Prefetching input stream stats should not be null", newInputStreamStatistics); | ||
| assertNotEquals("Position retrieved from prefetching input stream should be greater than 0", 0, | ||
| newPos); | ||
|
|
||
| // compare status probes after closing of the stream with status probes done before | ||
| // closing the stream | ||
| assertEquals("Position retrieved through stream before and after closing should match", pos, | ||
| newPos); | ||
| assertEquals("IO stats retrieved through stream before and after closing should match", ioStats, | ||
| newIoStats); | ||
| assertEquals("Stream stats retrieved through stream before and after closing should match", | ||
| inputStreamStatistics, newInputStreamStatistics); | ||
|
|
||
| assertFalse("Not supported with prefetch", in.seekToNewSource(10)); | ||
|
||
|
|
||
| } | ||
|
|
||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can just use
path()and one is built up from the method name. this is better as it avoids cut and paste bugs and if a build is parameterized, the parameterized string is used in the path (though tests fail if that string isn't a valid path any more)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah my bad, should have used
methodPath(). You meantmethodPath()only, correct?