You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/12/13 05:25:19 UTC

[GitHub] [doris] morningman commented on a diff in pull request #15026: [feature](multi-catalog) support connecting to hive metastore with ke…

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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org