Repository: hbase Updated Branches: refs/heads/master 4ac457a7b -> 9b7f36b8c
http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java index 992a978..8b41594 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java @@ -50,6 +50,7 @@ import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.NavigableMap; @@ -127,8 +128,10 @@ import org.apache.hadoop.hbase.protobuf.generated.WALProtos.RegionEventDescripto import org.apache.hadoop.hbase.regionserver.HRegion.RegionScannerImpl; import org.apache.hadoop.hbase.regionserver.HRegion.RowLock; import org.apache.hadoop.hbase.regionserver.TestStore.FaultyFileSystem; +import org.apache.hadoop.hbase.regionserver.wal.MetricsWAL; import org.apache.hadoop.hbase.regionserver.wal.MetricsWALSource; import org.apache.hadoop.hbase.regionserver.wal.HLogKey; +import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener; import org.apache.hadoop.hbase.regionserver.wal.WALUtil; import org.apache.hadoop.hbase.regionserver.wal.WALEdit; import org.apache.hadoop.hbase.wal.DefaultWALProvider; @@ -253,7 +256,7 @@ public class TestHRegion { // Close with something in memstore and something in the snapshot. Make sure all is cleared. region.close(); assertEquals(0, region.getMemstoreSize().get()); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /* @@ -305,7 +308,24 @@ public class TestHRegion { } long sz = store.getFlushableSize(); assertTrue("flushable size should be zero, but it is " + sz, sz == 0); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); + } + + /** + * Create a WAL outside of the usual helper in + * {@link HBaseTestingUtility#createWal(Configuration, Path, HRegionInfo)} because that method + * doesn't play nicely with FaultyFileSystem. Call this method before overriding + * {@code fs.file.impl}. + * @param callingMethod a unique component for the path, probably the name of the test method. + */ + private static WAL createWALCompatibleWithFaultyFileSystem(String callingMethod, + Configuration conf, byte[] tableName) throws IOException { + final Path logDir = TEST_UTIL.getDataTestDirOnTestFS(callingMethod + ".log"); + final Configuration walConf = new Configuration(conf); + FSUtils.setRootDir(walConf, logDir); + return (new WALFactory(walConf, + Collections.<WALActionsListener>singletonList(new MetricsWAL()), callingMethod)) + .getWAL(tableName); } /** @@ -326,6 +346,8 @@ public class TestHRegion { @Test (timeout=60000) public void testFlushSizeAccounting() throws Exception { final Configuration conf = HBaseConfiguration.create(CONF); + final String callingMethod = name.getMethodName(); + final WAL wal = createWALCompatibleWithFaultyFileSystem(callingMethod, conf, tableName); // Only retry once. conf.setInt("hbase.hstore.flush.retries.number", 1); final User user = @@ -342,7 +364,8 @@ public class TestHRegion { HRegion region = null; try { // Initialize region - region = initHRegion(tableName, name.getMethodName(), conf, COLUMN_FAMILY_BYTES); + region = initHRegion(tableName, null, null, callingMethod, conf, false, + Durability.SYNC_WAL, wal, COLUMN_FAMILY_BYTES); long size = region.getMemstoreSize().get(); Assert.assertEquals(0, size); // Put one item into memstore. Measure the size of one item in memstore. @@ -376,7 +399,7 @@ public class TestHRegion { // Make sure our memory accounting is right. Assert.assertEquals(sizeOfOnePut * 2, region.getMemstoreSize().get()); } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } return null; } @@ -387,6 +410,8 @@ public class TestHRegion { @Test (timeout=60000) public void testCloseWithFailingFlush() throws Exception { final Configuration conf = HBaseConfiguration.create(CONF); + final String callingMethod = name.getMethodName(); + final WAL wal = createWALCompatibleWithFaultyFileSystem(callingMethod, conf, tableName); // Only retry once. conf.setInt("hbase.hstore.flush.retries.number", 1); final User user = @@ -403,7 +428,8 @@ public class TestHRegion { HRegion region = null; try { // Initialize region - region = initHRegion(tableName, name.getMethodName(), conf, COLUMN_FAMILY_BYTES); + region = initHRegion(tableName, null, null, callingMethod, conf, false, + Durability.SYNC_WAL, wal, COLUMN_FAMILY_BYTES); long size = region.getMemstoreSize().get(); Assert.assertEquals(0, size); // Put one item into memstore. Measure the size of one item in memstore. @@ -428,7 +454,7 @@ public class TestHRegion { } finally { // Make it so all writes succeed from here on out so can close clean ffs.fault.set(false); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } return null; } @@ -561,7 +587,7 @@ public class TestHRegion { assertArrayEquals(Bytes.toBytes(i), CellUtil.cloneValue(kvs.get(0))); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; wals.close(); } @@ -619,7 +645,7 @@ public class TestHRegion { } } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; wals.close(); } @@ -652,7 +678,7 @@ public class TestHRegion { long seqId = region.replayRecoveredEditsIfAny(regiondir, maxSeqIdInStores, null, null); assertEquals(minSeqId, seqId); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -717,7 +743,7 @@ public class TestHRegion { region.getStores().keySet().toArray(new byte[0][])).size()); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; wals.close(); } @@ -812,7 +838,7 @@ public class TestHRegion { assertArrayEquals(Bytes.toBytes(i), value); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; wals.close(); } @@ -931,7 +957,7 @@ public class TestHRegion { assertArrayEquals(Bytes.toBytes(i), value); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; wals.close(); } @@ -1051,7 +1077,7 @@ public class TestHRegion { } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1092,7 +1118,7 @@ public class TestHRegion { } } finally { if (this.region != null) { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); } } done.set(true); @@ -1108,7 +1134,7 @@ public class TestHRegion { } } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1185,7 +1211,7 @@ public class TestHRegion { assertEquals("Got back incorrect number of rows from scan: " + keyPrefix3, 0, getNumberOfRows(keyPrefix3, value2, this.region)); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1204,7 +1230,7 @@ public class TestHRegion { } catch (IOException e) { exceptionCaught = true; } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } assertTrue(exceptionCaught == true); @@ -1223,7 +1249,7 @@ public class TestHRegion { } catch (IOException e) { exceptionCaught = true; } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } assertTrue(exceptionCaught == true); @@ -1319,7 +1345,7 @@ public class TestHRegion { } assertTrue(exception); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1360,7 +1386,7 @@ public class TestHRegion { metricsAssertHelper.assertCounter("syncTimeNumOps", syncs + 2, source); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1412,7 +1438,7 @@ public class TestHRegion { @Override public void run() { try { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } catch (IOException e) { throw new RuntimeException(e); } @@ -1448,7 +1474,7 @@ public class TestHRegion { codes[i].getOperationStatusCode()); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1496,7 +1522,7 @@ public class TestHRegion { metricsAssertHelper.assertCounter("syncTimeNumOps", syncs, source); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } @@ -1575,7 +1601,7 @@ public class TestHRegion { .checkAndMutate(row1, fam1, qf1, CompareOp.EQUAL, new NullComparator(), put, true); assertTrue(res); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1609,7 +1635,7 @@ public class TestHRegion { put, true); assertEquals(false, res); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1642,7 +1668,7 @@ public class TestHRegion { delete, true); assertEquals(true, res); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1737,7 +1763,7 @@ public class TestHRegion { new BinaryComparator(val3), put, true); assertEquals(true, res); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1784,7 +1810,7 @@ public class TestHRegion { assertEquals(expected[i], actual[i]); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1804,7 +1830,7 @@ public class TestHRegion { // expected exception. } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1881,7 +1907,7 @@ public class TestHRegion { r = region.get(get); assertEquals(0, r.size()); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1916,7 +1942,7 @@ public class TestHRegion { Result r = region.get(get); assertEquals(0, r.size()); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1960,7 +1986,7 @@ public class TestHRegion { } assertEquals("Family " + new String(family) + " does exist", true, ok); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2028,7 +2054,7 @@ public class TestHRegion { result = region.get(get); assertEquals(1, result.size()); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2067,7 +2093,7 @@ public class TestHRegion { result = region.get(get); assertEquals(0, result.size()); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2117,7 +2143,7 @@ public class TestHRegion { assertTrue("LATEST_TIMESTAMP was not replaced with real timestamp", kv.getTimestamp() != HConstants.LATEST_TIMESTAMP); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } @@ -2152,7 +2178,7 @@ public class TestHRegion { } assertTrue("Should catch FailedSanityCheckException", caughtExcep); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2194,7 +2220,7 @@ public class TestHRegion { s.next(results); assertTrue(CellUtil.matchingRow(results.get(0), rowB)); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2253,7 +2279,7 @@ public class TestHRegion { assertArrayEquals(qual1, CellUtil.cloneQualifier(kv)); assertArrayEquals(row, CellUtil.cloneRow(kv)); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2293,7 +2319,7 @@ public class TestHRegion { now = cell.getTimestamp(); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2324,7 +2350,7 @@ public class TestHRegion { } assertFalse(true); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2376,7 +2402,7 @@ public class TestHRegion { res = region.get(g); assertEquals(count, res.size()); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2395,7 +2421,7 @@ public class TestHRegion { assertTrue(r.isEmpty()); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2438,14 +2464,14 @@ public class TestHRegion { } finally { for (int i = 0; i < subregions.length; i++) { try { - HRegion.closeHRegion(subregions[i]); + HBaseTestingUtility.closeRegionAndWAL(subregions[i]); } catch (IOException e) { // Ignore. } } } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2511,7 +2537,7 @@ public class TestHRegion { assertTrue("Families could not be found in Region", false); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2537,7 +2563,7 @@ public class TestHRegion { } assertTrue("Families could not be found in Region", ok); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2581,7 +2607,7 @@ public class TestHRegion { is = (RegionScannerImpl) region.getScanner(scan); assertEquals(families.length - 1, ((RegionScannerImpl) is).storeHeap.getHeap().size()); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2618,7 +2644,7 @@ public class TestHRegion { + e.getMessage()); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2684,7 +2710,7 @@ public class TestHRegion { assertTrue(CellComparator.equalsIgnoreMvccVersion(expected2.get(i), res.get(i))); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2743,7 +2769,7 @@ public class TestHRegion { assertEquals(expected.get(i), actual.get(i)); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2806,7 +2832,7 @@ public class TestHRegion { assertTrue(CellComparator.equalsIgnoreMvccVersion(expected.get(i), actual.get(i))); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2888,7 +2914,7 @@ public class TestHRegion { assertTrue(CellComparator.equalsIgnoreMvccVersion(expected.get(i), actual.get(i))); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2949,7 +2975,7 @@ public class TestHRegion { assertEquals(expected.get(i), actual.get(i)); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -3010,7 +3036,7 @@ public class TestHRegion { assertTrue(CellComparator.equalsIgnoreMvccVersion(expected.get(i), actual.get(i))); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -3058,7 +3084,7 @@ public class TestHRegion { assertEquals(false, s.next(results)); assertEquals(0, results.size()); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -3137,7 +3163,7 @@ public class TestHRegion { assertTrue(CellComparator.equalsIgnoreMvccVersion(expected.get(i), actual.get(i))); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -3206,7 +3232,7 @@ public class TestHRegion { assertFalse(s.next(results)); assertEquals(results.size(), 0); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -3301,7 +3327,7 @@ public class TestHRegion { break; } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -3395,7 +3421,7 @@ public class TestHRegion { } } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -3434,7 +3460,7 @@ public class TestHRegion { verifyData(regions[1], splitRow, numRows, qualifier, families); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -3502,7 +3528,7 @@ public class TestHRegion { verifyData(regions[1], splitRow, numRows, qualifier, families); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -3574,7 +3600,7 @@ public class TestHRegion { flushThread.join(); flushThread.checkNoError(); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -3708,7 +3734,7 @@ public class TestHRegion { flushThread.checkNoError(); } finally { try { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); } catch (DroppedSnapshotException dse) { // We could get this on way out because we interrupt the background flusher and it could // fail anywhere causing a DSE over in the background flusher... only it is not properly @@ -3735,11 +3761,11 @@ public class TestHRegion { } /** - * Block until this thread has put at least one row. + * Block calling thread until this instance of PutThread has put at least one row. */ public void waitForFirstPut() throws InterruptedException { // wait until put thread actually puts some data - while (numPutsFinished == 0) { + while (isAlive() && numPutsFinished == 0) { checkNoError(); Thread.sleep(50); } @@ -3909,7 +3935,7 @@ public class TestHRegion { } ctx.stop(); - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -3932,7 +3958,7 @@ public class TestHRegion { g = new Get(row); region.get(g); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -3971,7 +3997,7 @@ public class TestHRegion { ; assertEquals(1L, res.size()); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -4032,7 +4058,7 @@ public class TestHRegion { assertEquals(num_unique_rows, reader.getFilterEntries()); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -4075,7 +4101,7 @@ public class TestHRegion { checkOneCell(kvs[2], FAMILY, 0, 0, 2); checkOneCell(kvs[3], FAMILY, 0, 0, 1); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -4118,7 +4144,7 @@ public class TestHRegion { Cell[] keyValues = region.get(get).rawCells(); assertTrue(keyValues.length == 0); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -4228,7 +4254,7 @@ public class TestHRegion { } } } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } } @@ -4246,11 +4272,10 @@ public class TestHRegion { HRegionInfo hri = new HRegionInfo(htd.getTableName()); // Create a region and skip the initialization (like CreateTableHandler) - HRegion region = HRegion.createHRegion(hri, rootDir, CONF, htd, null, false, true); -// HRegion region = TEST_UTIL.createLocalHRegion(hri, htd); + HRegion region = HBaseTestingUtility.createRegionAndWAL(hri, rootDir, CONF, htd, false); Path regionDir = region.getRegionFileSystem().getRegionDir(); FileSystem fs = region.getRegionFileSystem().getFileSystem(); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); Path regionInfoFile = new Path(regionDir, HRegionFileSystem.REGION_INFO_FILE); @@ -4261,7 +4286,7 @@ public class TestHRegion { // Try to open the region region = HRegion.openHRegion(rootDir, hri, htd, null, CONF); assertEquals(regionDir, region.getRegionFileSystem().getRegionDir()); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); // Verify that the .regioninfo file is still there assertTrue(HRegionFileSystem.REGION_INFO_FILE + " should be present in the region dir", @@ -4275,7 +4300,7 @@ public class TestHRegion { region = HRegion.openHRegion(rootDir, hri, htd, null, CONF); // region = TEST_UTIL.openHRegion(hri, htd); assertEquals(regionDir, region.getRegionFileSystem().getRegionDir()); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); // Verify that the .regioninfo file is still there assertTrue(HRegionFileSystem.REGION_INFO_FILE + " should be present in the region dir", @@ -4621,7 +4646,7 @@ public class TestHRegion { verify(wal, never()).sync(); } - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } @@ -4652,8 +4677,8 @@ public class TestHRegion { HRegion primaryRegion = null, secondaryRegion = null; try { - primaryRegion = HRegion.createHRegion(primaryHri, - rootDir, TEST_UTIL.getConfiguration(), htd); + primaryRegion = HBaseTestingUtility.createRegionAndWAL(primaryHri, + rootDir, TEST_UTIL.getConfiguration(), htd); // load some data putData(primaryRegion, 0, 1000, cq, families); @@ -4667,10 +4692,10 @@ public class TestHRegion { verifyData(secondaryRegion, 0, 1000, cq, families); } finally { if (primaryRegion != null) { - HRegion.closeHRegion(primaryRegion); + HBaseTestingUtility.closeRegionAndWAL(primaryRegion); } if (secondaryRegion != null) { - HRegion.closeHRegion(secondaryRegion); + HBaseTestingUtility.closeRegionAndWAL(secondaryRegion); } } } @@ -4702,8 +4727,8 @@ public class TestHRegion { HRegion primaryRegion = null, secondaryRegion = null; try { - primaryRegion = HRegion.createHRegion(primaryHri, - rootDir, TEST_UTIL.getConfiguration(), htd); + primaryRegion = HBaseTestingUtility.createRegionAndWAL(primaryHri, + rootDir, TEST_UTIL.getConfiguration(), htd); // load some data putData(primaryRegion, 0, 1000, cq, families); @@ -4722,10 +4747,10 @@ public class TestHRegion { } } finally { if (primaryRegion != null) { - HRegion.closeHRegion(primaryRegion); + HBaseTestingUtility.closeRegionAndWAL(primaryRegion); } if (secondaryRegion != null) { - HRegion.closeHRegion(secondaryRegion); + HBaseTestingUtility.closeRegionAndWAL(secondaryRegion); } } } @@ -4755,8 +4780,8 @@ public class TestHRegion { HRegion primaryRegion = null, secondaryRegion = null; try { - primaryRegion = HRegion.createHRegion(primaryHri, - rootDir, TEST_UTIL.getConfiguration(), htd); + primaryRegion = HBaseTestingUtility.createRegionAndWAL(primaryHri, + rootDir, TEST_UTIL.getConfiguration(), htd); // load some data putData(primaryRegion, 0, 1000, cq, families); @@ -4776,10 +4801,10 @@ public class TestHRegion { verifyData(secondaryRegion, 0, 1000, cq, families); } finally { if (primaryRegion != null) { - HRegion.closeHRegion(primaryRegion); + HBaseTestingUtility.closeRegionAndWAL(primaryRegion); } if (secondaryRegion != null) { - HRegion.closeHRegion(secondaryRegion); + HBaseTestingUtility.closeRegionAndWAL(secondaryRegion); } } } @@ -4930,9 +4955,9 @@ public class TestHRegion { * @param families * @throws IOException * @return A region on which you must call - * {@link HRegion#closeHRegion(HRegion)} when done. + * {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} when done. */ - public static HRegion initHRegion(TableName tableName, String callingMethod, Configuration conf, + private static HRegion initHRegion(TableName tableName, String callingMethod, Configuration conf, byte[]... families) throws IOException { return initHRegion(tableName.getName(), null, null, callingMethod, conf, false, families); } @@ -4944,9 +4969,9 @@ public class TestHRegion { * @param families * @throws IOException * @return A region on which you must call - * {@link HRegion#closeHRegion(HRegion)} when done. + * {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} when done. */ - public static HRegion initHRegion(byte[] tableName, String callingMethod, Configuration conf, + private static HRegion initHRegion(byte[] tableName, String callingMethod, Configuration conf, byte[]... families) throws IOException { return initHRegion(tableName, null, null, callingMethod, conf, false, families); } @@ -4959,9 +4984,9 @@ public class TestHRegion { * @param families * @throws IOException * @return A region on which you must call - * {@link HRegion#closeHRegion(HRegion)} when done. + * {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} when done. */ - public static HRegion initHRegion(byte[] tableName, String callingMethod, Configuration conf, + private static HRegion initHRegion(byte[] tableName, String callingMethod, Configuration conf, boolean isReadOnly, byte[]... families) throws IOException { return initHRegion(tableName, null, null, callingMethod, conf, isReadOnly, families); } @@ -4969,8 +4994,11 @@ public class TestHRegion { private static HRegion initHRegion(byte[] tableName, byte[] startKey, byte[] stopKey, String callingMethod, Configuration conf, boolean isReadOnly, byte[]... families) throws IOException { + Path logDir = TEST_UTIL.getDataTestDirOnTestFS(callingMethod + ".log"); + HRegionInfo hri = new HRegionInfo(TableName.valueOf(tableName), startKey, stopKey); + final WAL wal = HBaseTestingUtility.createWal(conf, logDir, hri); return initHRegion(tableName, startKey, stopKey, callingMethod, conf, isReadOnly, - Durability.SYNC_WAL, null, families); + Durability.SYNC_WAL, wal, families); } /** @@ -4983,7 +5011,7 @@ public class TestHRegion { * @param families * @throws IOException * @return A region on which you must call - * {@link HRegion#closeHRegion(HRegion)} when done. + * {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} when done. */ private static HRegion initHRegion(byte[] tableName, byte[] startKey, byte[] stopKey, String callingMethod, Configuration conf, boolean isReadOnly, Durability durability, @@ -5060,7 +5088,7 @@ public class TestHRegion { assertFalse(hasNext); scanner.close(); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -5117,7 +5145,7 @@ public class TestHRegion { assertFalse(hasNext); scanner.close(); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -5171,7 +5199,7 @@ public class TestHRegion { assertFalse(hasNext); scanner.close(); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -5249,7 +5277,7 @@ public class TestHRegion { assertTrue(Bytes.equals(currRow.get(0).getRow(), rowD)); scanner.close(); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -5329,7 +5357,7 @@ public class TestHRegion { assertTrue(Bytes.equals(currRow.get(0).getRow(), rowD)); scanner.close(); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -5490,7 +5518,7 @@ public class TestHRegion { scanner.close(); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -5564,7 +5592,7 @@ public class TestHRegion { assertTrue(Bytes.equals(currRow.get(0).getRow(), row1)); assertFalse(hasNext); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -5659,7 +5687,7 @@ public class TestHRegion { assertEquals(verify, startRow - 1); scanner.close(); } finally { - HRegion.closeHRegion(this.region); + this.region.close(); this.region = null; } } @@ -5686,7 +5714,7 @@ public class TestHRegion { region.delete(new Delete(row)); Assert.assertEquals(4L, region.getWriteRequestsCount()); - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } @@ -5706,14 +5734,14 @@ public class TestHRegion { // open the region w/o rss and wal and flush some files HRegion region = - HRegion.createHRegion(hri, TEST_UTIL.getDataTestDir(), TEST_UTIL - .getConfiguration(), htd); + HBaseTestingUtility.createRegionAndWAL(hri, TEST_UTIL.getDataTestDir(), TEST_UTIL + .getConfiguration(), htd); assertNotNull(region); // create a file in fam1 for the region before opening in OpenRegionHandler region.put(new Put(Bytes.toBytes("a")).add(fam1, fam1, fam1)); region.flushcache(); - region.close(); + HBaseTestingUtility.closeRegionAndWAL(region); ArgumentCaptor<WALEdit> editCaptor = ArgumentCaptor.forClass(WALEdit.class); @@ -5757,7 +5785,7 @@ public class TestHRegion { assertEquals(0, store.getStoreFileCount()); // no store files } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } } @@ -5867,7 +5895,7 @@ public class TestHRegion { } catch (Throwable e) { } - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); region = null; CONF.setLong("hbase.busy.wait.duration", defaultBusyWaitDuration); } @@ -5892,9 +5920,9 @@ public class TestHRegion { Configuration conf = new Configuration(TEST_UTIL.getConfiguration()); conf.setInt(HFile.FORMAT_VERSION_KEY, HFile.MIN_FORMAT_VERSION_WITH_TAGS); - HRegion region = HRegion.createHRegion(new HRegionInfo(htd.getTableName(), - HConstants.EMPTY_BYTE_ARRAY, HConstants.EMPTY_BYTE_ARRAY), - TEST_UTIL.getDataTestDir(), conf, htd); + HRegion region = HBaseTestingUtility.createRegionAndWAL(new HRegionInfo(htd.getTableName(), + HConstants.EMPTY_BYTE_ARRAY, HConstants.EMPTY_BYTE_ARRAY), + TEST_UTIL.getDataTestDir(), conf, htd); assertNotNull(region); try { long now = EnvironmentEdgeManager.currentTime(); @@ -5996,7 +6024,7 @@ public class TestHRegion { assertNull(r.getValue(fam1, q1)); } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } } http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java index c7142fd..5fde726 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java @@ -65,11 +65,11 @@ public class TestHRegionInfo { Path basedir = htu.getDataTestDir(); // Create a region. That'll write the .regioninfo file. FSTableDescriptors fsTableDescriptors = new FSTableDescriptors(htu.getConfiguration()); - HRegion r = HRegion.createHRegion(hri, basedir, htu.getConfiguration(), - fsTableDescriptors.get(TableName.META_TABLE_NAME)); + HRegion r = HBaseTestingUtility.createRegionAndWAL(hri, basedir, htu.getConfiguration(), + fsTableDescriptors.get(TableName.META_TABLE_NAME)); // Get modtime on the file. long modtime = getModTime(r); - HRegion.closeHRegion(r); + HBaseTestingUtility.closeRegionAndWAL(r); Thread.sleep(1001); r = HRegion.openHRegion(basedir, hri, fsTableDescriptors.get(TableName.META_TABLE_NAME), null, htu.getConfiguration()); @@ -80,6 +80,7 @@ public class TestHRegionInfo { HRegionInfo deserializedHri = HRegionFileSystem.loadRegionInfoFileContent( r.getRegionFileSystem().getFileSystem(), r.getRegionFileSystem().getRegionDir()); assertTrue(hri.equals(deserializedHri)); + HBaseTestingUtility.closeRegionAndWAL(r); } long getModTime(final HRegion r) throws IOException { http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestJoinedScanners.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestJoinedScanners.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestJoinedScanners.java index d30b5f8..81d681c 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestJoinedScanners.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestJoinedScanners.java @@ -31,12 +31,8 @@ import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.fs.FileSystem; -import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HColumnDescriptor; -import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.MiniHBaseCluster; import org.apache.hadoop.hbase.TableName; @@ -176,26 +172,6 @@ public class TestJoinedScanners { + " seconds, got " + Long.toString(rows_count/2) + " rows"); } - private static HRegion initHRegion(byte[] tableName, byte[] startKey, byte[] stopKey, - String callingMethod, Configuration conf, byte[]... families) - throws IOException { - HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName)); - for(byte [] family : families) { - HColumnDescriptor hcd = new HColumnDescriptor(family); - hcd.setDataBlockEncoding(DataBlockEncoding.FAST_DIFF); - htd.addFamily(hcd); - } - HRegionInfo info = new HRegionInfo(htd.getTableName(), startKey, stopKey, false); - Path path = new Path(DIR + callingMethod); - FileSystem fs = FileSystem.get(conf); - if (fs.exists(path)) { - if (!fs.delete(path, true)) { - throw new IOException("Failed delete of " + path); - } - } - return HRegion.createHRegion(info, path, conf, htd); - } - private static Options options = new Options(); /** http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestKeepDeletes.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestKeepDeletes.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestKeepDeletes.java index 341b02c..49ee7e9 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestKeepDeletes.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestKeepDeletes.java @@ -179,7 +179,7 @@ public class TestKeepDeletes { checkResult(r, c0, c0, T1); assertEquals(0, countDeleteMarkers(region)); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /** @@ -229,7 +229,7 @@ public class TestKeepDeletes { scan.next(kvs); assertTrue(kvs.isEmpty()); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /** @@ -274,7 +274,7 @@ public class TestKeepDeletes { // major compaction deleted it assertEquals(0, countDeleteMarkers(region)); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /** @@ -298,7 +298,7 @@ public class TestKeepDeletes { // ok! } - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /** @@ -388,7 +388,7 @@ public class TestKeepDeletes { assertTrue(CellUtil.isDelete(kvs.get(1))); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /** @@ -431,7 +431,7 @@ public class TestKeepDeletes { region.compactStores(true); assertEquals(0, countDeleteMarkers(region)); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /** @@ -494,7 +494,7 @@ public class TestKeepDeletes { region.compactStores(true); assertEquals(0, countDeleteMarkers(region)); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /** @@ -572,7 +572,7 @@ public class TestKeepDeletes { region.compactStores(true); assertEquals(1, countDeleteMarkers(region)); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /** @@ -652,7 +652,7 @@ public class TestKeepDeletes { checkGet(region, T2, c1, c0, ts+3, T2, T1); checkGet(region, T2, c1, c1, ts+3, T2, T1); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /** @@ -747,7 +747,7 @@ public class TestKeepDeletes { region.compactStores(true); assertEquals(1, countDeleteMarkers(region)); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /** @@ -797,7 +797,7 @@ public class TestKeepDeletes { assertEquals(4, kvs.size()); scanner.close(); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /** @@ -876,7 +876,7 @@ public class TestKeepDeletes { region.compactStores(true); assertEquals(0, countDeleteMarkers(region)); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /** @@ -921,7 +921,7 @@ public class TestKeepDeletes { // all delete marker gone assertEquals(0, countDeleteMarkers(region)); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } private void checkGet(HRegion region, byte[] row, byte[] fam, byte[] col, http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMinVersions.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMinVersions.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMinVersions.java index d022acb..16f29dc 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMinVersions.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMinVersions.java @@ -105,7 +105,7 @@ public class TestMinVersions { r = region.getClosestRowBefore(T2, c0); checkResult(r, c0, T4); } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } } @@ -162,7 +162,7 @@ public class TestMinVersions { r = region.get(g); // this'll use ExplicitColumnTracker checkResult(r, c0, T3,T2,T1); } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } } @@ -221,7 +221,7 @@ public class TestMinVersions { r = region.get(g); // this'll use ExplicitColumnTracker checkResult(r, c0, T3); } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } } @@ -296,7 +296,7 @@ public class TestMinVersions { r = region.get(g); // this'll use ExplicitColumnTracker checkResult(r, c0, T5,T4); } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } } @@ -388,7 +388,7 @@ public class TestMinVersions { r = region.get(g); assertTrue(r.isEmpty()); } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } } @@ -463,7 +463,7 @@ public class TestMinVersions { r = region.get(g); checkResult(r, c0, T2); } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } } http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMultiColumnScanner.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMultiColumnScanner.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMultiColumnScanner.java index 51cc9d5..9f0b339 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMultiColumnScanner.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMultiColumnScanner.java @@ -285,7 +285,7 @@ public class TestMultiColumnScanner { "pairs", lastDelTimeMap.size() > 0); LOG.info("Number of row/col pairs deleted at least once: " + lastDelTimeMap.size()); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } private static String getRowQualStr(Cell kv) { http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestPerColumnFamilyFlush.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestPerColumnFamilyFlush.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestPerColumnFamilyFlush.java index ae8f64f..e3f51ea 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestPerColumnFamilyFlush.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestPerColumnFamilyFlush.java @@ -65,8 +65,6 @@ import com.google.common.hash.Hashing; public class TestPerColumnFamilyFlush { private static final Log LOG = LogFactory.getLog(TestPerColumnFamilyFlush.class); - HRegion region = null; - private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); private static final Path DIR = TEST_UTIL.getDataTestDir("TestHRegion"); @@ -82,14 +80,14 @@ public class TestPerColumnFamilyFlush { public static final byte[] FAMILY3 = families[2]; - private void initHRegion(String callingMethod, Configuration conf) throws IOException { + private HRegion initHRegion(String callingMethod, Configuration conf) throws IOException { HTableDescriptor htd = new HTableDescriptor(TABLENAME); for (byte[] family : families) { htd.addFamily(new HColumnDescriptor(family)); } HRegionInfo info = new HRegionInfo(TABLENAME, null, null, false); Path path = new Path(DIR, callingMethod); - region = HRegion.createHRegion(info, path, conf, htd); + return HBaseTestingUtility.createRegionAndWAL(info, path, conf, htd); } // A helper function to create puts. @@ -129,7 +127,7 @@ public class TestPerColumnFamilyFlush { conf.set(FlushPolicyFactory.HBASE_FLUSH_POLICY_KEY, FlushLargeStoresPolicy.class.getName()); conf.setLong(FlushLargeStoresPolicy.HREGION_COLUMNFAMILY_FLUSH_SIZE_LOWER_BOUND, 100 * 1024); // Intialize the HRegion - initHRegion("testSelectiveFlushWhenEnabled", conf); + HRegion region = initHRegion("testSelectiveFlushWhenEnabled", conf); // Add 1200 entries for CF1, 100 for CF2 and 50 for CF3 for (int i = 1; i <= 1200; i++) { region.put(createPut(1, i)); @@ -257,6 +255,7 @@ public class TestPerColumnFamilyFlush { // Since we won't find any CF above the threshold, and hence no specific // store to flush, we should flush all the memstores. assertEquals(0, region.getMemstoreSize().get()); + HBaseTestingUtility.closeRegionAndWAL(region); } @Test (timeout=180000) @@ -267,7 +266,7 @@ public class TestPerColumnFamilyFlush { conf.set(FlushPolicyFactory.HBASE_FLUSH_POLICY_KEY, FlushAllStoresPolicy.class.getName()); // Intialize the HRegion - initHRegion("testSelectiveFlushWhenNotEnabled", conf); + HRegion region = initHRegion("testSelectiveFlushWhenNotEnabled", conf); // Add 1200 entries for CF1, 100 for CF2 and 50 for CF3 for (int i = 1; i <= 1200; i++) { region.put(createPut(1, i)); @@ -312,6 +311,7 @@ public class TestPerColumnFamilyFlush { assertEquals(DefaultMemStore.DEEP_OVERHEAD, cf3MemstoreSize); assertEquals(0, totalMemstoreSize); assertEquals(HConstants.NO_SEQNUM, smallestSeqInRegionCurrentMemstore); + HBaseTestingUtility.closeRegionAndWAL(region); } // Find the (first) region which has the specified name. @@ -585,7 +585,7 @@ public class TestPerColumnFamilyFlush { table.close(); conn.close(); - region = getRegionWithName(TABLENAME).getFirst(); + HRegion region = getRegionWithName(TABLENAME).getFirst(); cf1StoreFileCount1 = region.getStore(FAMILY1).getStorefilesCount(); cf2StoreFileCount1 = region.getStore(FAMILY2).getStorefilesCount(); cf3StoreFileCount1 = region.getStore(FAMILY3).getStorefilesCount(); http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionMergeTransaction.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionMergeTransaction.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionMergeTransaction.java index 8b5b4a3..8bcd89e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionMergeTransaction.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionMergeTransaction.java @@ -248,7 +248,7 @@ public class TestRegionMergeTransaction { assertEquals((rowCountOfRegionA + rowCountOfRegionB), mergedRegionRowCount); } finally { - HRegion.closeHRegion(mergedRegion); + HBaseTestingUtility.closeRegionAndWAL(mergedRegion); } // Assert the write lock is no longer held on region_a and region_b assertTrue(!this.region_a.lock.writeLock().isHeldByCurrentThread()); @@ -308,7 +308,7 @@ public class TestRegionMergeTransaction { assertEquals((rowCountOfRegionA + rowCountOfRegionB), mergedRegionRowCount); } finally { - HRegion.closeHRegion(mergedRegion); + HBaseTestingUtility.closeRegionAndWAL(mergedRegion); } // Assert the write lock is no longer held on region_a and region_b assertTrue(!this.region_a.lock.writeLock().isHeldByCurrentThread()); @@ -412,9 +412,9 @@ public class TestRegionMergeTransaction { HColumnDescriptor hcd = new HColumnDescriptor(CF); htd.addFamily(hcd); HRegionInfo hri = new HRegionInfo(htd.getTableName(), startrow, endrow); - HRegion a = HRegion.createHRegion(hri, testdir, + HRegion a = HBaseTestingUtility.createRegionAndWAL(hri, testdir, TEST_UTIL.getConfiguration(), htd); - HRegion.closeHRegion(a); + HBaseTestingUtility.closeRegionAndWAL(a); return HRegion.openHRegion(testdir, hri, htd, wals.getWAL(hri.getEncodedNameAsBytes()), TEST_UTIL.getConfiguration()); } http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestResettingCounters.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestResettingCounters.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestResettingCounters.java index 27bdda0..dd7ef29 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestResettingCounters.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestResettingCounters.java @@ -69,7 +69,7 @@ public class TestResettingCounters { throw new IOException("Failed delete of " + path); } } - HRegion region = HRegion.createHRegion(hri, path, conf, htd); + HRegion region = HBaseTestingUtility.createRegionAndWAL(hri, path, conf, htd); try { Increment odd = new Increment(rows[0]); odd.setDurability(Durability.SKIP_WAL); @@ -100,9 +100,9 @@ public class TestResettingCounters { assertEquals(6, Bytes.toLong(CellUtil.cloneValue(kvs[i]))); } } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } } http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestReversibleScanners.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestReversibleScanners.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestReversibleScanners.java index 5a95df11..9cb35ca 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestReversibleScanners.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestReversibleScanners.java @@ -31,19 +31,19 @@ import java.util.NavigableSet; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.Cell; -import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HBaseTestingUtility; +import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HConstants; +import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.KeepDeletedCells; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.KeyValueUtil; +import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests; -import org.apache.hadoop.hbase.client.Durability; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.Scan; @@ -308,12 +308,11 @@ public class TestReversibleScanners { @Test public void testReversibleRegionScanner() throws IOException { - byte[] tableName = Bytes.toBytes("testtable"); byte[] FAMILYNAME2 = Bytes.toBytes("testCf2"); - Configuration conf = HBaseConfiguration.create(); - HRegion region = TEST_UTIL.createLocalHRegion(tableName, null, null, - "testReversibleRegionScanner", conf, false, Durability.SYNC_WAL, null, - FAMILYNAME, FAMILYNAME2); + HTableDescriptor htd = new HTableDescriptor(TableName.valueOf("testtable")) + .addFamily(new HColumnDescriptor(FAMILYNAME)) + .addFamily(new HColumnDescriptor(FAMILYNAME2)); + HRegion region = TEST_UTIL.createLocalHRegion(htd, null, null); loadDataToRegion(region, FAMILYNAME2); // verify row count with forward scan http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScanWithBloomError.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScanWithBloomError.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScanWithBloomError.java index afe02be..9163e61 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScanWithBloomError.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScanWithBloomError.java @@ -113,7 +113,7 @@ public class TestScanWithBloomError { createStoreFile(new int[] {1, 9}); scanColSet(new int[]{1, 4, 6, 7}, new int[]{1, 6, 7}); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } private void scanColSet(int[] colSet, int[] expectedResultCols) http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScanner.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScanner.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScanner.java index 08b8dcc..72f556e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScanner.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScanner.java @@ -162,7 +162,7 @@ public class TestScanner { assertTrue(count > 10); s.close(); } finally { - HRegion.closeHRegion(this.r); + HBaseTestingUtility.closeRegionAndWAL(this.r); } } @@ -215,7 +215,7 @@ public class TestScanner { rowInclusiveStopFilter(scan, stopRow); } finally { - HRegion.closeHRegion(this.r); + HBaseTestingUtility.closeRegionAndWAL(this.r); } } @@ -242,7 +242,7 @@ public class TestScanner { return; } } finally { - HRegion.closeHRegion(this.r); + HBaseTestingUtility.closeRegionAndWAL(this.r); } } @@ -355,7 +355,7 @@ public class TestScanner { } finally { // clean up - HRegion.closeHRegion(r); + HBaseTestingUtility.closeRegionAndWAL(r); } } @@ -475,7 +475,7 @@ public class TestScanner { LOG.error("Failed", e); throw e; } finally { - HRegion.closeHRegion(this.r); + HBaseTestingUtility.closeRegionAndWAL(this.r); } } @@ -498,7 +498,7 @@ public class TestScanner { LOG.error("Failed", e); throw e; } finally { - HRegion.closeHRegion(this.r); + HBaseTestingUtility.closeRegionAndWAL(this.r); } } @@ -555,7 +555,7 @@ public class TestScanner { assertTrue(CellUtil.matchingFamily(results.get(0), fam1)); assertTrue(CellUtil.matchingFamily(results.get(1), fam2)); } finally { - HRegion.closeHRegion(this.r); + HBaseTestingUtility.closeRegionAndWAL(this.r); } } http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSeekOptimizations.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSeekOptimizations.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSeekOptimizations.java index ec81ac1..ffc76f3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSeekOptimizations.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSeekOptimizations.java @@ -439,7 +439,7 @@ public class TestSeekOptimizations { @After public void tearDown() throws IOException { if (region != null) { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } // We have to re-set the lazy seek flag back to the default so that other http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransaction.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransaction.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransaction.java index 66375e9..9c9fa6f 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransaction.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransaction.java @@ -24,7 +24,6 @@ import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doCallRealMethod; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.spy; @@ -248,7 +247,7 @@ public class TestSplitTransaction { assertTrue(count > 0 && count != rowcount); daughtersRowCount += count; } finally { - HRegion.closeHRegion(openRegion); + HBaseTestingUtility.closeRegionAndWAL(openRegion); } } assertEquals(rowcount, daughtersRowCount); @@ -332,7 +331,7 @@ public class TestSplitTransaction { assertTrue(count > 0 && count != rowcount); daughtersRowCount += count; } finally { - HRegion.closeHRegion(openRegion); + HBaseTestingUtility.closeRegionAndWAL(openRegion); } } assertEquals(rowcount, daughtersRowCount); @@ -376,8 +375,9 @@ public class TestSplitTransaction { HColumnDescriptor hcd = new HColumnDescriptor(CF); htd.addFamily(hcd); HRegionInfo hri = new HRegionInfo(htd.getTableName(), STARTROW, ENDROW); - HRegion r = HRegion.createHRegion(hri, testdir, TEST_UTIL.getConfiguration(), htd); - HRegion.closeHRegion(r); + HRegion r = HBaseTestingUtility.createRegionAndWAL(hri, testdir, TEST_UTIL.getConfiguration(), + htd); + HBaseTestingUtility.closeRegionAndWAL(r); return HRegion.openHRegion(testdir, hri, htd, wals.getWAL(hri.getEncodedNameAsBytes()), TEST_UTIL.getConfiguration()); } http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestWideScanner.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestWideScanner.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestWideScanner.java index b929cfe..ba05e9a 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestWideScanner.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestWideScanner.java @@ -30,6 +30,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.CellUtil; import org.apache.hadoop.hbase.HBaseTestCase; +import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.testclassification.RegionServerTests; @@ -138,7 +139,7 @@ public class TestWideScanner extends HBaseTestCase { s.close(); } finally { - HRegion.closeHRegion(this.r); + HBaseTestingUtility.closeRegionAndWAL(this.r); } } http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestFSHLog.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestFSHLog.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestFSHLog.java index 970b0f2..2c25e3b 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestFSHLog.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestFSHLog.java @@ -37,7 +37,6 @@ import java.util.concurrent.atomic.AtomicLong; import org.apache.commons.lang.mutable.MutableBoolean; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.commons.logging.impl.Log4JLogger; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; @@ -68,10 +67,6 @@ import org.apache.hadoop.hbase.util.Threads; import org.apache.hadoop.hbase.wal.DefaultWALProvider; import org.apache.hadoop.hbase.wal.WAL; import org.apache.hadoop.hbase.wal.WALKey; -import org.apache.hadoop.hdfs.DFSClient; -import org.apache.hadoop.hdfs.server.datanode.DataNode; -import org.apache.hadoop.hdfs.server.namenode.LeaseManager; -import org.apache.log4j.Level; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -395,7 +390,7 @@ public class TestFSHLog { * flush. The addition of the sync over HRegion in flush should fix an issue where flush was * returning before all of its appends had made it out to the WAL (HBASE-11109). * @throws IOException - * @see HBASE-11109 + * @see <a href="https://issues.apache.org/jira/browse/HBASE-11109">HBASE-11109</a> */ @Test public void testFlushSequenceIdIsGreaterThanAllEditsInHFile() throws IOException { @@ -405,9 +400,9 @@ public class TestFSHLog { final byte[] rowName = tableName.getName(); final HTableDescriptor htd = new HTableDescriptor(tableName); htd.addFamily(new HColumnDescriptor("f")); - HRegion r = HRegion.createHRegion(hri, TEST_UTIL.getDefaultRootDirPath(), - TEST_UTIL.getConfiguration(), htd); - HRegion.closeHRegion(r); + HRegion r = HBaseTestingUtility.createRegionAndWAL(hri, TEST_UTIL.getDefaultRootDirPath(), + TEST_UTIL.getConfiguration(), htd); + HBaseTestingUtility.closeRegionAndWAL(r); final int countPerFamily = 10; final MutableBoolean goslow = new MutableBoolean(false); // subclass and doctor a method. http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplay.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplay.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplay.java index c441969..bb634d1 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplay.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplay.java @@ -57,7 +57,6 @@ import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.ZooKeeperConnectionException; import org.apache.hadoop.hbase.client.Delete; import org.apache.hadoop.hbase.client.Get; -import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.ResultScanner; @@ -273,7 +272,7 @@ public class TestWALReplay { /** * Tests for hbase-2727. * @throws Exception - * @see https://issues.apache.org/jira/browse/HBASE-2727 + * @see <a href="https://issues.apache.org/jira/browse/HBASE-2727">HBASE-2727</a> */ @Test public void test2727() throws Exception { @@ -286,9 +285,8 @@ public class TestWALReplay { deleteDir(basedir); HTableDescriptor htd = createBasic3FamilyHTD(tableName); - HRegion region2 = HRegion.createHRegion(hri, - hbaseRootDir, this.conf, htd); - HRegion.closeHRegion(region2); + HRegion region2 = HBaseTestingUtility.createRegionAndWAL(hri, hbaseRootDir, this.conf, htd); + HBaseTestingUtility.closeRegionAndWAL(region2); final byte [] rowName = tableName.getName(); WAL wal1 = createWAL(this.conf); @@ -348,9 +346,8 @@ public class TestWALReplay { final Path basedir = new Path(this.hbaseRootDir, tableName.getNameAsString()); deleteDir(basedir); final HTableDescriptor htd = createBasic3FamilyHTD(tableName); - HRegion region2 = HRegion.createHRegion(hri, - hbaseRootDir, this.conf, htd); - HRegion.closeHRegion(region2); + HRegion region2 = HBaseTestingUtility.createRegionAndWAL(hri, hbaseRootDir, this.conf, htd); + HBaseTestingUtility.closeRegionAndWAL(region2); WAL wal = createWAL(this.conf); HRegion region = HRegion.openHRegion(hri, htd, wal, this.conf); @@ -415,9 +412,8 @@ public class TestWALReplay { final Path basedir = new Path(this.hbaseRootDir, tableName.getNameAsString()); deleteDir(basedir); final HTableDescriptor htd = createBasic3FamilyHTD(tableName); - HRegion region2 = HRegion.createHRegion(hri, - hbaseRootDir, this.conf, htd); - HRegion.closeHRegion(region2); + HRegion region2 = HBaseTestingUtility.createRegionAndWAL(hri, hbaseRootDir, this.conf, htd); + HBaseTestingUtility.closeRegionAndWAL(region2); WAL wal = createWAL(this.conf); HRegion region = HRegion.openHRegion(hri, htd, wal, this.conf); @@ -488,9 +484,8 @@ public class TestWALReplay { final byte[] rowName = tableName.getName(); final int countPerFamily = 10; final HTableDescriptor htd = createBasic3FamilyHTD(tableName); - HRegion region3 = HRegion.createHRegion(hri, - hbaseRootDir, this.conf, htd); - HRegion.closeHRegion(region3); + HRegion region3 = HBaseTestingUtility.createRegionAndWAL(hri, hbaseRootDir, this.conf, htd); + HBaseTestingUtility.closeRegionAndWAL(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. @@ -598,9 +593,8 @@ public class TestWALReplay { final byte[] rowName = tableName.getName(); final int countPerFamily = 10; final HTableDescriptor htd = createBasic3FamilyHTD(tableName); - HRegion region3 = HRegion.createHRegion(hri, - hbaseRootDir, this.conf, htd); - HRegion.closeHRegion(region3); + HRegion region3 = HBaseTestingUtility.createRegionAndWAL(hri, hbaseRootDir, this.conf, htd); + HBaseTestingUtility.closeRegionAndWAL(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. @@ -681,9 +675,8 @@ public class TestWALReplay { final Path basedir = FSUtils.getTableDir(this.hbaseRootDir, tableName); deleteDir(basedir); final HTableDescriptor htd = createBasic3FamilyHTD(tableName); - HRegion region3 = HRegion.createHRegion(hri, hbaseRootDir, this.conf, htd); - region3.close(); - region3.getWAL().close(); + HRegion region3 = HBaseTestingUtility.createRegionAndWAL(hri, hbaseRootDir, this.conf, htd); + HBaseTestingUtility.closeRegionAndWAL(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. @@ -780,9 +773,8 @@ public class TestWALReplay { deleteDir(basedir); final HTableDescriptor htd = createBasic3FamilyHTD(tableName); - HRegion region2 = HRegion.createHRegion(hri, - hbaseRootDir, this.conf, htd); - HRegion.closeHRegion(region2); + HRegion region2 = HBaseTestingUtility.createRegionAndWAL(hri, hbaseRootDir, this.conf, htd); + HBaseTestingUtility.closeRegionAndWAL(region2); final WAL wal = createWAL(this.conf); final byte[] rowName = tableName.getName(); final byte[] regionName = hri.getEncodedNameAsBytes(); http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMergeTable.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMergeTable.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMergeTable.java index 69e5d70..6a86580 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMergeTable.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMergeTable.java @@ -31,9 +31,6 @@ import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.*; import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; -import org.apache.hadoop.hbase.client.ConnectionFactory; -import org.apache.hadoop.hbase.client.HBaseAdmin; -import org.apache.hadoop.hbase.client.HConnectionManager; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Durability; import org.apache.hadoop.hbase.regionserver.HRegion; @@ -143,7 +140,8 @@ public class TestMergeTable { byte [] startKey, byte [] endKey, int firstRow, int nrows, Path rootdir) throws IOException { HRegionInfo hri = new HRegionInfo(desc.getTableName(), startKey, endKey); - HRegion region = HRegion.createHRegion(hri, rootdir, UTIL.getConfiguration(), desc); + HRegion region = HBaseTestingUtility.createRegionAndWAL(hri, rootdir, UTIL.getConfiguration(), + desc); LOG.info("Created region " + region.getRegionNameAsString()); for(int i = firstRow; i < firstRow + nrows; i++) { Put put = new Put(Bytes.toBytes("row_" + String.format("%1$05d", i))); @@ -155,19 +153,19 @@ public class TestMergeTable { region.flushcache(); } } - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); return region; } protected void setupMeta(Path rootdir, final HRegion [] regions) throws IOException { HRegion meta = - HRegion.createHRegion(HRegionInfo.FIRST_META_REGIONINFO, rootdir, - UTIL.getConfiguration(), UTIL.getMetaTableDescriptor()); + HBaseTestingUtility.createRegionAndWAL(HRegionInfo.FIRST_META_REGIONINFO, rootdir, + UTIL.getConfiguration(), UTIL.getMetaTableDescriptor()); for (HRegion r: regions) { HRegion.addRegionToMETA(meta, r); } - HRegion.closeHRegion(meta); + HBaseTestingUtility.closeRegionAndWAL(meta); } } http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMergeTool.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMergeTool.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMergeTool.java index 0f6d697..b04e5de 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMergeTool.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMergeTool.java @@ -156,7 +156,8 @@ public class TestMergeTool extends HBaseTestCase { */ for (int i = 0; i < sourceRegions.length; i++) { regions[i] = - HRegion.createHRegion(this.sourceRegions[i], testDir, this.conf, this.desc); + HBaseTestingUtility.createRegionAndWAL(this.sourceRegions[i], testDir, this.conf, + this.desc); /* * Insert data */ @@ -183,7 +184,7 @@ public class TestMergeTool extends HBaseTestCase { for (int i = 0; i < sourceRegions.length; i++) { HRegion r = regions[i]; if (r != null) { - HRegion.closeHRegion(r); + HBaseTestingUtility.closeRegionAndWAL(r); } } wals.close(); @@ -272,7 +273,7 @@ public class TestMergeTool extends HBaseTestCase { assertTrue(Bytes.equals(bytes, rows[i][j])); } // Close the region and delete the log - HRegion.closeHRegion(regions[i]); + HBaseTestingUtility.closeRegionAndWAL(regions[i]); } WAL log = wals.getWAL(new byte[]{}); // Merge Region 0 and Region 1
