deniskuzZ commented on code in PR #6024:
URL: https://github.com/apache/hive/pull/6024#discussion_r2285705649
##########
jdbc/src/java/org/apache/hive/jdbc/ZooKeeperHiveClientHelper.java:
##########
@@ -195,38 +200,33 @@ static void configureConnParams(JdbcConnectionParams
connParams) throws ZooKeepe
if (isZkHADynamicDiscoveryMode(connParams.getSessionVars())) {
configureConnParamsHA(connParams);
} else {
- CuratorFramework zooKeeperClient = null;
- try {
- zooKeeperClient = getZkClient(connParams);
-
+ try (CuratorFramework zooKeeperClient = getZkClient(connParams)) {
final List<String> serverHosts = getServerHosts(connParams,
zooKeeperClient);
-
if (serverHosts.isEmpty()) {
throw new ZooKeeperHiveClientException("No more HiveServer2 URIs
from ZooKeeper to attempt");
}
-
// Pick a server node randomly
final String serverNode =
serverHosts.get(ThreadLocalRandom.current().nextInt(serverHosts.size()));
-
updateParamsWithZKServerNode(connParams, zooKeeperClient, serverNode);
} catch (ZooKeeperHiveClientException zkhce) {
throw zkhce;
} catch (Exception e) {
throw new ZooKeeperHiveClientException("Unable to read HiveServer2
configs from ZooKeeper", e);
- } finally {
- if (zooKeeperClient != null) {
- zooKeeperClient.close();
- }
}
}
}
private static void configureConnParamsHA(JdbcConnectionParams connParams)
throws ZooKeeperHiveClientException {
try {
+
Configuration registryConf = new Configuration();
registryConf.set(HiveConf.ConfVars.HIVE_ZOOKEEPER_QUORUM.varname,
connParams.getZooKeeperEnsemble());
registryConf.set(HiveConf.ConfVars.HIVE_SERVER2_ACTIVE_PASSIVE_HA_REGISTRY_NAMESPACE.varname,
getZooKeeperNamespace(connParams));
+ Map<String, String> sessionVars = connParams.getSessionVars();
+
registryConf.setBoolean(HiveConf.ConfVars.HIVE_ZOOKEEPER_USE_KERBEROS.varname,
+ sessionVars.containsKey(JdbcConnectionParams.AUTH_PRINCIPAL) &&
Review Comment:
can we extract this condition into the helper method and reuse?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]