You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by mb...@apache.org on 2013/03/15 23:19:35 UTC

svn commit: r1457148 [2/2] - in /hbase/trunk/hbase-server/src: main/java/org/apache/hadoop/hbase/backup/ main/java/org/apache/hadoop/hbase/master/ main/java/org/apache/hadoop/hbase/regionserver/ main/java/org/apache/hadoop/hbase/snapshot/ main/java/org...

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransaction.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransaction.java?rev=1457148&r1=1457147&r2=1457148&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransaction.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransaction.java Fri Mar 15 22:19:34 2013
@@ -95,9 +95,9 @@ public class TestSplitTransaction {
 
   @After public void teardown() throws IOException {
     if (this.parent != null && !this.parent.isClosed()) this.parent.close();
-    if (this.fs.exists(this.parent.getRegionDir()) &&
-        !this.fs.delete(this.parent.getRegionDir(), true)) {
-      throw new IOException("Failed delete of " + this.parent.getRegionDir());
+    Path regionDir = this.parent.getRegionFileSystem().getRegionDir();
+    if (this.fs.exists(regionDir) && !this.fs.delete(regionDir, true)) {
+      throw new IOException("Failed delete of " + regionDir);
     }
     if (this.wal != null) this.wal.closeAndDelete();
     this.fs.delete(this.testdir, true);
@@ -136,11 +136,9 @@ public class TestSplitTransaction {
     // Make sure that region a and region b are still in the filesystem, that
     // they have not been removed; this is supposed to be the case if we go
     // past point of no return.
-    Path tableDir =  this.parent.getRegionDir().getParent();
-    Path daughterADir =
-      new Path(tableDir, spiedUponSt.getFirstDaughter().getEncodedName());
-    Path daughterBDir =
-      new Path(tableDir, spiedUponSt.getSecondDaughter().getEncodedName());
+    Path tableDir =  this.parent.getRegionFileSystem().getTableDir();
+    Path daughterADir = new Path(tableDir, spiedUponSt.getFirstDaughter().getEncodedName());
+    Path daughterBDir = new Path(tableDir, spiedUponSt.getSecondDaughter().getEncodedName());
     assertTrue(TEST_UTIL.getTestFileSystem().exists(daughterADir));
     assertTrue(TEST_UTIL.getTestFileSystem().exists(daughterBDir));
   }
@@ -154,7 +152,11 @@ public class TestSplitTransaction {
   }
 
   private SplitTransaction prepareGOOD_SPLIT_ROW() {
-    SplitTransaction st = new SplitTransaction(this.parent, GOOD_SPLIT_ROW);
+    return prepareGOOD_SPLIT_ROW(this.parent);
+  }
+
+  private SplitTransaction prepareGOOD_SPLIT_ROW(final HRegion parentRegion) {
+    SplitTransaction st = new SplitTransaction(parentRegion, GOOD_SPLIT_ROW);
     assertTrue(st.prepare());
     return st;
   }
@@ -165,6 +167,7 @@ public class TestSplitTransaction {
   @Test public void testPrepareWithRegionsWithReference() throws IOException {
     HStore storeMock = Mockito.mock(HStore.class);
     when(storeMock.hasReferences()).thenReturn(true);
+    when(storeMock.getFamily()).thenReturn(new HColumnDescriptor("cf"));
     when(storeMock.close()).thenReturn(ImmutableList.<StoreFile>of());
     this.parent.stores.put(Bytes.toBytes(""), storeMock);
 
@@ -214,13 +217,13 @@ public class TestSplitTransaction {
     when(mockServer.getConfiguration()).thenReturn(TEST_UTIL.getConfiguration());
     PairOfSameType<HRegion> daughters = st.execute(mockServer, null);
     // Do some assertions about execution.
-    assertTrue(this.fs.exists(st.getSplitDir()));
+    assertTrue(this.fs.exists(this.parent.getRegionFileSystem().getSplitsDir()));
     // Assert the parent region is closed.
     assertTrue(this.parent.isClosed());
 
     // Assert splitdir is empty -- because its content will have been moved out
     // to be under the daughter region dirs.
-    assertEquals(0, this.fs.listStatus(st.getSplitDir()).length);
+    assertEquals(0, this.fs.listStatus(this.parent.getRegionFileSystem().getSplitsDir()).length);
     // Check daughters have correct key span.
     assertTrue(Bytes.equals(this.parent.getStartKey(), daughters.getFirst().getStartKey()));
     assertTrue(Bytes.equals(GOOD_SPLIT_ROW, daughters.getFirst().getEndKey()));
@@ -249,9 +252,10 @@ public class TestSplitTransaction {
     assertEquals(rowcount, parentRowCount);
 
     // Start transaction.
-    SplitTransaction st = prepareGOOD_SPLIT_ROW();
+    HRegion spiedRegion = spy(this.parent);
+    SplitTransaction st = prepareGOOD_SPLIT_ROW(spiedRegion);
     SplitTransaction spiedUponSt = spy(st);
-    when(spiedUponSt.createDaughterRegion(spiedUponSt.getSecondDaughter())).
+    when(spiedRegion.createDaughterRegionFromSplits(spiedUponSt.getSecondDaughter())).
       thenThrow(new MockedFailedDaughterCreation());
     // Run the execute.  Look at what it returns.
     boolean expectedException = false;

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java?rev=1457148&r1=1457147&r2=1457148&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java Fri Mar 15 22:19:34 2013
@@ -68,10 +68,10 @@ public class TestStoreFile extends HBase
   static final Log LOG = LogFactory.getLog(TestStoreFile.class);
   private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
   private CacheConfig cacheConf =  new CacheConfig(TEST_UTIL.getConfiguration());
-  private static String ROOT_DIR =
-    TEST_UTIL.getDataTestDir("TestStoreFile").toString();
+  private static String ROOT_DIR = TEST_UTIL.getDataTestDir("TestStoreFile").toString();
   private static final ChecksumType CKTYPE = ChecksumType.CRC32;
   private static final int CKBYTES = 512;
+  private static String TEST_FAMILY = "cf";
 
   @Override
   public void setUp() throws Exception {
@@ -89,16 +89,19 @@ public class TestStoreFile extends HBase
    * @throws Exception
    */
   public void testBasicHalfMapFile() throws Exception {
-    // Make up a directory hierarchy that has a regiondir ("7e0102") and familyname.
-    Path outputDir = new Path(new Path(this.testDir, "7e0102"),
-        "familyname");
-    StoreFile.Writer writer = new StoreFile.WriterBuilder(conf, cacheConf,
-        this.fs, 2 * 1024)
-            .withOutputDir(outputDir)
+    final HRegionInfo hri = new HRegionInfo(Bytes.toBytes("testBasicHalfMapFileTb"));
+    HRegionFileSystem regionFs = HRegionFileSystem.createRegionOnFileSystem(
+      conf, fs, new Path(this.testDir, hri.getTableNameAsString()), hri);
+
+    StoreFile.Writer writer = new StoreFile.WriterBuilder(conf, cacheConf, this.fs, 2 * 1024)
+            .withFilePath(regionFs.createTempName())
             .build();
     writeStoreFile(writer);
-    checkHalfHFile(new StoreFile(this.fs, writer.getPath(), conf, cacheConf,
-        BloomType.NONE, NoOpDataBlockEncoder.INSTANCE));
+
+    Path sfPath = regionFs.commitStoreFile(TEST_FAMILY, writer.getPath());
+    StoreFile sf = new StoreFile(this.fs, sfPath, conf, cacheConf,
+        BloomType.NONE, NoOpDataBlockEncoder.INSTANCE);
+    checkHalfHFile(regionFs, sf);
   }
 
   private void writeStoreFile(final StoreFile.Writer writer) throws IOException {
@@ -134,17 +137,19 @@ public class TestStoreFile extends HBase
    * store files in other regions works.
    * @throws IOException
    */
-  public void testReference()
-  throws IOException {
-    // Make up a directory hierarchy that has a regiondir ("7e0102") and familyname.
-    Path storedir = new Path(new Path(this.testDir, "7e0102"), "familyname");
+  public void testReference() throws IOException {
+    final HRegionInfo hri = new HRegionInfo(Bytes.toBytes("testReferenceTb"));
+    HRegionFileSystem regionFs = HRegionFileSystem.createRegionOnFileSystem(
+      conf, fs, new Path(this.testDir, hri.getTableNameAsString()), hri);
+
     // Make a store file and write data to it.
-    StoreFile.Writer writer = new StoreFile.WriterBuilder(conf, cacheConf,
-        this.fs, 8 * 1024)
-            .withOutputDir(storedir)
+    StoreFile.Writer writer = new StoreFile.WriterBuilder(conf, cacheConf, this.fs, 8 * 1024)
+            .withFilePath(regionFs.createTempName())
             .build();
     writeStoreFile(writer);
-    StoreFile hsf = new StoreFile(this.fs, writer.getPath(), conf, cacheConf,
+
+    Path hsfPath = regionFs.commitStoreFile(TEST_FAMILY, writer.getPath());
+    StoreFile hsf = new StoreFile(this.fs, hsfPath, conf, cacheConf,
         BloomType.NONE, NoOpDataBlockEncoder.INSTANCE);
     StoreFile.Reader reader = hsf.createReader();
     // Split on a row, not in middle of row.  Midkey returned by reader
@@ -155,7 +160,8 @@ public class TestStoreFile extends HBase
     kv = KeyValue.createKeyValueFromKey(reader.getLastKey());
     byte [] finalRow = kv.getRow();
     // Make a reference
-    Path refPath = StoreFile.split(fs, storedir, hsf, midRow, true);
+    HRegionInfo splitHri = new HRegionInfo(hri.getTableName(), null, midRow);
+    Path refPath = splitStoreFile(regionFs, splitHri, TEST_FAMILY, hsf, midRow, true);
     StoreFile refHsf = new StoreFile(this.fs, refPath, conf, cacheConf,
         BloomType.NONE, NoOpDataBlockEncoder.INSTANCE);
     // Now confirm that I can read from the reference and that it only gets
@@ -173,26 +179,21 @@ public class TestStoreFile extends HBase
   }
 
   public void testHFileLink() throws IOException {
-    final String columnFamily = "f";
-
-    // force temp data in hbase/target/test-data instead of /tmp/hbase-xxxx/ 
-    Configuration testConf = new Configuration(this.conf); 
-    FSUtils.setRootDir(testConf, this.testDir);  
-
-    HRegionInfo hri = new HRegionInfo(Bytes.toBytes("table-link"));
-    Path storedir = new Path(new Path(this.testDir,
-        new Path(hri.getTableNameAsString(), hri.getEncodedName())), columnFamily);
+    final HRegionInfo hri = new HRegionInfo(Bytes.toBytes("testHFileLinkTb"));
+    // force temp data in hbase/target/test-data instead of /tmp/hbase-xxxx/
+    Configuration testConf = new Configuration(this.conf);
+    FSUtils.setRootDir(testConf, this.testDir);
+    HRegionFileSystem regionFs = HRegionFileSystem.createRegionOnFileSystem(
+      testConf, fs, new Path(this.testDir, hri.getTableNameAsString()), hri);
 
     // Make a store file and write data to it.
-    StoreFile.Writer writer = new StoreFile.WriterBuilder(testConf, cacheConf,
-         this.fs, 8 * 1024)
-            .withOutputDir(storedir)
+    StoreFile.Writer writer = new StoreFile.WriterBuilder(testConf, cacheConf, this.fs, 8 * 1024)
+            .withFilePath(regionFs.createTempName())
             .build();
-    Path storeFilePath = writer.getPath();
     writeStoreFile(writer);
-    writer.close();
 
-    Path dstPath = new Path(this.testDir, new Path("test-region", columnFamily));
+    Path storeFilePath = regionFs.commitStoreFile(TEST_FAMILY, writer.getPath());
+    Path dstPath = new Path(regionFs.getTableDir(), new Path("test-region", TEST_FAMILY));
     HFileLink.create(testConf, this.fs, dstPath, hri, storeFilePath.getName());
     Path linkFilePath = new Path(dstPath,
                   HFileLink.createHFileLinkName(hri, storeFilePath.getName()));
@@ -218,53 +219,49 @@ public class TestStoreFile extends HBase
    * to hfilelinks (created by snapshot clones) can be properly interpreted.
    */
   public void testReferenceToHFileLink() throws IOException {
-    final String columnFamily = "f";
-
-    Path rootDir = FSUtils.getRootDir(conf);
-
-    String tablename = "_original-evil-name"; // adding legal table name chars to verify regex handles it.
-    HRegionInfo hri = new HRegionInfo(Bytes.toBytes(tablename));
-    // store dir = <root>/<tablename>/<rgn>/<cf>
-    Path storedir = new Path(new Path(rootDir,
-      new Path(hri.getTableNameAsString(), hri.getEncodedName())), columnFamily);
+    // force temp data in hbase/target/test-data instead of /tmp/hbase-xxxx/
+    Configuration testConf = new Configuration(this.conf);
+    FSUtils.setRootDir(testConf, this.testDir);
+
+    // adding legal table name chars to verify regex handles it.
+    HRegionInfo hri = new HRegionInfo(Bytes.toBytes("_original-evil-name"));
+    HRegionFileSystem regionFs = HRegionFileSystem.createRegionOnFileSystem(
+      testConf, fs, new Path(this.testDir, hri.getTableNameAsString()), hri);
 
     // Make a store file and write data to it. <root>/<tablename>/<rgn>/<cf>/<file>
-    StoreFile.Writer writer = new StoreFile.WriterBuilder(conf, cacheConf,
-         this.fs, 8 * 1024)
-            .withOutputDir(storedir)
+    StoreFile.Writer writer = new StoreFile.WriterBuilder(testConf, cacheConf, this.fs, 8 * 1024)
+            .withFilePath(regionFs.createTempName())
             .build();
-    Path storeFilePath = writer.getPath();
     writeStoreFile(writer);
-    writer.close();
+    Path storeFilePath = regionFs.commitStoreFile(TEST_FAMILY, writer.getPath());
 
     // create link to store file. <root>/clone/region/<cf>/<hfile>-<region>-<table>
-    String target = "clone";
-    Path dstPath = new Path(rootDir, new Path(new Path(target, "7e0102"), columnFamily));
-    HFileLink.create(conf, this.fs, dstPath, hri, storeFilePath.getName());
+    HRegionInfo hriClone = new HRegionInfo(Bytes.toBytes("clone"));
+    HRegionFileSystem cloneRegionFs = HRegionFileSystem.createRegionOnFileSystem(
+      testConf, fs, new Path(this.testDir, hri.getTableNameAsString()), hriClone);
+    Path dstPath = cloneRegionFs.getStoreDir(TEST_FAMILY);
+    HFileLink.create(testConf, this.fs, dstPath, hri, storeFilePath.getName());
     Path linkFilePath = new Path(dstPath,
                   HFileLink.createHFileLinkName(hri, storeFilePath.getName()));
 
     // create splits of the link.
     // <root>/clone/splitA/<cf>/<reftohfilelink>,
     // <root>/clone/splitB/<cf>/<reftohfilelink>
-    Path splitDirA = new Path(new Path(rootDir,
-        new Path(target, "571A")), columnFamily);
-    Path splitDirB = new Path(new Path(rootDir,
-        new Path(target, "571B")), columnFamily);
-    StoreFile f = new StoreFile(fs, linkFilePath, conf, cacheConf, BloomType.NONE,
+    HRegionInfo splitHriA = new HRegionInfo(hri.getTableName(), null, SPLITKEY);
+    HRegionInfo splitHriB = new HRegionInfo(hri.getTableName(), SPLITKEY, null);
+    StoreFile f = new StoreFile(fs, linkFilePath, testConf, cacheConf, BloomType.NONE,
         NoOpDataBlockEncoder.INSTANCE);
-    byte[] splitRow = SPLITKEY;
-    Path pathA = StoreFile.split(fs, splitDirA, f, splitRow, true); // top
-    Path pathB = StoreFile.split(fs, splitDirB, f, splitRow, false); // bottom
+    Path pathA = splitStoreFile(cloneRegionFs, splitHriA, TEST_FAMILY, f, SPLITKEY, true); // top
+    Path pathB = splitStoreFile(cloneRegionFs, splitHriB, TEST_FAMILY, f, SPLITKEY, false);// bottom
 
     // OK test the thing
-    FSUtils.logFileSystemState(fs, rootDir, LOG);
+    FSUtils.logFileSystemState(fs, this.testDir, LOG);
 
     // There is a case where a file with the hfilelink pattern is actually a daughter
     // reference to a hfile link.  This code in StoreFile that handles this case.
-    
+
     // Try to open store file from link
-    StoreFile hsfA = new StoreFile(this.fs, pathA,  conf, cacheConf,
+    StoreFile hsfA = new StoreFile(this.fs, pathA, testConf, cacheConf,
         BloomType.NONE, NoOpDataBlockEncoder.INSTANCE);
 
     // Now confirm that I can read from the ref to link
@@ -275,9 +272,9 @@ public class TestStoreFile extends HBase
       count++;
     }
     assertTrue(count > 0); // read some rows here
-    
+
     // Try to open store file from link
-    StoreFile hsfB = new StoreFile(this.fs, pathB,  conf, cacheConf,
+    StoreFile hsfB = new StoreFile(this.fs, pathB, testConf, cacheConf,
         BloomType.NONE, NoOpDataBlockEncoder.INSTANCE);
 
     // Now confirm that I can read from the ref to link
@@ -291,31 +288,21 @@ public class TestStoreFile extends HBase
     assertEquals((LAST_CHAR - FIRST_CHAR + 1) * (LAST_CHAR - FIRST_CHAR + 1), count);
   }
 
-  private void checkHalfHFile(final StoreFile f)
-  throws IOException {
+  private void checkHalfHFile(final HRegionFileSystem regionFs, final StoreFile f)
+      throws IOException {
     byte [] midkey = f.createReader().midkey();
     KeyValue midKV = KeyValue.createKeyValueFromKey(midkey);
     byte [] midRow = midKV.getRow();
     // Create top split.
-    Path topDir = HStore.getStoreHomedir(this.testDir, "1",
-      Bytes.toBytes(f.getPath().getParent().getName()));
-    if (this.fs.exists(topDir)) {
-      this.fs.delete(topDir, true);
-    }
-    Path topPath = StoreFile.split(this.fs, topDir, f, midRow, true);
+    HRegionInfo topHri = new HRegionInfo(regionFs.getRegionInfo().getTableName(), null, midRow);
+    Path topPath = splitStoreFile(regionFs, topHri, TEST_FAMILY, f, midRow, true);
     // Create bottom split.
-    Path bottomDir = HStore.getStoreHomedir(this.testDir, "2",
-      Bytes.toBytes(f.getPath().getParent().getName()));
-    if (this.fs.exists(bottomDir)) {
-      this.fs.delete(bottomDir, true);
-    }
-    Path bottomPath = StoreFile.split(this.fs, bottomDir, f, midRow, false);
+    HRegionInfo bottomHri = new HRegionInfo(regionFs.getRegionInfo().getTableName(), midRow, null);
+    Path bottomPath = splitStoreFile(regionFs, bottomHri, TEST_FAMILY, f, midRow, false);
     // Make readers on top and bottom.
-    StoreFile.Reader top =
-        new StoreFile(this.fs, topPath, conf, cacheConf, BloomType.NONE,
-            NoOpDataBlockEncoder.INSTANCE).createReader();
-    StoreFile.Reader bottom = new StoreFile(this.fs, bottomPath,
-        conf, cacheConf, BloomType.NONE,
+    StoreFile.Reader top = new StoreFile(this.fs, topPath, conf, cacheConf, BloomType.NONE,
+        NoOpDataBlockEncoder.INSTANCE).createReader();
+    StoreFile.Reader bottom = new StoreFile(this.fs, bottomPath, conf, cacheConf, BloomType.NONE,
         NoOpDataBlockEncoder.INSTANCE).createReader();
     ByteBuffer previous = null;
     LOG.info("Midkey: " + midKV.toString());
@@ -329,7 +316,7 @@ public class TestStoreFile extends HBase
       ByteBuffer key = null;
       HFileScanner topScanner = top.getScanner(false, false);
       while ((!topScanner.isSeeked() && topScanner.seekTo()) ||
-          (topScanner.isSeeked() && topScanner.next())) {
+             (topScanner.isSeeked() && topScanner.next())) {
         key = topScanner.getKey();
 
         if (topScanner.getReader().getComparator().compare(key.array(),
@@ -361,20 +348,19 @@ public class TestStoreFile extends HBase
         LOG.info("Last in bottom: " + Bytes.toString(Bytes.toBytes(previous)));
       }
       // Remove references.
-      this.fs.delete(topPath, false);
-      this.fs.delete(bottomPath, false);
+      regionFs.cleanupDaughterRegion(topHri);
+      regionFs.cleanupDaughterRegion(bottomHri);
 
       // Next test using a midkey that does not exist in the file.
       // First, do a key that is < than first key. Ensure splits behave
       // properly.
       byte [] badmidkey = Bytes.toBytes("  .");
-      topPath = StoreFile.split(this.fs, topDir, f, badmidkey, true);
-      bottomPath = StoreFile.split(this.fs, bottomDir, f, badmidkey, false);
-      top = new StoreFile(this.fs, topPath, conf, cacheConf,
-          BloomType.NONE,
+      assertTrue(fs.exists(f.getPath()));
+      topPath = splitStoreFile(regionFs, topHri, TEST_FAMILY, f, badmidkey, true);
+      bottomPath = splitStoreFile(regionFs, bottomHri, TEST_FAMILY, f, badmidkey, false);
+      top = new StoreFile(this.fs, topPath, conf, cacheConf, BloomType.NONE,
           NoOpDataBlockEncoder.INSTANCE).createReader();
-      bottom = new StoreFile(this.fs, bottomPath, conf, cacheConf,
-          BloomType.NONE,
+      bottom = new StoreFile(this.fs, bottomPath, conf, cacheConf, BloomType.NONE,
           NoOpDataBlockEncoder.INSTANCE).createReader();
       bottomScanner = bottom.getScanner(false, false);
       int count = 0;
@@ -409,18 +395,16 @@ public class TestStoreFile extends HBase
         assertTrue(tmp.charAt(i) == 'z');
       }
       // Remove references.
-      this.fs.delete(topPath, false);
-      this.fs.delete(bottomPath, false);
+      regionFs.cleanupDaughterRegion(topHri);
+      regionFs.cleanupDaughterRegion(bottomHri);
 
       // Test when badkey is > than last key in file ('||' > 'zz').
       badmidkey = Bytes.toBytes("|||");
-      topPath = StoreFile.split(this.fs, topDir, f, badmidkey, true);
-      bottomPath = StoreFile.split(this.fs, bottomDir, f, badmidkey, false);
-      top = new StoreFile(this.fs, topPath, conf, cacheConf,
-          BloomType.NONE,
+      topPath = splitStoreFile(regionFs,topHri, TEST_FAMILY, f, badmidkey, true);
+      bottomPath = splitStoreFile(regionFs, bottomHri, TEST_FAMILY, f, badmidkey, false);
+      top = new StoreFile(this.fs, topPath, conf, cacheConf, BloomType.NONE,
           NoOpDataBlockEncoder.INSTANCE).createReader();
-      bottom = new StoreFile(this.fs, bottomPath, conf, cacheConf,
-          BloomType.NONE,
+      bottom = new StoreFile(this.fs, bottomPath, conf, cacheConf, BloomType.NONE,
           NoOpDataBlockEncoder.INSTANCE).createReader();
       first = true;
       bottomScanner = bottom.getScanner(false, false);
@@ -463,10 +447,8 @@ public class TestStoreFile extends HBase
 
   private static final String localFormatter = "%010d";
 
-  private void bloomWriteRead(StoreFile.Writer writer, FileSystem fs)
-  throws Exception {
-    float err = conf.getFloat(
-        BloomFilterFactory.IO_STOREFILE_BLOOM_ERROR_RATE, 0);
+  private void bloomWriteRead(StoreFile.Writer writer, FileSystem fs) throws Exception {
+    float err = conf.getFloat(BloomFilterFactory.IO_STOREFILE_BLOOM_ERROR_RATE, 0);
     Path f = writer.getPath();
     long now = System.currentTimeMillis();
     for (int i = 0; i < 2000; i += 2) {
@@ -511,8 +493,7 @@ public class TestStoreFile extends HBase
 
   public void testBloomFilter() throws Exception {
     FileSystem fs = FileSystem.getLocal(conf);
-    conf.setFloat(BloomFilterFactory.IO_STOREFILE_BLOOM_ERROR_RATE,
-        (float) 0.01);
+    conf.setFloat(BloomFilterFactory.IO_STOREFILE_BLOOM_ERROR_RATE, (float) 0.01);
     conf.setBoolean(BloomFilterFactory.IO_STOREFILE_BLOOM_ENABLED, true);
 
     // write the file
@@ -530,11 +511,9 @@ public class TestStoreFile extends HBase
 
   public void testDeleteFamilyBloomFilter() throws Exception {
     FileSystem fs = FileSystem.getLocal(conf);
-    conf.setFloat(BloomFilterFactory.IO_STOREFILE_BLOOM_ERROR_RATE,
-        (float) 0.01);
+    conf.setFloat(BloomFilterFactory.IO_STOREFILE_BLOOM_ERROR_RATE, (float) 0.01);
     conf.setBoolean(BloomFilterFactory.IO_STOREFILE_BLOOM_ENABLED, true);
-    float err = conf.getFloat(BloomFilterFactory.IO_STOREFILE_BLOOM_ERROR_RATE,
-        0);
+    float err = conf.getFloat(BloomFilterFactory.IO_STOREFILE_BLOOM_ERROR_RATE, 0);
 
     // write the file
     Path f = new Path(ROOT_DIR, getName());
@@ -624,9 +603,8 @@ public class TestStoreFile extends HBase
     int versions = 2;
 
     // run once using columns and once using rows
-    BloomType[] bt =
-      {BloomType.ROWCOL, BloomType.ROW};
-    int[] expKeys    = {rowCount*colCount, rowCount};
+    BloomType[] bt = {BloomType.ROWCOL, BloomType.ROW};
+    int[] expKeys  = {rowCount*colCount, rowCount};
     // below line deserves commentary.  it is expected bloom false positives
     //  column = rowCount*2*colCount inserts
     //  row-level = only rowCount*2 inserts, but failures will be magnified by
@@ -946,6 +924,15 @@ public class TestStoreFile extends HBase
     assertEquals(startEvicted, cs.getEvictedCount());
   }
 
+  private Path splitStoreFile(final HRegionFileSystem regionFs, final HRegionInfo hri,
+      final String family, final StoreFile sf, final byte[] splitKey, boolean isTopRef)
+      throws IOException {
+    FileSystem fs = regionFs.getFileSystem();
+    Path path = regionFs.splitStoreFile(hri, family, sf, splitKey, isTopRef);
+    Path regionDir = regionFs.commitDaughterRegion(hri);
+    return new Path(new Path(regionDir, family), path.getName());
+  }
+
   private StoreFile.Writer writeStoreFile(Configuration conf,
       CacheConfig cacheConf, Path path, int numBlocks)
   throws IOException {
@@ -961,8 +948,7 @@ public class TestStoreFile extends HBase
       totalSize += kv.getLength() + 1;
     }
     int blockSize = totalSize / numBlocks;
-    StoreFile.Writer writer = new StoreFile.WriterBuilder(conf, cacheConf, fs,
-        blockSize)
+    StoreFile.Writer writer = new StoreFile.WriterBuilder(conf, cacheConf, fs, blockSize)
             .withFilePath(path)
             .withMaxKeyCount(2000)
             .withChecksumType(CKTYPE)
@@ -1003,16 +989,14 @@ public class TestStoreFile extends HBase
             .withBytesPerChecksum(CKBYTES)
             .build();
     writer.close();
-    
+
     StoreFile storeFile = new StoreFile(fs, writer.getPath(), conf,
         cacheConf, BloomType.NONE, dataBlockEncoder);
     StoreFile.Reader reader = storeFile.createReader();
-    
+
     Map<byte[], byte[]> fileInfo = reader.loadFileInfo();
     byte[] value = fileInfo.get(HFileDataBlockEncoder.DATA_BLOCK_ENCODING);
-
     assertEquals(dataBlockEncoderAlgo.getNameInBytes(), value);
   }
-
 }
 

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplay.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplay.java?rev=1457148&r1=1457147&r2=1457148&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplay.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALReplay.java Fri Mar 15 22:19:34 2013
@@ -530,8 +530,7 @@ public class TestWALReplay {
     for (HColumnDescriptor hcd: htd.getFamilies()) {
       cf_count++;
       if (cf_count == 2) {
-        this.fs.delete(new Path(region.getRegionDir(), Bytes.toString(hcd.getName()))
-            , true);
+        region.getRegionFileSystem().deleteFamily(hcd.getNameAsString());
       }
     }
 

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestRestoreSnapshotHelper.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestRestoreSnapshotHelper.java?rev=1457148&r1=1457147&r2=1457148&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestRestoreSnapshotHelper.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestRestoreSnapshotHelper.java Fri Mar 15 22:19:34 2013
@@ -46,7 +46,7 @@ import org.apache.hadoop.hbase.client.HC
 import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher;
 import org.apache.hadoop.hbase.io.HFileLink;
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
-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.util.Bytes;
 import org.apache.hadoop.hbase.util.FSTableDescriptors;
@@ -156,19 +156,21 @@ public class TestRestoreSnapshotHelper {
   private void createSnapshot(final Path rootDir, final Path snapshotDir, final HTableDescriptor htd)
       throws IOException {
     // First region, simple with one plain hfile.
-    HRegion r0 = HRegion.createHRegion(new HRegionInfo(htd.getName()), archiveDir,
-        conf, htd, null, true, true);
-    Path storeFile = new Path(new Path(r0.getRegionDir(), TEST_FAMILY), TEST_HFILE);
+    HRegionInfo hri = new HRegionInfo(htd.getName());
+    HRegionFileSystem r0fs = HRegionFileSystem.createRegionOnFileSystem(conf,
+      fs, new Path(archiveDir, hri.getTableNameAsString()), hri);
+    Path storeFile = new Path(rootDir, TEST_HFILE);
     fs.createNewFile(storeFile);
-    r0.close();
+    r0fs.commitStoreFile(TEST_FAMILY, storeFile);
 
     // Second region, used to test the split case.
     // This region contains a reference to the hfile in the first region.
-    HRegion r1 = HRegion.createHRegion(new HRegionInfo(htd.getName()), archiveDir,
-        conf, htd, null, true, true);
-    fs.createNewFile(new Path(new Path(r1.getRegionDir(), TEST_FAMILY),
-        storeFile.getName() + '.' + r0.getRegionInfo().getEncodedName()));
-    r1.close();
+    hri = new HRegionInfo(htd.getName());
+    HRegionFileSystem r1fs = HRegionFileSystem.createRegionOnFileSystem(conf,
+      fs, new Path(archiveDir, hri.getTableNameAsString()), hri);
+    storeFile = new Path(rootDir, TEST_HFILE + '.' + r0fs.getRegionInfo().getEncodedName());
+    fs.createNewFile(storeFile);
+    r1fs.commitStoreFile(TEST_FAMILY, storeFile);
 
     Path tableDir = HTableDescriptor.getTableDir(archiveDir, htd.getName());
     FileUtil.copy(fs, tableDir, fs, snapshotDir, false, conf);

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/HFileArchiveTestingUtil.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/HFileArchiveTestingUtil.java?rev=1457148&r1=1457147&r2=1457148&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/HFileArchiveTestingUtil.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/HFileArchiveTestingUtil.java Fri Mar 15 22:19:34 2013
@@ -213,7 +213,8 @@ public class HFileArchiveTestingUtil {
    * @return {@link Path} to the archive directory for the given region
    */
   public static Path getRegionArchiveDir(Configuration conf, HRegion region) {
-    return HFileArchiveUtil.getRegionArchiveDir(conf, region.getTableDir(), region.getRegionDir());
+    return HFileArchiveUtil.getRegionArchiveDir(region.getRegionFileSystem().getTableDir(),
+        region.getRegionFileSystem().getRegionDir());
   }
 
   /**
@@ -225,9 +226,8 @@ public class HFileArchiveTestingUtil {
    */
   public static Path getStoreArchivePath(Configuration conf, HRegion region, Store store)
       throws IOException {
-    HRegionInfo hri = region.getRegionInfo();
-    return HFileArchiveUtil.getStoreArchivePath(conf, hri.getTableNameAsString(), hri,
-        store.getFamily().getNameAsString());
+    return HFileArchiveUtil.getStoreArchivePath(conf, region.getRegionInfo(),
+        region.getRegionFileSystem().getTableDir(), store.getFamily().getName());
   }
 
   public static Path getStoreArchivePath(HBaseTestingUtility util, String tableName,

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHFileArchiveUtil.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHFileArchiveUtil.java?rev=1457148&r1=1457147&r2=1457148&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHFileArchiveUtil.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHFileArchiveUtil.java Fri Mar 15 22:19:34 2013
@@ -50,10 +50,9 @@ public class TestHFileArchiveUtil {
   
   @Test
   public void testRegionArchiveDir() {
-    Configuration conf = null;
     Path tableDir = new Path("table");
     Path regionDir = new Path("region");
-    assertNotNull(HFileArchiveUtil.getRegionArchiveDir(conf, tableDir, regionDir));
+    assertNotNull(HFileArchiveUtil.getRegionArchiveDir(tableDir, regionDir));
   }
   
   @Test