HBASE-15606 Limit creating zk connection in HBaseAdmin#getCompactionState() only to case when 'hbase:meta' is checked.

Signed-off-by: stack <stack@apache.org>
This commit is contained in:
Samir Ahmic 2016-04-07 21:52:51 +02:00 committed by stack
parent ac8cd373eb
commit d393603dea
1 changed files with 6 additions and 4 deletions

View File

@ -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<Pair<HRegionInfo, ServerName>> 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;
}