World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#4165] improvement(Filesystem): Improve the potential storage replication issues in Hadoop GVFS (#4166)
xloyab2a93022553a
diff --git a/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/GravitinoVirtualFileSystem.java b/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/GravitinoVirtualFileSystem.javaindex ef51c17531..bbcf0c71ea 100644--- a/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/GravitinoVirtualFileSystem.java+++ b/clients/filesystem-hadoop3/src/main/java/org/apache/gravitino/filesystem/hadoop/GravitinoVirtualFileSystem.java@@ -515,6 +515,18 @@ public class GravitinoVirtualFileSystem extends FileSystem {return context.getFileSystem().mkdirs(context.getActualPath(), permission);}+ @Override+ public short getDefaultReplication(Path f) {+ FilesetContext context = getFilesetContext(f);+ return context.getFileSystem().getDefaultReplication(context.getActualPath());+ }++ @Override+ public long getDefaultBlockSize(Path f) {+ FilesetContext context = getFilesetContext(f);+ return context.getFileSystem().getDefaultBlockSize(context.getActualPath());+ }+@Overridepublic synchronized void close() throws IOException {// close all actual FileSystemsdiff --git a/clients/filesystem-hadoop3/src/test/java/org/apache/gravitino/filesystem/hadoop/TestGvfsBase.java b/clients/filesystem-hadoop3/src/test/java/org/apache/gravitino/filesystem/hadoop/TestGvfsBase.javaindex ce87d8d02d..13b365a255 100644--- a/clients/filesystem-hadoop3/src/test/java/org/apache/gravitino/filesystem/hadoop/TestGvfsBase.java+++ b/clients/filesystem-hadoop3/src/test/java/org/apache/gravitino/filesystem/hadoop/TestGvfsBase.java@@ -591,4 +591,20 @@ public class TestGvfsBase extends GravitinoMockServerBase {() -> fs.extractIdentifier(new URI("/catalog1/schema1/fileset1/dir//")));}}++ @Test+ public void testGetDefaultReplications() throws IOException {+ try (GravitinoVirtualFileSystem fs =+ (GravitinoVirtualFileSystem) managedFilesetPath.getFileSystem(conf)) {+ assertEquals(1, fs.getDefaultReplication(managedFilesetPath));+ }+ }++ @Test+ public void testGetDefaultBlockSize() throws IOException {+ try (GravitinoVirtualFileSystem fs =+ (GravitinoVirtualFileSystem) managedFilesetPath.getFileSystem(conf)) {+ assertEquals(32 * 1024 * 1024, fs.getDefaultBlockSize(managedFilesetPath));+ }+ }}diff --git a/integration-test/src/test/java/org/apache/gravitino/integration/test/client/filesystem/hadoop/GravitinoVirtualFileSystemIT.java b/integration-test/src/test/java/org/apache/gravitino/integration/test/client/filesystem/hadoop/GravitinoVirtualFileSystemIT.javaindex 9321080d9d..feb8446be7 100644--- a/integration-test/src/test/java/org/apache/gravitino/integration/test/client/filesystem/hadoop/GravitinoVirtualFileSystemIT.java+++ b/integration-test/src/test/java/org/apache/gravitino/integration/test/client/filesystem/hadoop/GravitinoVirtualFileSystemIT.java@@ -422,6 +422,48 @@ public class GravitinoVirtualFileSystemIT extends AbstractIT {}}+ @Test+ public void testGetDefaultReplications() throws IOException {+ String filesetName = "test_get_default_replications";+ NameIdentifier filesetIdent = NameIdentifier.of(schemaName, filesetName);+ Catalog catalog = metalake.loadCatalog(catalogName);+ String storageLocation = genStorageLocation(filesetName);+ catalog+ .asFilesetCatalog()+ .createFileset(+ filesetIdent,+ "fileset comment",+ Fileset.Type.MANAGED,+ storageLocation,+ new HashMap<>());+ Assertions.assertTrue(catalog.asFilesetCatalog().filesetExists(filesetIdent));+ Path gvfsPath = genGvfsPath(filesetName);+ try (FileSystem gvfs = gvfsPath.getFileSystem(conf)) {+ assertEquals(3, gvfs.getDefaultReplication(gvfsPath));+ }+ }++ @Test+ public void testGetDefaultBlockSizes() throws IOException {+ String filesetName = "test_get_default_block_sizes";+ NameIdentifier filesetIdent = NameIdentifier.of(schemaName, filesetName);+ Catalog catalog = metalake.loadCatalog(catalogName);+ String storageLocation = genStorageLocation(filesetName);+ catalog+ .asFilesetCatalog()+ .createFileset(+ filesetIdent,+ "fileset comment",+ Fileset.Type.MANAGED,+ storageLocation,+ new HashMap<>());+ Assertions.assertTrue(catalog.asFilesetCatalog().filesetExists(filesetIdent));+ Path gvfsPath = genGvfsPath(filesetName);+ try (FileSystem gvfs = gvfsPath.getFileSystem(conf)) {+ assertEquals(128 * 1024 * 1024, gvfs.getDefaultBlockSize(gvfsPath));+ }+ }+private String genStorageLocation(String fileset) {return String.format("%s/%s", baseHdfsPath(), fileset);}