HBASE-6108 Use HRegion.closeHRegion instead of HRegion.close() and HRegion.getLog().close()

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1343857 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2012-05-29 17:12:09 +00:00
parent ccb9c74400
commit 00e53c8fa2
22 changed files with 63 additions and 130 deletions

View File

@ -405,10 +405,8 @@ public class MasterFileSystem {
setInfoFamilyCachingForMeta(true);
// Add first region from the META table to the ROOT region.
HRegion.addRegionToMETA(root, meta);
root.close();
root.getLog().closeAndDelete();
meta.close();
meta.getLog().closeAndDelete();
HRegion.closeHRegion(root);
HRegion.closeHRegion(meta);
} catch (IOException e) {
e = RemoteExceptionHandler.checkIOException(e);
LOG.error("bootstrap", e);

View File

@ -705,8 +705,7 @@ public class HBaseFsck {
// Add first region from the META table to the ROOT region.
HRegion.addRegionToMETA(root, meta);
root.close();
root.getLog().closeAndDelete();
HRegion.closeHRegion(root);
return meta;
}
@ -821,8 +820,7 @@ public class HBaseFsck {
return false;
}
meta.put(puts.toArray(new Put[0]));
meta.close();
meta.getLog().closeAndDelete();
HRegion.closeHRegion(meta);
LOG.info("Success! .META. table rebuilt.");
return true;
}

View File

@ -681,14 +681,8 @@ public abstract class HBaseTestCase extends TestCase {
}
protected void closeRootAndMeta() throws IOException {
if (meta != null) {
meta.close();
meta.getLog().closeAndDelete();
}
if (root != null) {
root.close();
root.getLog().closeAndDelete();
}
HRegion.closeHRegion(meta);
HRegion.closeHRegion(root);
}
public static void assertByteEquals(byte[] expected,

View File

@ -237,8 +237,7 @@ public class TestCoprocessorInterface extends HBaseTestCase {
for (int i = 0; i < regions.length; i++) {
regions[i] = reopenRegion(regions[i], CoprocessorImpl.class);
}
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
Coprocessor c = region.getCoprocessorHost().
findCoprocessor(CoprocessorImpl.class.getName());
@ -258,8 +257,7 @@ public class TestCoprocessorInterface extends HBaseTestCase {
assertTrue(((CoprocessorImpl)c).wasSplit());
for (int i = 0; i < regions.length; i++) {
regions[i].close();
regions[i].getLog().closeAndDelete();
HRegion.closeHRegion(regions[i]);
c = region.getCoprocessorHost()
.findCoprocessor(CoprocessorImpl.class.getName());
assertTrue("Coprocessor not started", ((CoprocessorImpl)c).wasStarted());

View File

@ -98,12 +98,10 @@ public class TestColumnPrefixFilter {
assertEquals(prefixMap.get(s).size(), results.size());
}
} finally {
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
@Test
@ -165,12 +163,10 @@ public class TestColumnPrefixFilter {
assertEquals(prefixMap.get(s).size(), results.size());
}
} finally {
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
List<String> generateRandomWords(int numberOfWords, String suffix) {

View File

@ -82,8 +82,7 @@ public class TestDependentColumnFilter extends TestCase {
@Override
protected void tearDown() throws Exception {
super.tearDown();
this.region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(this.region);
}
private void addData() throws IOException {

View File

@ -100,8 +100,7 @@ public class TestMultipleColumnPrefixFilter {
while(scanner.next(results));
assertEquals(prefixMap.get("p").size() + prefixMap.get("q").size(), results.size());
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
@Test
@ -169,8 +168,7 @@ public class TestMultipleColumnPrefixFilter {
while(scanner.next(results));
assertEquals(prefixMap.get("p").size() + prefixMap.get("q").size(), results.size());
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
@Test
@ -225,8 +223,7 @@ public class TestMultipleColumnPrefixFilter {
assertEquals(results1.size(), results2.size());
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
List<String> generateRandomWords(int numberOfWords, String suffix) {

View File

@ -160,8 +160,7 @@ public class TestOpenedRegionHandler {
assertEquals("The region should not be opened successfully.", regionName,
region.getRegionInfo().getEncodedName());
} finally {
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
TEST_UTIL.shutdownMiniZKCluster();
}
}

View File

@ -156,8 +156,7 @@ public class TestColumnSeeking {
HRegion.closeHRegion(region);
}
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
@SuppressWarnings("unchecked")
@ -265,8 +264,7 @@ public class TestColumnSeeking {
assertTrue(results.containsAll(kvSet));
}
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
List<String> generateRandomWords(int numberOfWords, String suffix) {

View File

@ -312,8 +312,7 @@ public class TestHRegion extends HBaseTestCase {
}
} finally {
if (this.region != null) {
this.region.close();
this.region.getLog().closeAndDelete();
HRegion.closeHRegion(this.region);
}
}
done.set(true);
@ -1608,8 +1607,7 @@ public class TestHRegion extends HBaseTestCase {
} finally {
for (int i = 0; i < subregions.length; i++) {
try {
subregions[i].close();
subregions[i].getLog().closeAndDelete();
HRegion.closeHRegion(subregions[i]);
} catch (IOException e) {
// Ignore.
}

View File

@ -134,8 +134,7 @@ public class TestKeepDeletes extends HBaseTestCase {
checkResult(r, c0, c0, T1);
assertEquals(0, countDeleteMarkers(region));
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
/**
@ -184,8 +183,7 @@ public class TestKeepDeletes extends HBaseTestCase {
scan.next(kvs);
assertTrue(kvs.isEmpty());
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
/**
@ -229,8 +227,7 @@ public class TestKeepDeletes extends HBaseTestCase {
// major compaction deleted it
assertEquals(0, countDeleteMarkers(region));
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
/**
@ -253,8 +250,7 @@ public class TestKeepDeletes extends HBaseTestCase {
// ok!
}
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
/**
@ -300,8 +296,7 @@ public class TestKeepDeletes extends HBaseTestCase {
assertEquals(kvs.get(4).getValue(), T2);
assertEquals(kvs.get(5).getValue(), T1);
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
/**
@ -343,8 +338,7 @@ public class TestKeepDeletes extends HBaseTestCase {
region.compactStores(true);
assertEquals(0, countDeleteMarkers(region));
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
/**
@ -406,8 +400,7 @@ public class TestKeepDeletes extends HBaseTestCase {
region.compactStores(true);
assertEquals(0, countDeleteMarkers(region));
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
/**
@ -486,8 +479,7 @@ public class TestKeepDeletes extends HBaseTestCase {
checkGet(region, T2, c1, c0, ts+3, T2, T1);
checkGet(region, T2, c1, c1, ts+3, T2, T1);
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
/**
@ -581,8 +573,7 @@ public class TestKeepDeletes extends HBaseTestCase {
region.compactStores(true);
assertEquals(1, countDeleteMarkers(region));
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
/**
@ -632,8 +623,7 @@ public class TestKeepDeletes extends HBaseTestCase {
assertEquals(4, kvs.size());
scanner.close();
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
/**
@ -710,8 +700,7 @@ public class TestKeepDeletes extends HBaseTestCase {
region.compactStores(true);
assertEquals(0, countDeleteMarkers(region));
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
private void checkGet(HRegion region, byte[] row, byte[] fam, byte[] col,

View File

@ -88,8 +88,7 @@ public class TestMinVersions extends HBaseTestCase {
r = region.getClosestRowBefore(T2, c0);
checkResult(r, c0, T4);
} finally {
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
}
@ -144,8 +143,7 @@ public class TestMinVersions extends HBaseTestCase {
r = region.get(g, null); // this'll use ExplicitColumnTracker
checkResult(r, c0, T3,T2,T1);
} finally {
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
}
@ -202,8 +200,7 @@ public class TestMinVersions extends HBaseTestCase {
r = region.get(g, null); // this'll use ExplicitColumnTracker
checkResult(r, c0, T3);
} finally {
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
}
@ -276,8 +273,7 @@ public class TestMinVersions extends HBaseTestCase {
r = region.get(g, null); // this'll use ExplicitColumnTracker
checkResult(r, c0, T5,T4);
} finally {
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
}
@ -367,8 +363,7 @@ public class TestMinVersions extends HBaseTestCase {
r = region.get(g, null);
assertTrue(r.isEmpty());
} finally {
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
}
@ -441,8 +436,7 @@ public class TestMinVersions extends HBaseTestCase {
r = region.get(g, null);
checkResult(r, c0, T2);
} finally {
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
}

View File

@ -291,8 +291,7 @@ public class TestMultiColumnScanner {
"pairs", lastDelTimeMap.size() > 0);
LOG.info("Number of row/col pairs deleted at least once: " +
lastDelTimeMap.size());
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
private static String getRowQualStr(KeyValue kv) {

View File

@ -97,8 +97,7 @@ public class TestResettingCounters {
} finally {
HRegion.closeHRegion(region);
}
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
@org.junit.Rule

View File

@ -113,8 +113,7 @@ public class TestScanWithBloomError {
createStoreFile(new int[] {1, 9});
scanColSet(new int[]{1, 4, 6, 7}, new int[]{1, 6, 7});
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
private void scanColSet(int[] colSet, int[] expectedResultCols)

View File

@ -147,8 +147,7 @@ public class TestScanner extends HBaseTestCase {
assertTrue(count > 10);
s.close();
} finally {
this.r.close();
this.r.getLog().closeAndDelete();
HRegion.closeHRegion(this.r);
}
}
@ -200,8 +199,7 @@ public class TestScanner extends HBaseTestCase {
rowInclusiveStopFilter(scan, stopRow);
} finally {
this.r.close();
this.r.getLog().closeAndDelete();
HRegion.closeHRegion(this.r);
}
}
@ -227,8 +225,7 @@ public class TestScanner extends HBaseTestCase {
return;
}
} finally {
this.r.close();
this.r.getLog().closeAndDelete();
HRegion.closeHRegion(this.r);
}
}
@ -343,8 +340,7 @@ public class TestScanner extends HBaseTestCase {
} finally {
// clean up
r.close();
r.getLog().closeAndDelete();
HRegion.closeHRegion(r);
}
}
@ -464,8 +460,7 @@ public class TestScanner extends HBaseTestCase {
LOG.error("Failed", e);
throw e;
} finally {
this.r.close();
this.r.getLog().closeAndDelete();
HRegion.closeHRegion(this.r);
}
}
@ -487,8 +482,7 @@ public class TestScanner extends HBaseTestCase {
LOG.error("Failed", e);
throw e;
} finally {
this.r.close();
this.r.getLog().closeAndDelete();
HRegion.closeHRegion(this.r);
}
}
@ -549,8 +543,7 @@ public class TestScanner extends HBaseTestCase {
assertTrue(Bytes.BYTES_COMPARATOR.compare(fam2, results.get(1)
.getFamily()) == 0);
} finally {
this.r.close();
this.r.getLog().closeAndDelete();
HRegion.closeHRegion(this.r);
}
}

View File

@ -440,8 +440,7 @@ public class TestSeekOptimizations {
@After
public void tearDown() throws IOException {
if (region != null) {
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
}
// We have to re-set the lazy seek flag back to the default so that other

View File

@ -219,8 +219,7 @@ public class TestSplitTransaction {
assertTrue(count > 0 && count != rowcount);
daughtersRowCount += count;
} finally {
openRegion.close();
openRegion.getLog().closeAndDelete();
HRegion.closeHRegion(openRegion);
}
}
assertEquals(rowcount, daughtersRowCount);
@ -275,8 +274,7 @@ public class TestSplitTransaction {
assertTrue(count > 0 && count != rowcount);
daughtersRowCount += count;
} finally {
openRegion.close();
openRegion.getLog().closeAndDelete();
HRegion.closeHRegion(openRegion);
}
}
assertEquals(rowcount, daughtersRowCount);
@ -316,8 +314,7 @@ public class TestSplitTransaction {
htd.addFamily(hcd);
HRegionInfo hri = new HRegionInfo(htd.getName(), STARTROW, ENDROW);
HRegion r = HRegion.createHRegion(hri, testdir, TEST_UTIL.getConfiguration(), htd);
r.close();
r.getLog().closeAndDelete();
HRegion.closeHRegion(r);
return HRegion.openHRegion(testdir, hri, htd, wal,
TEST_UTIL.getConfiguration());
}

View File

@ -131,8 +131,7 @@ public class TestWideScanner extends HBaseTestCase {
s.close();
} finally {
this.r.close();
this.r.getLog().closeAndDelete();
HRegion.closeHRegion(this.r);
}
}

View File

@ -135,8 +135,7 @@ public class TestWALReplay {
HTableDescriptor htd = createBasic3FamilyHTD(tableNameStr);
HRegion region2 = HRegion.createHRegion(hri,
hbaseRootDir, this.conf, htd);
region2.close();
region2.getLog().closeAndDelete();
HRegion.closeHRegion(region2);
final byte [] tableName = Bytes.toBytes(tableNameStr);
final byte [] rowName = tableName;
@ -196,8 +195,7 @@ public class TestWALReplay {
final HTableDescriptor htd = createBasic3FamilyHTD(tableNameStr);
HRegion region2 = HRegion.createHRegion(hri,
hbaseRootDir, this.conf, htd);
region2.close();
region2.getLog().closeAndDelete();
HRegion.closeHRegion(region2);
HLog wal = createWAL(this.conf);
HRegion region = HRegion.openHRegion(hri, htd, wal, this.conf);
Path f = new Path(basedir, "hfile");
@ -257,8 +255,7 @@ public class TestWALReplay {
final HTableDescriptor htd = createBasic3FamilyHTD(tableNameStr);
HRegion region3 = HRegion.createHRegion(hri,
hbaseRootDir, this.conf, htd);
region3.close();
region3.getLog().closeAndDelete();
HRegion.closeHRegion(region3);
// Write countPerFamily edits into the three families. Do a flush on one
// of the families during the load of edits so its seqid is not same as
// others to test we do right thing when different seqids.
@ -375,8 +372,7 @@ public class TestWALReplay {
final HTableDescriptor htd = createBasic3FamilyHTD(tableNameStr);
HRegion region3 = HRegion.createHRegion(hri,
hbaseRootDir, this.conf, htd);
region3.close();
region3.getLog().closeAndDelete();
HRegion.closeHRegion(region3);
// Write countPerFamily edits into the three families. Do a flush on one
// of the families during the load of edits so its seqid is not same as
// others to test we do right thing when different seqids.
@ -442,8 +438,7 @@ public class TestWALReplay {
final HTableDescriptor htd = createBasic3FamilyHTD(tableNameStr);
HRegion region2 = HRegion.createHRegion(hri,
hbaseRootDir, this.conf, htd);
region2.close();
region2.getLog().closeAndDelete();
HRegion.closeHRegion(region2);
final HLog wal = createWAL(this.conf);
final byte[] tableName = Bytes.toBytes(tableNameStr);
final byte[] rowName = tableName;

View File

@ -150,8 +150,7 @@ public class TestMergeTable {
region.flushcache();
}
}
region.close();
region.getLog().closeAndDelete();
HRegion.closeHRegion(region);
return region;
}
@ -167,10 +166,8 @@ public class TestMergeTable {
for (HRegion r: regions) {
HRegion.addRegionToMETA(meta, r);
}
meta.close();
meta.getLog().closeAndDelete();
root.close();
root.getLog().closeAndDelete();
HRegion.closeHRegion(meta);
HRegion.closeHRegion(root);
}
@org.junit.Rule

View File

@ -172,8 +172,7 @@ public class TestMergeTool extends HBaseTestCase {
for (int i = 0; i < sourceRegions.length; i++) {
HRegion r = regions[i];
if (r != null) {
r.close();
r.getLog().closeAndDelete();
HRegion.closeHRegion(r);
}
}
TEST_UTIL.shutdownMiniCluster();
@ -260,8 +259,7 @@ public class TestMergeTool extends HBaseTestCase {
assertTrue(Bytes.equals(bytes, rows[i][j]));
}
// Close the region and delete the log
regions[i].close();
regions[i].getLog().closeAndDelete();
HRegion.closeHRegion(regions[i]);
}
// Create a log that we can reuse when we need to open regions