HBASE-13810 Table is left unclosed in VerifyReplication#Verifier

This commit is contained in:
tedyu 2015-05-29 17:43:47 -07:00
parent adbc3dd097
commit 20e01d2812
1 changed files with 10 additions and 2 deletions

View File

@ -87,6 +87,7 @@ public class VerifyReplication extends Configured implements Tool {
private ResultScanner replicatedScanner; private ResultScanner replicatedScanner;
private Result currentCompareRowInPeerTable; private Result currentCompareRowInPeerTable;
private Table replicatedTable;
/** /**
* Map method that compares every scanned row with the equivalent from * Map method that compares every scanned row with the equivalent from
@ -127,8 +128,7 @@ public class VerifyReplication extends Configured implements Tool {
ZKUtil.applyClusterKeyToConf(peerConf, zkClusterKey); ZKUtil.applyClusterKeyToConf(peerConf, zkClusterKey);
TableName tableName = TableName.valueOf(conf.get(NAME + ".tableName")); TableName tableName = TableName.valueOf(conf.get(NAME + ".tableName"));
// TODO: THis HTable doesn't get closed. Fix! replicatedTable = new HTable(peerConf, tableName);
Table replicatedTable = new HTable(peerConf, tableName);
scan.setStartRow(value.getRow()); scan.setStartRow(value.getRow());
scan.setStopRow(tableSplit.getEndRow()); scan.setStopRow(tableSplit.getEndRow());
replicatedScanner = replicatedTable.getScanner(scan); replicatedScanner = replicatedTable.getScanner(scan);
@ -189,6 +189,14 @@ public class VerifyReplication extends Configured implements Tool {
replicatedScanner = null; replicatedScanner = null;
} }
} }
if (replicatedTable != null) {
TableName tableName = replicatedTable.getName();
try {
replicatedTable.close();
} catch (IOException ioe) {
LOG.warn("Exception closing " + tableName, ioe);
}
}
} }
} }