HBASE-10995 Fix resource leak related to unclosed HBaseAdmin
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1587966 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
224aab57a0
commit
d177b9b9a2
|
@ -2722,11 +2722,21 @@ public class HBaseFsck extends Configured {
|
||||||
|
|
||||||
HTableDescriptor[] getHTableDescriptors(List<TableName> tableNames) {
|
HTableDescriptor[] getHTableDescriptors(List<TableName> tableNames) {
|
||||||
HTableDescriptor[] htd = new HTableDescriptor[0];
|
HTableDescriptor[] htd = new HTableDescriptor[0];
|
||||||
|
HBaseAdmin admin = null;
|
||||||
try {
|
try {
|
||||||
LOG.info("getHTableDescriptors == tableNames => " + tableNames);
|
LOG.info("getHTableDescriptors == tableNames => " + tableNames);
|
||||||
htd = new HBaseAdmin(getConf()).getTableDescriptorsByTableName(tableNames);
|
admin = new HBaseAdmin(getConf());
|
||||||
|
htd = admin.getTableDescriptorsByTableName(tableNames);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.debug("Exception getting table descriptors", e);
|
LOG.debug("Exception getting table descriptors", e);
|
||||||
|
} finally {
|
||||||
|
if (admin != null) {
|
||||||
|
try {
|
||||||
|
admin.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOG.debug("Exception closing HBaseAdmin", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return htd;
|
return htd;
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,9 +125,13 @@ class HMerge {
|
||||||
"HBase instance must be running to merge a normal table");
|
"HBase instance must be running to merge a normal table");
|
||||||
}
|
}
|
||||||
HBaseAdmin admin = new HBaseAdmin(conf);
|
HBaseAdmin admin = new HBaseAdmin(conf);
|
||||||
|
try {
|
||||||
if (!admin.isTableDisabled(tableName)) {
|
if (!admin.isTableDisabled(tableName)) {
|
||||||
throw new TableNotDisabledException(tableName);
|
throw new TableNotDisabledException(tableName);
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
admin.close();
|
||||||
|
}
|
||||||
new OnlineMerger(conf, fs, tableName).process();
|
new OnlineMerger(conf, fs, tableName).process();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue