Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#2640] feat(docs): Add the doc for gvfs (#2791)

xloyab8f04c54e0c6
diff --git a/clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop3/FilesetContext.java b/clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop/FilesetContext.java
similarity index 98%
rename from clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop3/FilesetContext.java
rename to clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop/FilesetContext.java
index 3ac23dc028..ed1aa5b139 100644
--- a/clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop3/FilesetContext.java
+++ b/clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop/FilesetContext.java
@@ -2,7 +2,7 @@
* Copyright 2024 Datastrato Pvt Ltd.
* This software is licensed under the Apache License version 2.
*/
-package com.datastrato.gravitino.filesystem.hadoop3;
+package com.datastrato.gravitino.filesystem.hadoop;
import com.datastrato.gravitino.NameIdentifier;
import com.datastrato.gravitino.file.Fileset;
diff --git a/clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop3/GravitinoVirtualFileSystem.java b/clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop/GravitinoVirtualFileSystem.java
similarity index 99%
rename from clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop3/GravitinoVirtualFileSystem.java
rename to clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop/GravitinoVirtualFileSystem.java
index 578f461693..e3a6b33a2e 100644
--- a/clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop3/GravitinoVirtualFileSystem.java
+++ b/clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop/GravitinoVirtualFileSystem.java
@@ -2,7 +2,7 @@
* Copyright 2024 Datastrato Pvt Ltd.
* This software is licensed under the Apache License version 2.
*/
-package com.datastrato.gravitino.filesystem.hadoop3;
+package com.datastrato.gravitino.filesystem.hadoop;
import com.datastrato.gravitino.Catalog;
import com.datastrato.gravitino.NameIdentifier;
diff --git a/clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop3/GravitinoVirtualFileSystemConfiguration.java b/clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop/GravitinoVirtualFileSystemConfiguration.java
similarity index 96%
rename from clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop3/GravitinoVirtualFileSystemConfiguration.java
rename to clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop/GravitinoVirtualFileSystemConfiguration.java
index 48a1e8c019..ab9fee5a6d 100644
--- a/clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop3/GravitinoVirtualFileSystemConfiguration.java
+++ b/clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop/GravitinoVirtualFileSystemConfiguration.java
@@ -2,7 +2,7 @@
* Copyright 2024 Datastrato Pvt Ltd.
* This software is licensed under the Apache License version 2.
*/
-package com.datastrato.gravitino.filesystem.hadoop3;
+package com.datastrato.gravitino.filesystem.hadoop;
/** Configuration class for Gravitino Virtual File System. */
class GravitinoVirtualFileSystemConfiguration {
diff --git a/clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop3/Gvfs.java b/clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop/Gvfs.java
similarity index 94%
rename from clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop3/Gvfs.java
rename to clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop/Gvfs.java
index edcb1892c1..356ae2ea41 100644
--- a/clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop3/Gvfs.java
+++ b/clients/filesystem-hadoop3/src/main/java/com/datastrato/gravitino/filesystem/hadoop/Gvfs.java
@@ -2,7 +2,7 @@
* Copyright 2024 Datastrato Pvt Ltd.
* This software is licensed under the Apache License version 2.
*/
-package com.datastrato.gravitino.filesystem.hadoop3;
+package com.datastrato.gravitino.filesystem.hadoop;
import java.io.IOException;
import java.net.URI;
diff --git a/clients/filesystem-hadoop3/src/test/java/com/datastrato/gravitino/filesystem/hadoop3/FileSystemTestUtils.java b/clients/filesystem-hadoop3/src/test/java/com/datastrato/gravitino/filesystem/hadoop/FileSystemTestUtils.java
similarity index 98%
rename from clients/filesystem-hadoop3/src/test/java/com/datastrato/gravitino/filesystem/hadoop3/FileSystemTestUtils.java
rename to clients/filesystem-hadoop3/src/test/java/com/datastrato/gravitino/filesystem/hadoop/FileSystemTestUtils.java
index 00faf5ea98..66204fa683 100644
--- a/clients/filesystem-hadoop3/src/test/java/com/datastrato/gravitino/filesystem/hadoop3/FileSystemTestUtils.java
+++ b/clients/filesystem-hadoop3/src/test/java/com/datastrato/gravitino/filesystem/hadoop/FileSystemTestUtils.java
@@ -2,7 +2,7 @@
* Copyright 2024 Datastrato Pvt Ltd.
* This software is licensed under the Apache License version 2.
*/
-package com.datastrato.gravitino.filesystem.hadoop3;
+package com.datastrato.gravitino.filesystem.hadoop;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
diff --git a/clients/filesystem-hadoop3/src/test/java/com/datastrato/gravitino/filesystem/hadoop3/MockServerTestBase.java b/clients/filesystem-hadoop3/src/test/java/com/datastrato/gravitino/filesystem/hadoop/MockServerTestBase.java
similarity index 99%
rename from clients/filesystem-hadoop3/src/test/java/com/datastrato/gravitino/filesystem/hadoop3/MockServerTestBase.java
rename to clients/filesystem-hadoop3/src/test/java/com/datastrato/gravitino/filesystem/hadoop/MockServerTestBase.java
index 967cbadc70..de5c35cf66 100644
--- a/clients/filesystem-hadoop3/src/test/java/com/datastrato/gravitino/filesystem/hadoop3/MockServerTestBase.java
+++ b/clients/filesystem-hadoop3/src/test/java/com/datastrato/gravitino/filesystem/hadoop/MockServerTestBase.java
@@ -2,7 +2,7 @@
* Copyright 2024 Datastrato Pvt Ltd.
* This software is licensed under the Apache License version 2.
*/
-package com.datastrato.gravitino.filesystem.hadoop3;
+package com.datastrato.gravitino.filesystem.hadoop;
import static org.apache.hc.core5.http.HttpStatus.SC_OK;
diff --git a/clients/filesystem-hadoop3/src/test/java/com/datastrato/gravitino/filesystem/hadoop3/TestGravitinoVirtualFileSystem.java b/clients/filesystem-hadoop3/src/test/java/com/datastrato/gravitino/filesystem/hadoop/TestGravitinoVirtualFileSystem.java
similarity index 99%
rename from clients/filesystem-hadoop3/src/test/java/com/datastrato/gravitino/filesystem/hadoop3/TestGravitinoVirtualFileSystem.java
rename to clients/filesystem-hadoop3/src/test/java/com/datastrato/gravitino/filesystem/hadoop/TestGravitinoVirtualFileSystem.java
index 85a6b8363d..38ad99424c 100644
--- a/clients/filesystem-hadoop3/src/test/java/com/datastrato/gravitino/filesystem/hadoop3/TestGravitinoVirtualFileSystem.java
+++ b/clients/filesystem-hadoop3/src/test/java/com/datastrato/gravitino/filesystem/hadoop/TestGravitinoVirtualFileSystem.java
@@ -2,7 +2,7 @@
* Copyright 2024 Datastrato Pvt Ltd.
* This software is licensed under the Apache License version 2.
*/
-package com.datastrato.gravitino.filesystem.hadoop3;
+package com.datastrato.gravitino.filesystem.hadoop;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
diff --git a/docs/how-to-use-gvfs.md b/docs/how-to-use-gvfs.md
new file mode 100644
index 0000000000..66e977cc01
--- /dev/null
+++ b/docs/how-to-use-gvfs.md
@@ -0,0 +1,225 @@
+---
+title: How to use Gravitino Virtual File System with Filesets
+slug: /how-to-use-gvfs
+license: "Copyright 2024 Datastrato Pvt Ltd.
+This software is licensed under the Apache License version 2."
+---
+
+## Introduction
+
+`Fileset` is a concept brought in by Gravitino, which is a logical collection of files and
+directories, with `fileset` you can manage the non-tabular data through Gravitino. For the
+details you can see [How to manage fileset metadata using Gravitino](./manage-fileset-metadata-using-gravitino.md).
+
+To use `Fileset` managed by Gravitino, Gravitino provides a virtual file system layer called
+Gravitino Virtual File System (GVFS) that is built on top of the Hadoop Compatible File System
+(HCFS) interface.
+
+GVFS is a virtual layer that manages the files and directories in the fileset through a virtual
+path, without needing to understand the specific storage details of the fileset. You can access
+the files or folders like below:
+
+```text
+gvfs://fileset/${catalog_name}/${schema_name}/${fileset_name}/sub_dir/
+```
+
+Here `gvfs` is the scheme of the GVFS, `fileset` is the root directory of the GVFS and cannot be
+modified, the `${catalog_name}/${schema_name}/${fileset_name}` is the virtual path of the fileset.
+You can access the files and folders under this virtual path by concatenating the file or folder
+name to the virtual path.
+
+The usage pattern for GVFS is exactly the same as HDFS, S3 and others, GVFS internally will manage
+the path mapping and converting automatically.
+
+## Prerequisites
+
++ A Hadoop environment (Hadoop 3.1.0 has been tested) with HDFS running. GVFS is built against
+ Hadoop 3.1.0, it is recommended to use Hadoop 3.1.0 or later, but it should work with Hadoop 2.
+ x. Please create an [issue](https://www.github.com/datastrato/gravitino/issues) if you find any
+ compatibility issues.
++ You already manage the filesets with Gravitino.
+
+## Configuration
+
+| Configuration item | Description | Default value | Required | Since version |
+|-------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|----------|---------------|
+| `fs.AbstractFileSystem.gvfs.impl` | The Gravitino Virtual File System abstract class. Please configure it as `com.datastrato.gravitino.filesystem.hadoop.Gvfs`. | (none) | Yes | 0.5.0 |
+| `fs.gvfs.impl` | The Gravitino Virtual File System implementation class. Please configure it as `com.datastrato.gravitino.filesystem.hadoop.GravitinoVirtualFileSystem`. | (none) | Yes | 0.5.0 |
+| `fs.gvfs.impl.disable.cache` | Close the Gravitino Virtual File System cache in Hadoop environment. If you need to proxy multi-user operations, please set this value to `true` and create a separate File System for each user. | `false` | No | 0.5.0 |
+| `fs.gravitino.server.uri` | The Gravitino server uri which gvfs needs to load the fileset meta. | (none) | Yes | 0.5.0 |
+| `fs.gravitino.client.metalake` | The metalake which fileset belongs. | (none) | Yes | 0.5.0 |
+| `fs.gravitino.fileset.cache.maxCapacity` | The cache capacity in the Gravitino Virtual File System. | `20` | No | 0.5.0 |
+| `fs.gravitino.fileset.cache.evictionMillsAfterAccess` | The value of time that the cache evicts the element after access in the Gravitino Virtual File System. The value is in `milliseconds`. | `300000` | No | 0.5.0 |
+
+You can configure these properties in two ways:
+
+1. Before getting the `FileSystem` in the code, construct the `Configuration` and set the properties:
+
+ ```java
+ Configuration conf = new Configuration();
+ conf.set("fs.AbstractFileSystem.gvfs.impl","com.datastrato.gravitino.filesystem.hadoop.Gvfs");
+ conf.set("fs.gvfs.impl","com.datastrato.gravitino.filesystem.hadoop.GravitinoVirtualFileSystem");
+ conf.set("fs.gravitino.server.uri","http://localhost:8090");
+ conf.set("fs.gravitino.client.metalake","test_metalake");
+ Path filesetPath = new Path("gvfs://fileset/test_catalog/test_schema/test_fileset_1");
+ FileSystem fs = filesetPath.getFileSystem(conf);
+ ```
+
+2. Configure these properties in the `core-site.xml` file of the Hadoop environment:
+
+ ```xml
+ <property>
+ <name>fs.AbstractFileSystem.gvfs.impl</name>
+ <value>com.datastrato.gravitino.filesystem.hadoop.Gvfs</value>
+ </property>
+
+ <property>
+ <name>fs.gvfs.impl</name>
+ <value>com.datastrato.gravitino.filesystem.hadoop.GravitinoVirtualFileSystem</value>
+ </property>
+
+ <property>
+ <name>fs.gravitino.server.uri</name>
+ <value>http://localhost:8090</value>
+ </property>
+
+ <property>
+ <name>fs.gravitino.client.metalake</name>
+ <value>test_metalake</value>
+ </property>
+ ```
+
+## How to use
+
+Please make sure to have the Gravitino Virtual File System runtime jar firstly, you can get it in
+two ways:
+
+1. Download from the maven central repository: You can download the runtime jar which name is like
+ `gravitino-filesystem-hadoop3-runtime-{version}.jar` from [Maven repository](https://mvnrepository.com/).
+2. Compile from the source code:
+
+ Download the [Gravitino source code](https://github.com/datastrato/gravitino), and compile it
+ locally using the following command in the Gravitino source code directory:
+
+ ```shell
+ ./gradlew :clients:filesystem-hadoop3-runtime:build -x test
+ ```
+
+### Use GVFS via Hadoop shell command
+
+You can use the Hadoop shell command to operate the fileset storage. For example:
+
+```shell
+# 1. Configure the hadoop `core-site.xml` configuration
+# you should put the properties above into this file
+vi ${HADOOP_HOME}/etc/hadoop/core-site.xml
+
+# 2. Place the gvfs runtime jar into your Hadoop environment
+cp gravitino-filesystem-hadoop3-runtime-{version}.jar ${HADOOP_HOME}/share/hadoop/common/lib/
+
+# 3. Complete the Kerberos authentication of the Hadoop environment (if necessary).
+# You need to ensure that the Kerberos has permission to operate the HDFS directory.
+kinit -kt your_kerberos.keytab [email protected]
+
+# 4. Try to list the fileset
+./${HADOOP_HOME}/bin/hadoop dfs -ls gvfs://fileset/test_catalog/test_schema/test_fileset_1
+```
+
+### Use GVFS via Java code
+
+You can also operate the files or directories managed by fileset through Java code.
+Please make sure that your code is running in the correct Hadoop environment, and the environment
+has the `gravitino-filesystem-hadoop3-runtime-{version}.jar` dependency.
+
+For example:
+
+```java
+Configuration conf = new Configuration();
+conf.set("fs.AbstractFileSystem.gvfs.impl","com.datastrato.gravitino.filesystem.hadoop.Gvfs");
+conf.set("fs.gvfs.impl","com.datastrato.gravitino.filesystem.hadoop.GravitinoVirtualFileSystem");
+conf.set("fs.gravitino.server.uri","http://localhost:8090");
+conf.set("fs.gravitino.client.metalake","test_metalake");
+Path filesetPath = new Path("gvfs://fileset/test_catalog/test_schema/test_fileset_1");
+FileSystem fs = filesetPath.getFileSystem(conf);
+fs.getFileStatus(filesetPath);
+```
+
+### Use GVFS with Apache Spark
+
+1. Add the gvfs runtime jar to the Spark environment.
+
+ You can use `--packages` or `--jars` in the Spark submit shell to include the Gravitino Virtual
+ File System runtime jar, like this:
+
+ ```shell
+ ./${SPARK_HOME}/bin/spark-submit --packages com.datastrato.gravitino:filesystem-hadoop3-runtime:${version}
+ ```
+
+ If you want to include Gravitino Virtual File System runtime jar in your Spark installation,
+ make sure to add it to the `${SPARK_HOME}/jars/` folder.
+
+2. Configure the Hadoop configuration when submitting the job.
+
+ Then, you can configure the Hadoop configuration in the shell command like this:
+
+ ```shell
+ --conf spark.hadoop.fs.AbstractFileSystem.gvfs.impl=com.datastrato.gravitino.filesystem.hadoop.Gvfs
+ --conf spark.hadoop.fs.gvfs.impl=com.datastrato.gravitino.filesystem.hadoop.GravitinoVirtualFileSystem
+ --conf spark.hadoop.fs.gravitino.server.uri=${your_gravitino_server_uri}
+ --conf spark.hadoop.fs.gravitino.client.metalake=${your_gravitino_metalake}
+ ```
+
+3. Operate the fileset storage in your code.
+
+ Finally, you can operate the fileset storage in your Spark program:
+
+ ```scala
+ // Scala
+ val spark = SparkSession.builder()
+ .appName("Gvfs Example")
+ .getOrCreate()
+
+ val rdd = spark.sparkContext.textFile("gvfs://fileset/test_catalog/test_schema/test_fileset_1")
+
+ rdd.foreach(println)
+ ```
+
+
+### Use GVFS with Tensorflow
+
+In order for tensorflow to support GVFS, you need to recompile the [tensorflow-io](https://github.com/tensorflow/io) module.
+
+1. Add a patch and recompile tensorflow-io.
+
+ You need to add a [patch](https://github.com/tensorflow/io/pull/1970) to support GVFS on
+ tensorflow-io. Then you can follow the [tutorial](https://github.com/tensorflow/io/blob/master/docs/development.md)
+ to recompile your code and release the tensorflow-io module.
+
+2. Configure the Hadoop configuration.
+
+ You need to configure the hadoop configuration and `gravitino-filesystem-hadoop3-runtime-{version}.jar`,
+ also kerberos environment according to the [Use GVFS via Hadoop shell command](#use-gvfs-via-hadoop-shell-command) sections.
+
+ Then you need to set your environment as follows:
+
+ ```shell
+ export HADOOP_HOME=${your_hadoop_home}
+ export HADOOP_CONF_DIR=${your_hadoop_conf_home}
+ export PATH=$PATH:$HADOOP_HOME/libexec/hadoop-config.sh
+ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAVA_HOME/jre/lib/amd64/server
+ export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
+ export CLASSPATH="$(hadoop classpath --glob)"
+ ```
+
+3. Import tensorflow-io and test.
+
+ ```python
+ import tensorflow as tf
+ import tensorflow_io as tfio
+
+ ## read a file
+ print(tf.io.read_file('gvfs://fileset/test_catalog/test_schema/test_fileset_1/test.txt'))
+
+ ## list directory
+ print(tf.io.gfile.listdir('gvfs://fileset/test_catalog/test_schema/test_fileset_1/'))
+ ```
diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/filesystem/hadoop3/GravitinoVirtualFileSystemIT.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/filesystem/hadoop/GravitinoVirtualFileSystemIT.java
similarity index 99%
rename from integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/filesystem/hadoop3/GravitinoVirtualFileSystemIT.java
rename to integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/filesystem/hadoop/GravitinoVirtualFileSystemIT.java
index 9cd832e74e..ad92e1211c 100644
--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/filesystem/hadoop3/GravitinoVirtualFileSystemIT.java
+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/client/filesystem/hadoop/GravitinoVirtualFileSystemIT.java
@@ -1,4 +1,4 @@
-package com.datastrato.gravitino.integration.test.client.filesystem.hadoop3;
+package com.datastrato.gravitino.integration.test.client.filesystem.hadoop;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -65,8 +65,8 @@ public class GravitinoVirtualFileSystemIT extends AbstractIT {
Assertions.assertTrue(catalog.asSchemas().schemaExists(schemaIdent));
conf.set(
- "fs.gvfs.impl", "com.datastrato.gravitino.filesystem.hadoop3.GravitinoVirtualFileSystem");
- conf.set("fs.AbstractFileSystem.gvfs.impl", "com.datastrato.gravitino.filesystem.hadoop3.Gvfs");
+ "fs.gvfs.impl", "com.datastrato.gravitino.filesystem.hadoop.GravitinoVirtualFileSystem");
+ conf.set("fs.AbstractFileSystem.gvfs.impl", "com.datastrato.gravitino.filesystem.hadoop.Gvfs");
conf.set("fs.gvfs.impl.disable.cache", "true");
conf.set("fs.gravitino.server.uri", serverUri);
conf.set("fs.gravitino.client.metalake", metalakeName);