-
Notifications
You must be signed in to change notification settings - Fork 304
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
[#5019] feat: (hadoop-catalog): Add a framework to support multi-storage in a pluginized manner for fileset catalog #5020
Open
yuqi1129
wants to merge
14
commits into
apache:main
Choose a base branch
from
yuqi1129:issue_5019
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d2447a2
Add a framework to support multi-storage in a pluginized manner for …
yuqi1129 7e5a8b5
Fix compile distribution error.
yuqi1129 f53c5ef
fix
yuqi1129 36fedcd
fix
yuqi1129 e93fba5
fix
yuqi1129 b1e04b6
fix
yuqi1129 db00e65
Changed according to comments.
yuqi1129 c793582
fix
yuqi1129 013f5cb
fix
yuqi1129 dba5753
Merge branch 'main' of github.com:datastrato/graviton into issue_5019
yuqi1129 16dfc73
resolve comments.
yuqi1129 278fcd8
Polish code.
yuqi1129 3fb55ad
fix
yuqi1129 cd04666
fix
yuqi1129 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 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
50 changes: 50 additions & 0 deletions
50
.../catalog-hadoop/src/main/java/org/apache/gravitino/catalog/hadoop/FileSystemProvider.java
This file contains 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,50 @@ | ||
/* | ||
* 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.gravitino.catalog.hadoop; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
import org.apache.hadoop.fs.FileSystem; | ||
|
||
public interface FileSystemProvider { | ||
|
||
/** | ||
* Get the FileSystem instance according to the configuration and the path. | ||
* | ||
* <p>Compared to the FileSystem.get method, this method allows the provider to create a | ||
* FileSystem instance with a specific configuration and path and do further initialization if | ||
* needed. | ||
* | ||
* <p>For example, we can check endpoint configurations for S3AFileSystem, or set the default one. | ||
* | ||
* @param config The configuration for the FileSystem instance. | ||
* @return The FileSystem instance. | ||
* @throws IOException If the FileSystem instance cannot be created. | ||
*/ | ||
FileSystem getFileSystem(Map<String, String> config) throws IOException; | ||
|
||
/** | ||
* Get the scheme of this FileSystem provider. file for LocalFileSystem, hdfs for HDFS, s3a for | ||
* S3AFileSystem, etc. | ||
* | ||
* @return The scheme of this FileSystem provider. | ||
*/ | ||
String getScheme(); | ||
} |
This file contains 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 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
76 changes: 76 additions & 0 deletions
76
...g-hadoop/src/main/java/org/apache/gravitino/catalog/hadoop/fs/HDFSFileSystemProvider.java
This file contains 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,76 @@ | ||
/* | ||
* 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.gravitino.catalog.hadoop.fs; | ||
|
||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.util.Map; | ||
import org.apache.gravitino.catalog.hadoop.FileSystemProvider; | ||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.fs.FileSystem; | ||
import org.apache.hadoop.fs.Path; | ||
|
||
public class HDFSFileSystemProvider implements FileSystemProvider { | ||
|
||
@Override | ||
public FileSystem getFileSystem(Map<String, String> config) throws IOException { | ||
Configuration configuration = new Configuration(); | ||
config.forEach(configuration::set); | ||
|
||
String pathString = configuration.get("fs.defaultFS"); | ||
if (pathString == null) { | ||
throw new IllegalArgumentException("The path should be specified."); | ||
} | ||
|
||
URI uri = new Path(pathString).toUri(); | ||
if (uri.getScheme() != null && !uri.getScheme().equals("hdfs")) { | ||
throw new IllegalArgumentException("The path should be a HDFS path."); | ||
} | ||
|
||
// Should we call DistributedFileSystem to create file system instance explicitly? If we | ||
// explicitly create a HDFS file system here, we can't reuse the file system cache in the | ||
// FileSystem class. | ||
String impl = configuration.get("fs.hdfs.impl"); | ||
if (impl == null) { | ||
configuration.set("fs.hdfs.impl", "org.apache.hadoop.hdfs.DistributedFileSystem"); | ||
} else { | ||
if (!impl.equals("org.apache.hadoop.hdfs.DistributedFileSystem")) { | ||
throw new IllegalArgumentException( | ||
"The HDFS file system implementation class should be 'org.apache.hadoop.hdfs.DistributedFileSystem'."); | ||
} | ||
} | ||
|
||
try { | ||
if (HDFSFileSystemProvider.class.getClassLoader().loadClass(configuration.get("fs.hdfs.impl")) | ||
== null) { | ||
throw new IllegalArgumentException( | ||
"The HDFS file system implementation class is not found."); | ||
} | ||
} catch (ClassNotFoundException e) { | ||
throw new IllegalArgumentException("The HDFS file system implementation class is not found."); | ||
} | ||
|
||
return FileSystem.get(uri, configuration); | ||
} | ||
|
||
@Override | ||
public String getScheme() { | ||
return "hdfs"; | ||
} | ||
} |
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.
The initialization of Hadoop conf here seems to be useless. It's better to move these codes above into the
DefaultConfigurationProvider
.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.
Yeah, you are right, I will do it according to your suggestion.