HADOOP-2321 TestScanner2 does not release resources which sometimes cause the test to time out
git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/contrib/hbase@600443 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7ac136887a
commit
ffe660105a
|
@ -48,6 +48,8 @@ Trunk (unreleased changes)
|
|||
HADOOP-2320 Committed TestGet2 is managled (breaks build).
|
||||
HADOOP-2322 getRow(row, TS) client interface not properly connected
|
||||
HADOOP-2309 ConcurrentModificationException doing get of all region start keys
|
||||
HADOOP-2321 TestScanner2 does not release resources which sometimes cause the
|
||||
test to time out
|
||||
|
||||
IMPROVEMENTS
|
||||
HADOOP-2401 Add convenience put method that takes writable
|
||||
|
|
|
@ -122,11 +122,13 @@ public class HTable implements HConstants {
|
|||
* other methods will throw an IllegalStateException
|
||||
*/
|
||||
public synchronized void close() {
|
||||
if (!closed) {
|
||||
closed = true;
|
||||
tableServers = null;
|
||||
batch.set(null);
|
||||
connection.close(tableName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that no update is in progress
|
||||
|
@ -361,6 +363,7 @@ public class HTable implements HConstants {
|
|||
* Get all the data for the specified row at a specified timestamp
|
||||
*
|
||||
* @param row row key
|
||||
* @param ts timestamp
|
||||
* @return map of colums to values
|
||||
* @throws IOException
|
||||
*/
|
||||
|
|
|
@ -78,6 +78,7 @@ public class TestScanner2 extends HBaseClusterTestCase {
|
|||
Text tableName = new Text(getName());
|
||||
createTable(new HBaseAdmin(this.conf), tableName);
|
||||
HTable table = new HTable(this.conf, tableName);
|
||||
try {
|
||||
final String lastKey = "aac";
|
||||
addContent(new HTableIncommon(table), FIRST_COLKEY + ":");
|
||||
HScannerInterface scanner =
|
||||
|
@ -87,6 +88,9 @@ public class TestScanner2 extends HBaseClusterTestCase {
|
|||
LOG.info(e.getKey());
|
||||
assertTrue(e.getKey().getRow().toString().compareTo(lastKey) < 0);
|
||||
}
|
||||
} finally {
|
||||
table.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,6 +98,7 @@ public class TestScanner2 extends HBaseClusterTestCase {
|
|||
*/
|
||||
public void testIterator() throws Exception {
|
||||
HTable table = new HTable(this.conf, HConstants.ROOT_TABLE_NAME);
|
||||
try {
|
||||
HScannerInterface scanner =
|
||||
table.obtainScanner(HConstants.COLUMN_FAMILY_ARRAY,
|
||||
HConstants.EMPTY_START_ROW);
|
||||
|
@ -101,6 +106,9 @@ public class TestScanner2 extends HBaseClusterTestCase {
|
|||
assertNotNull(e.getKey());
|
||||
assertNotNull(e.getValue());
|
||||
}
|
||||
} finally {
|
||||
table.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,6 +122,7 @@ public class TestScanner2 extends HBaseClusterTestCase {
|
|||
Text tableName = new Text(getName());
|
||||
createTable(admin, tableName);
|
||||
HTable table = new HTable(this.conf, tableName);
|
||||
try {
|
||||
// Add a row to columns without qualifiers and then two with. Make one
|
||||
// numbers only so easy to find w/ a regex.
|
||||
long id = table.startUpdate(new Text(getName()));
|
||||
|
@ -126,6 +135,9 @@ public class TestScanner2 extends HBaseClusterTestCase {
|
|||
checkRegexingScanner(table, firstColkeyFamily + "\\d+");
|
||||
// Do a new scan that only matches on column family.
|
||||
checkRegexingScanner(table, firstColkeyFamily + "$");
|
||||
} finally {
|
||||
table.close();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -170,6 +182,7 @@ public class TestScanner2 extends HBaseClusterTestCase {
|
|||
|
||||
// Enter data
|
||||
HTable table = new HTable(conf, tableName);
|
||||
try {
|
||||
for (char i = FIRST_ROWKEY; i <= LAST_ROWKEY; i++) {
|
||||
Text rowKey = new Text(new String(new char[] { i }));
|
||||
long lockID = table.startUpdate(rowKey);
|
||||
|
@ -182,6 +195,9 @@ public class TestScanner2 extends HBaseClusterTestCase {
|
|||
|
||||
regExpFilterTest(table, colKeys);
|
||||
rowFilterSetTest(table, colKeys);
|
||||
} finally {
|
||||
table.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -269,6 +285,7 @@ public class TestScanner2 extends HBaseClusterTestCase {
|
|||
*/
|
||||
public void testSplitDeleteOneAddTwoRegions() throws IOException {
|
||||
HTable metaTable = new HTable(conf, HConstants.META_TABLE_NAME);
|
||||
try {
|
||||
// First add a new table. Its intial region will be added to META region.
|
||||
HBaseAdmin admin = new HBaseAdmin(conf);
|
||||
Text tableName = new Text(getName());
|
||||
|
@ -280,8 +297,7 @@ public class TestScanner2 extends HBaseClusterTestCase {
|
|||
region.getRegionName().toString().startsWith(getName()));
|
||||
// Now do what happens at split time; remove old region and then add two
|
||||
// new ones in its place.
|
||||
removeRegionFromMETA(new HTable(conf, HConstants.META_TABLE_NAME),
|
||||
region.getRegionName());
|
||||
removeRegionFromMETA(metaTable, region.getRegionName());
|
||||
HTableDescriptor desc = region.getTableDesc();
|
||||
Path homedir = new Path(getName());
|
||||
List<HRegion> newRegions = new ArrayList<HRegion>(2);
|
||||
|
@ -304,6 +320,9 @@ public class TestScanner2 extends HBaseClusterTestCase {
|
|||
r.getLog().closeAndDelete();
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
metaTable.close();
|
||||
}
|
||||
}
|
||||
|
||||
private List<HRegionInfo> scan(final HTable t)
|
||||
|
@ -388,7 +407,6 @@ public class TestScanner2 extends HBaseClusterTestCase {
|
|||
*/
|
||||
private void removeRegionFromMETA(final HTable t, final Text regionName)
|
||||
throws IOException {
|
||||
try {
|
||||
long lockid = t.startUpdate(regionName);
|
||||
t.delete(lockid, HConstants.COL_REGIONINFO);
|
||||
t.delete(lockid, HConstants.COL_SERVER);
|
||||
|
@ -397,8 +415,5 @@ public class TestScanner2 extends HBaseClusterTestCase {
|
|||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Removed " + regionName + " from table " + t.getTableName());
|
||||
}
|
||||
} finally {
|
||||
t.close();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue