hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bus...@apache.org
Subject [1/3] hbase git commit: HBASE-16912 Cleanup for HBaseTestingUtility.
Date Tue, 29 Nov 2016 07:20:56 GMT
Repository: hbase
Updated Branches:
  refs/heads/hbase-14439 a36f80c7a -> 6d1813a2f


http://git-wip-us.apache.org/repos/asf/hbase/blob/6d1813a2/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestWALReplay.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestWALReplay.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestWALReplay.java
index 5995e28..3872784 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestWALReplay.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestWALReplay.java
@@ -18,6 +18,7 @@
  */
 package org.apache.hadoop.hbase.regionserver.wal;
 
+import static java.awt.SystemColor.info;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
@@ -71,6 +72,8 @@ import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.client.ResultScanner;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.fs.RegionStorage;
+import org.apache.hadoop.hbase.fs.legacy.LegacyPathIdentifier;
 import org.apache.hadoop.hbase.master.HMaster;
 import org.apache.hadoop.hbase.monitoring.MonitoredTask;
 import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.SplitLogTask.RecoveryMode;
@@ -95,8 +98,6 @@ import org.apache.hadoop.hbase.util.FSUtils;
 import org.apache.hadoop.hbase.util.HFileTestUtil;
 import org.apache.hadoop.hbase.util.Pair;
 import org.apache.hadoop.hbase.wal.AbstractFSWALProvider;
-import org.apache.hadoop.hbase.wal.AsyncFSWALProvider;
-import org.apache.hadoop.hbase.wal.FSHLogProvider;
 import org.apache.hadoop.hbase.wal.WAL;
 import org.apache.hadoop.hbase.wal.WALFactory;
 import org.apache.hadoop.hbase.wal.WALKey;
@@ -120,7 +121,7 @@ public abstract class AbstractTestWALReplay {
   private static final Log LOG = LogFactory.getLog(AbstractTestWALReplay.class);
   static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
   private final EnvironmentEdge ee = EnvironmentEdgeManager.getDelegate();
-  private Path hbaseRootDir = null;
+  private Path hbaseRootDir;
   private String logName;
   private Path oldLogDir;
   private Path logDir;
@@ -183,10 +184,6 @@ public abstract class AbstractTestWALReplay {
     }
   }
 
-  /**
-   *
-   * @throws Exception
-   */
   @Test
   public void testReplayEditsAfterRegionMovedWithMultiCF() throws Exception {
     final TableName tableName =
@@ -281,383 +278,352 @@ public abstract class AbstractTestWALReplay {
     }
   }
 
-//  /**
-//   * Tests for hbase-2727.
-//   * @throws Exception
-//   * @see <a href="https://issues.apache.org/jira/browse/HBASE-2727">HBASE-2727</a>
-//   */
-//  @Test
-//  public void test2727() throws Exception {
-//    // Test being able to have > 1 set of edits in the recovered.edits directory.
-//    // Ensure edits are replayed properly.
-//    final TableName tableName =
-//        TableName.valueOf("test2727");
-//
-//    MultiVersionConcurrencyControl mvcc = new MultiVersionConcurrencyControl();
-//    HRegionInfo hri = createBasic3FamilyHRegionInfo(tableName);
-//    Path basedir = FSUtils.getTableDir(hbaseRootDir, tableName);
-//    deleteDir(basedir);
-//
-//    HTableDescriptor htd = createBasic3FamilyHTD(tableName);
-//    Region region2 = HBaseTestingUtility.createRegionAndWAL(hri, hbaseRootDir, this.conf, htd);
-//    HBaseTestingUtility.closeRegionAndWAL(region2);
-//    final byte [] rowName = tableName.getName();
-//
-//    WAL wal1 = createWAL(this.conf, hbaseRootDir, logName);
-//    // Add 1k to each family.
-//    final int countPerFamily = 1000;
-//
-//    NavigableMap<byte[], Integer> scopes = new TreeMap<byte[], Integer>(
-//        Bytes.BYTES_COMPARATOR);
-//    for(byte[] fam : htd.getFamiliesKeys()) {
-//      scopes.put(fam, 0);
-//    }
-//    for (HColumnDescriptor hcd: htd.getFamilies()) {
-//      addWALEdits(tableName, hri, rowName, hcd.getName(), countPerFamily, ee,
-//          wal1, htd, mvcc, scopes);
-//    }
-//    wal1.shutdown();
-//    runWALSplit(this.conf);
-//
-//    WAL wal2 = createWAL(this.conf, hbaseRootDir, logName);
-//    // Add 1k to each family.
-//    for (HColumnDescriptor hcd: htd.getFamilies()) {
-//      addWALEdits(tableName, hri, rowName, hcd.getName(), countPerFamily,
-//          ee, wal2, htd, mvcc, scopes);
-//    }
-//    wal2.shutdown();
-//    runWALSplit(this.conf);
-//
-//    WAL wal3 = createWAL(this.conf, hbaseRootDir, logName);
-//    try {
-//      HRegion region = HRegion.openHRegion(this.conf, this.fs, hbaseRootDir, hri, htd, wal3);
-//      long seqid = region.getOpenSeqNum();
-//      // The regions opens with sequenceId as 1. With 6k edits, its sequence number reaches 6k + 1.
-//      // When opened, this region would apply 6k edits, and increment the sequenceId by 1
-//      assertTrue(seqid > mvcc.getWritePoint());
-//      assertEquals(seqid - 1, mvcc.getWritePoint());
-//      LOG.debug("region.getOpenSeqNum(): " + region.getOpenSeqNum() + ", wal3.id: "
-//          + mvcc.getReadPoint());
-//
-//      // TODO: Scan all.
-//      region.close();
-//    } finally {
-//      wal3.close();
-//    }
-//  }
-
-//  /**
-//   * Test case of HRegion that is only made out of bulk loaded files.  Assert
-//   * that we don't 'crash'.
-//   * @throws IOException
-//   * @throws IllegalAccessException
-//   * @throws NoSuchFieldException
-//   * @throws IllegalArgumentException
-//   * @throws SecurityException
-//   */
-//  @Test
-//  public void testRegionMadeOfBulkLoadedFilesOnly()
-//  throws IOException, SecurityException, IllegalArgumentException,
-//      NoSuchFieldException, IllegalAccessException, InterruptedException {
-//    final TableName tableName =
-//        TableName.valueOf("testRegionMadeOfBulkLoadedFilesOnly");
-//    final HRegionInfo hri = createBasic3FamilyHRegionInfo(tableName);
-//    final Path basedir = new Path(this.hbaseRootDir, tableName.getNameAsString());
-//    deleteDir(basedir);
-//    final HTableDescriptor htd = createBasic3FamilyHTD(tableName);
-//    Region region2 = HBaseTestingUtility.createRegionAndWAL(hri, hbaseRootDir, this.conf, htd);
-//    HBaseTestingUtility.closeRegionAndWAL(region2);
-//    WAL wal = createWAL(this.conf, hbaseRootDir, logName);
-//    Region region = HRegion.openHRegion(hri, htd, wal, this.conf);
-//
-//    byte [] family = htd.getFamilies().iterator().next().getName();
-//    Path f =  new Path(basedir, "hfile");
-//    HFileTestUtil.createHFile(this.conf, fs, f, family, family, Bytes.toBytes(""),
-//        Bytes.toBytes("z"), 10);
-//    List <Pair<byte[],String>>  hfs= new ArrayList<Pair<byte[],String>>(1);
-//    hfs.add(Pair.newPair(family, f.toString()));
-//    region.bulkLoadHFiles(hfs, true, null);
-//
-//    // Add an edit so something in the WAL
-//    byte [] row = tableName.getName();
-//    region.put((new Put(row)).addColumn(family, family, family));
-//    wal.sync();
-//    final int rowsInsertedCount = 11;
-//
-//    assertEquals(rowsInsertedCount, getScannedCount(region.getScanner(new Scan())));
-//
-//    // Now 'crash' the region by stealing its wal
-//    final Configuration newConf = HBaseConfiguration.create(this.conf);
-//    User user = HBaseTestingUtility.getDifferentUser(newConf,
-//        tableName.getNameAsString());
-//    user.runAs(new PrivilegedExceptionAction() {
-//      @Override
-//      public Object run() throws Exception {
-//        runWALSplit(newConf);
-//        WAL wal2 = createWAL(newConf, hbaseRootDir, logName);
-//
-//        HRegion region2 = HRegion.openHRegion(newConf, FileSystem.get(newConf),
-//          hbaseRootDir, hri, htd, wal2);
-//        long seqid2 = region2.getOpenSeqNum();
-//        assertTrue(seqid2 > -1);
-//        assertEquals(rowsInsertedCount, getScannedCount(region2.getScanner(new Scan())));
-//
-//        // I can't close wal1.  Its been appropriated when we split.
-//        region2.close();
-//        wal2.close();
-//        return null;
-//      }
-//    });
-//  }
-
-//  /**
-//   * HRegion test case that is made of a major compacted HFile (created with three bulk loaded
-//   * files) and an edit in the memstore.
-//   * This is for HBASE-10958 "[dataloss] Bulk loading with seqids can prevent some log entries
-//   * from being replayed"
-//   * @throws IOException
-//   * @throws IllegalAccessException
-//   * @throws NoSuchFieldException
-//   * @throws IllegalArgumentException
-//   * @throws SecurityException
-//   */
-//  @Test
-//  public void testCompactedBulkLoadedFiles()
-//      throws IOException, SecurityException, IllegalArgumentException,
-//      NoSuchFieldException, IllegalAccessException, InterruptedException {
-//    final TableName tableName =
-//        TableName.valueOf("testCompactedBulkLoadedFiles");
-//    final HRegionInfo hri = createBasic3FamilyHRegionInfo(tableName);
-//    final Path basedir = new Path(this.hbaseRootDir, tableName.getNameAsString());
-//    deleteDir(basedir);
-//    final HTableDescriptor htd = createBasic3FamilyHTD(tableName);
-//    HRegion region2 = HBaseTestingUtility.createRegionAndWAL(hri, hbaseRootDir, this.conf, htd);
-//    HBaseTestingUtility.closeRegionAndWAL(region2);
-//    WAL wal = createWAL(this.conf, hbaseRootDir, logName);
-//    HRegion region = HRegion.openHRegion(hri, htd, wal, this.conf);
-//
-//    // Add an edit so something in the WAL
-//    byte [] row = tableName.getName();
-//    byte [] family = htd.getFamilies().iterator().next().getName();
-//    region.put((new Put(row)).addColumn(family, family, family));
-//    wal.sync();
-//
-//    List <Pair<byte[],String>>  hfs= new ArrayList<Pair<byte[],String>>(1);
-//    for (int i = 0; i < 3; i++) {
-//      Path f = new Path(basedir, "hfile"+i);
-//      HFileTestUtil.createHFile(this.conf, fs, f, family, family, Bytes.toBytes(i + "00"),
-//          Bytes.toBytes(i + "50"), 10);
-//      hfs.add(Pair.newPair(family, f.toString()));
-//    }
-//    region.bulkLoadHFiles(hfs, true, null);
-//    final int rowsInsertedCount = 31;
-//    assertEquals(rowsInsertedCount, getScannedCount(region.getScanner(new Scan())));
-//
-//    // major compact to turn all the bulk loaded files into one normal file
-//    region.compact(true);
-//    assertEquals(rowsInsertedCount, getScannedCount(region.getScanner(new Scan())));
-//
-//    // Now 'crash' the region by stealing its wal
-//    final Configuration newConf = HBaseConfiguration.create(this.conf);
-//    User user = HBaseTestingUtility.getDifferentUser(newConf,
-//        tableName.getNameAsString());
-//    user.runAs(new PrivilegedExceptionAction() {
-//      @Override
-//      public Object run() throws Exception {
-//        runWALSplit(newConf);
-//        WAL wal2 = createWAL(newConf, hbaseRootDir, logName);
-//
-//        HRegion region2 = HRegion.openHRegion(newConf, FileSystem.get(newConf),
-//            hbaseRootDir, hri, htd, wal2);
-//        long seqid2 = region2.getOpenSeqNum();
-//        assertTrue(seqid2 > -1);
-//        assertEquals(rowsInsertedCount, getScannedCount(region2.getScanner(new Scan())));
-//
-//        // I can't close wal1.  Its been appropriated when we split.
-//        region2.close();
-//        wal2.close();
-//        return null;
-//      }
-//    });
-//  }
-//
-//
-//  /**
-//   * Test writing edits into an HRegion, closing it, splitting logs, opening
-//   * Region again.  Verify seqids.
-//   * @throws IOException
-//   * @throws IllegalAccessException
-//   * @throws NoSuchFieldException
-//   * @throws IllegalArgumentException
-//   * @throws SecurityException
-//   */
-//  @Test
-//  public void testReplayEditsWrittenViaHRegion()
-//  throws IOException, SecurityException, IllegalArgumentException,
-//      NoSuchFieldException, IllegalAccessException, InterruptedException {
-//    final TableName tableName =
-//        TableName.valueOf("testReplayEditsWrittenViaHRegion");
-//    final HRegionInfo hri = createBasic3FamilyHRegionInfo(tableName);
-//    final Path basedir = FSUtils.getTableDir(this.hbaseRootDir, tableName);
-//    deleteDir(basedir);
-//    final byte[] rowName = tableName.getName();
-//    final int countPerFamily = 10;
-//    final HTableDescriptor htd = createBasic3FamilyHTD(tableName);
-//    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.
-//    WAL wal = createWAL(this.conf, hbaseRootDir, logName);
-//    HRegion region = HRegion.openHRegion(this.conf, this.fs, hbaseRootDir, hri, htd, wal);
-//    long seqid = region.getOpenSeqNum();
-//    boolean first = true;
-//    for (HColumnDescriptor hcd: htd.getFamilies()) {
-//      addRegionEdits(rowName, hcd.getName(), countPerFamily, this.ee, region, "x");
-//      if (first) {
-//        // If first, so we have at least one family w/ different seqid to rest.
-//        region.flush(true);
-//        first = false;
-//      }
-//    }
-//    // Now assert edits made it in.
-//    final Get g = new Get(rowName);
-//    Result result = region.get(g);
-//    assertEquals(countPerFamily * htd.getFamilies().size(),
-//      result.size());
-//    // Now close the region (without flush), split the log, reopen the region and assert that
-//    // replay of log has the correct effect, that our seqids are calculated correctly so
-//    // all edits in logs are seen as 'stale'/old.
-//    region.close(true);
-//    wal.shutdown();
-//    runWALSplit(this.conf);
-//    WAL wal2 = createWAL(this.conf, hbaseRootDir, logName);
-//    HRegion region2 = HRegion.openHRegion(conf, this.fs, hbaseRootDir, hri, htd, wal2);
-//    long seqid2 = region2.getOpenSeqNum();
-//    assertTrue(seqid + result.size() < seqid2);
-//    final Result result1b = region2.get(g);
-//    assertEquals(result.size(), result1b.size());
-//
-//    // Next test.  Add more edits, then 'crash' this region by stealing its wal
-//    // out from under it and assert that replay of the log adds the edits back
-//    // correctly when region is opened again.
-//    for (HColumnDescriptor hcd: htd.getFamilies()) {
-//      addRegionEdits(rowName, hcd.getName(), countPerFamily, this.ee, region2, "y");
-//    }
-//    // Get count of edits.
-//    final Result result2 = region2.get(g);
-//    assertEquals(2 * result.size(), result2.size());
-//    wal2.sync();
-//    final Configuration newConf = HBaseConfiguration.create(this.conf);
-//    User user = HBaseTestingUtility.getDifferentUser(newConf,
-//      tableName.getNameAsString());
-//    user.runAs(new PrivilegedExceptionAction() {
-//      @Override
-//      public Object run() throws Exception {
-//        runWALSplit(newConf);
-//        FileSystem newFS = FileSystem.get(newConf);
-//        // Make a new wal for new region open.
-//        WAL wal3 = createWAL(newConf, hbaseRootDir, logName);
-//        final AtomicInteger countOfRestoredEdits = new AtomicInteger(0);
-//        HRegion region3 = new HRegion(basedir, wal3, newFS, newConf, hri, htd, null) {
-//          @Override
-//          protected boolean restoreEdit(Store s, Cell cell) {
-//            boolean b = super.restoreEdit(s, cell);
-//            countOfRestoredEdits.incrementAndGet();
-//            return b;
-//          }
-//        };
-//        long seqid3 = region3.initialize();
-//        Result result3 = region3.get(g);
-//        // Assert that count of cells is same as before crash.
-//        assertEquals(result2.size(), result3.size());
-//        assertEquals(htd.getFamilies().size() * countPerFamily,
-//          countOfRestoredEdits.get());
-//
-//        // I can't close wal1.  Its been appropriated when we split.
-//        region3.close();
-//        wal3.close();
-//        return null;
-//      }
-//    });
-//  }
-//
-//  /**
-//   * Test that we recover correctly when there is a failure in between the
-//   * flushes. i.e. Some stores got flushed but others did not.
-//   *
-//   * Unfortunately, there is no easy hook to flush at a store level. The way
-//   * we get around this is by flushing at the region level, and then deleting
-//   * the recently flushed store file for one of the Stores. This would put us
-//   * back in the situation where all but that store got flushed and the region
-//   * died.
-//   *
-//   * We restart Region again, and verify that the edits were replayed.
-//   *
-//   * @throws IOException
-//   * @throws IllegalAccessException
-//   * @throws NoSuchFieldException
-//   * @throws IllegalArgumentException
-//   * @throws SecurityException
-//   */
-//  @Test
-//  public void testReplayEditsAfterPartialFlush()
-//  throws IOException, SecurityException, IllegalArgumentException,
-//      NoSuchFieldException, IllegalAccessException, InterruptedException {
-//    final TableName tableName =
-//        TableName.valueOf("testReplayEditsWrittenViaHRegion");
-//    final HRegionInfo hri = createBasic3FamilyHRegionInfo(tableName);
-//    final Path basedir = FSUtils.getTableDir(this.hbaseRootDir, tableName);
-//    deleteDir(basedir);
-//    final byte[] rowName = tableName.getName();
-//    final int countPerFamily = 10;
-//    final HTableDescriptor htd = createBasic3FamilyHTD(tableName);
-//    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.
-//    WAL wal = createWAL(this.conf, hbaseRootDir, logName);
-//    HRegion region = HRegion.openHRegion(this.conf, this.fs, hbaseRootDir, hri, htd, wal);
-//    long seqid = region.getOpenSeqNum();
-//    for (HColumnDescriptor hcd: htd.getFamilies()) {
-//      addRegionEdits(rowName, hcd.getName(), countPerFamily, this.ee, region, "x");
-//    }
-//
-//    // Now assert edits made it in.
-//    final Get g = new Get(rowName);
-//    Result result = region.get(g);
-//    assertEquals(countPerFamily * htd.getFamilies().size(),
-//      result.size());
-//
-//    // Let us flush the region
-//    region.flush(true);
-//    region.close(true);
-//    wal.shutdown();
-//
-//    // delete the store files in the second column family to simulate a failure
-//    // in between the flushcache();
-//    // we have 3 families. killing the middle one ensures that taking the maximum
-//    // will make us fail.
-//    int cf_count = 0;
-//    for (HColumnDescriptor hcd: htd.getFamilies()) {
-//      cf_count++;
-//      if (cf_count == 2) {
-//        region.getRegionStorage().deleteFamily(hcd.getNameAsString());
-//      }
-//    }
-//
-//
-//    // Let us try to split and recover
-//    runWALSplit(this.conf);
-//    WAL wal2 = createWAL(this.conf, hbaseRootDir, logName);
-//    HRegion region2 = HRegion.openHRegion(this.conf, this.fs, hbaseRootDir, hri, htd, wal2);
-//    long seqid2 = region2.getOpenSeqNum();
-//    assertTrue(seqid + result.size() < seqid2);
-//
-//    final Result result1b = region2.get(g);
-//    assertEquals(result.size(), result1b.size());
-//  }
+  /**
+   * Tests for hbase-2727.
+   * @throws Exception
+   * @see <a href="https://issues.apache.org/jira/browse/HBASE-2727">HBASE-2727</a>
+   */
+  @Test
+  public void test2727() throws Exception {
+    // Test being able to have > 1 set of edits in the recovered.edits directory.
+    // Ensure edits are replayed properly.
+    final TableName tableName = TableName.valueOf("test2727");
+
+    MultiVersionConcurrencyControl mvcc = new MultiVersionConcurrencyControl();
+    HRegionInfo hri = createBasic3FamilyHRegionInfo(tableName);
+    //Path basedir = FSUtils.getTableDir(hbaseRootDir, tableName);
+    //deleteDir(basedir);
+
+    HTableDescriptor htd = createBasic3FamilyHTD(tableName);
+    HRegion region2 = TEST_UTIL.createLocalHRegion(hri, htd, conf);
+    HBaseTestingUtility.closeRegionAndWAL(region2);
+    final byte [] rowName = tableName.getName();
+
+    WAL wal1 = createWAL(this.conf, hbaseRootDir, logName);
+    // Add 1k to each family.
+    final int countPerFamily = 1000;
+
+    NavigableMap<byte[], Integer> scopes = new TreeMap<byte[], Integer>(
+        Bytes.BYTES_COMPARATOR);
+    for(byte[] fam : htd.getFamiliesKeys()) {
+      scopes.put(fam, 0);
+    }
+    for (HColumnDescriptor hcd: htd.getFamilies()) {
+      addWALEdits(tableName, hri, rowName, hcd.getName(), countPerFamily, ee,
+          wal1, htd, mvcc, scopes);
+    }
+    wal1.shutdown();
+    runWALSplit(this.conf);
+
+    WAL wal2 = createWAL(this.conf, hbaseRootDir, logName);
+    // Add 1k to each family.
+    for (HColumnDescriptor hcd: htd.getFamilies()) {
+      addWALEdits(tableName, hri, rowName, hcd.getName(), countPerFamily,
+          ee, wal2, htd, mvcc, scopes);
+    }
+    wal2.shutdown();
+    runWALSplit(this.conf);
+
+    WAL wal3 = createWAL(this.conf, hbaseRootDir, logName);
+    try {
+      HRegion region = HRegion.openHRegion(hri, htd, wal3, conf);
+      long seqid = region.getOpenSeqNum();
+      // The regions opens with sequenceId as 1. With 6k edits, its sequence number reaches 6k + 1.
+      // When opened, this region would apply 6k edits, and increment the sequenceId by 1
+      assertTrue(seqid > mvcc.getWritePoint());
+      assertEquals(seqid - 1, mvcc.getWritePoint());
+      LOG.debug("region.getOpenSeqNum(): " + region.getOpenSeqNum() + ", wal3.id: "
+          + mvcc.getReadPoint());
+
+      // TODO: Scan all.
+      region.close();
+    } finally {
+      wal3.close();
+    }
+  }
+
+  /**
+   * Test case of HRegion that is only made out of bulk loaded files.  Assert
+   * that we don't 'crash'.
+   */
+  @Test
+  public void testRegionMadeOfBulkLoadedFilesOnly() throws Exception {
+    final TableName tableName =
+        TableName.valueOf("testRegionMadeOfBulkLoadedFilesOnly");
+    final HRegionInfo hri = createBasic3FamilyHRegionInfo(tableName);
+    final Path basedir = new Path(this.hbaseRootDir, tableName.getNameAsString());
+    deleteDir(basedir);
+    final HTableDescriptor htd = createBasic3FamilyHTD(tableName);
+    Region region2 = TEST_UTIL.createLocalHRegion(hri, htd);
+    HBaseTestingUtility.closeRegionAndWAL(region2);
+    WAL wal = createWAL(this.conf, hbaseRootDir, logName);
+    Region region = HRegion.openHRegion(hri, htd, wal, conf);
+
+    byte [] family = htd.getFamilies().iterator().next().getName();
+    Path f =  new Path(basedir, "hfile");
+    HFileTestUtil.createHFile(this.conf, fs, f, family, family, Bytes.toBytes(""),
+        Bytes.toBytes("z"), 10);
+    List <Pair<byte[],String>>  hfs= new ArrayList<Pair<byte[],String>>(1);
+    hfs.add(Pair.newPair(family, f.toString()));
+    region.bulkLoadHFiles(hfs, true, null);
+
+    // Add an edit so something in the WAL
+    byte [] row = tableName.getName();
+    region.put((new Put(row)).addColumn(family, family, family));
+    wal.sync();
+    final int rowsInsertedCount = 11;
+
+    assertEquals(rowsInsertedCount, getScannedCount(region.getScanner(new Scan())));
+
+    // Now 'crash' the region by stealing its wal
+    final Configuration newConf = HBaseConfiguration.create(this.conf);
+    User user = HBaseTestingUtility.getDifferentUser(newConf,
+        tableName.getNameAsString());
+    user.runAs(new PrivilegedExceptionAction() {
+      @Override
+      public Object run() throws Exception {
+        runWALSplit(newConf);
+        WAL wal2 = createWAL(newConf, hbaseRootDir, logName);
+
+        HRegion region2 = HRegion.openHRegion(hri, htd, wal2, newConf);
+        long seqid2 = region2.getOpenSeqNum();
+        assertTrue(seqid2 > -1);
+        assertEquals(rowsInsertedCount, getScannedCount(region2.getScanner(new Scan())));
+
+        // I can't close wal1.  Its been appropriated when we split.
+        region2.close();
+        wal2.close();
+        return null;
+      }
+    });
+  }
+
+  /**
+   * HRegion test case that is made of a major compacted HFile (created with three bulk loaded
+   * files) and an edit in the memstore.
+   * This is for HBASE-10958 "[dataloss] Bulk loading with seqids can prevent some log entries
+   * from being replayed"
+   */
+  @Test
+  public void testCompactedBulkLoadedFiles() throws Exception {
+    final TableName tableName =
+        TableName.valueOf("testCompactedBulkLoadedFiles");
+    final HRegionInfo hri = createBasic3FamilyHRegionInfo(tableName);
+    final Path basedir = new Path(this.hbaseRootDir, tableName.getNameAsString());
+    deleteDir(basedir);
+    final HTableDescriptor htd = createBasic3FamilyHTD(tableName);
+    Region region2 = TEST_UTIL.createLocalHRegion(hri, htd);
+    HBaseTestingUtility.closeRegionAndWAL(region2);
+    WAL wal = createWAL(this.conf, hbaseRootDir, logName);
+    HRegion region = HRegion.openHRegion(hri, htd, wal, this.conf);
+
+    // Add an edit so something in the WAL
+    byte [] row = tableName.getName();
+    byte [] family = htd.getFamilies().iterator().next().getName();
+    region.put((new Put(row)).addColumn(family, family, family));
+    wal.sync();
+
+    List <Pair<byte[],String>>  hfs= new ArrayList<Pair<byte[],String>>(1);
+    for (int i = 0; i < 3; i++) {
+      Path f = new Path(basedir, "hfile"+i);
+      HFileTestUtil.createHFile(this.conf, fs, f, family, family, Bytes.toBytes(i + "00"),
+          Bytes.toBytes(i + "50"), 10);
+      hfs.add(Pair.newPair(family, f.toString()));
+    }
+    region.bulkLoadHFiles(hfs, true, null);
+    final int rowsInsertedCount = 31;
+    assertEquals(rowsInsertedCount, getScannedCount(region.getScanner(new Scan())));
+
+    // major compact to turn all the bulk loaded files into one normal file
+    region.compact(true);
+    assertEquals(rowsInsertedCount, getScannedCount(region.getScanner(new Scan())));
+
+    // Now 'crash' the region by stealing its wal
+    final Configuration newConf = HBaseConfiguration.create(this.conf);
+    User user = HBaseTestingUtility.getDifferentUser(newConf,
+        tableName.getNameAsString());
+    user.runAs(new PrivilegedExceptionAction() {
+      @Override
+      public Object run() throws Exception {
+        runWALSplit(newConf);
+        WAL wal2 = createWAL(newConf, hbaseRootDir, logName);
+
+        HRegion region2 = HRegion.openHRegion(hri, htd, wal2, newConf);
+        long seqid2 = region2.getOpenSeqNum();
+        assertTrue(seqid2 > -1);
+        assertEquals(rowsInsertedCount, getScannedCount(region2.getScanner(new Scan())));
+
+        // I can't close wal1.  Its been appropriated when we split.
+        region2.close();
+        wal2.close();
+        return null;
+      }
+    });
+  }
+
+
+  /**
+   * Test writing edits into an HRegion, closing it, splitting logs, opening
+   * Region again.  Verify seqids.
+   */
+  @Test
+  public void testReplayEditsWrittenViaHRegion() throws Exception {
+    final TableName tableName =
+        TableName.valueOf("testReplayEditsWrittenViaHRegion");
+    final HRegionInfo hri = createBasic3FamilyHRegionInfo(tableName);
+    final Path basedir = FSUtils.getTableDir(this.hbaseRootDir, tableName);
+    deleteDir(basedir);
+    final byte[] rowName = tableName.getName();
+    final int countPerFamily = 10;
+    final HTableDescriptor htd = createBasic3FamilyHTD(tableName);
+    Region region3 = TEST_UTIL.createLocalHRegion(hri, 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.
+    WAL wal = createWAL(this.conf, hbaseRootDir, logName);
+    HRegion region = HRegion.openHRegion(hri, htd, wal, conf);
+    long seqid = region.getOpenSeqNum();
+    boolean first = true;
+    for (HColumnDescriptor hcd: htd.getFamilies()) {
+      addRegionEdits(rowName, hcd.getName(), countPerFamily, this.ee, region, "x");
+      if (first) {
+        // If first, so we have at least one family w/ different seqid to rest.
+        region.flush(true);
+        first = false;
+      }
+    }
+    // Now assert edits made it in.
+    final Get g = new Get(rowName);
+    Result result = region.get(g);
+    assertEquals(countPerFamily * htd.getFamilies().size(),
+      result.size());
+    // Now close the region (without flush), split the log, reopen the region and assert that
+    // replay of log has the correct effect, that our seqids are calculated correctly so
+    // all edits in logs are seen as 'stale'/old.
+    region.close(true);
+    wal.shutdown();
+    runWALSplit(this.conf);
+    WAL wal2 = createWAL(this.conf, hbaseRootDir, logName);
+    HRegion region2 = HRegion.openHRegion(hri, htd, wal2, conf);
+    long seqid2 = region2.getOpenSeqNum();
+    assertTrue(seqid + result.size() < seqid2);
+    final Result result1b = region2.get(g);
+    assertEquals(result.size(), result1b.size());
+
+    // Next test.  Add more edits, then 'crash' this region by stealing its wal
+    // out from under it and assert that replay of the log adds the edits back
+    // correctly when region is opened again.
+    for (HColumnDescriptor hcd: htd.getFamilies()) {
+      addRegionEdits(rowName, hcd.getName(), countPerFamily, this.ee, region2, "y");
+    }
+    // Get count of edits.
+    final Result result2 = region2.get(g);
+    assertEquals(2 * result.size(), result2.size());
+    wal2.sync();
+    final Configuration newConf = HBaseConfiguration.create(this.conf);
+    User user = HBaseTestingUtility.getDifferentUser(newConf,
+      tableName.getNameAsString());
+    user.runAs(new PrivilegedExceptionAction() {
+      @Override
+      public Object run() throws Exception {
+        runWALSplit(newConf);
+        FileSystem newFS = FileSystem.get(newConf);
+        // Make a new wal for new region open.
+        WAL wal3 = createWAL(newConf, hbaseRootDir, logName);
+        final AtomicInteger countOfRestoredEdits = new AtomicInteger(0);
+        RegionStorage regionStorage = RegionStorage.open(newConf, hri, true);
+        HRegion region3 = new HRegion(regionStorage, htd, wal3, null) {
+          @Override
+          protected boolean restoreEdit(Store s, Cell cell) {
+            boolean b = super.restoreEdit(s, cell);
+            countOfRestoredEdits.incrementAndGet();
+            return b;
+          }
+        };
+        long seqid3 = region3.initialize();
+        Result result3 = region3.get(g);
+        // Assert that count of cells is same as before crash.
+        assertEquals(result2.size(), result3.size());
+        assertEquals(htd.getFamilies().size() * countPerFamily,
+          countOfRestoredEdits.get());
+
+        // I can't close wal1.  Its been appropriated when we split.
+        region3.close();
+        wal3.close();
+        return null;
+      }
+    });
+  }
+
+  /**
+   * Test that we recover correctly when there is a failure in between the
+   * flushes. i.e. Some stores got flushed but others did not.
+   *
+   * Unfortunately, there is no easy hook to flush at a store level. The way
+   * we get around this is by flushing at the region level, and then deleting
+   * the recently flushed store file for one of the Stores. This would put us
+   * back in the situation where all but that store got flushed and the region
+   * died.
+   *
+   * We restart Region again, and verify that the edits were replayed.
+   */
+  @Test
+  public void testReplayEditsAfterPartialFlush() throws Exception {
+    final TableName tableName =
+        TableName.valueOf("testReplayEditsWrittenViaHRegion");
+    final HRegionInfo hri = createBasic3FamilyHRegionInfo(tableName);
+    final Path basedir = FSUtils.getTableDir(this.hbaseRootDir, tableName);
+    deleteDir(basedir);
+    final byte[] rowName = tableName.getName();
+    final int countPerFamily = 10;
+    final HTableDescriptor htd = createBasic3FamilyHTD(tableName);
+    Region region3 = TEST_UTIL.createLocalHRegion(hri, 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.
+    WAL wal = createWAL(this.conf, hbaseRootDir, logName);
+    HRegion region = HRegion.openHRegion(hri, htd, wal, conf);
+    long seqid = region.getOpenSeqNum();
+    for (HColumnDescriptor hcd: htd.getFamilies()) {
+      addRegionEdits(rowName, hcd.getName(), countPerFamily, this.ee, region, "x");
+    }
+
+    // Now assert edits made it in.
+    final Get g = new Get(rowName);
+    Result result = region.get(g);
+    assertEquals(countPerFamily * htd.getFamilies().size(),
+      result.size());
+
+    // Let us flush the region
+    region.flush(true);
+    region.close(true);
+    wal.shutdown();
+
+    // delete the store files in the second column family to simulate a failure
+    // in between the flushcache();
+    // we have 3 families. killing the middle one ensures that taking the maximum
+    // will make us fail.
+    int cf_count = 0;
+    for (HColumnDescriptor hcd: htd.getFamilies()) {
+      cf_count++;
+      if (cf_count == 2) {
+        region.getRegionStorage().deleteFamily(hcd.getNameAsString(), false);
+      }
+    }
+
+
+    // Let us try to split and recover
+    runWALSplit(this.conf);
+    WAL wal2 = createWAL(this.conf, hbaseRootDir, logName);
+    HRegion region2 = HRegion.openHRegion(hri, htd, wal2, conf);
+    long seqid2 = region2.getOpenSeqNum();
+    assertTrue(seqid + result.size() < seqid2);
+
+    final Result result1b = region2.get(g);
+    assertEquals(result.size(), result1b.size());
+  }
 
 
   // StoreFlusher implementation used in testReplayEditsAfterAbortingFlush.
@@ -680,91 +646,89 @@ public abstract class AbstractTestWALReplay {
 
   };
 
-//  /**
-//   * Test that we could recover the data correctly after aborting flush. In the
-//   * test, first we abort flush after writing some data, then writing more data
-//   * and flush again, at last verify the data.
-//   * @throws IOException
-//   */
-//  @Test
-//  public void testReplayEditsAfterAbortingFlush() throws IOException {
-//    final TableName tableName =
-//        TableName.valueOf("testReplayEditsAfterAbortingFlush");
-//    final HRegionInfo hri = createBasic3FamilyHRegionInfo(tableName);
-//    final Path basedir = FSUtils.getTableDir(this.hbaseRootDir, tableName);
-//    deleteDir(basedir);
-//    final HTableDescriptor htd = createBasic3FamilyHTD(tableName);
-//    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.
-//    WAL wal = createWAL(this.conf, hbaseRootDir, logName);
-//    RegionServerServices rsServices = Mockito.mock(RegionServerServices.class);
-//    Mockito.doReturn(false).when(rsServices).isAborted();
-//    when(rsServices.getServerName()).thenReturn(ServerName.valueOf("foo", 10, 10));
-//    Configuration customConf = new Configuration(this.conf);
-//    customConf.set(DefaultStoreEngine.DEFAULT_STORE_FLUSHER_CLASS_KEY,
-//        CustomStoreFlusher.class.getName());
-//    HRegion region =
-//      HRegion.openHRegion(this.hbaseRootDir, hri, htd, wal, customConf, rsServices, null);
-//    int writtenRowCount = 10;
-//    List<HColumnDescriptor> families = new ArrayList<HColumnDescriptor>(
-//        htd.getFamilies());
-//    for (int i = 0; i < writtenRowCount; i++) {
-//      Put put = new Put(Bytes.toBytes(tableName + Integer.toString(i)));
-//      put.addColumn(families.get(i % families.size()).getName(), Bytes.toBytes("q"),
-//          Bytes.toBytes("val"));
-//      region.put(put);
-//    }
-//
-//    // Now assert edits made it in.
-//    RegionScanner scanner = region.getScanner(new Scan());
-//    assertEquals(writtenRowCount, getScannedCount(scanner));
-//
-//    // Let us flush the region
-//    CustomStoreFlusher.throwExceptionWhenFlushing.set(true);
-//    try {
-//      region.flush(true);
-//      fail("Injected exception hasn't been thrown");
-//    } catch (Throwable t) {
-//      LOG.info("Expected simulated exception when flushing region,"
-//          + t.getMessage());
-//      // simulated to abort server
-//      Mockito.doReturn(true).when(rsServices).isAborted();
-//      region.setClosing(false); // region normally does not accept writes after
-//      // DroppedSnapshotException. We mock around it for this test.
-//    }
-//    // writing more data
-//    int moreRow = 10;
-//    for (int i = writtenRowCount; i < writtenRowCount + moreRow; i++) {
-//      Put put = new Put(Bytes.toBytes(tableName + Integer.toString(i)));
-//      put.addColumn(families.get(i % families.size()).getName(), Bytes.toBytes("q"),
-//          Bytes.toBytes("val"));
-//      region.put(put);
-//    }
-//    writtenRowCount += moreRow;
-//    // call flush again
-//    CustomStoreFlusher.throwExceptionWhenFlushing.set(false);
-//    try {
-//      region.flush(true);
-//    } catch (IOException t) {
-//      LOG.info("Expected exception when flushing region because server is stopped,"
-//          + t.getMessage());
-//    }
-//
-//    region.close(true);
-//    wal.shutdown();
-//
-//    // Let us try to split and recover
-//    runWALSplit(this.conf);
-//    WAL wal2 = createWAL(this.conf, hbaseRootDir, logName);
-//    Mockito.doReturn(false).when(rsServices).isAborted();
-//    HRegion region2 =
-//      HRegion.openHRegion(this.hbaseRootDir, hri, htd, wal2, this.conf, rsServices, null);
-//    scanner = region2.getScanner(new Scan());
-//    assertEquals(writtenRowCount, getScannedCount(scanner));
-//  }
+  /**
+   * Test that we could recover the data correctly after aborting flush. In the
+   * test, first we abort flush after writing some data, then writing more data
+   * and flush again, at last verify the data.
+   * @throws IOException
+   */
+  @Test
+  public void testReplayEditsAfterAbortingFlush() throws IOException {
+    final TableName tableName =
+        TableName.valueOf("testReplayEditsAfterAbortingFlush");
+    final HRegionInfo hri = createBasic3FamilyHRegionInfo(tableName);
+    final Path basedir = FSUtils.getTableDir(this.hbaseRootDir, tableName);
+    deleteDir(basedir);
+    final HTableDescriptor htd = createBasic3FamilyHTD(tableName);
+    Region region3 = TEST_UTIL.createLocalHRegion(hri, 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.
+    WAL wal = createWAL(this.conf, hbaseRootDir, logName);
+    RegionServerServices rsServices = Mockito.mock(RegionServerServices.class);
+    Mockito.doReturn(false).when(rsServices).isAborted();
+    when(rsServices.getServerName()).thenReturn(ServerName.valueOf("foo", 10, 10));
+    Configuration customConf = new Configuration(this.conf);
+    customConf.set(DefaultStoreEngine.DEFAULT_STORE_FLUSHER_CLASS_KEY,
+        CustomStoreFlusher.class.getName());
+    HRegion region = HRegion.openHRegion(hri, htd, wal, customConf, rsServices, null);
+    int writtenRowCount = 10;
+    List<HColumnDescriptor> families = new ArrayList<HColumnDescriptor>(
+        htd.getFamilies());
+    for (int i = 0; i < writtenRowCount; i++) {
+      Put put = new Put(Bytes.toBytes(tableName + Integer.toString(i)));
+      put.addColumn(families.get(i % families.size()).getName(), Bytes.toBytes("q"),
+          Bytes.toBytes("val"));
+      region.put(put);
+    }
+
+    // Now assert edits made it in.
+    RegionScanner scanner = region.getScanner(new Scan());
+    assertEquals(writtenRowCount, getScannedCount(scanner));
+
+    // Let us flush the region
+    CustomStoreFlusher.throwExceptionWhenFlushing.set(true);
+    try {
+      region.flush(true);
+      fail("Injected exception hasn't been thrown");
+    } catch (Throwable t) {
+      LOG.info("Expected simulated exception when flushing region,"
+          + t.getMessage());
+      // simulated to abort server
+      Mockito.doReturn(true).when(rsServices).isAborted();
+      region.setClosing(false); // region normally does not accept writes after
+      // DroppedSnapshotException. We mock around it for this test.
+    }
+    // writing more data
+    int moreRow = 10;
+    for (int i = writtenRowCount; i < writtenRowCount + moreRow; i++) {
+      Put put = new Put(Bytes.toBytes(tableName + Integer.toString(i)));
+      put.addColumn(families.get(i % families.size()).getName(), Bytes.toBytes("q"),
+          Bytes.toBytes("val"));
+      region.put(put);
+    }
+    writtenRowCount += moreRow;
+    // call flush again
+    CustomStoreFlusher.throwExceptionWhenFlushing.set(false);
+    try {
+      region.flush(true);
+    } catch (IOException t) {
+      LOG.info("Expected exception when flushing region because server is stopped,"
+          + t.getMessage());
+    }
+
+    region.close(true);
+    wal.shutdown();
+
+    // Let us try to split and recover
+    runWALSplit(this.conf);
+    WAL wal2 = createWAL(this.conf, hbaseRootDir, logName);
+    Mockito.doReturn(false).when(rsServices).isAborted();
+    HRegion region2 = HRegion.openHRegion(hri, htd, wal2, this.conf, rsServices, null);
+    scanner = region2.getScanner(new Scan());
+    assertEquals(writtenRowCount, getScannedCount(scanner));
+  }
 
   private int getScannedCount(RegionScanner scanner) throws IOException {
     int scannedCount = 0;
@@ -780,315 +744,315 @@ public abstract class AbstractTestWALReplay {
     return scannedCount;
   }
 
-//  /**
-//   * Create an HRegion with the result of a WAL split and test we only see the
-//   * good edits
-//   * @throws Exception
-//   */
-//  @Test
-//  public void testReplayEditsWrittenIntoWAL() throws Exception {
-//    final TableName tableName =
-//        TableName.valueOf("testReplayEditsWrittenIntoWAL");
-//    final MultiVersionConcurrencyControl mvcc = new MultiVersionConcurrencyControl();
-//    final HRegionInfo hri = createBasic3FamilyHRegionInfo(tableName);
-//    final Path basedir = FSUtils.getTableDir(hbaseRootDir, tableName);
-//    deleteDir(basedir);
-//
-//    final HTableDescriptor htd = createBasic3FamilyHTD(tableName);
-//    HRegion region2 = HBaseTestingUtility.createRegionAndWAL(hri, hbaseRootDir, this.conf, htd);
-//    HBaseTestingUtility.closeRegionAndWAL(region2);
-//    final WAL wal = createWAL(this.conf, hbaseRootDir, logName);
-//    final byte[] rowName = tableName.getName();
-//    final byte[] regionName = hri.getEncodedNameAsBytes();
-//
-//    // Add 1k to each family.
-//    final int countPerFamily = 1000;
-//    Set<byte[]> familyNames = new HashSet<byte[]>();
-//    NavigableMap<byte[], Integer> scopes = new TreeMap<byte[], Integer>(
-//        Bytes.BYTES_COMPARATOR);
-//    for(byte[] fam : htd.getFamiliesKeys()) {
-//      scopes.put(fam, 0);
-//    }
-//    for (HColumnDescriptor hcd: htd.getFamilies()) {
-//      addWALEdits(tableName, hri, rowName, hcd.getName(), countPerFamily,
-//          ee, wal, htd, mvcc, scopes);
-//      familyNames.add(hcd.getName());
-//    }
-//
-//    // Add a cache flush, shouldn't have any effect
-//    wal.startCacheFlush(regionName, familyNames);
-//    wal.completeCacheFlush(regionName);
-//
-//    // Add an edit to another family, should be skipped.
-//    WALEdit edit = new WALEdit();
-//    long now = ee.currentTime();
-//    edit.add(new KeyValue(rowName, Bytes.toBytes("another family"), rowName,
-//      now, rowName));
-//    wal.append(hri, new WALKey(hri.getEncodedNameAsBytes(), tableName, now, mvcc, scopes), edit,
-//        true);
-//
-//    // Delete the c family to verify deletes make it over.
-//    edit = new WALEdit();
-//    now = ee.currentTime();
-//    edit.add(new KeyValue(rowName, Bytes.toBytes("c"), null, now, KeyValue.Type.DeleteFamily));
-//    wal.append(hri, new WALKey(hri.getEncodedNameAsBytes(), tableName, now, mvcc, scopes), edit,
-//        true);
-//
-//    // Sync.
-//    wal.sync();
-//    // Make a new conf and a new fs for the splitter to run on so we can take
-//    // over old wal.
-//    final Configuration newConf = HBaseConfiguration.create(this.conf);
-//    User user = HBaseTestingUtility.getDifferentUser(newConf,
-//      ".replay.wal.secondtime");
-//    user.runAs(new PrivilegedExceptionAction<Void>() {
-//      @Override
-//      public Void run() throws Exception {
-//        runWALSplit(newConf);
-//        FileSystem newFS = FileSystem.get(newConf);
-//        // 100k seems to make for about 4 flushes during HRegion#initialize.
-//        newConf.setInt(HConstants.HREGION_MEMSTORE_FLUSH_SIZE, 1024 * 100);
-//        // Make a new wal for new region.
-//        WAL newWal = createWAL(newConf, hbaseRootDir, logName);
-//        final AtomicInteger flushcount = new AtomicInteger(0);
-//        try {
-//          final HRegion region =
-//              new HRegion(basedir, newWal, newFS, newConf, hri, htd, null) {
-//            @Override
-//            protected FlushResult internalFlushcache(final WAL wal, final long myseqid,
-//                final Collection<Store> storesToFlush, MonitoredTask status,
-//                boolean writeFlushWalMarker)
-//                    throws IOException {
-//              LOG.info("InternalFlushCache Invoked");
-//              FlushResult fs = super.internalFlushcache(wal, myseqid, storesToFlush,
-//                  Mockito.mock(MonitoredTask.class), writeFlushWalMarker);
-//              flushcount.incrementAndGet();
-//              return fs;
-//            }
-//          };
-//          // The seq id this region has opened up with
-//          long seqid = region.initialize();
-//
-//          // The mvcc readpoint of from inserting data.
-//          long writePoint = mvcc.getWritePoint();
-//
-//          // We flushed during init.
-//          assertTrue("Flushcount=" + flushcount.get(), flushcount.get() > 0);
-//          assertTrue((seqid - 1) == writePoint);
-//
-//          Get get = new Get(rowName);
-//          Result result = region.get(get);
-//          // Make sure we only see the good edits
-//          assertEquals(countPerFamily * (htd.getFamilies().size() - 1),
-//            result.size());
-//          region.close();
-//        } finally {
-//          newWal.close();
-//        }
-//        return null;
-//      }
-//    });
-//  }
-
-//  @Test
-//  // the following test is for HBASE-6065
-//  public void testSequentialEditLogSeqNum() throws IOException {
-//    final TableName tableName = TableName.valueOf(currentTest.getMethodName());
-//    final HRegionInfo hri = createBasic3FamilyHRegionInfo(tableName);
-//    final Path basedir =
-//        FSUtils.getTableDir(this.hbaseRootDir, tableName);
-//    deleteDir(basedir);
-//    final byte[] rowName = tableName.getName();
-//    final int countPerFamily = 10;
-//    final HTableDescriptor htd = createBasic1FamilyHTD(tableName);
-//
-//    // Mock the WAL
-//    MockWAL wal = createMockWAL();
-//
-//    HRegion region = HRegion.openHRegion(this.conf, this.fs, hbaseRootDir, hri, htd, wal);
-//    for (HColumnDescriptor hcd : htd.getFamilies()) {
-//      addRegionEdits(rowName, hcd.getName(), countPerFamily, this.ee, region, "x");
-//    }
-//
-//    // Let us flush the region
-//    // But this time completeflushcache is not yet done
-//    region.flush(true);
-//    for (HColumnDescriptor hcd : htd.getFamilies()) {
-//      addRegionEdits(rowName, hcd.getName(), 5, this.ee, region, "x");
-//    }
-//    long lastestSeqNumber = region.getReadPoint(null);
-//    // get the current seq no
-//    wal.doCompleteCacheFlush = true;
-//    // allow complete cache flush with the previous seq number got after first
-//    // set of edits.
-//    wal.completeCacheFlush(hri.getEncodedNameAsBytes());
-//    wal.shutdown();
-//    FileStatus[] listStatus = wal.getFiles();
-//    assertNotNull(listStatus);
-//    assertTrue(listStatus.length > 0);
-//    WALSplitter.splitLogFile(hbaseRootDir, listStatus[0],
-//        this.fs, this.conf, null, null, null, mode, wals);
-//    FileStatus[] listStatus1 = this.fs.listStatus(
-//      new Path(FSUtils.getTableDir(hbaseRootDir, tableName), new Path(hri.getEncodedName(),
-//          "recovered.edits")), new PathFilter() {
-//        @Override
-//        public boolean accept(Path p) {
-//          if (WALSplitter.isSequenceIdFile(p)) {
-//            return false;
-//          }
-//          return true;
-//        }
-//      });
-//    int editCount = 0;
-//    for (FileStatus fileStatus : listStatus1) {
-//      editCount = Integer.parseInt(fileStatus.getPath().getName());
-//    }
-//    // The sequence number should be same
-//    assertEquals(
-//        "The sequence number of the recoverd.edits and the current edit seq should be same",
-//        lastestSeqNumber, editCount);
-//  }
-
-//  /**
-//   * testcase for https://issues.apache.org/jira/browse/HBASE-15252
-//   */
-//  @Test
-//  public void testDatalossWhenInputError() throws IOException, InstantiationException,
-//      IllegalAccessException {
-//    final TableName tableName = TableName.valueOf("testDatalossWhenInputError");
-//    final HRegionInfo hri = createBasic3FamilyHRegionInfo(tableName);
-//    final Path basedir = FSUtils.getTableDir(this.hbaseRootDir, tableName);
-//    deleteDir(basedir);
-//    final byte[] rowName = tableName.getName();
-//    final int countPerFamily = 10;
-//    final HTableDescriptor htd = createBasic1FamilyHTD(tableName);
-//    HRegion region1 = HBaseTestingUtility.createRegionAndWAL(hri, hbaseRootDir, this.conf, htd);
-//    Path regionDir = region1.getRegionStorage().getRegionDir();
-//    HBaseTestingUtility.closeRegionAndWAL(region1);
-//
-//    WAL wal = createWAL(this.conf, hbaseRootDir, logName);
-//    HRegion region = HRegion.openHRegion(this.conf, this.fs, hbaseRootDir, hri, htd, wal);
-//    for (HColumnDescriptor hcd : htd.getFamilies()) {
-//      addRegionEdits(rowName, hcd.getName(), countPerFamily, this.ee, region, "x");
-//    }
-//    // Now assert edits made it in.
-//    final Get g = new Get(rowName);
-//    Result result = region.get(g);
-//    assertEquals(countPerFamily * htd.getFamilies().size(), result.size());
-//    // Now close the region (without flush), split the log, reopen the region and assert that
-//    // replay of log has the correct effect.
-//    region.close(true);
-//    wal.shutdown();
-//
-//    runWALSplit(this.conf);
-//
-//    // here we let the DFSInputStream throw an IOException just after the WALHeader.
-//    Path editFile = WALSplitter.getSplitEditFilesSorted(this.fs, regionDir).first();
-//    FSDataInputStream stream = fs.open(editFile);
-//    stream.seek(ProtobufLogReader.PB_WAL_MAGIC.length);
-//    Class<? extends AbstractFSWALProvider.Reader> logReaderClass =
-//        conf.getClass("hbase.regionserver.hlog.reader.impl", ProtobufLogReader.class,
-//          AbstractFSWALProvider.Reader.class);
-//    AbstractFSWALProvider.Reader reader = logReaderClass.newInstance();
-//    reader.init(this.fs, editFile, conf, stream);
-//    final long headerLength = stream.getPos();
-//    reader.close();
-//    FileSystem spyFs = spy(this.fs);
-//    doAnswer(new Answer<FSDataInputStream>() {
-//
-//      @Override
-//      public FSDataInputStream answer(InvocationOnMock invocation) throws Throwable {
-//        FSDataInputStream stream = (FSDataInputStream) invocation.callRealMethod();
-//        Field field = FilterInputStream.class.getDeclaredField("in");
-//        field.setAccessible(true);
-//        final DFSInputStream in = (DFSInputStream) field.get(stream);
-//        DFSInputStream spyIn = spy(in);
-//        doAnswer(new Answer<Integer>() {
-//
-//          private long pos;
-//
-//          @Override
-//          public Integer answer(InvocationOnMock invocation) throws Throwable {
-//            if (pos >= headerLength) {
-//              throw new IOException("read over limit");
-//            }
-//            int b = (Integer) invocation.callRealMethod();
-//            if (b > 0) {
-//              pos += b;
-//            }
-//            return b;
-//          }
-//        }).when(spyIn).read(any(byte[].class), any(int.class), any(int.class));
-//        doAnswer(new Answer<Void>() {
-//
-//          @Override
-//          public Void answer(InvocationOnMock invocation) throws Throwable {
-//            invocation.callRealMethod();
-//            in.close();
-//            return null;
-//          }
-//        }).when(spyIn).close();
-//        field.set(stream, spyIn);
-//        return stream;
-//      }
-//    }).when(spyFs).open(eq(editFile));
-//
-//    WAL wal2 = createWAL(this.conf, hbaseRootDir, logName);
-//    HRegion region2;
-//    try {
-//      // log replay should fail due to the IOException, otherwise we may lose data.
-//      region2 = HRegion.openHRegion(conf, spyFs, hbaseRootDir, hri, htd, wal2);
-//      assertEquals(result.size(), region2.get(g).size());
-//    } catch (IOException e) {
-//      assertEquals("read over limit", e.getMessage());
-//    }
-//    region2 = HRegion.openHRegion(conf, fs, hbaseRootDir, hri, htd, wal2);
-//    assertEquals(result.size(), region2.get(g).size());
-//  }
-//
-//  /**
-//   * testcase for https://issues.apache.org/jira/browse/HBASE-14949.
-//   */
-//  private void testNameConflictWhenSplit(boolean largeFirst) throws IOException {
-//    final TableName tableName = TableName.valueOf("testReplayEditsWrittenIntoWAL");
-//    final MultiVersionConcurrencyControl mvcc = new MultiVersionConcurrencyControl();
-//    final HRegionInfo hri = createBasic3FamilyHRegionInfo(tableName);
-//    final Path basedir = FSUtils.getTableDir(hbaseRootDir, tableName);
-//    deleteDir(basedir);
-//
-//    final HTableDescriptor htd = createBasic1FamilyHTD(tableName);
-//    NavigableMap<byte[], Integer> scopes = new TreeMap<byte[], Integer>(Bytes.BYTES_COMPARATOR);
-//    for (byte[] fam : htd.getFamiliesKeys()) {
-//      scopes.put(fam, 0);
-//    }
-//    HRegion region = HBaseTestingUtility.createRegionAndWAL(hri, hbaseRootDir, this.conf, htd);
-//    HBaseTestingUtility.closeRegionAndWAL(region);
-//    final byte[] family = htd.getColumnFamilies()[0].getName();
-//    final byte[] rowName = tableName.getName();
-//    FSWALEntry entry1 = createFSWALEntry(htd, hri, 1L, rowName, family, ee, mvcc, 1, scopes);
-//    FSWALEntry entry2 = createFSWALEntry(htd, hri, 2L, rowName, family, ee, mvcc, 2, scopes);
-//
-//    Path largeFile = new Path(logDir, "wal-1");
-//    Path smallFile = new Path(logDir, "wal-2");
-//    writerWALFile(largeFile, Arrays.asList(entry1, entry2));
-//    writerWALFile(smallFile, Arrays.asList(entry2));
-//    FileStatus first, second;
-//    if (largeFirst) {
-//      first = fs.getFileStatus(largeFile);
-//      second = fs.getFileStatus(smallFile);
-//    } else {
-//      first = fs.getFileStatus(smallFile);
-//      second = fs.getFileStatus(largeFile);
-//    }
-//    WALSplitter.splitLogFile(hbaseRootDir, first, fs, conf, null, null, null,
-//      RecoveryMode.LOG_SPLITTING, wals);
-//    WALSplitter.splitLogFile(hbaseRootDir, second, fs, conf, null, null, null,
-//      RecoveryMode.LOG_SPLITTING, wals);
-//    WAL wal = createWAL(this.conf, hbaseRootDir, logName);
-//    region = HRegion.openHRegion(conf, this.fs, hbaseRootDir, hri, htd, wal);
-//    assertTrue(region.getOpenSeqNum() > mvcc.getWritePoint());
-//    assertEquals(2, region.get(new Get(rowName)).size());
-//  }
+  /**
+   * Create an HRegion with the result of a WAL split and test we only see the
+   * good edits
+   */
+  @Test
+  public void testReplayEditsWrittenIntoWAL() throws Exception {
+    final TableName tableName =
+        TableName.valueOf("testReplayEditsWrittenIntoWAL");
+    final MultiVersionConcurrencyControl mvcc = new MultiVersionConcurrencyControl();
+    final HRegionInfo hri = createBasic3FamilyHRegionInfo(tableName);
+    final Path basedir = FSUtils.getTableDir(hbaseRootDir, tableName);
+    deleteDir(basedir);
+
+    final HTableDescriptor htd = createBasic3FamilyHTD(tableName);
+    Region region2 = TEST_UTIL.createLocalHRegion(hri, htd);
+    HBaseTestingUtility.closeRegionAndWAL(region2);
+    final WAL wal = createWAL(this.conf, hbaseRootDir, logName);
+    final byte[] rowName = tableName.getName();
+    final byte[] regionName = hri.getEncodedNameAsBytes();
+
+    // Add 1k to each family.
+    final int countPerFamily = 1000;
+    Set<byte[]> familyNames = new HashSet<byte[]>();
+    NavigableMap<byte[], Integer> scopes = new TreeMap<byte[], Integer>(
+        Bytes.BYTES_COMPARATOR);
+    for(byte[] fam : htd.getFamiliesKeys()) {
+      scopes.put(fam, 0);
+    }
+    for (HColumnDescriptor hcd: htd.getFamilies()) {
+      addWALEdits(tableName, hri, rowName, hcd.getName(), countPerFamily,
+          ee, wal, htd, mvcc, scopes);
+      familyNames.add(hcd.getName());
+    }
+
+    // Add a cache flush, shouldn't have any effect
+    wal.startCacheFlush(regionName, familyNames);
+    wal.completeCacheFlush(regionName);
+
+    // Add an edit to another family, should be skipped.
+    WALEdit edit = new WALEdit();
+    long now = ee.currentTime();
+    edit.add(new KeyValue(rowName, Bytes.toBytes("another family"), rowName,
+      now, rowName));
+    wal.append(hri, new WALKey(hri.getEncodedNameAsBytes(), tableName, now, mvcc, scopes), edit,
+        true);
+
+    // Delete the c family to verify deletes make it over.
+    edit = new WALEdit();
+    now = ee.currentTime();
+    edit.add(new KeyValue(rowName, Bytes.toBytes("c"), null, now, KeyValue.Type.DeleteFamily));
+    wal.append(hri, new WALKey(hri.getEncodedNameAsBytes(), tableName, now, mvcc, scopes), edit,
+        true);
+
+    // Sync.
+    wal.sync();
+    // Make a new conf and a new fs for the splitter to run on so we can take
+    // over old wal.
+    final Configuration newConf = HBaseConfiguration.create(this.conf);
+    User user = HBaseTestingUtility.getDifferentUser(newConf,
+      ".replay.wal.secondtime");
+    user.runAs(new PrivilegedExceptionAction<Void>() {
+      @Override
+      public Void run() throws Exception {
+        runWALSplit(newConf);
+        FileSystem newFS = FileSystem.get(newConf);
+        // 100k seems to make for about 4 flushes during HRegion#initialize.
+        newConf.setInt(HConstants.HREGION_MEMSTORE_FLUSH_SIZE, 1024 * 100);
+        // Make a new wal for new region.
+        WAL newWal = createWAL(newConf, hbaseRootDir, logName);
+        final AtomicInteger flushcount = new AtomicInteger(0);
+        try {
+          RegionStorage regionStorage = RegionStorage.open(newConf, hri, true);
+          final HRegion region = new HRegion(regionStorage, htd, newWal, null) {
+            @Override
+            protected FlushResult internalFlushcache(final WAL wal, final long myseqid,
+                final Collection<Store> storesToFlush, MonitoredTask status,
+                boolean writeFlushWalMarker)
+                    throws IOException {
+              LOG.info("InternalFlushCache Invoked");
+              FlushResult fs = super.internalFlushcache(wal, myseqid, storesToFlush,
+                  Mockito.mock(MonitoredTask.class), writeFlushWalMarker);
+              flushcount.incrementAndGet();
+              return fs;
+            }
+          };
+          // The seq id this region has opened up with
+          long seqid = region.initialize();
+
+          // The mvcc readpoint of from inserting data.
+          long writePoint = mvcc.getWritePoint();
+
+          // We flushed during init.
+          assertTrue("Flushcount=" + flushcount.get(), flushcount.get() > 0);
+          assertTrue((seqid - 1) == writePoint);
+
+          Get get = new Get(rowName);
+          Result result = region.get(get);
+          // Make sure we only see the good edits
+          assertEquals(countPerFamily * (htd.getFamilies().size() - 1),
+            result.size());
+          region.close();
+        } finally {
+          newWal.close();
+        }
+        return null;
+      }
+    });
+  }
+
+  @Test
+  // the following test is for HBASE-6065
+  public void testSequentialEditLogSeqNum() throws IOException {
+    final TableName tableName = TableName.valueOf(currentTest.getMethodName());
+    final HRegionInfo hri = createBasic3FamilyHRegionInfo(tableName);
+    final Path basedir =
+        FSUtils.getTableDir(this.hbaseRootDir, tableName);
+    deleteDir(basedir);
+    final byte[] rowName = tableName.getName();
+    final int countPerFamily = 10;
+    final HTableDescriptor htd = createBasic1FamilyHTD(tableName);
+
+    // Mock the WAL
+    MockWAL wal = createMockWAL();
+
+    HRegion region = HRegion.openHRegion(hri, htd, wal, conf);
+    for (HColumnDescriptor hcd : htd.getFamilies()) {
+      addRegionEdits(rowName, hcd.getName(), countPerFamily, this.ee, region, "x");
+    }
+
+    // Let us flush the region
+    // But this time completeflushcache is not yet done
+    region.flush(true);
+    for (HColumnDescriptor hcd : htd.getFamilies()) {
+      addRegionEdits(rowName, hcd.getName(), 5, this.ee, region, "x");
+    }
+    long lastestSeqNumber = region.getReadPoint(null);
+    // get the current seq no
+    wal.doCompleteCacheFlush = true;
+    // allow complete cache flush with the previous seq number got after first
+    // set of edits.
+    wal.completeCacheFlush(hri.getEncodedNameAsBytes());
+    wal.shutdown();
+    FileStatus[] listStatus = wal.getFiles();
+    assertNotNull(listStatus);
+    assertTrue(listStatus.length > 0);
+    WALSplitter.splitLogFile(hbaseRootDir, listStatus[0],
+        this.fs, this.conf, null, null, null, mode, wals);
+    FileStatus[] listStatus1 = this.fs.listStatus(
+      new Path(FSUtils.getTableDir(hbaseRootDir, tableName), new Path(hri.getEncodedName(),
+          "recovered.edits")), new PathFilter() {
+        @Override
+        public boolean accept(Path p) {
+          if (WALSplitter.isSequenceIdFile(p)) {
+            return false;
+          }
+          return true;
+        }
+      });
+    int editCount = 0;
+    for (FileStatus fileStatus : listStatus1) {
+      editCount = Integer.parseInt(fileStatus.getPath().getName());
+    }
+    // The sequence number should be same
+    assertEquals(
+        "The sequence number of the recoverd.edits and the current edit seq should be same",
+        lastestSeqNumber, editCount);
+  }
+
+  /**
+   * testcase for https://issues.apache.org/jira/browse/HBASE-15252
+   */
+  @Test
+  public void testDatalossWhenInputError() throws IOException, InstantiationException,
+      IllegalAccessException {
+    final TableName tableName = TableName.valueOf("testDatalossWhenInputError");
+    final HRegionInfo hri = createBasic3FamilyHRegionInfo(tableName);
+    final Path basedir = FSUtils.getTableDir(this.hbaseRootDir, tableName);
+    deleteDir(basedir);
+    final byte[] rowName = tableName.getName();
+    final int countPerFamily = 10;
+    final HTableDescriptor htd = createBasic1FamilyHTD(tableName);
+    HRegion region1 = TEST_UTIL.createLocalHRegion(hri, htd);
+    // todo(fsredo): remove this after phase 1?
+    Path regionDir = ((LegacyPathIdentifier)region1.getRegionStorage().getRegionContainer()).path;
+    HBaseTestingUtility.closeRegionAndWAL(region1);
+
+    WAL wal = createWAL(this.conf, hbaseRootDir, logName);
+    HRegion region = HRegion.openHRegion(hri, htd, wal, conf);
+    for (HColumnDescriptor hcd : htd.getFamilies()) {
+      addRegionEdits(rowName, hcd.getName(), countPerFamily, this.ee, region, "x");
+    }
+    // Now assert edits made it in.
+    final Get g = new Get(rowName);
+    Result result = region.get(g);
+    assertEquals(countPerFamily * htd.getFamilies().size(), result.size());
+    // Now close the region (without flush), split the log, reopen the region and assert that
+    // replay of log has the correct effect.
+    region.close(true);
+    wal.shutdown();
+
+    runWALSplit(this.conf);
+
+    // here we let the DFSInputStream throw an IOException just after the WALHeader.
+    Path editFile = WALSplitter.getSplitEditFilesSorted(this.fs, regionDir).first();
+    FSDataInputStream stream = fs.open(editFile);
+    stream.seek(ProtobufLogReader.PB_WAL_MAGIC.length);
+    Class<? extends AbstractFSWALProvider.Reader> logReaderClass =
+        conf.getClass("hbase.regionserver.hlog.reader.impl", ProtobufLogReader.class,
+          AbstractFSWALProvider.Reader.class);
+    AbstractFSWALProvider.Reader reader = logReaderClass.newInstance();
+    reader.init(this.fs, editFile, conf, stream);
+    final long headerLength = stream.getPos();
+    reader.close();
+    FileSystem spyFs = spy(this.fs);
+    doAnswer(new Answer<FSDataInputStream>() {
+
+      @Override
+      public FSDataInputStream answer(InvocationOnMock invocation) throws Throwable {
+        FSDataInputStream stream = (FSDataInputStream) invocation.callRealMethod();
+        Field field = FilterInputStream.class.getDeclaredField("in");
+        field.setAccessible(true);
+        final DFSInputStream in = (DFSInputStream) field.get(stream);
+        DFSInputStream spyIn = spy(in);
+        doAnswer(new Answer<Integer>() {
+
+          private long pos;
+
+          @Override
+          public Integer answer(InvocationOnMock invocation) throws Throwable {
+            if (pos >= headerLength) {
+              throw new IOException("read over limit");
+            }
+            int b = (Integer) invocation.callRealMethod();
+            if (b > 0) {
+              pos += b;
+            }
+            return b;
+          }
+        }).when(spyIn).read(any(byte[].class), any(int.class), any(int.class));
+        doAnswer(new Answer<Void>() {
+
+          @Override
+          public Void answer(InvocationOnMock invocation) throws Throwable {
+            invocation.callRealMethod();
+            in.close();
+            return null;
+          }
+        }).when(spyIn).close();
+        field.set(stream, spyIn);
+        return stream;
+      }
+    }).when(spyFs).open(eq(editFile));
+
+    WAL wal2 = createWAL(this.conf, hbaseRootDir, logName);
+    HRegion region2;
+    try {
+      // log replay should fail due to the IOException, otherwise we may lose data.
+      region2 = HRegion.openHRegion(hri, htd, wal2, conf);
+      assertEquals(result.size(), region2.get(g).size());
+    } catch (IOException e) {
+      assertEquals("read over limit", e.getMessage());
+    }
+    region2 = HRegion.openHRegion(hri, htd, wal2, conf);
+    assertEquals(result.size(), region2.get(g).size());
+  }
+
+  /**
+   * testcase for https://issues.apache.org/jira/browse/HBASE-14949.
+   */
+  private void testNameConflictWhenSplit(boolean largeFirst) throws IOException {
+    final TableName tableName = TableName.valueOf("testReplayEditsWrittenIntoWAL");
+    final MultiVersionConcurrencyControl mvcc = new MultiVersionConcurrencyControl();
+    final HRegionInfo hri = createBasic3FamilyHRegionInfo(tableName);
+    final Path basedir = FSUtils.getTableDir(hbaseRootDir, tableName);
+    deleteDir(basedir);
+
+    final HTableDescriptor htd = createBasic1FamilyHTD(tableName);
+    NavigableMap<byte[], Integer> scopes = new TreeMap<byte[], Integer>(Bytes.BYTES_COMPARATOR);
+    for (byte[] fam : htd.getFamiliesKeys()) {
+      scopes.put(fam, 0);
+    }
+    Region region = TEST_UTIL.createLocalHRegion(hri, htd);
+    HBaseTestingUtility.closeRegionAndWAL(region);
+    final byte[] family = htd.getColumnFamilies()[0].getName();
+    final byte[] rowName = tableName.getName();
+    FSWALEntry entry1 = createFSWALEntry(htd, hri, 1L, rowName, family, ee, mvcc, 1, scopes);
+    FSWALEntry entry2 = createFSWALEntry(htd, hri, 2L, rowName, family, ee, mvcc, 2, scopes);
+
+    Path largeFile = new Path(logDir, "wal-1");
+    Path smallFile = new Path(logDir, "wal-2");
+    writerWALFile(largeFile, Arrays.asList(entry1, entry2));
+    writerWALFile(smallFile, Arrays.asList(entry2));
+    FileStatus first, second;
+    if (largeFirst) {
+      first = fs.getFileStatus(largeFile);
+      second = fs.getFileStatus(smallFile);
+    } else {
+      first = fs.getFileStatus(smallFile);
+      second = fs.getFileStatus(largeFile);
+    }
+    WALSplitter.splitLogFile(hbaseRootDir, first, fs, conf, null, null, null,
+      RecoveryMode.LOG_SPLITTING, wals);
+    WALSplitter.splitLogFile(hbaseRootDir, second, fs, conf, null, null, null,
+      RecoveryMode.LOG_SPLITTING, wals);
+    WAL wal = createWAL(this.conf, hbaseRootDir, logName);
+    region = HRegion.openHRegion(hri, htd, wal, conf);
+    assertTrue(region.getOpenSeqNum() > mvcc.getWritePoint());
+    assertEquals(2, region.get(new Get(rowName)).size());
+  }
 
   @Test
   public void testNameConflictWhenSplit0() throws IOException {

http://git-wip-us.apache.org/repos/asf/hbase/blob/6d1813a2/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMergeTable.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMergeTable.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMergeTable.java
index 661af14..bda24a5 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
@@ -33,6 +33,7 @@ import org.apache.hadoop.hbase.client.Admin;
 import org.apache.hadoop.hbase.client.Connection;
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.client.Durability;
+import org.apache.hadoop.hbase.fs.MasterStorage;
 import org.apache.hadoop.hbase.regionserver.HRegion;
 import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.apache.hadoop.hbase.testclassification.MiscTests;
@@ -63,9 +64,9 @@ public class TestMergeTable {
    * Hand-makes regions of a mergeable size and adds the hand-made regions to
    * hand-made meta.  The hand-made regions are created offline.  We then start
    * up mini cluster, disables the hand-made table and starts in on merging.
-   * @throws Exception
    */
-  @Test (timeout=300000) public void testMergeTable() throws Exception {
+  @Test (timeout=300000)
+  public void testMergeTable() throws Exception {
     // Table we are manually creating offline.
     HTableDescriptor desc = new HTableDescriptor(org.apache.hadoop.hbase.TableName.valueOf(Bytes.toBytes("test")));
     desc.addFamily(new HColumnDescriptor(COLUMN_NAME));
@@ -77,13 +78,7 @@ public class TestMergeTable {
     // Startup hdfs.  Its in here we'll be putting our manually made regions.
     UTIL.startMiniDFSCluster(1);
     // Create hdfs hbase rootdir.
-    Path rootdir = UTIL.createRootDir();
-    FileSystem fs = FileSystem.get(UTIL.getConfiguration());
-    if (fs.exists(rootdir)) {
-      if (fs.delete(rootdir, true)) {
-        LOG.info("Cleaned up existing " + rootdir);
-      }
-    }
+    UTIL.createRootDir();
 
     // Now create three data regions: The first is too large to merge since it
     // will be > 64 MB in size. The second two will be smaller and will be
@@ -96,16 +91,17 @@ public class TestMergeTable {
 
     // Create regions and populate them at same time.  Create the tabledir
     // for them first.
-    new FSTableDescriptors(UTIL.getConfiguration(), fs, rootdir).createTableDescriptor(desc);
+    MasterStorage masterStorage = MasterStorage.open(UTIL.getConfiguration(), true);
+    masterStorage.createTableDescriptor(desc, false);
     HRegion [] regions = {
-      createRegion(desc, null, row_70001, 1, 70000, rootdir),
-      createRegion(desc, row_70001, row_80001, 70001, 10000, rootdir),
-      createRegion(desc, row_80001, null, 80001, 11000, rootdir)
+      createRegion(desc, null, row_70001, 1, 70000),
+      createRegion(desc, row_70001, row_80001, 70001, 10000),
+      createRegion(desc, row_80001, null, 80001, 11000)
     };
 
     // Now create the root and meta regions and insert the data regions
     // created above into hbase:meta
-    setupMeta(rootdir, regions);
+    setupMeta(regions);
     try {
       LOG.info("Starting mini zk cluster");
       UTIL.startMiniZKCluster();
@@ -137,11 +133,10 @@ public class TestMergeTable {
   }
 
   private HRegion createRegion(final HTableDescriptor desc,
-      byte [] startKey, byte [] endKey, int firstRow, int nrows, Path rootdir)
+      byte [] startKey, byte [] endKey, int firstRow, int nrows)
   throws IOException {
     HRegionInfo hri = new HRegionInfo(desc.getTableName(), startKey, endKey);
-    HRegion region = HBaseTestingUtility.createRegionAndWAL(hri, rootdir, UTIL.getConfiguration(),
-        desc);
+    HRegion region = UTIL.createLocalHRegion(hri, desc);
     LOG.info("Created region " + region.getRegionInfo().getRegionNameAsString());
     for(int i = firstRow; i < firstRow + nrows; i++) {
       Put put = new Put(Bytes.toBytes("row_" + String.format("%1$05d", i)));
@@ -157,16 +152,13 @@ public class TestMergeTable {
     return region;
   }
 
-  protected void setupMeta(Path rootdir, final HRegion [] regions)
-  throws IOException {
-    HRegion meta =
-      HBaseTestingUtility.createRegionAndWAL(HRegionInfo.FIRST_META_REGIONINFO, rootdir,
-          UTIL.getConfiguration(), UTIL.getMetaTableDescriptor());
-    for (HRegion r: regions) {
+  protected void setupMeta(final HRegion[] regions) throws IOException {
+    HRegion meta = UTIL.createLocalHRegion(HRegionInfo.FIRST_META_REGIONINFO,
+        UTIL.getMetaTableDescriptor());
+    for (HRegion r : regions) {
       HRegion.addRegionToMETA(meta, r);
     }
     HBaseTestingUtility.closeRegionAndWAL(meta);
   }
-
 }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/6d1813a2/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMergeTool.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMergeTool.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMergeTool.java
index 1924c9e..87f73b4 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
@@ -37,6 +37,7 @@ import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.fs.MasterStorage;
 import org.apache.hadoop.hbase.regionserver.HRegion;
 import org.apache.hadoop.hbase.regionserver.InternalScanner;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
@@ -149,14 +150,13 @@ public class TestMergeTool extends HBaseTestCase {
     try {
       // Create meta region
       createMetaRegion();
-      new FSTableDescriptors(this.conf, this.fs, testDir).createTableDescriptor(this.desc);
+      MasterStorage masterStorage = MasterStorage.open(conf, true);
+      masterStorage.createTableDescriptor(desc, false);
       /*
        * Create the regions we will merge
        */
       for (int i = 0; i < sourceRegions.length; i++) {
-        regions[i] =
-          HBaseTestingUtility.createRegionAndWAL(this.sourceRegions[i], testDir, this.conf,
-              this.desc);
+        regions[i] = TEST_UTIL.createLocalHRegion(sourceRegions[i], desc);
         /*
          * Insert data
          */


Mime
View raw message