-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[feat](params-refactor) restructure parameters for FS V2 integration #51177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
CalvinKirs
merged 10 commits into
apache:master
from
CalvinKirs:master-refactor-params-catalog-filesystem-step-1
Jun 5, 2025
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
99de4d4
[feat](params-refactor) restructure parameters for FS V2 integration
CalvinKirs d22e51a
commit
CalvinKirs fd8496d
fix checkstyle
CalvinKirs 333e234
Merge remote-tracking branch 'refs/remotes/upstream/master' into mast…
CalvinKirs 364f171
fix checkstyle
CalvinKirs 4e39f15
fix checkstyle
CalvinKirs 8f911bb
fix checkstyle
CalvinKirs ef21054
Merge branch 'master' into master-refactor-params-catalog-filesystem-…
CalvinKirs 20bcbbd
Merge branch 'master' into master-refactor-params-catalog-filesystem-…
CalvinKirs 742adf4
chore
CalvinKirs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
fe/fe-core/src/main/java/org/apache/doris/fsv2/DirectoryLister.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // 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. | ||
| // This file is copied from | ||
| // https://github.com/trinodb/trino/blob/438/plugin/trino-hive/src/main/java/io/trino/plugin/hive/fs/DirectoryLister.java | ||
| // and modified by Doris | ||
|
|
||
| package org.apache.doris.fsv2; | ||
|
|
||
| import org.apache.doris.catalog.TableIf; | ||
| import org.apache.doris.fsv2.remote.RemoteFile; | ||
|
|
||
| public interface DirectoryLister { | ||
| RemoteIterator<RemoteFile> listFiles(FileSystem fs, boolean recursive, TableIf table, String location) | ||
| throws FileSystemIOException; | ||
| } |
117 changes: 117 additions & 0 deletions
117
fe/fe-core/src/main/java/org/apache/doris/fsv2/FileSystemCache.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| // 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. | ||
|
|
||
| package org.apache.doris.fsv2; | ||
|
|
||
| import org.apache.doris.common.CacheFactory; | ||
| import org.apache.doris.common.Config; | ||
| import org.apache.doris.common.Pair; | ||
| import org.apache.doris.common.UserException; | ||
| import org.apache.doris.fsv2.remote.RemoteFileSystem; | ||
|
|
||
| import com.github.benmanes.caffeine.cache.LoadingCache; | ||
| import org.apache.hadoop.conf.Configuration; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.Objects; | ||
| import java.util.OptionalLong; | ||
|
|
||
| public class FileSystemCache { | ||
|
|
||
| private final LoadingCache<FileSystemCacheKey, RemoteFileSystem> fileSystemCache; | ||
|
|
||
| public FileSystemCache() { | ||
| // no need to set refreshAfterWrite, because the FileSystem is created once and never changed | ||
| CacheFactory fsCacheFactory = new CacheFactory( | ||
| OptionalLong.of(86400L), | ||
| OptionalLong.empty(), | ||
| Config.max_remote_file_system_cache_num, | ||
| false, | ||
| null); | ||
| fileSystemCache = fsCacheFactory.buildCache(this::loadFileSystem); | ||
| } | ||
|
|
||
| private RemoteFileSystem loadFileSystem(FileSystemCacheKey key) throws UserException { | ||
| return FileSystemFactory.get(key.type, key.getFsProperties(), key.bindBrokerName); | ||
| } | ||
|
|
||
| public RemoteFileSystem getRemoteFileSystem(FileSystemCacheKey key) { | ||
| return fileSystemCache.get(key); | ||
| } | ||
|
|
||
| public static class FileSystemCacheKey { | ||
| private final FileSystemType type; | ||
| // eg: hdfs://nameservices1 | ||
| private final String fsIdent; | ||
| private final Map<String, String> properties; | ||
| private final String bindBrokerName; | ||
| // only for creating new file system | ||
| private final Configuration conf; | ||
|
|
||
| public FileSystemCacheKey(Pair<FileSystemType, String> fs, | ||
| Map<String, String> properties, | ||
| String bindBrokerName, | ||
| Configuration conf) { | ||
| this.type = fs.first; | ||
| this.fsIdent = fs.second; | ||
| this.properties = properties; | ||
| this.bindBrokerName = bindBrokerName; | ||
| this.conf = conf; | ||
| } | ||
|
|
||
| public FileSystemCacheKey(Pair<FileSystemType, String> fs, | ||
| Map<String, String> properties, String bindBrokerName) { | ||
| this(fs, properties, bindBrokerName, null); | ||
| } | ||
|
|
||
| public Map<String, String> getFsProperties() { | ||
| if (conf == null) { | ||
| return properties; | ||
| } | ||
| Map<String, String> result = new HashMap<>(); | ||
| conf.iterator().forEachRemaining(e -> result.put(e.getKey(), e.getValue())); | ||
| return result; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object obj) { | ||
| if (this == obj) { | ||
| return true; | ||
| } | ||
| if (!(obj instanceof FileSystemCacheKey)) { | ||
| return false; | ||
| } | ||
| FileSystemCacheKey o = (FileSystemCacheKey) obj; | ||
| boolean equalsWithoutBroker = type.equals(o.type) | ||
| && fsIdent.equals(o.fsIdent) | ||
| && properties.equals(o.properties); | ||
| if (bindBrokerName == null) { | ||
| return equalsWithoutBroker && o.bindBrokerName == null; | ||
| } | ||
| return equalsWithoutBroker && bindBrokerName.equals(o.bindBrokerName); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| if (bindBrokerName == null) { | ||
| return Objects.hash(properties, fsIdent, type); | ||
| } | ||
| return Objects.hash(properties, fsIdent, type, bindBrokerName); | ||
| } | ||
| } | ||
| } | ||
37 changes: 37 additions & 0 deletions
37
fe/fe-core/src/main/java/org/apache/doris/fsv2/FileSystemDirectoryLister.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // 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. | ||
|
|
||
| package org.apache.doris.fsv2; | ||
|
|
||
| import org.apache.doris.backup.Status; | ||
| import org.apache.doris.catalog.TableIf; | ||
| import org.apache.doris.fsv2.remote.RemoteFile; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| public class FileSystemDirectoryLister implements DirectoryLister { | ||
| public RemoteIterator<RemoteFile> listFiles(FileSystem fs, boolean recursive, TableIf table, String location) | ||
| throws FileSystemIOException { | ||
| List<RemoteFile> result = new ArrayList<>(); | ||
| Status status = fs.listFiles(location, recursive, result); | ||
| if (!status.ok()) { | ||
| throw new FileSystemIOException(status.getErrCode(), status.getErrMsg()); | ||
| } | ||
| return new RemoteFileRemoteIterator(result); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ | |
| import org.apache.doris.fsv2.remote.BrokerFileSystem; | ||
| import org.apache.doris.fsv2.remote.RemoteFileSystem; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| public class FileSystemFactory { | ||
|
|
@@ -52,6 +53,22 @@ public static RemoteFileSystem get(String name, Map<String, String> properties) | |
| return new BrokerFileSystem(name, properties); | ||
| } | ||
|
|
||
| public static RemoteFileSystem get(FileSystemType fileSystemType, Map<String, String> properties, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think in this class, we should only keep |
||
| String bindBrokerName) | ||
| throws UserException { | ||
| if (fileSystemType == FileSystemType.BROKER) { | ||
| return new BrokerFileSystem(bindBrokerName, properties); | ||
| } | ||
| List<StorageProperties> storagePropertiesList = StorageProperties.createAll(properties); | ||
|
|
||
| for (StorageProperties storageProperties : storagePropertiesList) { | ||
| if (storageProperties.getStorageName().equalsIgnoreCase(fileSystemType.name())) { | ||
| return StorageTypeMapper.create(storageProperties); | ||
| } | ||
| } | ||
| throw new RuntimeException("Unsupported file system type: " + fileSystemType); | ||
| } | ||
|
|
||
| public static RemoteFileSystem get(BrokerDesc brokerDesc) { | ||
| if (null != brokerDesc.getStorageProperties()) { | ||
| return get(brokerDesc.getStorageProperties()); | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still using a raw map?