cxzl25 commented on a change in pull request #1418:
URL: https://github.com/apache/incubator-kyuubi/pull/1418#discussion_r752921624
##########
File path:
kyuubi-ha/src/main/scala/org/apache/kyuubi/ha/client/ServiceDiscovery.scala
##########
@@ -205,6 +204,23 @@ object ServiceDiscovery extends Logging {
}
}
+ @VisibleForTesting
+ private[client] def parseInstanceHostPort(instance: String): (String, Int) =
{
+ val maybeInfos = instance.split(";")
+ .map(_.split("=", 2))
+ .filter(_.size == 2)
+ .map(i => (i(0), i(1)))
+ .toMap
+ if (maybeInfos.size > 0) {
+ (maybeInfos.get("hive.server2.thrift.bind.host").get,
+ maybeInfos.get("hive.server2.thrift.port").get.toInt)
+ } else {
+ val strings = instance.split(":")
+ (strings(0), strings(1).toInt)
+ }
+ }
+
+
Review comment:
LGTM
Hive uses regular expressions to be compatible.
https://issues.apache.org/jira/browse/HIVE-13326
org.apache.hive.jdbc.ZooKeeperHiveClientHelper#configureConnParams
```java
private static final Pattern kvPattern =
Pattern.compile("([^=;]*)=([^;]*)[;]?");
Matcher matcher = kvPattern.matcher(dataStr);
// If dataStr is not null and dataStr is not a KV pattern,
// it must be the server uri added by an older version HS2
if ((dataStr != null) && (!matcher.find())) {
String[] split = dataStr.split(":");
if (split.length != 2) {
throw new ZooKeeperHiveClientException("Unable to read HiveServer2
uri from ZooKeeper: "
+ dataStr);
}
connParams.setHost(split[0]);
connParams.setPort(Integer.parseInt(split[1]));
```
--
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]