FAQ
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
+ }
+ }
      }
    }
-
  }

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
groupcommits @
categorieshive, hadoop
postedOct 26, '14 at 11:54p
activeOct 26, '14 at 11:54p
posts1
users1
websitehive.apache.org

1 user in discussion

Vgumashta: 1 post

People

Translate

site design / logo © 2021 Grokbase