From d393603dea23306cd3f18f6dbd1cf14561d45bd0 Mon Sep 17 00:00:00 2001 From: Samir Ahmic Date: Thu, 7 Apr 2016 21:52:51 +0200 Subject: [PATCH] HBASE-15606 Limit creating zk connection in HBaseAdmin#getCompactionState() only to case when 'hbase:meta' is checked. Signed-off-by: stack --- .../org/apache/hadoop/hbase/client/HBaseAdmin.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java index aea86b99f2a..a900abd30d0 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java @@ -3017,12 +3017,12 @@ public class HBaseAdmin implements Admin { break; case NORMAL: default: - ZooKeeperWatcher zookeeper = - new ZooKeeperWatcher(conf, ZK_IDENTIFIER_PREFIX + connection.toString(), - new ThrowableAbortable()); + ZooKeeperWatcher zookeeper = null; try { List> pairs; if (TableName.META_TABLE_NAME.equals(tableName)) { + zookeeper = new ZooKeeperWatcher(conf, ZK_IDENTIFIER_PREFIX + connection.toString(), + new ThrowableAbortable()); pairs = new MetaTableLocator().getMetaRegionsAndLocations(zookeeper); } else { pairs = MetaTableAccessor.getTableRegionsAndLocations(connection, tableName); @@ -3074,7 +3074,9 @@ public class HBaseAdmin implements Admin { } catch (ServiceException se) { throw ProtobufUtil.getRemoteException(se); } finally { - zookeeper.close(); + if (zookeeper != null) { + zookeeper.close(); + } } break; }