From 879ab1b8fbbf26104184fb2d707b53fcff894df3 Mon Sep 17 00:00:00 2001 From: Zhihong Yu Date: Fri, 16 Sep 2011 19:04:12 +0000 Subject: [PATCH] HBASE-4417 HBaseAdmin.checkHBaseAvailable() doesn't close ZooKeeper connections (Stefan Seelmann) git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1171734 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 2 ++ .../org/apache/hadoop/hbase/client/HBaseAdmin.java | 7 ++++++- .../org/apache/hadoop/hbase/client/TestAdmin.java | 11 +++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 31e7583e1b4..b024cd78224 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -275,6 +275,8 @@ Release 0.91.0 - Unreleased HBASE-4322 HBASE-4322 [hbck] Update checkIntegrity/checkRegionChain to present more accurate region split problem (Jon Hseih) + HBASE-4417 HBaseAdmin.checkHBaseAvailable() doesn't close ZooKeeper connections + (Stefan Seelmann) IMPROVEMENTS HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack) diff --git a/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java b/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java index 7805f1c16be..f2abc5926e0 100644 --- a/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java +++ b/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java @@ -1576,7 +1576,12 @@ public class HBaseAdmin implements Abortable, Closeable { throws MasterNotRunningException, ZooKeeperConnectionException { Configuration copyOfConf = HBaseConfiguration.create(conf); copyOfConf.setInt("hbase.client.retries.number", 1); - new HBaseAdmin(copyOfConf); + HBaseAdmin admin = new HBaseAdmin(copyOfConf); + try { + admin.close(); + } catch (IOException ioe) { + admin.LOG.info("Failed to close connection", ioe); + } } /** diff --git a/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java b/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java index b7633868261..4d7ee22277e 100644 --- a/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java +++ b/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java @@ -1268,4 +1268,15 @@ public class TestAdmin { return regionServer; } + /** + * HBASE-4417 checkHBaseAvailable() doesn't close zk connections + */ + @Test + public void testCheckHBaseAvailableClosesConnection() throws Exception { + Configuration conf = TEST_UTIL.getConfiguration(); + for(int i=0; i<1000;i++) { + HBaseAdmin.checkHBaseAvailable(conf); + } + } + }