yuqi1129 commented on code in PR #5806:
URL: https://github.com/apache/gravitino/pull/5806#discussion_r1897178299
##########
bundles/aws-bundle/src/main/java/org/apache/gravitino/s3/fs/S3FileSystemProvider.java:
##########
@@ -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) {
Review Comment:
Yeah, this change aims to make it work in hadoop 2.x
--
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]