Copilot commented on code in PR #11455:
URL: https://github.com/apache/gravitino/pull/11455#discussion_r3361413026
##########
catalogs/hive-metastore-common/src/main/java/org/apache/gravitino/hive/client/Util.java:
##########
@@ -41,8 +50,38 @@ public static void updateConfigurationFromProperties(
}
properties.forEach((k, v) -> config.set(k.toString(), v.toString()));
+ resolveMetastoreUriHosts(config);
} catch (Exception e) {
throw new RuntimeException("Failed to create configuration", e);
}
}
+
+ // Pre-resolve to IP so Hive's resolveUris() doesn't receive Docker FQDNs
with underscores.
+ private static void resolveMetastoreUriHosts(Configuration config) {
+ String urisValue = config.get(HIVE_METASTORE_URIS);
+ if (StringUtils.isBlank(urisValue)) {
+ return;
+ }
+ String resolved =
+ Arrays.stream(urisValue.split(","))
+ .map(uri -> resolveUriHost(uri.trim()))
+ .collect(Collectors.joining(","));
+ config.set(HIVE_METASTORE_URIS, resolved);
+ }
+
+ private static String resolveUriHost(String uriStr) {
+ try {
+ URI uri = new URI(uriStr);
+ String host = uri.getHost();
+ if (StringUtils.isBlank(host)) {
+ return uriStr;
+ }
+ String ip = InetAddress.getByName(host).getHostAddress();
+ return new URI(uri.getScheme(), null, ip, uri.getPort(), uri.getPath(),
null, null)
+ .toString();
Review Comment:
resolveUriHost() rebuilds the URI but drops user-info, query, and fragment
(passing nulls), so any metastore URI containing those components would be
silently altered. Since the intent is only to replace the host, preserve all
URI components when reconstructing the URI.
##########
catalogs/hive-metastore-common/src/main/java/org/apache/gravitino/hive/client/Util.java:
##########
@@ -18,14 +18,23 @@
*/
package org.apache.gravitino.hive.client;
+import java.net.InetAddress;
+import java.net.URI;
+import java.util.Arrays;
import java.util.Properties;
+import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class Util {
+ private static final Logger LOG = LoggerFactory.getLogger(Util.class);
+
public static final String HIVE_CONFIG_RESOURCES = "hive.config.resources";
+ private static final String HIVE_METASTORE_URIS = "hive.metastore.uris";
Review Comment:
Util duplicates the Hive metastore URI key string even though the codebase
already defines HiveConstants.HIVE_METASTORE_URIS (and this module already uses
it in HiveClientFactory). Reusing the shared constant avoids drift if the key
ever changes and keeps the code consistent.
--
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]