Hisoka-X commented on code in PR #9282:
URL: https://github.com/apache/seatunnel/pull/9282#discussion_r2078784984


##########
seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveMetaStoreProxy.java:
##########
@@ -32,125 +32,129 @@
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
 import org.apache.hadoop.hive.metastore.api.AlreadyExistsException;
-import org.apache.hadoop.hive.metastore.api.MetaException;
 import org.apache.hadoop.hive.metastore.api.Table;
 import org.apache.thrift.TException;
 
 import lombok.NonNull;
 import lombok.extern.slf4j.Slf4j;
 
+import java.io.Closeable;
 import java.io.File;
 import java.io.IOException;
+import java.io.Serializable;
 import java.net.MalformedURLException;
 import java.nio.file.Files;
+import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.List;
 import java.util.Objects;
 
 @Slf4j
-public class HiveMetaStoreProxy {
-    private HiveMetaStoreClient hiveMetaStoreClient;
-    private static volatile HiveMetaStoreProxy INSTANCE = null;
+public class HiveMetaStoreProxy implements Closeable, Serializable {
     private static final List<String> HADOOP_CONF_FILES = 
ImmutableList.of("hive-site.xml");
 
-    private HiveMetaStoreProxy(ReadonlyConfig readonlyConfig) {
-        String metastoreUri = readonlyConfig.get(HiveOptions.METASTORE_URI);
-        String hiveHadoopConfigPath = 
readonlyConfig.get(HiveConfig.HADOOP_CONF_PATH);
-        String hiveSitePath = readonlyConfig.get(HiveConfig.HIVE_SITE_PATH);
-        HiveConf hiveConf = new HiveConf();
-        hiveConf.set("hive.metastore.uris", metastoreUri);
-        try {
-            if (StringUtils.isNotBlank(hiveHadoopConfigPath)) {
-                HADOOP_CONF_FILES.forEach(
-                        confFile -> {
-                            java.nio.file.Path path = 
Paths.get(hiveHadoopConfigPath, confFile);
-                            if (Files.exists(path)) {
-                                try {
-                                    hiveConf.addResource(path.toUri().toURL());
-                                } catch (IOException e) {
-                                    log.warn(
-                                            "Error adding Hadoop resource {}, 
resource was not added",
-                                            path,
-                                            e);
-                                }
-                            }
-                        });
-            }
+    private final String metastoreUri;
+    private final String hadoopConfDir;
+    private final String hiveSitePath;
+    private final boolean kerberosEnabled;
+    private final boolean remoteUserEnabled;
 
-            if (StringUtils.isNotBlank(hiveSitePath)) {
-                hiveConf.addResource(new File(hiveSitePath).toURI().toURL());
-            }
+    private final String krb5Path;
+    private final String principal;
+    private final String keytabPath;
+    private final String remoteUser;
 
-            log.info("hive client conf:{}", hiveConf);
-            if (HiveMetaStoreProxyUtils.enableKerberos(readonlyConfig)) {
-                // login Kerberos
-                Configuration authConf = new Configuration();
-                authConf.set("hadoop.security.authentication", "kerberos");
-                this.hiveMetaStoreClient =
-                        HadoopLoginFactory.loginWithKerberos(
-                                authConf,
-                                
readonlyConfig.get(HdfsSourceConfigOptions.KRB5_PATH),
-                                
readonlyConfig.get(HdfsSourceConfigOptions.KERBEROS_PRINCIPAL),
-                                
readonlyConfig.get(HdfsSourceConfigOptions.KERBEROS_KEYTAB_PATH),
-                                (conf, userGroupInformation) -> {
-                                    return new HiveMetaStoreClient(hiveConf);
-                                });
-                return;
+    private HiveMetaStoreClient hiveClient;

Review Comment:
   ```suggestion
       private transient HiveMetaStoreClient hiveClient;
   ```



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

Reply via email to