From cc3ff57080c415b30cfba1b33874e200c49c53c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?alantong=28=E4=BD=9F=E6=98=8E=E8=BE=BE=29?= Date: Thu, 20 Jan 2022 18:55:21 +0800 Subject: [PATCH] alignment to inner version 8.0.2 --- pom.xml | 4 ++-- .../java/org/apache/hadoop/fs/CosNConfigKeys.java | 6 +++++- .../fs/auth/EMRInstanceCredentialsProvider.java | 15 ++++++++++++--- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 728cfd86..19d28250 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.qcloud.cos hadoop-cos - 8.0.1 + 8.0.2 jar Apache Hadoop Tencent Qcloud COS Support @@ -41,7 +41,7 @@ 1.7 1.7 3.3.0 - 5.6.62 + 5.6.65 24.1.1-jre 3.1 4.8 diff --git a/src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java b/src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java index 9b219fe4..87cbfb86 100644 --- a/src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java +++ b/src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java @@ -12,7 +12,7 @@ @InterfaceStability.Unstable public class CosNConfigKeys extends CommonConfigurationKeys { public static final String USER_AGENT = "fs.cosn.user.agent"; - public static final String DEFAULT_USER_AGENT = "cos-hadoop-plugin-v8.0.1"; + public static final String DEFAULT_USER_AGENT = "cos-hadoop-plugin-v8.0.2"; public static final String TENCENT_EMR_VERSION_KEY = "fs.emr.version"; @@ -125,4 +125,8 @@ public class CosNConfigKeys extends CommonConfigurationKeys { "org.apache.hadoop.fs.cosn.ranger.client.RangerQcloudObjectStorageClientImpl"; public static final String COSN_CLIENT_SOCKET_TIMEOUTSEC = "fs.cosn.client.socket.timeoutsec"; public static final int DEFAULT_CLIENT_SOCKET_TIMEOUTSEC = 30; + + // default disable emr v2 instance url. + public static final String COSN_EMRV2_INSTANCE_PROVIDER_ENABLED = "fs.cosn.emrv2.instance.provider.enabled"; + public static final boolean DEFAULT_COSN_EMRV2_INSTANCE_PROVIDER_ENABLED = false; } diff --git a/src/main/java/org/apache/hadoop/fs/auth/EMRInstanceCredentialsProvider.java b/src/main/java/org/apache/hadoop/fs/auth/EMRInstanceCredentialsProvider.java index 51ee16af..54e6903a 100644 --- a/src/main/java/org/apache/hadoop/fs/auth/EMRInstanceCredentialsProvider.java +++ b/src/main/java/org/apache/hadoop/fs/auth/EMRInstanceCredentialsProvider.java @@ -18,15 +18,24 @@ public class EMRInstanceCredentialsProvider extends AbstractCOSCredentialProvide private String appId; private final COSCredentialsProvider cosCredentialsProvider; + private boolean emrV2InstanceEnabled; public EMRInstanceCredentialsProvider(@Nullable URI uri, Configuration conf) { super(uri, conf); if (null != conf) { this.appId = conf.get(CosNConfigKeys.COSN_APPID_KEY); + this.emrV2InstanceEnabled = conf.getBoolean(CosNConfigKeys.COSN_EMRV2_INSTANCE_PROVIDER_ENABLED, + CosNConfigKeys.DEFAULT_COSN_EMRV2_INSTANCE_PROVIDER_ENABLED); + } + + InstanceMetadataCredentialsEndpointProvider endpointProvider; + if (emrV2InstanceEnabled) { + endpointProvider = new InstanceMetadataCredentialsEndpointProvider( + InstanceMetadataCredentialsEndpointProvider.Instance.EMRV2); + } else { + endpointProvider = new InstanceMetadataCredentialsEndpointProvider( + InstanceMetadataCredentialsEndpointProvider.Instance.EMR); } - InstanceMetadataCredentialsEndpointProvider endpointProvider = - new InstanceMetadataCredentialsEndpointProvider( - InstanceMetadataCredentialsEndpointProvider.Instance.EMR); InstanceCredentialsFetcher instanceCredentialsFetcher = new InstanceCredentialsFetcher(endpointProvider); this.cosCredentialsProvider = new InstanceCredentialsProvider(instanceCredentialsFetcher); }