HBASE-11983 HRegion constructors should not create HLog

Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/9b7f36b8
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/9b7f36b8
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/9b7f36b8

Branch: refs/heads/master
Commit: 9b7f36b8cf521bcc01ac6476349a9d2f34be8bb3
Parents: 4ac457a
Author: Nick Dimiduk <[email protected]>
Authored: Tue Jan 13 12:35:19 2015 -0800
Committer: Nick Dimiduk <[email protected]>
Committed: Tue Jan 13 15:07:59 2015 -0800

----------------------------------------------------------------------
 .../hadoop/hbase/master/MasterFileSystem.java   |   4 +-
 .../hadoop/hbase/regionserver/HRegion.java      | 115 +-------
 .../hbase/snapshot/RestoreSnapshotHelper.java   |   6 +-
 .../org/apache/hadoop/hbase/util/HBaseFsck.java |  29 ++-
 .../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 +-
 .../hadoop/hbase/HBaseTestingUtility.java       |  81 ++++--
 .../hbase/client/TestIntraRowPagination.java    |   6 +-
 .../coprocessor/TestCoprocessorInterface.java   |   7 +-
 .../TestRegionObserverScannerOpenHook.java      |   6 +-
 .../coprocessor/TestRegionObserverStacking.java |   3 +-
 .../hbase/filter/TestColumnPrefixFilter.java    |  16 +-
 .../hbase/filter/TestDependentColumnFilter.java |   6 +-
 .../apache/hadoop/hbase/filter/TestFilter.java  |  18 +-
 .../filter/TestInvocationRecordFilter.java      |   2 +-
 .../filter/TestMultipleColumnPrefixFilter.java  |  18 +-
 .../hbase/io/encoding/TestPrefixTree.java       |   4 +-
 .../TestScannerSelectionUsingKeyRange.java      |   5 +-
 .../io/hfile/TestScannerSelectionUsingTTL.java  |   5 +-
 .../hadoop/hbase/master/TestMasterFailover.java |   4 +-
 .../hbase/regionserver/TestAtomicOperation.java |   5 +-
 .../hbase/regionserver/TestBlocksRead.java      |  12 +-
 .../hbase/regionserver/TestColumnSeeking.java   |   6 +-
 .../TestDefaultCompactSelection.java            |   4 +-
 .../regionserver/TestGetClosestAtOrBefore.java  |  14 +-
 .../hadoop/hbase/regionserver/TestHRegion.java  | 260 ++++++++++---------
 .../hbase/regionserver/TestHRegionInfo.java     |   7 +-
 .../hbase/regionserver/TestJoinedScanners.java  |  24 --
 .../hbase/regionserver/TestKeepDeletes.java     |  26 +-
 .../hbase/regionserver/TestMinVersions.java     |  12 +-
 .../regionserver/TestMultiColumnScanner.java    |   2 +-
 .../regionserver/TestPerColumnFamilyFlush.java  |  14 +-
 .../TestRegionMergeTransaction.java             |   8 +-
 .../regionserver/TestResettingCounters.java     |   6 +-
 .../regionserver/TestReversibleScanners.java    |  15 +-
 .../regionserver/TestScanWithBloomError.java    |   2 +-
 .../hadoop/hbase/regionserver/TestScanner.java  |  14 +-
 .../regionserver/TestSeekOptimizations.java     |   2 +-
 .../regionserver/TestSplitTransaction.java      |  10 +-
 .../hbase/regionserver/TestWideScanner.java     |   3 +-
 .../hbase/regionserver/wal/TestFSHLog.java      |  13 +-
 .../hbase/regionserver/wal/TestWALReplay.java   |  38 ++-
 .../hadoop/hbase/util/TestMergeTable.java       |  14 +-
 .../apache/hadoop/hbase/util/TestMergeTool.java |   7 +-
 46 files changed, 422 insertions(+), 513 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
----------------------------------------------------------------------
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 fcfa07f..4d72312 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
@@ -513,9 +513,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 = e instanceof RemoteException ?
                 ((RemoteException)e).unwrapRemoteException() : e;

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
----------------------------------------------------------------------
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 6cf2ce3..dd1cf8d 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;
@@ -135,8 +134,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;
@@ -3383,13 +3380,10 @@ public class HRegion implements HeapSize, 
PropagatingConfigurationObserver { //
    * <b>not</b> 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<byte[], List<Cell>> familyMap,
     long mvccNum, List<Cell> memstoreCells, boolean isInReplay) throws 
IOException {
@@ -4673,55 +4667,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.  <b>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.</b>  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,
@@ -4730,75 +4682,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.<WALActionsListener>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.

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/RestoreSnapshotHelper.java
----------------------------------------------------------------------
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 a1c2777..441dbbf 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
@@ -506,7 +506,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 {
@@ -552,7 +552,7 @@ public class RestoreSnapshotHelper {
    * </ul>
    * @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 {
@@ -582,7 +582,7 @@ public class RestoreSnapshotHelper {
    * </pre></blockquote>
    * @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 {

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
----------------------------------------------------------------------
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 a5ac8b8..7841a0d 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
@@ -53,6 +53,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;
@@ -111,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;
@@ -119,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.ZooKeeperWatcher;
@@ -1214,17 +1219,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.<WALActionsListener>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;
   }
@@ -1282,8 +1296,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.
@@ -1339,7 +1353,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;

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsckRepair.java
----------------------------------------------------------------------
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 0a0abda..8175454 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
@@ -213,7 +213,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;
   }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/main/java/org/apache/hadoop/hbase/util/ModifyRegionUtils.java
----------------------------------------------------------------------
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<HRegionInfo> 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<HRegionInfo> 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<HRegionInfo> 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<HRegionInfo> 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<HRegionInfo>() {
         @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.<WALActionsListener>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();
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALFactory.java
----------------------------------------------------------------------
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 ba349e5..5dc1dde 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
@@ -62,7 +62,7 @@ import 
org.apache.hadoop.hbase.regionserver.wal.WALActionsListener;
  *                           server.</li>
  * </ul>
  *
- * 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 {

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestCase.java
----------------------------------------------------------------------
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 3705f3b..e4dc09e 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
@@ -149,9 +149,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
@@ -168,7 +167,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)
@@ -641,12 +640,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,

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
----------------------------------------------------------------------
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 40b1364..5ac5f96 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
@@ -17,6 +17,7 @@
  */
 package org.apache.hadoop.hbase;
 
+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;
@@ -62,6 +63,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.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;
@@ -75,6 +78,7 @@ 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.ZKConfig;
@@ -124,7 +128,7 @@ import static org.junit.Assert.fail;
  * 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
@@ -277,6 +281,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
@@ -1692,13 +1706,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 <code>name</code> 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));
@@ -1715,8 +1722,7 @@ public class HBaseTestingUtility extends 
HBaseCommonTestingUtility {
   }
 
   /**
-   * Create a table of name <code>name</code> with {@link COLUMNS} for
-   * families.
+   * Create a table of name <code>name</code>.
    * @param name Name to give table.
    * @return Column descriptor.
    */
@@ -1741,14 +1747,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);
   }
 
   /**
@@ -1774,7 +1777,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,
@@ -2108,6 +2111,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");
@@ -2292,6 +2296,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.<WALActionsListener>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.
@@ -2888,7 +2927,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
@@ -2907,7 +2945,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
@@ -2960,7 +2998,6 @@ public class HBaseTestingUtility extends 
HBaseCommonTestingUtility {
 
   /**
    * Waits for a table to be 'disabled'.  Disabled means that table is set as 
'disabled'
-   * @see #waitTableAvailable(byte[])
    * @param table Table to wait on.
    * @param timeoutMillis Time to wait on it being marked disabled.
    * @throws InterruptedException
@@ -3619,9 +3656,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) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestIntraRowPagination.java
----------------------------------------------------------------------
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 add8221..1f6dc98 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
@@ -60,8 +60,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;
@@ -101,7 +101,7 @@ public class TestIntraRowPagination {
       TestScannersFromClientSide.verifyResult(result, kvListExp, toLog,
           "Testing scan with storeOffset and storeLimit");
     } finally {
-      region.close();
+      HBaseTestingUtility.closeRegionAndWAL(region);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorInterface.java
----------------------------------------------------------------------
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 c3791c3..ce76e8a 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
@@ -350,6 +350,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
@@ -374,7 +375,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());
 
@@ -394,7 +395,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());
@@ -441,7 +442,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);

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverScannerOpenHook.java
----------------------------------------------------------------------
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 88b001d..4c4d6e5 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
@@ -42,7 +42,6 @@ import org.apache.hadoop.hbase.HTableDescriptor;
 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;
@@ -151,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
@@ -183,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
@@ -208,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);
   }
 
   /*

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverStacking.java
----------------------------------------------------------------------
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 126a2d2..78deed9 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
@@ -102,7 +102,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
@@ -139,6 +139,7 @@ public class TestRegionObserverStacking extends TestCase {
 
     assertTrue(idA < idB);
     assertTrue(idB < idC);
+    HBaseTestingUtility.closeRegionAndWAL(region);
   }
 
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestColumnPrefixFilter.java
----------------------------------------------------------------------
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 0fbad42..2e51c82 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
@@ -51,8 +51,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<String> rows = generateRandomWords(100, "row");
       List<String> columns = generateRandomWords(10000, "column");
@@ -101,10 +101,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
@@ -113,8 +113,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<String> rows = generateRandomWords(100, "row");
       List<String> columns = generateRandomWords(10000, "column");
@@ -166,10 +166,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<String> generateRandomWords(int numberOfWords, String suffix) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestDependentColumnFilter.java
----------------------------------------------------------------------
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 06e0260..40a4c43 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
@@ -81,14 +81,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 {

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilter.java
----------------------------------------------------------------------
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 3396587..61321dd 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
@@ -142,8 +142,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) {
@@ -217,9 +217,7 @@ public class TestFilter {
 
   @After
   public void tearDown() throws Exception {
-    WAL wal = region.getWAL();
-    region.close();
-    wal.close();
+    HBaseTestingUtility.closeRegionAndWAL(region);
   }
 
   @Test
@@ -656,8 +654,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.
    *
@@ -1453,7 +1450,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++) {
@@ -2007,13 +2004,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);

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestInvocationRecordFilter.java
----------------------------------------------------------------------
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 70ef51f..5454480d 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
@@ -68,7 +68,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);

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultipleColumnPrefixFilter.java
----------------------------------------------------------------------
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 0db5ecf..d2997af 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
@@ -54,8 +54,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<String> rows = generateRandomWords(100, "row");
     List<String> columns = generateRandomWords(10000, "column");
@@ -105,7 +105,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
@@ -120,8 +120,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<String> rows = generateRandomWords(100, "row");
     List<String> columns = generateRandomWords(10000, "column");
@@ -177,7 +177,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
@@ -186,8 +186,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<String> rows = generateRandomWords(100, "row");
     List<String> columns = generateRandomWords(10000, "column");
@@ -232,7 +232,7 @@ public class TestMultipleColumnPrefixFilter {
     
     assertEquals(results1.size(), results2.size());
 
-    HRegion.closeHRegion(region);
+    HBaseTestingUtility.closeRegionAndWAL(region);
   }
   
   List<String> generateRandomWords(int numberOfWords, String suffix) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestPrefixTree.java
----------------------------------------------------------------------
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 9b87c37..80a50b0 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
@@ -74,12 +74,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();
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestScannerSelectionUsingKeyRange.java
----------------------------------------------------------------------
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 55aa97b..e8f6c1b 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
@@ -99,7 +99,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) {
@@ -126,6 +127,6 @@ public class TestScannerSelectionUsingKeyRange {
     assertEquals(0, results.size());
     Set<String> accessedFiles = cache.getCachedFileNamesForTest();
     assertEquals(expectedCount, accessedFiles.size());
-    region.close();
+    HBaseTestingUtility.closeRegionAndWAL(region);
   }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestScannerSelectionUsingTTL.java
----------------------------------------------------------------------
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 c1a5061..1c426e4 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);
   }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java
----------------------------------------------------------------------
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 cae1258..f0c6bc2 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
@@ -64,13 +64,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;
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestAtomicOperation.java
----------------------------------------------------------------------
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 883e530..192c989 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
@@ -538,8 +538,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"));

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java
----------------------------------------------------------------------
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 2bb8076..1ae17ed 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
@@ -90,7 +90,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
@@ -112,7 +112,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;
   }
@@ -265,7 +265,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;
     }
   }
@@ -374,7 +374,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;
     }
   }
@@ -423,7 +423,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;
     }
   }
@@ -450,7 +450,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;
     }
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestColumnSeeking.java
----------------------------------------------------------------------
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 81ff370..7632a41 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
@@ -158,10 +158,10 @@ public class TestColumnSeeking {
         assertTrue(KeyValueTestUtil.containsIgnoreMvccVersion(results, kvSet));
       }
     } finally {
-      HRegion.closeHRegion(region);
+      HBaseTestingUtility.closeRegionAndWAL(region);
     }
 
-    HRegion.closeHRegion(region);
+    HBaseTestingUtility.closeRegionAndWAL(region);
   }
 
   @SuppressWarnings("unchecked")
@@ -270,7 +270,7 @@ public class TestColumnSeeking {
       assertTrue(KeyValueTestUtil.containsIgnoreMvccVersion(results, kvSet));
     }
 
-    HRegion.closeHRegion(region);
+    HBaseTestingUtility.closeRegionAndWAL(region);
   }
 
   List<String> generateRandomWords(int numberOfWords, String suffix) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultCompactSelection.java
----------------------------------------------------------------------
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 43bc9f1..4969a59 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
@@ -97,8 +97,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);

http://git-wip-us.apache.org/repos/asf/hbase/blob/9b7f36b8/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestGetClosestAtOrBefore.java
----------------------------------------------------------------------
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 92351f4..0d7820f 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;
@@ -73,8 +74,8 @@ public class TestGetClosestAtOrBefore extends HBaseTestCase {
     // 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++) {
@@ -136,14 +137,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);
     }
   }
 

Reply via email to