hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject svn commit: r1577404 - /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
Date Fri, 14 Mar 2014 01:04:59 GMT
Author: larsh
Date: Fri Mar 14 01:04:59 2014
New Revision: 1577404

URL: http://svn.apache.org/r1577404
Log:
HBASE-10722 [0.94] HRegion.computeHDFSBlocksDistribution does not account for links and reference
files.

Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=1577404&r1=1577403&r2=1577404&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java Fri
Mar 14 01:04:59 2014
@@ -104,10 +104,13 @@ import org.apache.hadoop.hbase.filter.Fi
 import org.apache.hadoop.hbase.filter.FilterBase;
 import org.apache.hadoop.hbase.filter.IncompatibleFilterException;
 import org.apache.hadoop.hbase.filter.WritableByteArrayComparable;
+import org.apache.hadoop.hbase.io.HFileLink;
 import org.apache.hadoop.hbase.io.HeapSize;
+import org.apache.hadoop.hbase.io.Reference;
 import org.apache.hadoop.hbase.io.TimeRange;
 import org.apache.hadoop.hbase.io.hfile.BlockCache;
 import org.apache.hadoop.hbase.io.hfile.CacheConfig;
+import org.apache.hadoop.hbase.io.hfile.HFile;
 import org.apache.hadoop.hbase.ipc.CoprocessorProtocol;
 import org.apache.hadoop.hbase.ipc.HBaseRPC;
 import org.apache.hadoop.hbase.ipc.HBaseServer;
@@ -736,15 +739,30 @@ public class HRegion implements HeapSize
    * @param tableDescriptor HTableDescriptor of the table
    * @param regionEncodedName encoded name of the region
    * @return The HDFS blocks distribution for the given region.
- * @throws IOException
+   * @throws IOException
    */
   static public HDFSBlocksDistribution computeHDFSBlocksDistribution(
     Configuration conf, HTableDescriptor tableDescriptor,
     String regionEncodedName) throws IOException {
-    HDFSBlocksDistribution hdfsBlocksDistribution =
-      new HDFSBlocksDistribution();
     Path tablePath = FSUtils.getTablePath(FSUtils.getRootDir(conf),
       tableDescriptor.getName());
+    return computeHDFSBlocksDistribution(conf, tableDescriptor, regionEncodedName, tablePath);
+  }
+
+  /**
+   * This is a helper function to compute HDFS block distribution on demand
+   * @param conf configuration
+   * @param tableDescriptor HTableDescriptor of the table
+   * @param regionEncodedName encoded name of the region
+   * @param tablePath The table's directory
+   * @return The HDFS blocks distribution for the given region.
+   * @throws IOException
+   */
+  static public HDFSBlocksDistribution computeHDFSBlocksDistribution(
+    Configuration conf, HTableDescriptor tableDescriptor,
+    String regionEncodedName, Path tablePath) throws IOException {
+    HDFSBlocksDistribution hdfsBlocksDistribution =
+      new HDFSBlocksDistribution();
     FileSystem fs = tablePath.getFileSystem(conf);
 
     for (HColumnDescriptor family: tableDescriptor.getFamilies()) {
@@ -756,6 +774,17 @@ public class HRegion implements HeapSize
       hfilesStatus = fs.listStatus(storeHomeDir);
 
       for (FileStatus hfileStatus : hfilesStatus) {
+        Path p = hfileStatus.getPath();
+        if (HFileLink.isHFileLink(p)) {
+          hfileStatus = new HFileLink(conf, p).getFileStatus(fs);
+        } else if (StoreFile.isReference(p)) {
+          p = StoreFile.getReferredToFile(p);
+          if (HFileLink.isHFileLink(p)) {
+            hfileStatus = new HFileLink(conf, p).getFileStatus(fs);
+          } else {
+            hfileStatus = fs.getFileStatus(p);
+          }
+        }
         HDFSBlocksDistribution storeFileBlocksDistribution =
           FSUtils.computeHDFSBlocksDistribution(fs, hfileStatus, 0,
           hfileStatus.getLen());



Mime
View raw message