Skip to content

Commit ef2c200

Browse files
branch-3.1: [chore](param-refactor)Optimize catalog parameter handling and add Hive hadoop.username mapping apache#54551 (apache#54753)
Cherry-picked from apache#54551 Co-authored-by: Calvin Kirs <[email protected]>
1 parent 9405263 commit ef2c200

File tree

15 files changed

+31
-19
lines changed

15 files changed

+31
-19
lines changed

fe/fe-common/src/main/java/org/apache/doris/common/security/authentication/AuthenticationConfig.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ public abstract class AuthenticationConfig {
3030
public static String HADOOP_USER_NAME = "hadoop.username";
3131
public static String HADOOP_KERBEROS_PRINCIPAL = "hadoop.kerberos.principal";
3232
public static String HADOOP_KERBEROS_KEYTAB = "hadoop.kerberos.keytab";
33-
public static String HIVE_KERBEROS_PRINCIPAL = "hive.metastore.kerberos.principal";
34-
public static String HIVE_KERBEROS_KEYTAB = "hive.metastore.kerberos.keytab.file";
33+
public static String HADOOP_SECURITY_AUTH_TO_LOCAL = "hadoop.security.auth_to_local";
3534
public static String DORIS_KRB5_DEBUG = "doris.krb5.debug";
3635
private static final String DEFAULT_HADOOP_USERNAME = "hadoop";
3736

fe/fe-core/src/main/java/org/apache/doris/datasource/property/metastore/AWSGlueMetaStoreBaseProperties.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public class AWSGlueMetaStoreBaseProperties {
7373
public static AWSGlueMetaStoreBaseProperties of(Map<String, String> properties) {
7474
AWSGlueMetaStoreBaseProperties propertiesObj = new AWSGlueMetaStoreBaseProperties();
7575
ConnectorPropertiesUtils.bindConnectorProperties(propertiesObj, properties);
76+
propertiesObj.checkAndInit();
7677
return propertiesObj;
7778
}
7879

@@ -102,7 +103,7 @@ private ParamRules buildRules() {
102103
.require(glueEndpoint, "glue.endpoint or aws.endpoint or aws.glue.endpoint is required");
103104
}
104105

105-
public void checkAndInit() {
106+
private void checkAndInit() {
106107
buildRules().validate();
107108

108109
Matcher matcher = ENDPOINT_PATTERN.matcher(glueEndpoint.toLowerCase());

fe/fe-core/src/main/java/org/apache/doris/datasource/property/metastore/AWSGlueMetaStoreProperties.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ public AWSGlueMetaStoreProperties(Map<String, String> origProps) {
4242
public void initNormalizeAndCheckProps() {
4343
super.initNormalizeAndCheckProps();
4444
baseProperties = AWSGlueMetaStoreBaseProperties.of(origProps);
45-
baseProperties.checkAndInit();
4645
}
4746

4847

fe/fe-core/src/main/java/org/apache/doris/datasource/property/metastore/AliyunDLFBaseProperties.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public class AliyunDLFBaseProperties {
4343
protected String dlfSessionToken = "";
4444

4545
@ConnectorProperty(names = {"dlf.region"},
46+
required = false,
4647
description = "The region of the Aliyun DLF.")
4748
protected String dlfRegion = "";
4849

@@ -84,7 +85,7 @@ private ParamRules buildRules() {
8485
.require(dlfSecretKey, "dlf.secret_key is required");
8586
}
8687

87-
public void checkAndInit() {
88+
private void checkAndInit() {
8889
buildRules().validate();
8990
if (StringUtils.isBlank(dlfEndpoint) && StringUtils.isNotBlank(dlfRegion)) {
9091
if (BooleanUtils.toBoolean(dlfAccessPublic)) {

fe/fe-core/src/main/java/org/apache/doris/datasource/property/metastore/HMSBaseProperties.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,15 @@ public class HMSBaseProperties {
6868

6969
@ConnectorProperty(names = {"hadoop.security.authentication"},
7070
required = false,
71-
description = "The authentication type of HDFS. The default value is 'none'.")
71+
description = "The authentication type of HDFS. The default value is 'simple'.")
7272
private String hdfsAuthenticationType = "";
7373

74+
@ConnectorProperty(names = {"hive.metastore.username", "hadoop.username"},
75+
required = false,
76+
description = "The user name for the Hive Metastore service. "
77+
+ "If not set, it will use the 'hadoop'.")
78+
private String hmsUserName;
79+
7480
@ConnectorProperty(names = {"hadoop.kerberos.principal"},
7581
required = false,
7682
description = "The principal of the kerberos authentication.")
@@ -98,6 +104,7 @@ public HMSBaseProperties(Map<String, String> origProps) {
98104
public static HMSBaseProperties of(Map<String, String> properties) {
99105
HMSBaseProperties propertiesObj = new HMSBaseProperties(properties);
100106
ConnectorPropertiesUtils.bindConnectorProperties(propertiesObj, properties);
107+
propertiesObj.checkAndInit();
101108
return propertiesObj;
102109
}
103110

@@ -137,6 +144,10 @@ private void initHadoopAuthenticator() {
137144
if (StringUtils.isNotBlank(hiveMetastoreServicePrincipal)) {
138145
hiveConf.set("hive.metastore.kerberos.principal", hiveMetastoreServicePrincipal);
139146
}
147+
if (StringUtils.isNotBlank(origProps.get(AuthenticationConfig.HADOOP_SECURITY_AUTH_TO_LOCAL))) {
148+
hiveConf.set(AuthenticationConfig.HADOOP_SECURITY_AUTH_TO_LOCAL,
149+
origProps.get(AuthenticationConfig.HADOOP_SECURITY_AUTH_TO_LOCAL));
150+
}
140151
if (this.hiveMetastoreAuthenticationType.equalsIgnoreCase("kerberos")) {
141152
hiveConf.set("hadoop.security.authentication", "kerberos");
142153
KerberosAuthenticationConfig authenticationConfig = new KerberosAuthenticationConfig(
@@ -169,12 +180,15 @@ private HiveConf loadHiveConfFromFile(String resourceConfig) {
169180
return CatalogConfigFileUtils.loadHiveConfFromHiveConfDir(resourceConfig);
170181
}
171182

172-
public void initAndCheckParams() {
183+
private void checkAndInit() {
173184
buildRules().validate();
174185
this.hiveConf = loadHiveConfFromFile(hiveConfResourcesConfig);
175186
initUserHiveConfig(origProps);
176187
userOverriddenHiveConfig.forEach(hiveConf::set);
177188
hiveConf.set("hive.metastore.uris", hiveMetastoreUri);
189+
if (StringUtils.isNotBlank(hmsUserName)) {
190+
hiveConf.set(AuthenticationConfig.HADOOP_USER_NAME, hmsUserName);
191+
}
178192
HiveConf.setVar(hiveConf, HiveConf.ConfVars.METASTORE_CLIENT_SOCKET_TIMEOUT,
179193
String.valueOf(Config.hive_metastore_client_timeout_second));
180194
initHadoopAuthenticator();

fe/fe-core/src/main/java/org/apache/doris/datasource/property/metastore/HMSGlueMetaStoreProperties.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ protected HMSGlueMetaStoreProperties(Type type, Map<String, String> origProps) {
8686
public void initNormalizeAndCheckProps() {
8787
super.initNormalizeAndCheckProps();
8888
baseProperties = AWSGlueMetaStoreBaseProperties.of(origProps);
89-
baseProperties.checkAndInit();
9089
initHiveConf();
9190
}
9291

fe/fe-core/src/main/java/org/apache/doris/datasource/property/metastore/HMSProperties.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ public void initNormalizeAndCheckProps() {
5555
super.initNormalizeAndCheckProps();
5656
initRefreshParams();
5757
hmsBaseProperties = HMSBaseProperties.of(origProps);
58-
hmsBaseProperties.initAndCheckParams();
5958
this.hiveConf = hmsBaseProperties.getHiveConf();
6059
this.executionAuthenticator = new HadoopExecutionAuthenticator(hmsBaseProperties.getHmsAuthenticator());
6160
}
@@ -66,6 +65,4 @@ private void initRefreshParams() {
6665
this.hmsEventsBatchSizePerRpc = hmsEventisBatchSizePerRpcInput;
6766
}
6867

69-
70-
7168
}

fe/fe-core/src/main/java/org/apache/doris/datasource/property/metastore/IcebergGlueMetaStoreProperties.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,16 @@ public String getIcebergCatalogType() {
5454
public void initNormalizeAndCheckProps() {
5555
super.initNormalizeAndCheckProps();
5656
glueProperties = AWSGlueMetaStoreBaseProperties.of(origProps);
57-
glueProperties.checkAndInit();
5857
s3Properties = S3Properties.of(origProps);
59-
s3Properties.initNormalizeAndCheckProps();
6058
}
6159

6260
@Override
6361
public Catalog initializeCatalog(String catalogName, List<StorageProperties> storageProperties) {
6462
Map<String, String> props = prepareBaseCatalogProps();
6563
appendS3Props(props);
6664
appendGlueProps(props);
67-
6865
props.put("client.region", glueProperties.glueRegion);
6966

70-
7167
if (StringUtils.isNotBlank(warehouse)) {
7268
props.put(CatalogProperties.WAREHOUSE_LOCATION, warehouse);
7369
} else {

fe/fe-core/src/main/java/org/apache/doris/datasource/property/metastore/IcebergHMSMetaStoreProperties.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ public String getIcebergCatalogType() {
5959
public void initNormalizeAndCheckProps() {
6060
super.initNormalizeAndCheckProps();
6161
hmsBaseProperties = HMSBaseProperties.of(origProps);
62-
hmsBaseProperties.initAndCheckParams();
6362
this.executionAuthenticator = new HadoopExecutionAuthenticator(hmsBaseProperties.getHmsAuthenticator());
6463
}
6564

fe/fe-core/src/main/java/org/apache/doris/datasource/property/metastore/IcebergS3TablesMetaStoreProperties.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public String getIcebergCatalogType() {
4848
public void initNormalizeAndCheckProps() {
4949
super.initNormalizeAndCheckProps();
5050
s3Properties = S3Properties.of(origProps);
51-
s3Properties.initNormalizeAndCheckProps();
5251
}
5352

5453
@Override

0 commit comments

Comments
 (0)