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; break;
case NORMAL: case NORMAL:
default: default:
ZooKeeperWatcher zookeeper = ZooKeeperWatcher zookeeper = null;
new ZooKeeperWatcher(conf, ZK_IDENTIFIER_PREFIX + connection.toString(),
new ThrowableAbortable());
try { try {
List<Pair<HRegionInfo, ServerName>> pairs; List<Pair<HRegionInfo, ServerName>> pairs;
if (TableName.META_TABLE_NAME.equals(tableName)) { if (TableName.META_TABLE_NAME.equals(tableName)) {
zookeeper = new ZooKeeperWatcher(conf, ZK_IDENTIFIER_PREFIX + connection.toString(),
new ThrowableAbortable());
pairs = new MetaTableLocator().getMetaRegionsAndLocations(zookeeper); pairs = new MetaTableLocator().getMetaRegionsAndLocations(zookeeper);
} else { } else {
pairs = MetaTableAccessor.getTableRegionsAndLocations(connection, tableName); pairs = MetaTableAccessor.getTableRegionsAndLocations(connection, tableName);
@ -3074,7 +3074,9 @@ public class HBaseAdmin implements Admin {
} catch (ServiceException se) { } catch (ServiceException se) {
throw ProtobufUtil.getRemoteException(se); throw ProtobufUtil.getRemoteException(se);
} finally { } finally {
zookeeper.close(); if (zookeeper != null) {
zookeeper.close();
}
} }
break; break;
} }