yzeng1618 commented on code in PR #10253:
URL: https://github.com/apache/seatunnel/pull/10253#discussion_r2655332169
##########
seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveMetaStoreCatalog.java:
##########
@@ -255,13 +319,39 @@ private HiveMetaStoreClient loginWithKerberos(HiveConf
hiveConf) throws Exceptio
keytabPath,
(conf, ugi) -> {
this.userGroupInformation = ugi;
- return new HiveMetaStoreClient(hiveConf);
+ return createClient(hiveConf);
});
}
- private HiveMetaStoreClient loginWithRemoteUser(HiveConf hiveConf) throws
Exception {
+ private IMetaStoreClient loginWithRemoteUser(HiveConf hiveConf) throws
Exception {
return HadoopLoginFactory.loginWithRemoteUser(
- new Configuration(), remoteUser, (conf, ugi) -> new
HiveMetaStoreClient(hiveConf));
+ new Configuration(), remoteUser, (conf, ugi) ->
createClient(hiveConf));
+ }
+
+ private static String normalizeMetastoreUris(String metastoreUri) {
+ if (metastoreUri == null) {
+ return null;
+ }
+ String[] uris = metastoreUri.split(",");
+ List<String> cleaned = new ArrayList<>(uris.length);
+ for (String uri : uris) {
+ String trimmed = uri.trim();
+ if (!trimmed.isEmpty()) {
+ cleaned.add(trimmed);
+ }
+ }
+ return String.join(",", cleaned);
+ }
+
+ private static String getFirstMetastoreUri(String metastoreUri) {
+ if (metastoreUri == null) {
+ return null;
+ }
+ int commaIndex = metastoreUri.indexOf(',');
+ if (commaIndex < 0) {
+ return metastoreUri.trim();
+ }
+ return metastoreUri.substring(0, commaIndex).trim();
Review Comment:
Thank you for your suggestions. We have made the revisions.
##########
seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveMetaStoreCatalog.java:
##########
@@ -136,6 +140,65 @@ private HiveMetaStoreClient initializeClient() {
}
}
+ private IMetaStoreClient createClient(HiveConf hiveConf) throws Exception {
+ IMetaStoreClient retryingClient = tryCreateRetryingClient(hiveConf);
+ if (retryingClient != null) {
+ return retryingClient;
+ }
+ return new HiveMetaStoreClient(hiveConf);
+ }
+
+ private IMetaStoreClient tryCreateRetryingClient(HiveConf hiveConf) {
+ try {
+ Class<?> clazz =
Class.forName(RETRYING_METASTORE_CLIENT_CLASS_NAME);
+ Method getProxyMethod = getProxyMethod(clazz);
+ if (getProxyMethod == null) {
+ log.warn(
+ "RetryingMetaStoreClient found but no compatible
getProxy method, falling back to HiveMetaStoreClient");
+ return null;
+ }
+
+ Object proxy = getProxyMethod.invoke(null, hiveConf, true);
+ if (proxy instanceof IMetaStoreClient) {
+ log.info(
+ "Using RetryingMetaStoreClient for Hive metastore
connection [uris={}]",
+ hiveConf.get("hive.metastore.uris"));
+ return (IMetaStoreClient) proxy;
+ }
+ log.warn(
+ "RetryingMetaStoreClient found but no compatible getProxy
method, falling back to HiveMetaStoreClient");
Review Comment:
Thank you for your suggestions. We have made the revisions.
--
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]