github-actions[bot] commented on code in PR #62511: URL: https://github.com/apache/doris/pull/62511#discussion_r3090826505
########## fe/fe-filesystem/ENV_TEST_README.md: ########## @@ -1,189 +1,221 @@ +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + # Filesystem Environment Tests -本目录下的环境测试(Layer 2)需要真实的云存储/HDFS/Broker 服务才能运行。默认 CI 构建会自动跳过它们。 +The environment tests (Layer 2) in this directory require real cloud storage / HDFS / Broker +services to run. They are automatically skipped in default CI builds. -## 快速开始 +## Quick Start -### 使用辅助脚本 +### Using the Helper Script -仓库根目录提供了 `run-fs-env-test.sh`,支持通过命令行参数或预设环境变量运行: +The repository root provides `run-fs-env-test.sh`, which supports running tests via command-line +arguments or pre-set environment variables: ```bash -# S3 测试 +# S3 tests ./run-fs-env-test.sh s3 \ --s3-endpoint=https://s3.us-east-1.amazonaws.com \ --s3-region=us-east-1 \ --s3-bucket=my-test-bucket \ --s3-ak=AKIAIOSFODNN7EXAMPLE \ --s3-sk=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY -# Azure 测试 +# Azure tests ./run-fs-env-test.sh azure \ --azure-account=myaccount \ --azure-key=base64key== \ --azure-container=testcontainer -# HDFS 测试(Simple Auth) +# HDFS tests (Simple Auth) ./run-fs-env-test.sh hdfs \ --hdfs-host=namenode.example.com \ --hdfs-port=8020 -# Kerberos 测试 +# Kerberos tests ./run-fs-env-test.sh kerberos \ --kdc-principal=hdfs/namenode@REALM \ --kdc-keytab=/path/to/hdfs.keytab \ --hdfs-host=namenode.example.com \ --hdfs-port=8020 -# COS(腾讯云)测试 +# COS (Tencent Cloud) tests ./run-fs-env-test.sh cos \ --cos-endpoint=https://cos.ap-guangzhou.myqcloud.com \ --cos-region=ap-guangzhou \ --cos-bucket=my-cos-bucket \ --cos-ak=SecretId \ --cos-sk=SecretKey -# OSS(阿里云)测试 +# OSS (Alibaba Cloud) tests ./run-fs-env-test.sh oss \ --oss-endpoint=https://oss-cn-hangzhou.aliyuncs.com \ --oss-region=cn-hangzhou \ --oss-bucket=my-oss-bucket \ --oss-ak=AccessKeyId \ --oss-sk=AccessKeySecret -# OBS(华为云)测试 +# OBS (Huawei Cloud) tests ./run-fs-env-test.sh obs \ --obs-endpoint=https://obs.cn-north-4.myhuaweicloud.com \ --obs-region=cn-north-4 \ --obs-bucket=my-obs-bucket \ --obs-ak=AK \ --obs-sk=SK -# Broker 测试 +# Broker tests ./run-fs-env-test.sh broker \ --broker-host=broker.example.com \ --broker-port=8060 -# 运行全部环境测试(需要所有环境变量已预设) +# Run all environment tests (requires all environment variables to be pre-set) ./run-fs-env-test.sh all ``` -### 使用 Maven 直接运行 +### Running Directly with Maven -也可以先导出环境变量,然后使用 Maven 命令直接运行: +You can also export environment variables first and then run tests directly with Maven: ```bash -# 导出凭据 +# Export credentials export DORIS_FS_TEST_S3_ENDPOINT=https://s3.us-east-1.amazonaws.com export DORIS_FS_TEST_S3_REGION=us-east-1 export DORIS_FS_TEST_S3_BUCKET=my-test-bucket export DORIS_FS_TEST_S3_AK=your-access-key export DORIS_FS_TEST_S3_SK=your-secret-key -# 运行 S3 相关环境测试 +# Run S3-related environment tests cd fe mvn test -pl fe-filesystem \ Review Comment: This command does not run any filesystem tests. `-pl fe-filesystem --also-make` only selects the aggregator POM, and I reproduced a `BUILD SUCCESS` with a reactor containing just `fe` and `fe-filesystem`, with no Surefire execution for any implementation module. Please point the direct Maven examples at the concrete module paths, for example `-pl fe-filesystem/fe-filesystem-s3 --also-make` here and `-pl fe-filesystem/fe-filesystem-hdfs --also-make` for the HDFS/Kerberos example below. ########## fe/fe-filesystem/README.md: ########## @@ -0,0 +1,403 @@ +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +# Doris FE Filesystem Module + +The `fe-filesystem` module provides a **pluggable filesystem abstraction** for the Doris FE +(Frontend). It decouples the query engine (`fe-core`) from concrete storage backends (S3, HDFS, +Azure Blob, etc.) at both the Maven dependency level and the runtime classpath level. + +Each storage backend is a self-contained plugin that is discovered and loaded at FE startup—no +modification to `fe-core` is required to add a new storage backend. + +## Module Structure + +``` +fe-filesystem/ (aggregator POM — no Java code) +│ +├── fe-filesystem-api/ [API] Core abstractions (FileSystem, Location, …) +├── fe-filesystem-spi/ [SPI] Provider interface + object-storage contracts +│ +├── fe-filesystem-s3/ [IMPL] AWS S3 / S3-compatible (MinIO, …) +├── fe-filesystem-oss/ [IMPL] Alibaba Cloud OSS (delegates to S3) +├── fe-filesystem-cos/ [IMPL] Tencent Cloud COS (delegates to S3) +├── fe-filesystem-obs/ [IMPL] Huawei Cloud OBS (delegates to S3) +├── fe-filesystem-azure/ [IMPL] Azure Blob Storage +├── fe-filesystem-hdfs/ [IMPL] HDFS / ViewFS / OFS / JFS +├── fe-filesystem-local/ [IMPL] Local filesystem (testing only) +└── fe-filesystem-broker/ [IMPL] Doris Broker process (Thrift RPC) +``` + +### Layering + +| Layer | Module | Compiled into fe-core? | Deployed as plugin? | +|-------|--------|:-----:|:------:| +| **API** | `fe-filesystem-api` | ✅ Yes | ❌ No | +| **SPI** | `fe-filesystem-spi` | ✅ Yes | ❌ No | +| **IMPL** | `fe-filesystem-s3`, `-hdfs`, … | ❌ No | ✅ Yes | + +* **API** — Pure-JDK interfaces and value types consumed by `fe-core` (zero third-party + dependencies). Defines `FileSystem`, `Location`, `FileEntry`, `DorisInputFile`, + `DorisOutputFile`, etc. +* **SPI** — The `FileSystemProvider` interface (extends `PluginFactory` from `fe-extension-spi`) + plus the object-storage layer (`ObjStorage`, `ObjFileSystem`, `HadoopAuthenticator`). Also + compiled into `fe-core`. +* **IMPL** — Concrete backends. Each one depends only on `fe-filesystem-spi` (and transitively on + `fe-filesystem-api`). They **must not** depend on `fe-core`, `fe-common`, or `fe-catalog`. + +## How It Works + +### Plugin Discovery & Loading + +At FE startup, `Env.initFileSystemPluginManager()` creates a `FileSystemPluginManager` and loads +providers in two phases: + +1. **ServiceLoader scan** — Discovers `FileSystemProvider` implementations already on the + classpath (built-in providers, test overrides). +2. **Directory plugin scan** — Uses `DirectoryPluginRuntimeManager` to scan the directory + configured by `Config.filesystem_plugin_root` (default: `${DORIS_HOME}/plugins/filesystem`). + Each direct child directory is treated as an **unpacked** plugin directory. The runtime + manager resolves `pluginDir/*.jar` (root-level jars, scanned for ServiceLoader registration) + and `pluginDir/lib/*.jar` (dependency jars, available for class loading only). + +Classpath providers have higher priority than directory-loaded providers. + +### Provider Selection + +When `fe-core` needs a filesystem, it calls `FileSystemFactory.getFileSystem(properties)`: + +``` +Map<String, String> properties + │ + ▼ +FileSystemPluginManager.createFileSystem(properties) + │ + │ for each registered FileSystemProvider: + │ 1. provider.supports(properties) ← cheap, no I/O + │ 2. if true → provider.create(properties) → return FileSystem + │ + ▼ +First matching provider wins +``` + +Each provider's `supports()` method examines property keys to decide if it can handle the +request. For example: + +| Provider | Matching Logic | +|----------|---------------| +| S3 | `AWS_ACCESS_KEY` + (`AWS_ENDPOINT` or `AWS_REGION`) | +| OSS | Endpoint contains `aliyuncs.com` or `_STORAGE_TYPE_` = `"OSS"` | +| HDFS | `_STORAGE_TYPE_` = `"HDFS"` or URI scheme is `hdfs`/`viewfs`/`ofs`/`jfs` | Review Comment: The HDFS matching table is missing the `oss` scheme. `HdfsFileSystemProvider.SUPPORTED_SCHEMES` currently includes `hdfs`, `viewfs`, `ofs`, `jfs`, and `oss`, and the module POM also describes OSSHdfs support. Omitting `oss` makes the documented routing logic incomplete for OSS-HDFS users. ########## fe/fe-filesystem/README.md: ########## @@ -0,0 +1,403 @@ +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +# Doris FE Filesystem Module + +The `fe-filesystem` module provides a **pluggable filesystem abstraction** for the Doris FE +(Frontend). It decouples the query engine (`fe-core`) from concrete storage backends (S3, HDFS, +Azure Blob, etc.) at both the Maven dependency level and the runtime classpath level. + +Each storage backend is a self-contained plugin that is discovered and loaded at FE startup—no +modification to `fe-core` is required to add a new storage backend. + +## Module Structure + +``` +fe-filesystem/ (aggregator POM — no Java code) +│ +├── fe-filesystem-api/ [API] Core abstractions (FileSystem, Location, …) +├── fe-filesystem-spi/ [SPI] Provider interface + object-storage contracts +│ +├── fe-filesystem-s3/ [IMPL] AWS S3 / S3-compatible (MinIO, …) +├── fe-filesystem-oss/ [IMPL] Alibaba Cloud OSS (delegates to S3) +├── fe-filesystem-cos/ [IMPL] Tencent Cloud COS (delegates to S3) +├── fe-filesystem-obs/ [IMPL] Huawei Cloud OBS (delegates to S3) +├── fe-filesystem-azure/ [IMPL] Azure Blob Storage +├── fe-filesystem-hdfs/ [IMPL] HDFS / ViewFS / OFS / JFS +├── fe-filesystem-local/ [IMPL] Local filesystem (testing only) +└── fe-filesystem-broker/ [IMPL] Doris Broker process (Thrift RPC) +``` + +### Layering + +| Layer | Module | Compiled into fe-core? | Deployed as plugin? | +|-------|--------|:-----:|:------:| +| **API** | `fe-filesystem-api` | ✅ Yes | ❌ No | +| **SPI** | `fe-filesystem-spi` | ✅ Yes | ❌ No | +| **IMPL** | `fe-filesystem-s3`, `-hdfs`, … | ❌ No | ✅ Yes | + +* **API** — Pure-JDK interfaces and value types consumed by `fe-core` (zero third-party + dependencies). Defines `FileSystem`, `Location`, `FileEntry`, `DorisInputFile`, + `DorisOutputFile`, etc. +* **SPI** — The `FileSystemProvider` interface (extends `PluginFactory` from `fe-extension-spi`) + plus the object-storage layer (`ObjStorage`, `ObjFileSystem`, `HadoopAuthenticator`). Also + compiled into `fe-core`. +* **IMPL** — Concrete backends. Each one depends only on `fe-filesystem-spi` (and transitively on Review Comment: This sentence does not match the current module graph. `fe-filesystem-cos`, `fe-filesystem-oss`, and `fe-filesystem-obs` depend directly on `fe-filesystem-s3` to reuse `S3FileSystem`; they do not depend only on `fe-filesystem-spi`. As written, the architecture section contradicts the delegation pattern described later and may steer new backends away from the existing reuse path. ########## fe/fe-filesystem/README.md: ########## @@ -0,0 +1,403 @@ +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +# Doris FE Filesystem Module + +The `fe-filesystem` module provides a **pluggable filesystem abstraction** for the Doris FE +(Frontend). It decouples the query engine (`fe-core`) from concrete storage backends (S3, HDFS, +Azure Blob, etc.) at both the Maven dependency level and the runtime classpath level. + +Each storage backend is a self-contained plugin that is discovered and loaded at FE startup—no +modification to `fe-core` is required to add a new storage backend. + +## Module Structure + +``` +fe-filesystem/ (aggregator POM — no Java code) +│ +├── fe-filesystem-api/ [API] Core abstractions (FileSystem, Location, …) +├── fe-filesystem-spi/ [SPI] Provider interface + object-storage contracts +│ +├── fe-filesystem-s3/ [IMPL] AWS S3 / S3-compatible (MinIO, …) +├── fe-filesystem-oss/ [IMPL] Alibaba Cloud OSS (delegates to S3) +├── fe-filesystem-cos/ [IMPL] Tencent Cloud COS (delegates to S3) +├── fe-filesystem-obs/ [IMPL] Huawei Cloud OBS (delegates to S3) +├── fe-filesystem-azure/ [IMPL] Azure Blob Storage +├── fe-filesystem-hdfs/ [IMPL] HDFS / ViewFS / OFS / JFS +├── fe-filesystem-local/ [IMPL] Local filesystem (testing only) +└── fe-filesystem-broker/ [IMPL] Doris Broker process (Thrift RPC) +``` + +### Layering + +| Layer | Module | Compiled into fe-core? | Deployed as plugin? | +|-------|--------|:-----:|:------:| +| **API** | `fe-filesystem-api` | ✅ Yes | ❌ No | +| **SPI** | `fe-filesystem-spi` | ✅ Yes | ❌ No | +| **IMPL** | `fe-filesystem-s3`, `-hdfs`, … | ❌ No | ✅ Yes | + +* **API** — Pure-JDK interfaces and value types consumed by `fe-core` (zero third-party + dependencies). Defines `FileSystem`, `Location`, `FileEntry`, `DorisInputFile`, + `DorisOutputFile`, etc. +* **SPI** — The `FileSystemProvider` interface (extends `PluginFactory` from `fe-extension-spi`) + plus the object-storage layer (`ObjStorage`, `ObjFileSystem`, `HadoopAuthenticator`). Also + compiled into `fe-core`. +* **IMPL** — Concrete backends. Each one depends only on `fe-filesystem-spi` (and transitively on + `fe-filesystem-api`). They **must not** depend on `fe-core`, `fe-common`, or `fe-catalog`. + +## How It Works + +### Plugin Discovery & Loading + +At FE startup, `Env.initFileSystemPluginManager()` creates a `FileSystemPluginManager` and loads +providers in two phases: + +1. **ServiceLoader scan** — Discovers `FileSystemProvider` implementations already on the + classpath (built-in providers, test overrides). +2. **Directory plugin scan** — Uses `DirectoryPluginRuntimeManager` to scan the directory + configured by `Config.filesystem_plugin_root` (default: `${DORIS_HOME}/plugins/filesystem`). + Each direct child directory is treated as an **unpacked** plugin directory. The runtime + manager resolves `pluginDir/*.jar` (root-level jars, scanned for ServiceLoader registration) + and `pluginDir/lib/*.jar` (dependency jars, available for class loading only). + +Classpath providers have higher priority than directory-loaded providers. + +### Provider Selection + +When `fe-core` needs a filesystem, it calls `FileSystemFactory.getFileSystem(properties)`: + +``` +Map<String, String> properties + │ + ▼ +FileSystemPluginManager.createFileSystem(properties) + │ + │ for each registered FileSystemProvider: + │ 1. provider.supports(properties) ← cheap, no I/O + │ 2. if true → provider.create(properties) → return FileSystem + │ + ▼ +First matching provider wins +``` + +Each provider's `supports()` method examines property keys to decide if it can handle the +request. For example: + +| Provider | Matching Logic | +|----------|---------------| +| S3 | `AWS_ACCESS_KEY` + (`AWS_ENDPOINT` or `AWS_REGION`) | +| OSS | Endpoint contains `aliyuncs.com` or `_STORAGE_TYPE_` = `"OSS"` | +| HDFS | `_STORAGE_TYPE_` = `"HDFS"` or URI scheme is `hdfs`/`viewfs`/`ofs`/`jfs` | +| Azure | `AZURE_ACCOUNT_NAME` or endpoint contains `blob.core.windows.net` | +| Local | URI starts with `file://` or `local://` | +| Broker | `_STORAGE_TYPE_` = `"BROKER"` and `BROKER_HOST` present | + +### Plugin Packaging & Class Loading + +Each implementation module uses `maven-assembly-plugin` to produce a **zip build artifact**. +The zip must be **unpacked** before deployment. At runtime, `DirectoryPluginRuntimeManager` +expects each plugin to be an unpacked directory under `filesystem_plugin_root`: + +``` +${DORIS_HOME}/plugins/filesystem/ +├── s3/ ← one directory per plugin +│ ├── doris-fe-filesystem-s3.jar ← plugin jar at root (scanned for ServiceLoader) +│ └── lib/ +│ ├── aws-sdk-*.jar ← third-party dependencies +│ └── ... +├── hdfs/ +│ ├── doris-fe-filesystem-hdfs.jar +│ └── lib/... +└── ... +``` + +The Maven build produces a zip with the same layout. To deploy, unzip it into the appropriate +subdirectory (e.g., `unzip doris-fe-filesystem-s3.zip -d plugins/filesystem/s3/`). Dropping +the raw `.zip` file into the directory will **not** work — `DirectoryPluginRuntimeManager` +resolves `pluginDir/*.jar` and `pluginDir/lib/*.jar` from unpacked directories only. + +Jars that are already on the fe-core classpath (`fe-filesystem-api`, `fe-filesystem-spi`, +`fe-extension-spi`) are **excluded** from the zip to avoid duplication. + +At runtime, `DirectoryPluginRuntimeManager` creates an isolated `ClassLoader` per plugin. A +`ClassLoadingPolicy` ensures that shared framework classes (`org.apache.doris.filesystem.*`, +`software.amazon.awssdk.*`, `org.apache.hadoop.*`) are loaded parent-first to avoid cross- +ClassLoader cast failures. + +### S3 Delegation Pattern + +Several cloud providers (OSS, COS, OBS) are S3-compatible. Instead of duplicating the S3 +implementation, they follow a **delegation pattern**: + +1. Translate cloud-native property keys to S3-compatible keys. +2. Extend `ObjStorage` to override cloud-specific operations (pre-signed URLs, STS tokens). +3. Delegate core I/O to `S3FileSystem` (from `fe-filesystem-s3`). + +``` +CosFileSystemProvider + └─→ creates S3FileSystem(CosObjStorage) + │ │ + │ FileSystem ops │ Overrides getPresignedUrl(), getStsToken() + └─────────────────────┘ +``` + +## Relationship to Other Modules + +``` +┌──────────────────────────────────────────────────────────┐ +│ fe-core │ +│ Uses: FileSystem, Location, FileEntry (from API) │ +│ Depends on: fe-filesystem-api, fe-filesystem-spi │ +│ Loads plugins from: ${DORIS_HOME}/plugins/filesystem │ +└────────────┬────────────────────────┬────────────────────┘ + │ compile-time │ runtime (plugin) + ▼ ▼ + ┌──────────────────┐ ┌─────────────────────────┐ + │ fe-filesystem-api│ │ fe-filesystem-s3 (zip) │ + │ fe-filesystem-spi│ │ fe-filesystem-hdfs (zip)│ + │ (compiled in) │ │ fe-filesystem-xxx (zip) │ + └──────────────────┘ └─────────────────────────┘ +``` + +* **`fe-core`** — Compile-time dependency on `fe-filesystem-api` and `fe-filesystem-spi`. + Implementation modules are **not** Maven dependencies of `fe-core`; they are loaded at runtime + from the plugin directory. +* **`fe-extension-spi`** — Provides the `PluginFactory` / `Plugin` interfaces and the + `DirectoryPluginRuntimeManager` class used by the plugin loading infrastructure. +* **`fe-filesystem-local`** — Used in `fe-core` unit tests (test-scope dependency) so that tests + can exercise `FileSystem` operations without cloud credentials. + +## Adding a New Filesystem Sub-Module + +Follow these steps to add support for a new storage backend (e.g., Google Cloud Storage): + +### 1. Create the Maven module + +Create a new directory `fe-filesystem/fe-filesystem-gcs/` with this structure: + +``` +fe-filesystem-gcs/ +├── pom.xml +└── src/ + ├── main/ + │ ├── assembly/ + │ │ └── plugin-zip.xml + │ ├── java/org/apache/doris/filesystem/gcs/ + │ │ ├── GcsFileSystemProvider.java + │ │ ├── GcsFileSystem.java + │ │ └── GcsObjStorage.java (if object-storage based) + │ └── resources/META-INF/services/ + │ └── org.apache.doris.filesystem.spi.FileSystemProvider + └── test/ + └── java/org/apache/doris/filesystem/gcs/ + └── ...Test.java +``` + +### 2. Write `pom.xml` + +```xml +<project> + <parent> + <groupId>org.apache.doris</groupId> + <artifactId>fe-filesystem</artifactId> + <version>${revision}</version> + </parent> + + <artifactId>fe-filesystem-gcs</artifactId> + <packaging>jar</packaging> + <name>Doris FE Filesystem - GCS</name> + + <dependencies> + <!-- REQUIRED: SPI contract (transitively includes API) --> + <dependency> + <groupId>org.apache.doris</groupId> + <artifactId>fe-filesystem-spi</artifactId> + <version>${revision}</version> + </dependency> + + <!-- Cloud SDK --> + <dependency> + <groupId>com.google.cloud</groupId> + <artifactId>google-cloud-storage</artifactId> + <version>...</version> + </dependency> + + <!-- Test --> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <finalName>doris-fe-filesystem-gcs</finalName> + <plugins> + <!-- Assembly: produces the plugin zip --> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <configuration> + <appendAssemblyId>false</appendAssemblyId> + <descriptors> + <descriptor>src/main/assembly/plugin-zip.xml</descriptor> + </descriptors> + </configuration> + <executions> + <execution> + <id>make-assembly</id> + <phase>package</phase> + <goals><goal>single</goal></goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> +``` + +**Important**: Do **not** add dependencies on `fe-core`, `fe-common`, or `fe-catalog`. + +### 3. Write the assembly descriptor + +Copy `plugin-zip.xml` from an existing module (e.g., `fe-filesystem-s3/src/main/assembly/`). +The key points: + +* Place the plugin jar at the **root** of the zip (for ServiceLoader discovery). +* Place all runtime dependencies in `lib/`. +* **Exclude** `fe-filesystem-api`, `fe-filesystem-spi`, and `fe-extension-spi` (they are + already on the fe-core classpath). + +### 4. Implement `FileSystemProvider` + +```java +package org.apache.doris.filesystem.gcs; + +import org.apache.doris.filesystem.FileSystem; +import org.apache.doris.filesystem.spi.FileSystemProvider; +import java.io.IOException; +import java.util.Map; + +public class GcsFileSystemProvider implements FileSystemProvider { + + // Public no-arg constructor — required by ServiceLoader + public GcsFileSystemProvider() {} + + @Override + public boolean supports(Map<String, String> properties) { + // Must be cheap (no network calls) and deterministic. + String type = properties.get("_STORAGE_TYPE_"); + return "GCS".equalsIgnoreCase(type); + } + + @Override + public FileSystem create(Map<String, String> properties) throws IOException { + return new GcsFileSystem(properties); + } + + @Override + public String name() { + return "GCS"; + } +} +``` + +### 5. Implement `FileSystem` + +You have two choices: + +* **Object-storage backend** — Extend `ObjFileSystem` (from SPI) and implement `ObjStorage<C>`. + This gives you `exists()`, `close()`, and cloud-specific delegates for free. +* **Custom backend** — Implement `FileSystem` directly (like `DFSFileSystem` for HDFS). + +At minimum, you must implement: + +| Method | Description | +|--------|-------------| +| `exists(Location)` | Check if a file/directory exists | +| `mkdirs(Location)` | Create directories | +| `delete(Location, boolean)` | Delete file or directory | +| `rename(Location, Location)` | Rename/move | +| `list(Location)` | List directory contents | +| `newInputFile(Location)` | Open a file for reading | +| `newOutputFile(Location)` | Open a file for writing | +| `close()` | Release resources | + +### 6. Register via ServiceLoader + +Create the file: + +``` +src/main/resources/META-INF/services/org.apache.doris.filesystem.spi.FileSystemProvider +``` + +With content: + +``` +org.apache.doris.filesystem.gcs.GcsFileSystemProvider +``` + +### 7. Register the module in the parent POM + +Add your module to `fe-filesystem/pom.xml`: + +```xml +<modules> + ... + <module>fe-filesystem-gcs</module> +</modules> +``` + +### 8. Add tests + +* **Unit tests** — Test your `FileSystem` and `ObjStorage` implementations with mocked cloud + clients. Place in `src/test/java/`. +* **Environment tests** — Tests that require real cloud credentials should be tagged with + `@Tag("environment")`. They are excluded by default and can be enabled with + `-Dtest.excludedGroups=none`. + +### 9. Build and deploy + +```bash +# Build the new module +cd fe/fe-filesystem/fe-filesystem-gcs +mvn package -DskipTests Review Comment: This build command fails from a clean checkout. Running `mvn package -DskipTests` inside `fe/fe-filesystem/fe-filesystem-gcs` made Maven try to resolve `org.apache.doris:fe-filesystem-spi:1.2-SNAPSHOT` from remote repositories and fail because the sibling Doris modules were not built or installed yet. The docs should send readers through the reactor, for example from `fe/` with `-pl fe-filesystem/fe-filesystem-gcs --also-make`, or explicitly require the parent modules to be installed first. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
