You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by jm...@apache.org on 2013/02/13 19:30:52 UTC

svn commit: r1445808 - in /hbase/branches/hbase-7290/hbase-server/src: main/java/org/apache/hadoop/hbase/io/HFileLink.java main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java

Author: jmhsieh
Date: Wed Feb 13 18:30:52 2013
New Revision: 1445808

URL: http://svn.apache.org/r1445808
Log:
HBASE-7439 HFileLink should not use the configuration from the Filesystem (Matteo Bertozzi)


Modified:
    hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HFileLink.java
    hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java
    hbase/branches/hbase-7290/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java

Modified: hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HFileLink.java
URL: http://svn.apache.org/viewvc/hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HFileLink.java?rev=1445808&r1=1445807&r2=1445808&view=diff
==============================================================================
--- hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HFileLink.java (original)
+++ hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HFileLink.java Wed Feb 13 18:30:52 2013
@@ -126,19 +126,6 @@ public class HFileLink extends FileLink 
 
   /**
    * The returned path can be the "original" file path like: /hbase/table/region/cf/hfile
-   * or a path to the archived file like: /hbase/archive/table/region/cf/hfile
-   *
-   * @param fs {@link FileSystem} on which to check the HFileLink
-   * @param path HFileLink path
-   * @return Referenced path (original path or archived path)
-   * @throws IOException on unexpected error.
-   */
-  public static Path getReferencedPath(FileSystem fs, final Path path) throws IOException {
-    return getReferencedPath(fs.getConf(), fs, path);
-  }
-
-  /**
-   * The returned path can be the "original" file path like: /hbase/table/region/cf/hfile
    * or a path to the archived file like: /hbase/.archive/table/region/cf/hfile
    *
    * @param fs {@link FileSystem} on which to check the HFileLink

Modified: hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java
URL: http://svn.apache.org/viewvc/hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java?rev=1445808&r1=1445807&r2=1445808&view=diff
==============================================================================
--- hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java (original)
+++ hbase/branches/hbase-7290/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java Wed Feb 13 18:30:52 2013
@@ -156,6 +156,8 @@ public class StoreFile {
   // If this storefile is a link to another, this is the link instance.
   private HFileLink link;
 
+  private Configuration conf;
+
   // Block cache configuration and reference.
   private final CacheConfig cacheConf;
 
@@ -257,6 +259,7 @@ public class StoreFile {
       throws IOException {
     this.fs = fs;
     this.path = p;
+    this.conf = conf;
     this.cacheConf = cacheConf;
     this.dataBlockEncoder =
         dataBlockEncoder == null ? NoOpDataBlockEncoder.INSTANCE
@@ -514,28 +517,6 @@ public class StoreFile {
   }
 
   /**
-   * helper function to compute HDFS blocks distribution of a given file.
-   * For reference file, it is an estimate
-   * @param fs  The FileSystem
-   * @param p  The path of the file
-   * @return HDFS blocks distribution
-   */
-  static public HDFSBlocksDistribution computeHDFSBlockDistribution(
-    FileSystem fs, Path p) throws IOException {
-    if (isReference(p)) {
-      Reference reference = Reference.read(fs, p);
-      Path referencePath = getReferredToFile(p);
-      return computeRefFileHDFSBlockDistribution(fs, reference, referencePath);
-    } else {
-      if (HFileLink.isHFileLink(p)) p = HFileLink.getReferencedPath(fs, p);
-      FileStatus status = fs.getFileStatus(p);
-      long length = status.getLen();
-      return FSUtils.computeHDFSBlocksDistribution(fs, status, 0, length);
-    }
-  }
-
-
-  /**
    * compute HDFS block distribution, for reference file, it is an estimate
    */
   private void computeHDFSBlockDistribution() throws IOException {
@@ -590,7 +571,7 @@ public class StoreFile {
         this.reference = Reference.read(fs, this.path);
         this.referencePath = getReferredToLink(this.path);
         LOG.debug("Reference file "+ path + " referred to " + referencePath + "!");
-        link = new HFileLink(fs.getConf(), referencePath);
+        link = new HFileLink(conf, referencePath);
         this.reader = new HalfStoreFileReader(this.fs, this.referencePath, link,
             this.cacheConf, this.reference,
             dataBlockEncoder.getEncodingInCache());

Modified: hbase/branches/hbase-7290/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java
URL: http://svn.apache.org/viewvc/hbase/branches/hbase-7290/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java?rev=1445808&r1=1445807&r2=1445808&view=diff
==============================================================================
--- hbase/branches/hbase-7290/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java (original)
+++ hbase/branches/hbase-7290/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFile.java Wed Feb 13 18:30:52 2013
@@ -240,10 +240,13 @@ public class TestStoreFile extends HBase
    */
   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(FSUtils.getRootDir(conf),
+    Path storedir = new Path(new Path(rootDir,
       new Path(hri.getTableNameAsString(), hri.getEncodedName())), columnFamily);
 
     // Make a store file and write data to it. <root>/<tablename>/<rgn>/<cf>/<file>
@@ -257,7 +260,7 @@ public class TestStoreFile extends HBase
 
     // create link to store file. <root>/clone/region/<cf>/<hfile>-<region>-<table>
     String target = "clone";
-    Path dstPath = new Path(FSUtils.getRootDir(conf), new Path(new Path(target, "region"), columnFamily));
+    Path dstPath = new Path(rootDir, new Path(new Path(target, "region"), columnFamily));
     HFileLink.create(conf, this.fs, dstPath, hri, storeFilePath.getName());
     Path linkFilePath = new Path(dstPath,
                   HFileLink.createHFileLinkName(hri, storeFilePath.getName()));
@@ -265,9 +268,9 @@ public class TestStoreFile extends HBase
     // create splits of the link.
     // <root>/clone/splitA/<cf>/<reftohfilelink>,
     // <root>/clone/splitB/<cf>/<reftohfilelink>
-    Path splitDirA = new Path(new Path(FSUtils.getRootDir(conf),
+    Path splitDirA = new Path(new Path(rootDir,
         new Path(target, "splitA")), columnFamily);
-    Path splitDirB = new Path(new Path(FSUtils.getRootDir(conf),
+    Path splitDirB = new Path(new Path(rootDir,
         new Path(target, "splitB")), columnFamily);
     StoreFile f = new StoreFile(fs, linkFilePath, conf, cacheConf, BloomType.NONE,
         NoOpDataBlockEncoder.INSTANCE);
@@ -276,7 +279,7 @@ public class TestStoreFile extends HBase
     Path pathB = StoreFile.split(fs, splitDirB, f, splitRow, false); // bottom
 
     // OK test the thing
-    FSUtils.logFileSystemState(fs, FSUtils.getRootDir(conf), LOG);
+    FSUtils.logFileSystemState(fs, rootDir, 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.