From f27db0f5d8295170963c83b4e0658ba9b5feef7a Mon Sep 17 00:00:00 2001 From: Nick Dimiduk Date: Tue, 13 Jan 2015 12:35:19 -0800 Subject: [PATCH] HBASE-11983 HRegion constructors should not create HLog Conflicts: hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestCase.java hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestGetClosestAtOrBefore.java hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestReversibleScanners.java hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMergeTable.java hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMergeTool.java --- .../hadoop/hbase/master/MasterFileSystem.java | 4 +- .../apache/hadoop/hbase/regionserver/HRegion.java | 115 +-------- .../hbase/snapshot/RestoreSnapshotHelper.java | 6 +- .../org/apache/hadoop/hbase/util/HBaseFsck.java | 30 ++- .../apache/hadoop/hbase/util/HBaseFsckRepair.java | 2 +- .../hadoop/hbase/util/ModifyRegionUtils.java | 65 ++---- .../org/apache/hadoop/hbase/wal/WALFactory.java | 2 +- .../org/apache/hadoop/hbase/HBaseTestCase.java | 13 +- .../apache/hadoop/hbase/HBaseTestingUtility.java | 82 +++++-- .../hbase/client/TestIntraRowPagination.java | 6 +- .../coprocessor/TestCoprocessorInterface.java | 7 +- .../TestRegionObserverScannerOpenHook.java | 7 +- .../coprocessor/TestRegionObserverStacking.java | 3 +- .../hbase/filter/TestColumnPrefixFilter.java | 16 +- .../hbase/filter/TestDependentColumnFilter.java | 6 +- .../org/apache/hadoop/hbase/filter/TestFilter.java | 18 +- .../hbase/filter/TestInvocationRecordFilter.java | 2 +- .../filter/TestMultipleColumnPrefixFilter.java | 18 +- .../hadoop/hbase/io/encoding/TestPrefixTree.java | 4 +- .../hfile/TestScannerSelectionUsingKeyRange.java | 5 +- .../io/hfile/TestScannerSelectionUsingTTL.java | 5 +- .../hadoop/hbase/master/TestMasterFailover.java | 4 +- .../hbase/master/TestOpenedRegionHandler.java | 5 +- .../hbase/migration/TestNamespaceUpgrade.java | 2 +- .../hbase/regionserver/TestAtomicOperation.java | 5 +- .../hadoop/hbase/regionserver/TestBlocksRead.java | 12 +- .../hbase/regionserver/TestColumnSeeking.java | 6 +- .../regionserver/TestDefaultCompactSelection.java | 4 +- .../regionserver/TestGetClosestAtOrBefore.java | 15 +- .../hadoop/hbase/regionserver/TestHRegion.java | 260 ++++++++++++--------- .../hadoop/hbase/regionserver/TestHRegionInfo.java | 8 +- .../hbase/regionserver/TestJoinedScanners.java | 24 -- .../hadoop/hbase/regionserver/TestKeepDeletes.java | 26 +-- .../hadoop/hbase/regionserver/TestMinVersions.java | 12 +- .../hbase/regionserver/TestMultiColumnScanner.java | 2 +- .../regionserver/TestPerColumnFamilyFlush.java | 14 +- .../regionserver/TestRegionMergeTransaction.java | 8 +- .../hbase/regionserver/TestResettingCounters.java | 6 +- .../hbase/regionserver/TestReversibleScanners.java | 15 +- .../hbase/regionserver/TestScanWithBloomError.java | 2 +- .../hadoop/hbase/regionserver/TestScanner.java | 14 +- .../hbase/regionserver/TestSeekOptimizations.java | 2 +- .../hbase/regionserver/TestSplitTransaction.java | 9 +- .../hadoop/hbase/regionserver/TestWideScanner.java | 3 +- .../handler/TestCloseRegionHandler.java | 2 +- .../handler/TestOpenRegionHandler.java | 14 +- .../hadoop/hbase/regionserver/wal/TestFSHLog.java | 8 +- .../hbase/regionserver/wal/TestWALReplay.java | 39 ++-- .../apache/hadoop/hbase/util/TestMergeTable.java | 11 +- .../apache/hadoop/hbase/util/TestMergeTool.java | 6 +- 50 files changed, 436 insertions(+), 518 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java index 93bde36..352fbfe 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java @@ -511,9 +511,9 @@ public class MasterFileSystem { HRegionInfo metaHRI = new HRegionInfo(HRegionInfo.FIRST_META_REGIONINFO); HTableDescriptor metaDescriptor = new FSTableDescriptors(c).get(TableName.META_TABLE_NAME); setInfoFamilyCachingForMeta(metaDescriptor, false); - HRegion meta = HRegion.createHRegion(metaHRI, rd, c, metaDescriptor); + HRegion meta = HRegion.createHRegion(metaHRI, rd, c, metaDescriptor, null); setInfoFamilyCachingForMeta(metaDescriptor, true); - HRegion.closeHRegion(meta); + meta.close(); } catch (IOException e) { e = RemoteExceptionHandler.checkIOException(e); LOG.error("bootstrap", e); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java index 7ada09a..a47868a 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java @@ -61,7 +61,6 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantReadWriteLock; -import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; @@ -133,8 +132,6 @@ import org.apache.hadoop.hbase.protobuf.generated.WALProtos.RegionEventDescripto import org.apache.hadoop.hbase.regionserver.MultiVersionConsistencyControl.WriteEntry; import org.apache.hadoop.hbase.regionserver.compactions.CompactionContext; import org.apache.hadoop.hbase.regionserver.wal.HLogKey; -import org.apache.hadoop.hbase.regionserver.wal.MetricsWAL; -import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener; import org.apache.hadoop.hbase.regionserver.wal.WALEdit; import org.apache.hadoop.hbase.regionserver.wal.WALUtil; import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; @@ -3368,13 +3365,10 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver { // * not check the families for validity. * * @param familyMap Map of kvs per family - * @param localizedWriteEntry The WriteEntry of the MVCC for this transaction. - * If null, then this method internally creates a mvcc transaction. - * @param output newly added KVs into memstore + * @param mvccNum The MVCC for this transaction. * @param isInReplay true when adding replayed KVs into memstore * @return the additional memory usage of the memstore caused by the * new entries. - * @throws IOException */ private long applyFamilyMapToMemstore(Map> familyMap, long mvccNum, List memstoreCells, boolean isInReplay) throws IOException { @@ -4658,55 +4652,13 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver { // } /** - * Convenience method creating new HRegions. Used by createTable and by the - * bootstrap code in the HMaster constructor. - * Note, this method creates an {@link WAL} for the created region. It - * needs to be closed explicitly. Use {@link HRegion#getWAL()} to get - * access. When done with a region created using this method, you will - * need to explicitly close the {@link WAL} it created too; it will not be - * done for you. Not closing the wal will leave at least a daemon thread - * running. Call {@link #closeHRegion(HRegion)} and it will do - * necessary cleanup for you. - * @param info Info for region to create. - * @param rootDir Root directory for HBase instance - * @return new HRegion - * - * @throws IOException - */ - public static HRegion createHRegion(final HRegionInfo info, final Path rootDir, - final Configuration conf, final HTableDescriptor hTableDescriptor) - throws IOException { - return createHRegion(info, rootDir, conf, hTableDescriptor, null); - } - - /** - * This will do the necessary cleanup a call to - * {@link #createHRegion(HRegionInfo, Path, Configuration, HTableDescriptor)} - * requires. This method will close the region and then close its - * associated {@link WAL} file. You can still use it if you call the other createHRegion, - * the one that takes an {@link WAL} instance but don't be surprised by the - * call to the {@link WAL#close()} on the {@link WAL} the - * HRegion was carrying. - * @throws IOException - */ - public static void closeHRegion(final HRegion r) throws IOException { - if (r == null) return; - r.close(); - if (r.getWAL() == null) return; - r.getWAL().close(); - } - - /** * Convenience method creating new HRegions. Used by createTable. - * The {@link WAL} for the created region needs to be closed explicitly. - * Use {@link HRegion#getWAL()} to get access. * * @param info Info for region to create. * @param rootDir Root directory for HBase instance * @param wal shared WAL * @param initialize - true to initialize the region * @return new HRegion - * * @throws IOException */ public static HRegion createHRegion(final HRegionInfo info, final Path rootDir, @@ -4715,75 +4667,14 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver { // final WAL wal, final boolean initialize) throws IOException { - return createHRegion(info, rootDir, conf, hTableDescriptor, - wal, initialize, false); - } - - /** - * Convenience method creating new HRegions. Used by createTable. - * The {@link WAL} for the created region needs to be closed - * explicitly, if it is not null. - * Use {@link HRegion#getWAL()} to get access. - * - * @param info Info for region to create. - * @param rootDir Root directory for HBase instance - * @param wal shared WAL - * @param initialize - true to initialize the region - * @param ignoreWAL - true to skip generate new wal if it is null, mostly for createTable - * @return new HRegion - * @throws IOException - */ - public static HRegion createHRegion(final HRegionInfo info, final Path rootDir, - final Configuration conf, - final HTableDescriptor hTableDescriptor, - final WAL wal, - final boolean initialize, final boolean ignoreWAL) - throws IOException { - Path tableDir = FSUtils.getTableDir(rootDir, info.getTable()); - return createHRegion(info, rootDir, tableDir, conf, hTableDescriptor, wal, initialize, - ignoreWAL); - } - - /** - * Convenience method creating new HRegions. Used by createTable. - * The {@link WAL} for the created region needs to be closed - * explicitly, if it is not null. - * Use {@link HRegion#getWAL()} to get access. - * - * @param info Info for region to create. - * @param rootDir Root directory for HBase instance - * @param tableDir table directory - * @param wal shared WAL - * @param initialize - true to initialize the region - * @param ignoreWAL - true to skip generate new wal if it is null, mostly for createTable - * @return new HRegion - * @throws IOException - */ - public static HRegion createHRegion(final HRegionInfo info, final Path rootDir, final Path tableDir, - final Configuration conf, - final HTableDescriptor hTableDescriptor, - final WAL wal, - final boolean initialize, final boolean ignoreWAL) - throws IOException { LOG.info("creating HRegion " + info.getTable().getNameAsString() + " HTD == " + hTableDescriptor + " RootDir = " + rootDir + " Table name == " + info.getTable().getNameAsString()); FileSystem fs = FileSystem.get(conf); + Path tableDir = FSUtils.getTableDir(rootDir, info.getTable()); HRegionFileSystem.createRegionOnFileSystem(conf, fs, tableDir, info); - WAL effectiveWAL = wal; - if (wal == null && !ignoreWAL) { - // TODO HBASE-11983 There'll be no roller for this wal? - // The WAL subsystem will use the default rootDir rather than the passed in rootDir - // unless I pass along via the conf. - Configuration confForWAL = new Configuration(conf); - confForWAL.set(HConstants.HBASE_DIR, rootDir.toString()); - effectiveWAL = (new WALFactory(confForWAL, - Collections.singletonList(new MetricsWAL()), - "hregion-" + RandomStringUtils.randomNumeric(8))). - getWAL(info.getEncodedNameAsBytes()); - } HRegion region = HRegion.newHRegion(tableDir, - effectiveWAL, fs, conf, info, hTableDescriptor, null); + wal, fs, conf, info, hTableDescriptor, null); if (initialize) { // If initializing, set the sequenceId. It is also required by WALPerformanceEvaluation when // verifying the WALEdits. diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/RestoreSnapshotHelper.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/RestoreSnapshotHelper.java index 08d776f..81e9c13 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/RestoreSnapshotHelper.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/RestoreSnapshotHelper.java @@ -507,7 +507,7 @@ public class RestoreSnapshotHelper { } // create the regions on disk - ModifyRegionUtils.createRegions(exec, conf, rootDir, tableDir, + ModifyRegionUtils.createRegions(exec, conf, rootDir, tableDesc, clonedRegionsInfo, new ModifyRegionUtils.RegionFillTask() { @Override public void fillRegion(final HRegion region) throws IOException { @@ -553,7 +553,7 @@ public class RestoreSnapshotHelper { * * @param familyDir destination directory for the store file * @param regionInfo destination region info for the table - * @param hfileName store file name (can be a Reference, HFileLink or simple HFile) + * @param storeFile store file name (can be a Reference, HFileLink or simple HFile) */ private void restoreStoreFile(final Path familyDir, final HRegionInfo regionInfo, final SnapshotRegionManifest.StoreFile storeFile) throws IOException { @@ -583,7 +583,7 @@ public class RestoreSnapshotHelper { * * @param familyDir destination directory for the store file * @param regionInfo destination region info for the table - * @param hfileName reference file name + * @param storeFile reference file name */ private void restoreReferenceFile(final Path familyDir, final HRegionInfo regionInfo, final SnapshotRegionManifest.StoreFile storeFile) throws IOException { diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java index a9f50cb..d8eb468 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java @@ -54,7 +54,7 @@ import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; - +import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -112,6 +112,8 @@ import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.AdminService.Block import org.apache.hadoop.hbase.regionserver.HRegion; import org.apache.hadoop.hbase.regionserver.HRegionFileSystem; import org.apache.hadoop.hbase.regionserver.StoreFileInfo; +import org.apache.hadoop.hbase.regionserver.wal.MetricsWAL; +import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener; import org.apache.hadoop.hbase.security.AccessDeniedException; import org.apache.hadoop.hbase.security.UserProvider; import org.apache.hadoop.hbase.util.Bytes.ByteArrayComparator; @@ -120,6 +122,8 @@ import org.apache.hadoop.hbase.util.hbck.HFileCorruptionChecker; import org.apache.hadoop.hbase.util.hbck.TableIntegrityErrorHandler; import org.apache.hadoop.hbase.util.hbck.TableIntegrityErrorHandlerImpl; import org.apache.hadoop.hbase.util.hbck.TableLockChecker; +import org.apache.hadoop.hbase.wal.WAL; +import org.apache.hadoop.hbase.wal.WALFactory; import org.apache.hadoop.hbase.wal.WALSplitter; import org.apache.hadoop.hbase.zookeeper.MetaTableLocator; import org.apache.hadoop.hbase.zookeeper.ZKTableStateClientSideReader; @@ -1217,17 +1221,26 @@ public class HBaseFsck extends Configured implements Closeable { } /** - * This borrows code from MasterFileSystem.bootstrap() + * This borrows code from MasterFileSystem.bootstrap(). Explicitly creates it's own WAL, so be + * sure to close it as well as the region when you're finished. * * @return an open hbase:meta HRegion */ private HRegion createNewMeta() throws IOException { - Path rootdir = FSUtils.getRootDir(getConf()); + Path rootdir = FSUtils.getRootDir(getConf()); Configuration c = getConf(); HRegionInfo metaHRI = new HRegionInfo(HRegionInfo.FIRST_META_REGIONINFO); HTableDescriptor metaDescriptor = new FSTableDescriptors(c).get(TableName.META_TABLE_NAME); MasterFileSystem.setInfoFamilyCachingForMeta(metaDescriptor, false); - HRegion meta = HRegion.createHRegion(metaHRI, rootdir, c, metaDescriptor); + // The WAL subsystem will use the default rootDir rather than the passed in rootDir + // unless I pass along via the conf. + Configuration confForWAL = new Configuration(c); + confForWAL.set(HConstants.HBASE_DIR, rootdir.toString()); + WAL wal = (new WALFactory(confForWAL, + Collections.singletonList(new MetricsWAL()), + "hbck-meta-recovery-" + RandomStringUtils.randomNumeric(8))). + getWAL(metaHRI.getEncodedNameAsBytes()); + HRegion meta = HRegion.createHRegion(metaHRI, rootdir, c, metaDescriptor, wal); MasterFileSystem.setInfoFamilyCachingForMeta(metaDescriptor, true); return meta; } @@ -1285,8 +1298,8 @@ public class HBaseFsck extends Configured implements Closeable { } /** - * Rebuilds meta from information in hdfs/fs. Depends on configuration - * settings passed into hbck constructor to point to a particular fs/dir. + * Rebuilds meta from information in hdfs/fs. Depends on configuration settings passed into + * hbck constructor to point to a particular fs/dir. Assumes HBase is OFFLINE. * * @param fix flag that determines if method should attempt to fix holes * @return true if successful, false if attempt failed. @@ -1342,7 +1355,10 @@ public class HBaseFsck extends Configured implements Closeable { return false; } meta.batchMutate(puts.toArray(new Put[puts.size()])); - HRegion.closeHRegion(meta); + meta.close(); + if (meta.getWAL() != null) { + meta.getWAL().close(); + } LOG.info("Success! hbase:meta table rebuilt."); LOG.info("Old hbase:meta is moved into " + backupDir); return true; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsckRepair.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsckRepair.java index d98f409..8d885b7 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsckRepair.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsckRepair.java @@ -199,7 +199,7 @@ public class HBaseFsckRepair { HRegion region = HRegion.createHRegion(hri, root, conf, htd, null); // Close the new region to flush to disk. Close log file too. - HRegion.closeHRegion(region); + region.close(); return region; } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/ModifyRegionUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/ModifyRegionUtils.java index 75884da..95d8a17 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/ModifyRegionUtils.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/ModifyRegionUtils.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.io.InterruptedIOException; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.CompletionService; @@ -32,8 +33,10 @@ import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; @@ -41,6 +44,10 @@ import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.regionserver.HRegion; import org.apache.hadoop.hbase.master.AssignmentManager; +import org.apache.hadoop.hbase.regionserver.wal.MetricsWAL; +import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener; +import org.apache.hadoop.hbase.wal.WAL; +import org.apache.hadoop.hbase.wal.WALFactory; /** * Utility methods for interacting with the regions. @@ -68,53 +75,18 @@ public abstract class ModifyRegionUtils { * @param rootDir Root directory for HBase instance * @param hTableDescriptor description of the table * @param newRegions {@link HRegionInfo} that describes the regions to create - * @throws IOException - */ - public static List createRegions(final Configuration conf, final Path rootDir, - final HTableDescriptor hTableDescriptor, final HRegionInfo[] newRegions) throws IOException { - return createRegions(conf, rootDir, hTableDescriptor, newRegions, null); - } - - /** - * Create new set of regions on the specified file-system. - * NOTE: that you should add the regions to hbase:meta after this operation. - * - * @param conf {@link Configuration} - * @param rootDir Root directory for HBase instance - * @param hTableDescriptor description of the table - * @param newRegions {@link HRegionInfo} that describes the regions to create * @param task {@link RegionFillTask} custom code to populate region after creation * @throws IOException */ public static List createRegions(final Configuration conf, final Path rootDir, final HTableDescriptor hTableDescriptor, final HRegionInfo[] newRegions, final RegionFillTask task) throws IOException { - - Path tableDir = FSUtils.getTableDir(rootDir, hTableDescriptor.getTableName()); - return createRegions(conf, rootDir, tableDir, hTableDescriptor, newRegions, task); - } - - /** - * Create new set of regions on the specified file-system. - * NOTE: that you should add the regions to hbase:meta after this operation. - * - * @param conf {@link Configuration} - * @param rootDir Root directory for HBase instance - * @param tableDir table directory - * @param hTableDescriptor description of the table - * @param newRegions {@link HRegionInfo} that describes the regions to create - * @param task {@link RegionFillTask} custom code to populate region after creation - * @throws IOException - */ - public static List createRegions(final Configuration conf, final Path rootDir, - final Path tableDir, final HTableDescriptor hTableDescriptor, final HRegionInfo[] newRegions, - final RegionFillTask task) throws IOException { if (newRegions == null) return null; int regionNumber = newRegions.length; ThreadPoolExecutor exec = getRegionOpenAndInitThreadPool(conf, "RegionOpenAndInitThread-" + hTableDescriptor.getTableName(), regionNumber); try { - return createRegions(exec, conf, rootDir, tableDir, hTableDescriptor, newRegions, task); + return createRegions(exec, conf, rootDir, hTableDescriptor, newRegions, task); } finally { exec.shutdownNow(); } @@ -127,14 +99,13 @@ public abstract class ModifyRegionUtils { * @param exec Thread Pool Executor * @param conf {@link Configuration} * @param rootDir Root directory for HBase instance - * @param tableDir table directory * @param hTableDescriptor description of the table * @param newRegions {@link HRegionInfo} that describes the regions to create * @param task {@link RegionFillTask} custom code to populate region after creation * @throws IOException */ public static List createRegions(final ThreadPoolExecutor exec, - final Configuration conf, final Path rootDir, final Path tableDir, + final Configuration conf, final Path rootDir, final HTableDescriptor hTableDescriptor, final HRegionInfo[] newRegions, final RegionFillTask task) throws IOException { if (newRegions == null) return null; @@ -146,7 +117,7 @@ public abstract class ModifyRegionUtils { completionService.submit(new Callable() { @Override public HRegionInfo call() throws IOException { - return createRegion(conf, rootDir, tableDir, hTableDescriptor, newRegion, task); + return createRegion(conf, rootDir, hTableDescriptor, newRegion, task); } }); } @@ -168,19 +139,24 @@ public abstract class ModifyRegionUtils { * Create new set of regions on the specified file-system. * @param conf {@link Configuration} * @param rootDir Root directory for HBase instance - * @param tableDir table directory * @param hTableDescriptor description of the table * @param newRegion {@link HRegionInfo} that describes the region to create * @param task {@link RegionFillTask} custom code to populate region after creation * @throws IOException */ public static HRegionInfo createRegion(final Configuration conf, final Path rootDir, - final Path tableDir, final HTableDescriptor hTableDescriptor, final HRegionInfo newRegion, + final HTableDescriptor hTableDescriptor, final HRegionInfo newRegion, final RegionFillTask task) throws IOException { // 1. Create HRegion - HRegion region = HRegion.createHRegion(newRegion, - rootDir, tableDir, conf, hTableDescriptor, null, - false, true); + // The WAL subsystem will use the default rootDir rather than the passed in rootDir + // unless I pass along via the conf. + Configuration confForWAL = new Configuration(conf); + confForWAL.set(HConstants.HBASE_DIR, rootDir.toString()); + WAL wal = (new WALFactory(confForWAL, + Collections.singletonList(new MetricsWAL()), + "hregion-" + RandomStringUtils.randomNumeric(8))). + getWAL(newRegion.getEncodedNameAsBytes()); + HRegion region = HRegion.createHRegion(newRegion, rootDir, conf, hTableDescriptor, wal, false); try { // 2. Custom user code to interact with the created region if (task != null) { @@ -189,6 +165,7 @@ public abstract class ModifyRegionUtils { } finally { // 3. Close the new region to flush to disk. Close log file too. region.close(); + wal.close(); } return region.getRegionInfo(); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALFactory.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALFactory.java index b8dee83..b7c0c31 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALFactory.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALFactory.java @@ -63,7 +63,7 @@ import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener; * server. * * - * Alternatively, you may provide a custome implementation of {@link WALProvider} by class name. + * Alternatively, you may provide a custom implementation of {@link WALProvider} by class name. */ @InterfaceAudience.Private public class WALFactory { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestCase.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestCase.java index 5b58bbe..9209415 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestCase.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestCase.java @@ -148,9 +148,8 @@ public abstract class HBaseTestCase extends TestCase { } /** - * You must call close on the returned region and then close on the log file - * it created. Do {@link HRegion#close()} followed by {@link HRegion#getWAL()} - * and on it call close. + * You must call close on the returned region and then close on the log file it created. Do + * {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} to close both the region and the WAL. * @param desc * @param startKey * @param endKey @@ -167,7 +166,7 @@ public abstract class HBaseTestCase extends TestCase { byte [] endKey, Configuration conf) throws IOException { HRegionInfo hri = new HRegionInfo(desc.getTableName(), startKey, endKey); - return HRegion.createHRegion(hri, testDir, conf, desc); + return HBaseTestingUtility.createRegionAndWAL(hri, testDir, conf, desc); } protected HRegion openClosedRegion(final HRegion closedRegion) @@ -640,12 +639,12 @@ public abstract class HBaseTestCase extends TestCase { */ protected void createMetaRegion() throws IOException { FSTableDescriptors fsTableDescriptors = new FSTableDescriptors(conf); - meta = HRegion.createHRegion(HRegionInfo.FIRST_META_REGIONINFO, testDir, conf, - fsTableDescriptors.get(TableName.META_TABLE_NAME)); + meta = HBaseTestingUtility.createRegionAndWAL(HRegionInfo.FIRST_META_REGIONINFO, testDir, + conf, fsTableDescriptors.get(TableName.META_TABLE_NAME)); } protected void closeRootAndMeta() throws IOException { - HRegion.closeHRegion(meta); + HBaseTestingUtility.closeRegionAndWAL(meta); } public static void assertByteEquals(byte[] expected, diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java index 5f44d13..e9bb1cc 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java @@ -44,6 +44,7 @@ import java.util.TreeSet; import java.util.UUID; import java.util.concurrent.TimeUnit; +import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.impl.Jdk14Logger; @@ -89,7 +90,8 @@ import org.apache.hadoop.hbase.regionserver.HStore; import org.apache.hadoop.hbase.regionserver.InternalScanner; import org.apache.hadoop.hbase.regionserver.RegionServerServices; import org.apache.hadoop.hbase.regionserver.RegionServerStoppedException; -import org.apache.hadoop.hbase.wal.WAL; +import org.apache.hadoop.hbase.regionserver.wal.MetricsWAL; +import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener; import org.apache.hadoop.hbase.security.User; import org.apache.hadoop.hbase.tool.Canary; import org.apache.hadoop.hbase.util.Bytes; @@ -102,6 +104,8 @@ import org.apache.hadoop.hbase.util.Pair; import org.apache.hadoop.hbase.util.RegionSplitter; import org.apache.hadoop.hbase.util.RetryCounter; import org.apache.hadoop.hbase.util.Threads; +import org.apache.hadoop.hbase.wal.WAL; +import org.apache.hadoop.hbase.wal.WALFactory; import org.apache.hadoop.hbase.zookeeper.EmptyWatcher; import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster; import org.apache.hadoop.hbase.zookeeper.ZKAssign; @@ -126,7 +130,7 @@ import org.apache.zookeeper.ZooKeeper.States; * Create an instance and keep it around testing HBase. This class is * meant to be your one-stop shop for anything you might need testing. Manages * one cluster at a time only. Managed cluster can be an in-process - * {@link MiniHBaseCluster}, or a deployed cluster of type {@link DistributedHBaseCluster}. + * {@link MiniHBaseCluster}, or a deployed cluster of type {@code DistributedHBaseCluster}. * Not all methods work with the real cluster. * Depends on log4j being on classpath and * hbase-site.xml for logging and test-run configuration. It does not set @@ -279,6 +283,16 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { } /** + * Close both the HRegion {@code r} and it's underlying WAL. For use in tests. + */ + public static void closeRegionAndWAL(final HRegion r) throws IOException { + if (r == null) return; + r.close(); + if (r.getWAL() == null) return; + r.getWAL().close(); + } + + /** * Returns this classes's instance of {@link Configuration}. Be careful how * you use the returned Configuration since {@link HConnection} instances * can be shared. The Map of HConnections is keyed by the Configuration. If @@ -1678,13 +1692,6 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { public static final byte [] START_KEY_BYTES = {FIRST_CHAR, FIRST_CHAR, FIRST_CHAR}; public static final String START_KEY = new String(START_KEY_BYTES, HConstants.UTF8_CHARSET); - /** - * Create a table of name name with {@link COLUMNS} for - * families. - * @param name Name to give table. - * @param versions How many versions to allow per column. - * @return Column descriptor. - */ public HTableDescriptor createTableDescriptor(final String name, final int minVersions, final int versions, final int ttl, KeepDeletedCells keepDeleted) { HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name)); @@ -1701,8 +1708,7 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { } /** - * Create a table of name name with {@link COLUMNS} for - * families. + * Create a table of name name. * @param name Name to give table. * @return Column descriptor. */ @@ -1727,14 +1733,11 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { } /** - * Create an HRegion that writes to the local tmp dirs - * @param info - * @param desc - * @return - * @throws IOException + * Create an HRegion that writes to the local tmp dirs. Creates the WAL for you. Be sure to call + * {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} when you're finished with it. */ public HRegion createLocalHRegion(HRegionInfo info, HTableDescriptor desc) throws IOException { - return HRegion.createHRegion(info, getDataTestDir(), getConfiguration(), desc); + return createRegionAndWAL(info, getDataTestDir(), getConfiguration(), desc); } /** @@ -1760,7 +1763,7 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { * @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 HRegion createLocalHRegion(byte[] tableName, byte[] startKey, byte[] stopKey, String callingMethod, Configuration conf, boolean isReadOnly, Durability durability, @@ -2025,6 +2028,7 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { * Return an md5 digest of the entire contents of a table. */ public String checksumRows(final Table table) throws Exception { + Scan scan = new Scan(); ResultScanner results = table.getScanner(scan); MessageDigest digest = MessageDigest.getInstance("MD5"); @@ -2209,6 +2213,41 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { } /** + * Create an unmanaged WAL. Be sure to close it when you're through. + */ + public static WAL createWal(final Configuration conf, final Path rootDir, final HRegionInfo hri) + throws IOException { + // The WAL subsystem will use the default rootDir rather than the passed in rootDir + // unless I pass along via the conf. + Configuration confForWAL = new Configuration(conf); + confForWAL.set(HConstants.HBASE_DIR, rootDir.toString()); + return (new WALFactory(confForWAL, + Collections.singletonList(new MetricsWAL()), + "hregion-" + RandomStringUtils.randomNumeric(8))). + getWAL(hri.getEncodedNameAsBytes()); + } + + /** + * Create a region with it's own WAL. Be sure to call + * {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} to clean up all resources. + */ + public static HRegion createRegionAndWAL(final HRegionInfo info, final Path rootDir, + final Configuration conf, final HTableDescriptor htd) throws IOException { + return createRegionAndWAL(info, rootDir, conf, htd, true); + } + + /** + * Create a region with it's own WAL. Be sure to call + * {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} to clean up all resources. + */ + public static HRegion createRegionAndWAL(final HRegionInfo info, final Path rootDir, + final Configuration conf, final HTableDescriptor htd, boolean initialize) + throws IOException { + WAL wal = createWal(conf, rootDir, info); + return HRegion.createHRegion(info, rootDir, conf, htd, wal, initialize); + } + + /** * Returns all rows from the hbase:meta table. * * @throws IOException When reading the rows fails. @@ -2805,7 +2844,6 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { /** * Waits for a table to be 'enabled'. Enabled means that table is set as 'enabled' and the * regions have been all assigned. Will timeout after default period (30 seconds) - * @see #waitTableAvailable(byte[]) * @param table Table to wait on. * @param table * @throws InterruptedException @@ -2824,7 +2862,7 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { /** * Waits for a table to be 'enabled'. Enabled means that table is set as 'enabled' and the * regions have been all assigned. - * @see #waitTableAvailable(byte[]) + * @see #waitTableEnabled(Admin, byte[], long) * @param table Table to wait on. * @param timeoutMillis Time to wait on it being marked enabled. * @throws InterruptedException @@ -3519,9 +3557,7 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { htd.addFamily(hcd); HRegionInfo info = new HRegionInfo(TableName.valueOf(tableName), null, null, false); - HRegion region = - HRegion.createHRegion(info, getDataTestDir(), getConfiguration(), htd); - return region; + return createRegionAndWAL(info, getDataTestDir(), getConfiguration(), htd); } public void setFileSystemURI(String fsURI) { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestIntraRowPagination.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestIntraRowPagination.java index c459a20..f482a34 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestIntraRowPagination.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestIntraRowPagination.java @@ -59,8 +59,8 @@ public class TestIntraRowPagination { HColumnDescriptor hcd = new HColumnDescriptor(family); htd.addFamily(hcd); } - HRegion region = - HRegion.createHRegion(info, TEST_UTIL.getDataTestDir(), TEST_UTIL.getConfiguration(), htd); + HRegion region = HBaseTestingUtility.createRegionAndWAL(info, TEST_UTIL.getDataTestDir(), + TEST_UTIL.getConfiguration(), htd); try { Put put; Scan scan; @@ -100,7 +100,7 @@ public class TestIntraRowPagination { TestScannersFromClientSide.verifyResult(result, kvListExp, toLog, "Testing scan with storeOffset and storeLimit"); } finally { - region.close(); + HBaseTestingUtility.closeRegionAndWAL(region); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorInterface.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorInterface.java index 439782e..e23a05b 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorInterface.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorInterface.java @@ -349,6 +349,7 @@ public class TestCoprocessorInterface { // hence the old entry was indeed removed by the GC and new one has been created Object o3 = ((CoprocessorII)c2).getSharedData().get("test2"); assertFalse(o3 == o2); + HBaseTestingUtility.closeRegionAndWAL(region); } @Test @@ -373,7 +374,7 @@ public class TestCoprocessorInterface { for (int i = 0; i < regions.length; i++) { regions[i] = reopenRegion(regions[i], CoprocessorImpl.class); } - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); Coprocessor c = region.getCoprocessorHost(). findCoprocessor(CoprocessorImpl.class.getName()); @@ -393,7 +394,7 @@ public class TestCoprocessorInterface { assertTrue(((CoprocessorImpl)c).wasSplit()); for (int i = 0; i < regions.length; i++) { - HRegion.closeHRegion(regions[i]); + HBaseTestingUtility.closeRegionAndWAL(regions[i]); c = region.getCoprocessorHost() .findCoprocessor(CoprocessorImpl.class.getName()); assertTrue("Coprocessor not started", ((CoprocessorImpl)c).wasStarted()); @@ -440,7 +441,7 @@ public class TestCoprocessorInterface { } HRegionInfo info = new HRegionInfo(tableName, null, null, false); Path path = new Path(DIR + callingMethod); - HRegion r = HRegion.createHRegion(info, path, conf, htd); + HRegion r = HBaseTestingUtility.createRegionAndWAL(info, path, conf, htd); // this following piece is a hack. RegionCoprocessorHost host = new RegionCoprocessorHost(r, null, conf); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverScannerOpenHook.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverScannerOpenHook.java index e7860d9..e231395 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverScannerOpenHook.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverScannerOpenHook.java @@ -39,11 +39,11 @@ import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Get; -import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.IsolationLevel; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Result; @@ -150,7 +150,8 @@ public class TestRegionObserverScannerOpenHook { } HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false); Path path = new Path(DIR + callingMethod); - HRegion r = HRegion.createHRegion(info, path, conf, htd); + WAL wal = HBaseTestingUtility.createWal(conf, path, info); + HRegion r = HRegion.createHRegion(info, path, conf, htd, wal); // this following piece is a hack. currently a coprocessorHost // is secretly loaded at OpenRegionHandler. we don't really // start a region server here, so just manually create cphost @@ -182,6 +183,7 @@ public class TestRegionObserverScannerOpenHook { assertNull( "Got an unexpected number of rows - no data should be returned with the NoDataFromScan coprocessor. Found: " + r, r.listCells()); + HBaseTestingUtility.closeRegionAndWAL(region); } @Test @@ -207,6 +209,7 @@ public class TestRegionObserverScannerOpenHook { assertNull( "Got an unexpected number of rows - no data should be returned with the NoDataFromScan coprocessor. Found: " + r, r.listCells()); + HBaseTestingUtility.closeRegionAndWAL(region); } /* diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverStacking.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverStacking.java index 53c234e..dc10703 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverStacking.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverStacking.java @@ -101,7 +101,7 @@ public class TestRegionObserverStacking extends TestCase { } HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false); Path path = new Path(DIR + callingMethod); - HRegion r = HRegion.createHRegion(info, path, conf, htd); + HRegion r = HBaseTestingUtility.createRegionAndWAL(info, path, conf, htd); // this following piece is a hack. currently a coprocessorHost // is secretly loaded at OpenRegionHandler. we don't really // start a region server here, so just manually create cphost @@ -138,6 +138,7 @@ public class TestRegionObserverStacking extends TestCase { assertTrue(idA < idB); assertTrue(idB < idC); + HBaseTestingUtility.closeRegionAndWAL(region); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestColumnPrefixFilter.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestColumnPrefixFilter.java index bc66d7d..a07dd69 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestColumnPrefixFilter.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestColumnPrefixFilter.java @@ -50,8 +50,8 @@ public class TestColumnPrefixFilter { HTableDescriptor htd = new HTableDescriptor(TableName.valueOf("TestColumnPrefixFilter")); htd.addFamily((new HColumnDescriptor(family)).setMaxVersions(3)); HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false); - HRegion region = HRegion.createHRegion(info, TEST_UTIL. - getDataTestDir(), TEST_UTIL.getConfiguration(), htd); + HRegion region = HBaseTestingUtility.createRegionAndWAL(info, TEST_UTIL.getDataTestDir(), + TEST_UTIL.getConfiguration(), htd); try { List rows = generateRandomWords(100, "row"); List columns = generateRandomWords(10000, "column"); @@ -100,10 +100,10 @@ public class TestColumnPrefixFilter { assertEquals(prefixMap.get(s).size(), results.size()); } } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } @Test @@ -112,8 +112,8 @@ public class TestColumnPrefixFilter { HTableDescriptor htd = new HTableDescriptor(TableName.valueOf("TestColumnPrefixFilter")); htd.addFamily((new HColumnDescriptor(family)).setMaxVersions(3)); HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false); - HRegion region = HRegion.createHRegion(info, TEST_UTIL. - getDataTestDir(), TEST_UTIL.getConfiguration(), htd); + HRegion region = HBaseTestingUtility.createRegionAndWAL(info, TEST_UTIL.getDataTestDir(), + TEST_UTIL.getConfiguration(), htd); try { List rows = generateRandomWords(100, "row"); List columns = generateRandomWords(10000, "column"); @@ -165,10 +165,10 @@ public class TestColumnPrefixFilter { assertEquals(prefixMap.get(s).size(), results.size()); } } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } List generateRandomWords(int numberOfWords, String suffix) { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestDependentColumnFilter.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestDependentColumnFilter.java index bd1f7ab..f7ab1bd 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestDependentColumnFilter.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestDependentColumnFilter.java @@ -80,14 +80,14 @@ public class TestDependentColumnFilter { hcd1.setMaxVersions(3); htd.addFamily(hcd1); HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false); - this.region = HRegion.createHRegion(info, TEST_UTIL.getDataTestDir(), - TEST_UTIL.getConfiguration(), htd); + this.region = HBaseTestingUtility.createRegionAndWAL(info, TEST_UTIL.getDataTestDir(), + TEST_UTIL.getConfiguration(), htd); addData(); } @After public void tearDown() throws Exception { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); } private void addData() throws IOException { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilter.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilter.java index ed6e6de..1f2c75a 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilter.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilter.java @@ -141,8 +141,8 @@ public class TestFilter { htd.addFamily(new HColumnDescriptor(NEW_FAMILIES[0])); htd.addFamily(new HColumnDescriptor(NEW_FAMILIES[1])); HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false); - this.region = HRegion.createHRegion(info, TEST_UTIL.getDataTestDir(), - TEST_UTIL.getConfiguration(), htd); + this.region = HBaseTestingUtility.createRegionAndWAL(info, TEST_UTIL.getDataTestDir(), + TEST_UTIL.getConfiguration(), htd); // Insert first half for(byte [] ROW : ROWS_ONE) { @@ -216,9 +216,7 @@ public class TestFilter { @After public void tearDown() throws Exception { - WAL wal = region.getWAL(); - region.close(); - wal.close(); + HBaseTestingUtility.closeRegionAndWAL(region); } @Test @@ -655,8 +653,7 @@ public class TestFilter { /** * Tests the the {@link WhileMatchFilter} works in combination with a - * {@link Filter} that uses the - * {@link Filter#filterKeyValue(org.apache.hadoop.hbase.KeyValue)} method. + * {@link Filter} that uses the {@link Filter#filterKeyValue(Cell)} method. * * See HBASE-2258. * @@ -1452,7 +1449,7 @@ public class TestFilter { HTableDescriptor htd = new HTableDescriptor(TableName.valueOf("TestFilter")); htd.addFamily(new HColumnDescriptor(family)); HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false); - HRegion testRegion = HRegion.createHRegion(info, TEST_UTIL.getDataTestDir(), + HRegion testRegion = HBaseTestingUtility.createRegionAndWAL(info, TEST_UTIL.getDataTestDir(), TEST_UTIL.getConfiguration(), htd); for(int i=0; i<5; i++) { @@ -2006,13 +2003,14 @@ public class TestFilter { } } + // TODO: intentionally disabled? public void testNestedFilterListWithSCVF() throws IOException { byte[] columnStatus = Bytes.toBytes("S"); HTableDescriptor htd = new HTableDescriptor(TableName.valueOf("testNestedFilterListWithSCVF")); htd.addFamily(new HColumnDescriptor(FAMILIES[0])); HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false); - HRegion testRegion = HRegion.createHRegion(info, TEST_UTIL.getDataTestDir(), - TEST_UTIL.getConfiguration(), htd); + HRegion testRegion = HBaseTestingUtility.createRegionAndWAL(info, TEST_UTIL.getDataTestDir(), + TEST_UTIL.getConfiguration(), htd); for(int i=0; i<10; i++) { Put p = new Put(Bytes.toBytes("row" + i)); p.setDurability(Durability.SKIP_WAL); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestInvocationRecordFilter.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestInvocationRecordFilter.java index 946f948..31a83c4 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestInvocationRecordFilter.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestInvocationRecordFilter.java @@ -67,7 +67,7 @@ public class TestInvocationRecordFilter { TableName.valueOf(TABLE_NAME_BYTES)); htd.addFamily(new HColumnDescriptor(FAMILY_NAME_BYTES)); HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false); - this.region = HRegion.createHRegion(info, TEST_UTIL.getDataTestDir(), + this.region = HBaseTestingUtility.createRegionAndWAL(info, TEST_UTIL.getDataTestDir(), TEST_UTIL.getConfiguration(), htd); Put put = new Put(ROW_BYTES); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultipleColumnPrefixFilter.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultipleColumnPrefixFilter.java index 90d6991..ac39c0d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultipleColumnPrefixFilter.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultipleColumnPrefixFilter.java @@ -53,8 +53,8 @@ public class TestMultipleColumnPrefixFilter { htd.addFamily(hcd); // HRegionInfo info = new HRegionInfo(htd, null, null, false); HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false); - HRegion region = HRegion.createHRegion(info, TEST_UTIL. - getDataTestDir(), TEST_UTIL.getConfiguration(), htd); + HRegion region = HBaseTestingUtility.createRegionAndWAL(info, TEST_UTIL. + getDataTestDir(), TEST_UTIL.getConfiguration(), htd); List rows = generateRandomWords(100, "row"); List columns = generateRandomWords(10000, "column"); @@ -104,7 +104,7 @@ public class TestMultipleColumnPrefixFilter { while(scanner.next(results)); assertEquals(prefixMap.get("p").size() + prefixMap.get("q").size(), results.size()); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } @Test @@ -119,8 +119,8 @@ public class TestMultipleColumnPrefixFilter { hcd2.setMaxVersions(3); htd.addFamily(hcd2); HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false); - HRegion region = HRegion.createHRegion(info, TEST_UTIL. - getDataTestDir(), TEST_UTIL.getConfiguration(), htd); + HRegion region = HBaseTestingUtility.createRegionAndWAL(info, TEST_UTIL. + getDataTestDir(), TEST_UTIL.getConfiguration(), htd); List rows = generateRandomWords(100, "row"); List columns = generateRandomWords(10000, "column"); @@ -176,7 +176,7 @@ public class TestMultipleColumnPrefixFilter { while(scanner.next(results)); assertEquals(prefixMap.get("p").size() + prefixMap.get("q").size(), results.size()); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } @Test @@ -185,8 +185,8 @@ public class TestMultipleColumnPrefixFilter { HTableDescriptor htd = new HTableDescriptor(TableName.valueOf("TestMultipleColumnPrefixFilter")); htd.addFamily(new HColumnDescriptor(family)); HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false); - HRegion region = HRegion.createHRegion(info, TEST_UTIL. - getDataTestDir(), TEST_UTIL.getConfiguration(),htd); + HRegion region = HBaseTestingUtility.createRegionAndWAL(info, TEST_UTIL. + getDataTestDir(), TEST_UTIL.getConfiguration(), htd); List rows = generateRandomWords(100, "row"); List columns = generateRandomWords(10000, "column"); @@ -231,7 +231,7 @@ public class TestMultipleColumnPrefixFilter { assertEquals(results1.size(), results2.size()); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } List generateRandomWords(int numberOfWords, String suffix) { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestPrefixTree.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestPrefixTree.java index 2aab662..3b940ac 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestPrefixTree.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestPrefixTree.java @@ -73,12 +73,12 @@ public class TestPrefixTree { htd.addFamily(new HColumnDescriptor(fam).setDataBlockEncoding(DataBlockEncoding.PREFIX_TREE)); HRegionInfo info = new HRegionInfo(tableName, null, null, false); Path path = testUtil.getDataTestDir(getClass().getSimpleName()); - region = HRegion.createHRegion(info, path, testUtil.getConfiguration(), htd); + region = HBaseTestingUtility.createRegionAndWAL(info, path, testUtil.getConfiguration(), htd); } @After public void tearDown() throws Exception { - region.close(true); + HBaseTestingUtility.closeRegionAndWAL(region); testUtil.cleanupTestDir(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestScannerSelectionUsingKeyRange.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestScannerSelectionUsingKeyRange.java index e96b394..179955f 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestScannerSelectionUsingKeyRange.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestScannerSelectionUsingKeyRange.java @@ -98,7 +98,8 @@ public class TestScannerSelectionUsingKeyRange { HTableDescriptor htd = new HTableDescriptor(TABLE); htd.addFamily(hcd); HRegionInfo info = new HRegionInfo(TABLE); - HRegion region = HRegion.createHRegion(info, TEST_UTIL.getDataTestDir(), conf, htd); + HRegion region = HBaseTestingUtility.createRegionAndWAL(info, TEST_UTIL.getDataTestDir(), conf, + htd); for (int iFile = 0; iFile < NUM_FILES; ++iFile) { for (int iRow = 0; iRow < NUM_ROWS; ++iRow) { @@ -125,6 +126,6 @@ public class TestScannerSelectionUsingKeyRange { assertEquals(0, results.size()); Set accessedFiles = cache.getCachedFileNamesForTest(); assertEquals(expectedCount, accessedFiles.size()); - region.close(); + HBaseTestingUtility.closeRegionAndWAL(region); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestScannerSelectionUsingTTL.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestScannerSelectionUsingTTL.java index 640ac6e..0b982ac 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestScannerSelectionUsingTTL.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestScannerSelectionUsingTTL.java @@ -107,7 +107,8 @@ public class TestScannerSelectionUsingTTL { htd.addFamily(hcd); HRegionInfo info = new HRegionInfo(TABLE); HRegion region = - HRegion.createHRegion(info, TEST_UTIL.getDataTestDir(info.getEncodedName()), + HBaseTestingUtility.createRegionAndWAL(info, + TEST_UTIL.getDataTestDir(info.getEncodedName()), conf, htd); long ts = EnvironmentEdgeManager.currentTime(); @@ -157,6 +158,6 @@ public class TestScannerSelectionUsingTTL { region.compactStores(); } - region.close(); + HBaseTestingUtility.closeRegionAndWAL(region); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java index 8ae26a3..5da5679 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java @@ -923,13 +923,13 @@ public class TestMasterFailover { HRegion createRegion(final HRegionInfo hri, final Path rootdir, final Configuration c, final HTableDescriptor htd) throws IOException { - HRegion r = HRegion.createHRegion(hri, rootdir, c, htd); + HRegion r = HBaseTestingUtility.createRegionAndWAL(hri, rootdir, c, htd); // The above call to create a region will create an wal file. Each // log file create will also create a running thread to do syncing. We need // to close out this log else we will have a running thread trying to sync // the file system continuously which is ugly when dfs is taken away at the // end of the test. - HRegion.closeHRegion(r); + HBaseTestingUtility.closeRegionAndWAL(r); return r; } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestOpenedRegionHandler.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestOpenedRegionHandler.java index 4ae6b24..d901ecf 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestOpenedRegionHandler.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestOpenedRegionHandler.java @@ -125,7 +125,8 @@ public class TestOpenedRegionHandler { TableName.valueOf("testShouldNotCompeleteOpenedRegionSuccessfullyIfVersionMismatches")); HRegionInfo hri = new HRegionInfo(htd.getTableName(), Bytes.toBytes(testIndex), Bytes.toBytes(testIndex + 1)); - region = HRegion.createHRegion(hri, TEST_UTIL.getDataTestDir(), TEST_UTIL.getConfiguration(), htd); + region = HBaseTestingUtility.createRegionAndWAL(hri, TEST_UTIL.getDataTestDir(), + TEST_UTIL.getConfiguration(), htd); assertNotNull(region); AssignmentManager am = Mockito.mock(AssignmentManager.class); RegionStates rsm = Mockito.mock(RegionStates.class); @@ -176,7 +177,7 @@ public class TestOpenedRegionHandler { assertEquals("The region should not be opened successfully.", regionName, region.getRegionInfo().getEncodedName()); } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); TEST_UTIL.shutdownMiniZKCluster(); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/migration/TestNamespaceUpgrade.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/migration/TestNamespaceUpgrade.java index 983b1ba..9da36d3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/migration/TestNamespaceUpgrade.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/migration/TestNamespaceUpgrade.java @@ -306,7 +306,7 @@ public class TestNamespaceUpgrade { FSTableDescriptors fstd = new FSTableDescriptors(conf, fs, rootDir); fstd.createTableDescriptor(aclTable); HRegionInfo hriAcl = new HRegionInfo(aclTable.getTableName(), null, null); - HRegion region = HRegion.createHRegion(hriAcl, rootDir, conf, aclTable); + HRegion region = HBaseTestingUtility.createRegionAndWAL(hriAcl, rootDir, conf, aclTable); try { // Create rows Put p = new Put(Bytes.toBytes("-ROOT-")); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestAtomicOperation.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestAtomicOperation.java index fd3f7ea..fec5ba6 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestAtomicOperation.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestAtomicOperation.java @@ -537,8 +537,9 @@ public class TestAtomicOperation { final String tableName = "testPutAndCheckAndPut"; Configuration conf = TEST_UTIL.getConfiguration(); conf.setClass(HConstants.REGION_IMPL, MockHRegion.class, HeapSize.class); - final MockHRegion region = (MockHRegion) TEST_UTIL.createLocalHRegion(Bytes.toBytes(tableName), - null, null, tableName, conf, false, Durability.SYNC_WAL, null, Bytes.toBytes(family)); + HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName)) + .addFamily(new HColumnDescriptor(family)); + final MockHRegion region = (MockHRegion) TEST_UTIL.createLocalHRegion(htd, null, null); Put[] puts = new Put[1]; Put put = new Put(Bytes.toBytes("r1")); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java index b22f3ac..b3b531e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java @@ -87,7 +87,7 @@ public class TestBlocksRead extends HBaseTestCase { } /** - * Callers must afterward call {@link HRegion#closeHRegion(HRegion)} + * Callers must afterward call {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} * @param tableName * @param callingMethod * @param conf @@ -109,7 +109,7 @@ public class TestBlocksRead extends HBaseTestCase { HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false); Path path = new Path(DIR + callingMethod); - HRegion r = HRegion.createHRegion(info, path, conf, htd); + HRegion r = HBaseTestingUtility.createRegionAndWAL(info, path, conf, htd); blockCache = new CacheConfig(conf).getBlockCache(); return r; } @@ -262,7 +262,7 @@ public class TestBlocksRead extends HBaseTestCase { assertEquals(1, kvs.length); verifyData(kvs[0], "row", "col5", 5); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -371,7 +371,7 @@ public class TestBlocksRead extends HBaseTestCase { verifyData(kvs[1], "row", "col2", 12); verifyData(kvs[2], "row", "col3", 13); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -420,7 +420,7 @@ public class TestBlocksRead extends HBaseTestCase { assertEquals(2 * BLOOM_TYPE.length, blocksEnd - blocksStart); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -447,7 +447,7 @@ public class TestBlocksRead extends HBaseTestCase { assertEquals(1, kvs.length); verifyData(kvs[0], "row", "col99", 201); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestColumnSeeking.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestColumnSeeking.java index 56c8796..8ce8f02 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestColumnSeeking.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestColumnSeeking.java @@ -157,10 +157,10 @@ public class TestColumnSeeking { assertTrue(KeyValueTestUtil.containsIgnoreMvccVersion(results, kvSet)); } } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } @SuppressWarnings("unchecked") @@ -269,7 +269,7 @@ public class TestColumnSeeking { assertTrue(KeyValueTestUtil.containsIgnoreMvccVersion(results, kvSet)); } - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } List generateRandomWords(int numberOfWords, String suffix) { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultCompactSelection.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultCompactSelection.java index 9779e47..b6a22a7 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultCompactSelection.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultCompactSelection.java @@ -94,8 +94,8 @@ public class TestDefaultCompactSelection extends TestCase { final Configuration walConf = new Configuration(conf); FSUtils.setRootDir(walConf, basedir); wals = new WALFactory(walConf, null, id); - region = HRegion.createHRegion(info, basedir, conf, htd); - HRegion.closeHRegion(region); + region = HBaseTestingUtility.createRegionAndWAL(info, basedir, conf, htd); + HBaseTestingUtility.closeRegionAndWAL(region); Path tableDir = FSUtils.getTableDir(basedir, htd.getTableName()); region = new HRegion(tableDir, wals.getWAL(info.getEncodedNameAsBytes()), fs, conf, info, htd, null); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestGetClosestAtOrBefore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestGetClosestAtOrBefore.java index 386bc9b..3b5b84e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestGetClosestAtOrBefore.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestGetClosestAtOrBefore.java @@ -29,6 +29,7 @@ import org.apache.hadoop.fs.Path; 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.HConstants; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HTableDescriptor; @@ -69,8 +70,9 @@ public class TestGetClosestAtOrBefore extends HBaseTestCase { Path rootdir = testDir; // Up flush size else we bind up when we use default catalog flush of 16k. fsTableDescriptors.get(TableName.META_TABLE_NAME).setMemStoreFlushSize(64 * 1024 * 1024); - HRegion mr = HRegion.createHRegion(HRegionInfo.FIRST_META_REGIONINFO, - rootdir, this.conf, fsTableDescriptors.get(TableName.META_TABLE_NAME)); + + HRegion mr = HBaseTestingUtility.createRegionAndWAL(HRegionInfo.FIRST_META_REGIONINFO, + rootdir, this.conf, fsTableDescriptors.get(TableName.META_TABLE_NAME)); try { // Write rows for three tables 'A', 'B', and 'C'. for (char c = 'A'; c < 'D'; c++) { @@ -132,14 +134,7 @@ public class TestGetClosestAtOrBefore extends HBaseTestCase { findRow(mr, 'C', 46, -1); findRow(mr, 'C', 43, -1); } finally { - if (mr != null) { - try { - mr.close(); - } catch (Exception e) { - e.printStackTrace(); - } - mr.getWAL().close(); - } + HBaseTestingUtility.closeRegionAndWAL(mr); } } 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 b238cd5..4ab03b4 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; @@ -128,8 +129,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; @@ -252,7 +255,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); } /* @@ -304,7 +307,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.singletonList(new MetricsWAL()), callingMethod)) + .getWAL(tableName); } /** @@ -325,6 +345,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 = @@ -341,7 +363,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. @@ -375,7 +398,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; } @@ -386,6 +409,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 = @@ -402,7 +427,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. @@ -427,7 +453,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; } @@ -560,7 +586,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(); } @@ -618,7 +644,7 @@ public class TestHRegion { } } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; wals.close(); } @@ -651,7 +677,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; } } @@ -716,7 +742,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(); } @@ -811,7 +837,7 @@ public class TestHRegion { assertArrayEquals(Bytes.toBytes(i), value); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; wals.close(); } @@ -930,7 +956,7 @@ public class TestHRegion { assertArrayEquals(Bytes.toBytes(i), value); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; wals.close(); } @@ -1050,7 +1076,7 @@ public class TestHRegion { } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1091,7 +1117,7 @@ public class TestHRegion { } } finally { if (this.region != null) { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); } } done.set(true); @@ -1107,7 +1133,7 @@ public class TestHRegion { } } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1184,7 +1210,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; } } @@ -1203,7 +1229,7 @@ public class TestHRegion { } catch (IOException e) { exceptionCaught = true; } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } assertTrue(exceptionCaught == true); @@ -1222,7 +1248,7 @@ public class TestHRegion { } catch (IOException e) { exceptionCaught = true; } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } assertTrue(exceptionCaught == true); @@ -1318,7 +1344,7 @@ public class TestHRegion { } assertTrue(exception); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1359,7 +1385,7 @@ public class TestHRegion { metricsAssertHelper.assertCounter("syncTimeNumOps", syncs + 2, source); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1411,7 +1437,7 @@ public class TestHRegion { @Override public void run() { try { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } catch (IOException e) { throw new RuntimeException(e); } @@ -1447,7 +1473,7 @@ public class TestHRegion { codes[i].getOperationStatusCode()); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1495,7 +1521,7 @@ public class TestHRegion { metricsAssertHelper.assertCounter("syncTimeNumOps", syncs, source); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } @@ -1574,7 +1600,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; } } @@ -1608,7 +1634,7 @@ public class TestHRegion { put, true); assertEquals(false, res); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1641,7 +1667,7 @@ public class TestHRegion { delete, true); assertEquals(true, res); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1736,7 +1762,7 @@ public class TestHRegion { new BinaryComparator(val3), put, true); assertEquals(true, res); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1783,7 +1809,7 @@ public class TestHRegion { assertEquals(expected[i], actual[i]); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1803,7 +1829,7 @@ public class TestHRegion { // expected exception. } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1880,7 +1906,7 @@ public class TestHRegion { r = region.get(get); assertEquals(0, r.size()); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -1915,7 +1941,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; } } @@ -1959,7 +1985,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; } } @@ -2027,7 +2053,7 @@ public class TestHRegion { result = region.get(get); assertEquals(1, result.size()); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2066,7 +2092,7 @@ public class TestHRegion { result = region.get(get); assertEquals(0, result.size()); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2116,7 +2142,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; } @@ -2151,7 +2177,7 @@ public class TestHRegion { } assertTrue("Should catch FailedSanityCheckException", caughtExcep); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2193,7 +2219,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; } } @@ -2252,7 +2278,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; } } @@ -2292,7 +2318,7 @@ public class TestHRegion { now = cell.getTimestamp(); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2323,7 +2349,7 @@ public class TestHRegion { } assertFalse(true); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2375,7 +2401,7 @@ public class TestHRegion { res = region.get(g); assertEquals(count, res.size()); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2394,7 +2420,7 @@ public class TestHRegion { assertTrue(r.isEmpty()); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2437,14 +2463,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; } } @@ -2510,7 +2536,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; } } @@ -2536,7 +2562,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; } } @@ -2580,7 +2606,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; } } @@ -2617,7 +2643,7 @@ public class TestHRegion { + e.getMessage()); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2683,7 +2709,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; } } @@ -2742,7 +2768,7 @@ public class TestHRegion { assertEquals(expected.get(i), actual.get(i)); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -2805,7 +2831,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; } } @@ -2887,7 +2913,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; } } @@ -2948,7 +2974,7 @@ public class TestHRegion { assertEquals(expected.get(i), actual.get(i)); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -3009,7 +3035,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; } } @@ -3057,7 +3083,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; } } @@ -3136,7 +3162,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; } } @@ -3205,7 +3231,7 @@ public class TestHRegion { assertFalse(s.next(results)); assertEquals(results.size(), 0); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -3300,7 +3326,7 @@ public class TestHRegion { break; } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -3394,7 +3420,7 @@ public class TestHRegion { } } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -3433,7 +3459,7 @@ public class TestHRegion { verifyData(regions[1], splitRow, numRows, qualifier, families); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -3501,7 +3527,7 @@ public class TestHRegion { verifyData(regions[1], splitRow, numRows, qualifier, families); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -3573,7 +3599,7 @@ public class TestHRegion { flushThread.join(); flushThread.checkNoError(); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -3707,7 +3733,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 @@ -3734,11 +3760,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); } @@ -3908,7 +3934,7 @@ public class TestHRegion { } ctx.stop(); - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -3931,7 +3957,7 @@ public class TestHRegion { g = new Get(row); region.get(g); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -3970,7 +3996,7 @@ public class TestHRegion { ; assertEquals(1L, res.size()); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -4031,7 +4057,7 @@ public class TestHRegion { assertEquals(num_unique_rows, reader.getFilterEntries()); } } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -4074,7 +4100,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; } } @@ -4117,7 +4143,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; } } @@ -4227,7 +4253,7 @@ public class TestHRegion { } } } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } } @@ -4245,11 +4271,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); @@ -4260,7 +4285,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", @@ -4274,7 +4299,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", @@ -4620,7 +4645,7 @@ public class TestHRegion { verify(wal, never()).sync(); } - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } @@ -4651,8 +4676,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); @@ -4666,10 +4691,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); } } } @@ -4701,8 +4726,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); @@ -4721,10 +4746,10 @@ public class TestHRegion { } } finally { if (primaryRegion != null) { - HRegion.closeHRegion(primaryRegion); + HBaseTestingUtility.closeRegionAndWAL(primaryRegion); } if (secondaryRegion != null) { - HRegion.closeHRegion(secondaryRegion); + HBaseTestingUtility.closeRegionAndWAL(secondaryRegion); } } } @@ -4754,8 +4779,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); @@ -4775,10 +4800,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); } } } @@ -4929,9 +4954,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); } @@ -4943,9 +4968,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); } @@ -4958,9 +4983,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); } @@ -4968,8 +4993,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); } /** @@ -4982,7 +5010,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, @@ -5059,7 +5087,7 @@ public class TestHRegion { assertFalse(hasNext); scanner.close(); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -5116,7 +5144,7 @@ public class TestHRegion { assertFalse(hasNext); scanner.close(); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -5170,7 +5198,7 @@ public class TestHRegion { assertFalse(hasNext); scanner.close(); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -5248,7 +5276,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; } } @@ -5328,7 +5356,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; } } @@ -5489,7 +5517,7 @@ public class TestHRegion { scanner.close(); } finally { - HRegion.closeHRegion(this.region); + HBaseTestingUtility.closeRegionAndWAL(this.region); this.region = null; } } @@ -5563,7 +5591,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; } } @@ -5658,7 +5686,7 @@ public class TestHRegion { assertEquals(verify, startRow - 1); scanner.close(); } finally { - HRegion.closeHRegion(this.region); + this.region.close(); this.region = null; } } @@ -5685,7 +5713,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; } @@ -5705,14 +5733,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 editCaptor = ArgumentCaptor.forClass(WALEdit.class); @@ -5756,7 +5784,7 @@ public class TestHRegion { assertEquals(0, store.getStoreFileCount()); // no store files } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } } @@ -5866,7 +5894,7 @@ public class TestHRegion { } catch (Throwable e) { } - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); region = null; CONF.setLong("hbase.busy.wait.duration", defaultBusyWaitDuration); } @@ -5891,9 +5919,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(); @@ -5995,7 +6023,7 @@ public class TestHRegion { assertNull(r.getValue(fam1, q1)); } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } } 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 e29bef8..879a7db 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 @@ -60,12 +60,11 @@ public class TestHRegionInfo { HRegionInfo hri = HRegionInfo.FIRST_META_REGIONINFO; Path basedir = htu.getDataTestDir(); FSTableDescriptors fsTableDescriptors = new FSTableDescriptors(htu.getConfiguration()); - // Create a region. That'll write the .regioninfo file. - 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()); @@ -76,6 +75,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 { 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 08e11f4..6a10137 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.testclassification.LargeTests; import org.apache.hadoop.hbase.MiniHBaseCluster; @@ -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(); /** 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 689f6ec..7743986 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 @@ -178,7 +178,7 @@ public class TestKeepDeletes { checkResult(r, c0, c0, T1); assertEquals(0, countDeleteMarkers(region)); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /** @@ -228,7 +228,7 @@ public class TestKeepDeletes { scan.next(kvs); assertTrue(kvs.isEmpty()); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /** @@ -273,7 +273,7 @@ public class TestKeepDeletes { // major compaction deleted it assertEquals(0, countDeleteMarkers(region)); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /** @@ -297,7 +297,7 @@ public class TestKeepDeletes { // ok! } - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /** @@ -387,7 +387,7 @@ public class TestKeepDeletes { assertTrue(CellUtil.isDelete(kvs.get(1))); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /** @@ -430,7 +430,7 @@ public class TestKeepDeletes { region.compactStores(true); assertEquals(0, countDeleteMarkers(region)); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /** @@ -493,7 +493,7 @@ public class TestKeepDeletes { region.compactStores(true); assertEquals(0, countDeleteMarkers(region)); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /** @@ -571,7 +571,7 @@ public class TestKeepDeletes { region.compactStores(true); assertEquals(1, countDeleteMarkers(region)); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /** @@ -651,7 +651,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); } /** @@ -746,7 +746,7 @@ public class TestKeepDeletes { region.compactStores(true); assertEquals(1, countDeleteMarkers(region)); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /** @@ -796,7 +796,7 @@ public class TestKeepDeletes { assertEquals(4, kvs.size()); scanner.close(); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /** @@ -875,7 +875,7 @@ public class TestKeepDeletes { region.compactStores(true); assertEquals(0, countDeleteMarkers(region)); - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } /** @@ -920,7 +920,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, 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 7f96cd5..a93b76b 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 @@ -104,7 +104,7 @@ public class TestMinVersions { r = region.getClosestRowBefore(T2, c0); checkResult(r, c0, T4); } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } } @@ -161,7 +161,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); } } @@ -220,7 +220,7 @@ public class TestMinVersions { r = region.get(g); // this'll use ExplicitColumnTracker checkResult(r, c0, T3); } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } } @@ -295,7 +295,7 @@ public class TestMinVersions { r = region.get(g); // this'll use ExplicitColumnTracker checkResult(r, c0, T5,T4); } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } } @@ -387,7 +387,7 @@ public class TestMinVersions { r = region.get(g); assertTrue(r.isEmpty()); } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } } @@ -462,7 +462,7 @@ public class TestMinVersions { r = region.get(g); checkResult(r, c0, T2); } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } } 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 a1df615..bf3b155 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 @@ -284,7 +284,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) { 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(); 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 8c67656..a3bd847 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 @@ -247,7 +247,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()); @@ -307,7 +307,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()); @@ -411,9 +411,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()); } 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 cb2a3ba..282476e 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 @@ -68,7 +68,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); @@ -99,9 +99,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); } } 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 5c27ff5..ac54429 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,18 +31,18 @@ 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.client.Durability; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.Scan; @@ -307,12 +307,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 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 bf6e4b1..3e97e9e 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 @@ -112,7 +112,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) 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 cea09f2..b129104 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); } } 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 748f94b..b92f19a 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 @@ -438,7 +438,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 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 9126c4d..3cad321 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 @@ -246,7 +246,7 @@ public class TestSplitTransaction { assertTrue(count > 0 && count != rowcount); daughtersRowCount += count; } finally { - HRegion.closeHRegion(openRegion); + HBaseTestingUtility.closeRegionAndWAL(openRegion); } } assertEquals(rowcount, daughtersRowCount); @@ -330,7 +330,7 @@ public class TestSplitTransaction { assertTrue(count > 0 && count != rowcount); daughtersRowCount += count; } finally { - HRegion.closeHRegion(openRegion); + HBaseTestingUtility.closeRegionAndWAL(openRegion); } } assertEquals(rowcount, daughtersRowCount); @@ -374,8 +374,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()); } 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 7ed85ca..5217e4a 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.SmallTests; @@ -135,7 +136,7 @@ public class TestWideScanner extends HBaseTestCase { s.close(); } finally { - HRegion.closeHRegion(this.r); + HBaseTestingUtility.closeRegionAndWAL(this.r); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestCloseRegionHandler.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestCloseRegionHandler.java index 75d4b3d..baab4b1 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestCloseRegionHandler.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestCloseRegionHandler.java @@ -137,7 +137,7 @@ public class TestCloseRegionHandler { assertTrue(server.isStopped()); } } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java index 8346787..8b377a4 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java @@ -95,9 +95,8 @@ public class TestOpenRegionHandler { HTableDescriptor htd = TEST_HTD; final HRegionInfo hri = TEST_HRI; - HRegion region = - HRegion.createHRegion(hri, HTU.getDataTestDir(), HTU - .getConfiguration(), htd); + HRegion region = HBaseTestingUtility.createRegionAndWAL(hri, HTU.getDataTestDir(), + HTU.getConfiguration(), htd); assertNotNull(region); try { ZkCoordinatedStateManager csm = new ZkCoordinatedStateManager(); @@ -138,7 +137,7 @@ public class TestOpenRegionHandler { // post OPENING; again will expect it to come back w/o NPE or exception. handler.process(); } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } } @@ -158,9 +157,8 @@ public class TestOpenRegionHandler { HTableDescriptor htd = TEST_HTD; final HRegionInfo hri = TEST_HRI; - HRegion region = - HRegion.createHRegion(hri, HTU.getDataTestDir(), HTU - .getConfiguration(), htd); + HRegion region = HBaseTestingUtility.createRegionAndWAL(hri, HTU.getDataTestDir(), + HTU.getConfiguration(), htd); assertNotNull(region); try { @@ -205,7 +203,7 @@ public class TestOpenRegionHandler { handler.process(); } catch (IOException ioe) { } finally { - HRegion.closeHRegion(region); + HBaseTestingUtility.closeRegionAndWAL(region); } // Region server is expected to abort due to OpenRegionHandler perceiving transitioning // to OPENED as failed 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 8c152fd..f874564 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 @@ -389,7 +389,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 HBASE-11109 */ @Test public void testFlushSequenceIdIsGreaterThanAllEditsInHFile() throws IOException { @@ -399,9 +399,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. 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 b6e7c02..e2c7b77 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 @@ -51,6 +51,7 @@ import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.MasterNotRunningException; +import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.MiniHBaseCluster; import org.apache.hadoop.hbase.ServerName; @@ -58,7 +59,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; @@ -272,7 +272,7 @@ public class TestWALReplay { /** * Tests for hbase-2727. * @throws Exception - * @see https://issues.apache.org/jira/browse/HBASE-2727 + * @see HBASE-2727 */ @Test public void test2727() throws Exception { @@ -285,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); @@ -347,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); @@ -414,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); @@ -487,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. @@ -597,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. @@ -680,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. @@ -779,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(); 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 04fa5bf..02a0579 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 @@ -142,7 +142,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))); @@ -154,19 +155,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); } } 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 d4c7fa8..52fc6e0 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 @@ -151,7 +151,7 @@ public class TestMergeTool extends HBaseTestCase { */ for (int i = 0; i < sourceRegions.length; i++) { regions[i] = - HRegion.createHRegion(this.sourceRegions[i], this.testDir, this.conf, + HBaseTestingUtility.createRegionAndWAL(this.sourceRegions[i], testDir, this.conf, this.desc); /* * Insert data @@ -179,7 +179,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(); @@ -267,7 +267,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 -- 1.9.3 (Apple Git-50)