-
Notifications
You must be signed in to change notification settings - Fork 383
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
[#5585] improvement(bundles): Refactor bundle jars and provide core jars that does not contains hadoop-{aws,gcp,aliyun,azure} #5806
Merged
Merged
Changes from 25 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
6be4e69
Refactor bundle jars and provide mini jars that does not contains had…
yuqi1129 e854f70
Fix build error.
yuqi1129 32be67a
fix
yuqi1129 b69a793
fix
yuqi1129 86e8c2e
fix
yuqi1129 4c04317
fix
yuqi1129 3abc788
Merge branch 'main' of github.com:apache/gravitino into fix_bundles_j…
yuqi1129 9a87b87
Merge branch 'main' of github.com:datastrato/graviton into fix_bundle…
yuqi1129 94179fa
Fix
yuqi1129 96b69e2
Merge branch 'main' of github.com:datastrato/graviton into fix_bundle…
yuqi1129 9d527cb
Fix
yuqi1129 cc65f17
Fix
yuqi1129 92b4539
Fix
yuqi1129 b876977
Fix
yuqi1129 0585df5
Merge branch 'main' of github.com:datastrato/graviton into fix_bundle…
yuqi1129 dc085ae
Fix
yuqi1129 6a0e87b
Fix
yuqi1129 b63a84e
Merge branch 'main' of github.com:datastrato/graviton into fix_bundle…
yuqi1129 e5a2083
fix
yuqi1129 df4884e
Merge branch 'main' of github.com:datastrato/graviton into fix_bundle…
yuqi1129 a78e4e8
optimize
yuqi1129 b7ca512
Rename bundle modules
yuqi1129 1f58642
fix
yuqi1129 742982c
polish again
yuqi1129 8c4386e
fix a minor mistake in docs
yuqi1129 9d0f57b
Merge branch 'main' of github.com:apache/gravitino into fix_bundles_j…
yuqi1129 258a328
Fix CI error.
yuqi1129 44e5807
Fix again.
yuqi1129 c4eac38
Fix again.
yuqi1129 bbefd00
Remove the newly added document as suggested.
yuqi1129 a9c1a29
Merge branch 'main' of github.com:datastrato/graviton into fix_bundle…
yuqi1129 1ee1dd1
fix docs
yuqi1129 1923707
fix
yuqi1129 3c6e20c
fix
yuqi1129 ac4b815
Fix again.
yuqi1129 d62f4c5
fix
yuqi1129 1e7abe4
fix
yuqi1129 af4bdd4
fix docs again
yuqi1129 0d7baf5
Fix a silly mistake in doc description.
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
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
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,58 @@ | ||
/* | ||
* 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. | ||
*/ | ||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar | ||
|
||
plugins { | ||
`maven-publish` | ||
id("java") | ||
alias(libs.plugins.shadow) | ||
} | ||
|
||
dependencies { | ||
implementation(project(":bundles:aliyun-bundle")) | ||
implementation(libs.commons.collections3) | ||
implementation(libs.hadoop3.client.api) | ||
implementation(libs.hadoop3.client.runtime) | ||
implementation(libs.hadoop3.oss) | ||
implementation(libs.httpclient) | ||
} | ||
|
||
tasks.withType(ShadowJar::class.java) { | ||
isZip64 = true | ||
configurations = listOf(project.configurations.runtimeClasspath.get()) | ||
archiveClassifier.set("") | ||
mergeServiceFiles() | ||
|
||
// Relocate dependencies to avoid conflicts | ||
relocate("org.jdom", "org.apache.gravitino.aliyun.shaded.org.jdom") | ||
relocate("org.apache.commons.lang3", "org.apache.gravitino.aliyun.shaded.org.apache.commons.lang3") | ||
relocate("com.fasterxml.jackson", "org.apache.gravitino.aliyun.shaded.com.fasterxml.jackson") | ||
relocate("com.google.common", "org.apache.gravitino.aliyun.shaded.com.google.common") | ||
relocate("org.apache.http", "org.apache.gravitino.aliyun.shaded.org.apache.http") | ||
relocate("org.apache.commons.collections", "org.apache.gravitino.aliyun.shaded.org.apache.commons.collections") | ||
} | ||
|
||
tasks.jar { | ||
dependsOn(tasks.named("shadowJar")) | ||
archiveClassifier.set("empty") | ||
} | ||
|
||
tasks.compileJava { | ||
dependsOn(":catalogs:catalog-hadoop:runtimeJars") | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,9 +19,14 @@ | |
|
||
package org.apache.gravitino.s3.fs; | ||
|
||
import com.amazonaws.auth.AWSCredentialsProvider; | ||
import com.google.common.annotations.VisibleForTesting; | ||
import com.google.common.base.Joiner; | ||
import com.google.common.base.Splitter; | ||
import com.google.common.collect.ImmutableMap; | ||
import com.google.common.collect.Lists; | ||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.apache.gravitino.catalog.hadoop.fs.FileSystemProvider; | ||
import org.apache.gravitino.catalog.hadoop.fs.FileSystemUtils; | ||
|
@@ -31,30 +36,81 @@ | |
import org.apache.hadoop.fs.Path; | ||
import org.apache.hadoop.fs.s3a.Constants; | ||
import org.apache.hadoop.fs.s3a.S3AFileSystem; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class S3FileSystemProvider implements FileSystemProvider { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(S3FileSystemProvider.class); | ||
|
||
@VisibleForTesting | ||
public static final Map<String, String> GRAVITINO_KEY_TO_S3_HADOOP_KEY = | ||
ImmutableMap.of( | ||
S3Properties.GRAVITINO_S3_ENDPOINT, Constants.ENDPOINT, | ||
S3Properties.GRAVITINO_S3_ACCESS_KEY_ID, Constants.ACCESS_KEY, | ||
S3Properties.GRAVITINO_S3_SECRET_ACCESS_KEY, Constants.SECRET_KEY); | ||
|
||
// We can't use Constants.AWS_CREDENTIALS_PROVIDER directly, as in 2.7, this key does not exist. | ||
private static final String S3_CREDENTIAL_KEY = "fs.s3a.aws.credentials.provider"; | ||
private static final String S3_SIMPLE_CREDENTIAL = | ||
"org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider"; | ||
|
||
@Override | ||
public FileSystem getFileSystem(Path path, Map<String, String> config) throws IOException { | ||
Configuration configuration = new Configuration(); | ||
Map<String, String> hadoopConfMap = | ||
FileSystemUtils.toHadoopConfigMap(config, GRAVITINO_KEY_TO_S3_HADOOP_KEY); | ||
|
||
if (!hadoopConfMap.containsKey(Constants.AWS_CREDENTIALS_PROVIDER)) { | ||
configuration.set( | ||
Constants.AWS_CREDENTIALS_PROVIDER, Constants.ASSUMED_ROLE_CREDENTIALS_DEFAULT); | ||
if (!hadoopConfMap.containsKey(S3_CREDENTIAL_KEY)) { | ||
hadoopConfMap.put(S3_CREDENTIAL_KEY, S3_SIMPLE_CREDENTIAL); | ||
} | ||
|
||
hadoopConfMap.forEach(configuration::set); | ||
|
||
// Hadoop-aws 2 does not support IAMInstanceCredentialsProvider | ||
checkAndSetCredentialProvider(configuration); | ||
|
||
return S3AFileSystem.newInstance(path.toUri(), configuration); | ||
} | ||
|
||
private void checkAndSetCredentialProvider(Configuration configuration) { | ||
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. Is it related to this PR? 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. Yeah, this change aims to make it work in hadoop 2.x |
||
String provides = configuration.get(S3_CREDENTIAL_KEY); | ||
if (provides == null) { | ||
return; | ||
} | ||
|
||
Splitter splitter = Splitter.on(',').trimResults().omitEmptyStrings(); | ||
Joiner joiner = Joiner.on(",").skipNulls(); | ||
// Split the list of providers | ||
List<String> providers = splitter.splitToList(provides); | ||
List<String> validProviders = Lists.newArrayList(); | ||
|
||
for (String provider : providers) { | ||
try { | ||
Class<?> c = Class.forName(provider); | ||
if (AWSCredentialsProvider.class.isAssignableFrom(c)) { | ||
validProviders.add(provider); | ||
} else { | ||
LOGGER.warn( | ||
"Credential provider {} is not a subclass of AWSCredentialsProvider, skipping", | ||
provider); | ||
} | ||
} catch (Exception e) { | ||
LOGGER.warn( | ||
"Credential provider {} not found in the Hadoop runtime, falling back to default", | ||
provider); | ||
configuration.set(S3_CREDENTIAL_KEY, S3_SIMPLE_CREDENTIAL); | ||
return; | ||
} | ||
} | ||
|
||
if (validProviders.isEmpty()) { | ||
configuration.set(S3_CREDENTIAL_KEY, S3_SIMPLE_CREDENTIAL); | ||
} else { | ||
configuration.set(S3_CREDENTIAL_KEY, joiner.join(validProviders)); | ||
} | ||
} | ||
|
||
/** | ||
* Get the scheme of the FileSystem. Attention, for S3 the schema is "s3a", not "s3". Users should | ||
* use "s3a://..." to access S3. | ||
|
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,51 @@ | ||
/* | ||
* 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. | ||
*/ | ||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar | ||
|
||
plugins { | ||
`maven-publish` | ||
id("java") | ||
alias(libs.plugins.shadow) | ||
} | ||
|
||
dependencies { | ||
implementation(project(":bundles:aws-bundle")) | ||
implementation(libs.hadoop3.aws) | ||
implementation(libs.hadoop3.client.api) | ||
implementation(libs.hadoop3.client.runtime) | ||
} | ||
|
||
tasks.withType(ShadowJar::class.java) { | ||
isZip64 = true | ||
configurations = listOf(project.configurations.runtimeClasspath.get()) | ||
archiveClassifier.set("") | ||
|
||
relocate("org.apache.commons.lang3", "org.apache.gravitino.aws.shaded.org.apache.commons.lang3") | ||
relocate("com.google.common", "org.apache.gravitino.aws.shaded.com.google.common") | ||
relocate("com.fasterxml.jackson", "org.apache.gravitino.aws.shaded.com.fasterxml.jackson") | ||
} | ||
|
||
tasks.jar { | ||
dependsOn(tasks.named("shadowJar")) | ||
archiveClassifier.set("empty") | ||
} | ||
|
||
tasks.compileJava { | ||
dependsOn(":catalogs:catalog-hadoop:runtimeJars") | ||
} |
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.
In theory, all modules under bundles do not need to copy dependencies.
Can we optimize the judgment condition here so that we can add sub-modules under bundles later without modifying this judgment condition?
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.
Use
endsWith("bundle")
orcontains("bundle")
?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.
how about
(it.parent?.name) != "bundles"
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.
Okay, I will take it.