morningman commented on code in PR #15026:
URL: https://github.com/apache/doris/pull/15026#discussion_r1046671355


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/HMSExternalCatalog.java:
##########
@@ -91,8 +97,32 @@ protected void init() {
     @Override
     protected void initLocalObjectsImpl() {
         HiveConf hiveConf = new HiveConf();
-        hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS, 
getHiveMetastoreUris());
+        for (String key : catalogProperty.getHdfsProperties().keySet()) {
+            String val = catalogProperty.getOrDefault(key, "");
+            hiveConf.set(key, val);
+        }
 
+        String authentication = catalogProperty.getOrDefault(
+                HdfsResource.HADOOP_SECURITY_AUTHENTICATION, "");
+        if (AuthType.KERBEROS.getDesc().equals(authentication)) {
+            Configuration conf = new Configuration();
+            conf.set(HdfsResource.HADOOP_SECURITY_AUTHENTICATION, 
authentication);
+            UserGroupInformation.setConfiguration(conf);
+            final UserGroupInformation ugi;
+            try {
+                /**
+                 * Because metastore client is created by using
+                 * {@link 
org.apache.hadoop.hive.metastore.RetryingMetaStoreClient#getProxy}
+                 * it will relogin when TGT is expired, so we don't need to 
relogin manually.
+                 */
+                ugi = UserGroupInformation.loginUserFromKeytabAndReturnUGI(
+                    
catalogProperty.getOrDefault(HdfsResource.HADOOP_KERBEROS_PRINCIPAL, ""),
+                    
catalogProperty.getOrDefault(HdfsResource.HADOOP_KERBEROS_KEYTAB, ""));
+                UserGroupInformation.setLoginUser(ugi);

Review Comment:
   Looks like no need to call `setLoginUser()`? Because 
`loginUserFromKeytabAndReturnUGI()` already set the current login user.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to