You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by vg...@apache.org on 2014/10/27 00:53:48 UTC
svn commit: r1634409 -
/hive/branches/branch-0.14/jdbc/src/java/org/apache/hive/jdbc/ZooKeeperHiveClientHelper.java
Author: vgumashta
Date: Sun Oct 26 23:53:48 2014
New Revision: 1634409
URL: http://svn.apache.org/r1634409
Log:
HIVE-8596: HiveServer2 dynamic service discovery: ZK throws too many connections error (Vaibhav Gumashta reviewed by Thejas Nair)
Modified:
hive/branches/branch-0.14/jdbc/src/java/org/apache/hive/jdbc/ZooKeeperHiveClientHelper.java
Modified: hive/branches/branch-0.14/jdbc/src/java/org/apache/hive/jdbc/ZooKeeperHiveClientHelper.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/jdbc/src/java/org/apache/hive/jdbc/ZooKeeperHiveClientHelper.java?rev=1634409&r1=1634408&r2=1634409&view=diff
==============================================================================
--- hive/branches/branch-0.14/jdbc/src/java/org/apache/hive/jdbc/ZooKeeperHiveClientHelper.java (original)
+++ hive/branches/branch-0.14/jdbc/src/java/org/apache/hive/jdbc/ZooKeeperHiveClientHelper.java Sun Oct 26 23:53:48 2014
@@ -59,9 +59,10 @@ public class ZooKeeperHiveClientHelper {
List<String> serverHosts;
Random randomizer = new Random();
String serverNode;
+ ZooKeeper zooKeeperClient = null;
// Pick a random HiveServer2 host from the ZooKeeper namspace
try {
- ZooKeeper zooKeeperClient =
+ zooKeeperClient =
new ZooKeeper(zooKeeperEnsemble, JdbcConnectionParams.ZOOKEEPER_SESSION_TIMEOUT,
new ZooKeeperHiveClientHelper.DummyWatcher());
// All the HiveServer2 host nodes that are in ZooKeeper currently
@@ -83,7 +84,15 @@ public class ZooKeeperHiveClientHelper {
return serverUri;
} catch (Exception e) {
throw new ZooKeeperHiveClientException("Unable to read HiveServer2 uri from ZooKeeper", e);
+ } finally {
+ // Try to close the client connection with ZooKeeper
+ if (zooKeeperClient != null) {
+ try {
+ zooKeeperClient.close();
+ } catch (Exception e) {
+ // No-op
+ }
+ }
}
}
-
}