From ce35a792aa22147c7578fd66238c57b287277109 Mon Sep 17 00:00:00 2001 From: "yuzhao.cyz" Date: Mon, 28 Nov 2022 16:22:39 +0800 Subject: [PATCH] [HUDI-5286] UnsupportedOperationException throws when enabling filesystem retry --- .../common/fs/HoodieRetryWrapperFileSystem.java | 5 +++++ .../fs/TestFSUtilsWithRetryWrapperEnable.java | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/hudi-common/src/main/java/org/apache/hudi/common/fs/HoodieRetryWrapperFileSystem.java b/hudi-common/src/main/java/org/apache/hudi/common/fs/HoodieRetryWrapperFileSystem.java index ed32eeee636c2..82ea10c459ecb 100644 --- a/hudi-common/src/main/java/org/apache/hudi/common/fs/HoodieRetryWrapperFileSystem.java +++ b/hudi-common/src/main/java/org/apache/hudi/common/fs/HoodieRetryWrapperFileSystem.java @@ -258,4 +258,9 @@ public boolean exists(Path f) throws IOException { public Configuration getConf() { return fileSystem.getConf(); } + + @Override + public String getScheme() { + return fileSystem.getScheme(); + } } diff --git a/hudi-common/src/test/java/org/apache/hudi/common/fs/TestFSUtilsWithRetryWrapperEnable.java b/hudi-common/src/test/java/org/apache/hudi/common/fs/TestFSUtilsWithRetryWrapperEnable.java index aa976cf11274c..68364865a5d90 100644 --- a/hudi-common/src/test/java/org/apache/hudi/common/fs/TestFSUtilsWithRetryWrapperEnable.java +++ b/hudi-common/src/test/java/org/apache/hudi/common/fs/TestFSUtilsWithRetryWrapperEnable.java @@ -37,6 +37,7 @@ import java.util.Arrays; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertThrows; /** @@ -79,6 +80,14 @@ public void testProcessFilesWithExceptions() throws Exception { folders.forEach(f -> assertThrows(RuntimeException.class, () -> metaClient.getFs().mkdirs(new Path(new Path(basePath), f)))); } + @Test + public void testGetSchema() { + FakeRemoteFileSystem fakeFs = new FakeRemoteFileSystem(FSUtils.getFs(metaClient.getMetaPath(), metaClient.getHadoopConf()), 100); + FileSystem fileSystem = new HoodieRetryWrapperFileSystem(fakeFs, maxRetryIntervalMs, maxRetryNumbers, initialRetryIntervalMs, ""); + HoodieWrapperFileSystem fs = new HoodieWrapperFileSystem(fileSystem, new NoOpConsistencyGuard()); + assertDoesNotThrow(fs::getScheme, "Method #getSchema does not implement correctly"); + } + /** * Fake remote FileSystem which will throw RuntimeException something like AmazonS3Exception 503. */ @@ -205,5 +214,10 @@ public RemoteIterator listLocatedStatus(Path f) throws IOExce public Configuration getConf() { return fs.getConf(); } + + @Override + public String getScheme() { + return fs.getScheme(); + } } }