Skip to content

Commit f6753e6

Browse files
author
Ajay Kumar Movva
committed
Addressing comments and adding UT's
1 parent 6c2d152 commit f6753e6

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
4343
- Make node duress values cacheable ([#18649](https://github.com/opensearch-project/OpenSearch/pull/18649))
4444
- Change default value of remote_data_ratio, which is used in Searchable Snapshots and Writeable Warm from 0 to 5 and min allowed value to 1 ([#18767](https://github.com/opensearch-project/OpenSearch/pull/18767))
4545
- Making multi rate limiters in repository dynamic [#18069](https://github.com/opensearch-project/OpenSearch/pull/18069)
46-
- Adding changes to support async fetch blob for transfer manager [#18754](https://github.com/opensearch-project/OpenSearch/pull/18754)
4746

4847
### Dependencies
4948
- Bump `stefanzweifel/git-auto-commit-action` from 5 to 6 ([#18524](https://github.com/opensearch-project/OpenSearch/pull/18524))

server/src/main/java/org/opensearch/index/store/CompositeDirectory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class CompositeDirectory extends FilterDirectory {
6060
protected final RemoteSegmentStoreDirectory remoteDirectory;
6161
protected final FileCache fileCache;
6262
protected final TransferManager transferManager;
63-
private final ThreadPool threadPool;
63+
protected final ThreadPool threadPool;
6464

6565
/**
6666
* Constructor to initialise the composite directory

server/src/test/java/org/opensearch/index/store/remote/utils/TransferManagerTestCase.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636

3737
import static org.hamcrest.Matchers.equalTo;
3838
import static org.hamcrest.Matchers.greaterThan;
39+
import static org.mockito.ArgumentMatchers.any;
3940
import static org.mockito.Mockito.doReturn;
41+
import static org.mockito.Mockito.doThrow;
4042
import static org.mockito.Mockito.mock;
4143

4244
@ThreadLeakFilters(filters = CleanerDaemonThreadLeakFilter.class)
@@ -234,6 +236,39 @@ public void testDownloadFailsAsyncDownload() throws Exception {
234236
MatcherAssert.assertThat(fileCache.usage(), equalTo(0L));
235237
}
236238

239+
public void testDownloadFailsAsyncDownloadException() throws Exception {
240+
mockExceptionWhileReading();
241+
doThrow(new IllegalArgumentException("Invalid thread pool")).when(threadPool).executor(ThreadPool.Names.REMOTE_RECOVERY);
242+
List<BlobFetchRequest.BlobPart> blobParts = new ArrayList<>();
243+
blobParts.add(new BlobFetchRequest.BlobPart("failure-blob", 0, EIGHT_MB));
244+
expectThrows(IllegalArgumentException.class, () -> {
245+
BlobFetchRequest blobFetchRequest = BlobFetchRequest.builder()
246+
.fileName("file")
247+
.directory(directory)
248+
.blobParts(blobParts)
249+
.build();
250+
transferManager.fetchBlobAsync(blobFetchRequest);
251+
});
252+
MatcherAssert.assertThat(fileCache.activeUsage(), equalTo(0L));
253+
}
254+
255+
public void testDownloadFailsAsyncDownloadExceptionFileCache() throws Exception {
256+
mockExceptionWhileReading();
257+
258+
doThrow(new IOException("Invalid key")).when(fileCache).compute(any(), any());
259+
List<BlobFetchRequest.BlobPart> blobParts = new ArrayList<>();
260+
blobParts.add(new BlobFetchRequest.BlobPart("failure-blob", 0, EIGHT_MB));
261+
expectThrows(IOException.class, () -> {
262+
BlobFetchRequest blobFetchRequest = BlobFetchRequest.builder()
263+
.fileName("file")
264+
.directory(directory)
265+
.blobParts(blobParts)
266+
.build();
267+
transferManager.fetchBlobAsync(blobFetchRequest);
268+
});
269+
MatcherAssert.assertThat(fileCache.activeUsage(), equalTo(0L));
270+
}
271+
237272
public void testFetchesToDifferentBlobsDoNotBlockOnEachOther() throws Exception {
238273
// Mock a call for a blob that will block until the latch is released,
239274
// then start the fetch for that blob on a separate thread

0 commit comments

Comments
 (0)