hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r735837 - in /hadoop/hbase/trunk: ./ src/java/org/apache/hadoop/hbase/ src/java/org/apache/hadoop/hbase/master/ src/java/org/apache/hadoop/hbase/regionserver/ src/webapps/master/
Date Mon, 19 Jan 2009 21:43:49 GMT
Author: stack
Date: Mon Jan 19 13:43:48 2009
New Revision: 735837

URL: http://svn.apache.org/viewvc?rev=735837&view=rev
Log:
HBASE-1089 Add count of regions on filesystem to master UI; add percentage online as difference
between whats open and whats on filesystem

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HConstants.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/RegionManager.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java
    hadoop/hbase/trunk/src/webapps/master/master.jsp

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=735837&r1=735836&r2=735837&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Mon Jan 19 13:43:48 2009
@@ -6,6 +6,11 @@
    HBASE-1136  HashFunction inadvertently destroys some randomness
                (Jonathan Ellis via Stack) 
 
+  IMPROVEMENTS
+   HBASE-1089  Add count of regions on filesystem to master UI; add percentage
+               online as difference between whats open and whats on filesystem
+               (Samuel Guo via Stack)
+
 Release 0.19.0 - Unreleased
   INCOMPATIBLE CHANGES
    HBASE-885   TableMap and TableReduce should be interfaces

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HConstants.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HConstants.java?rev=735837&r1=735836&r2=735837&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HConstants.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HConstants.java Mon Jan 19 13:43:48
2009
@@ -111,6 +111,9 @@
   /** Name of old log file for reconstruction */
   static final String HREGION_OLDLOGFILE_NAME = "oldlogfile.log";
   
+  /** Used to construct the name of the compaction directory during compaction */
+  static final String HREGION_COMPACTIONDIR_NAME = "compaction.dir";
+  
   /** Default maximum file size */
   static final long DEFAULT_MAX_FILE_SIZE = 256 * 1024 * 1024;
   

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java?rev=735837&r1=735836&r2=735837&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java Mon Jan 19 13:43:48
2009
@@ -79,6 +79,7 @@
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.ipc.RemoteException;
+import org.apache.hadoop.util.StringUtils;
 
 /**
  * HMaster is the "master server" for a HBase.
@@ -316,6 +317,17 @@
   public double getAverageLoad() {
     return serverManager.getAverageLoad();
   }
+  
+  /** @return the number of regions on filesystem */
+  public int countRegionsOnFS() {
+    try {
+      return regionManager.countRegionsOnFS();
+    } catch (IOException e) {
+      LOG.warn("Get count of Regions on FileSystem error : " + 
+          StringUtils.stringifyException(e));
+    }
+    return -1;
+  }
 
   /**
    * @return Location of the <code>-ROOT-</code> region.

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/RegionManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/RegionManager.java?rev=735837&r1=735836&r2=735837&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/RegionManager.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/RegionManager.java Mon Jan
19 13:43:48 2009
@@ -38,6 +38,9 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.PathFilter;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HServerAddress;
 import org.apache.hadoop.hbase.HServerInfo;
@@ -447,6 +450,51 @@
     LOG.info("Skipped " + skipped + " region(s) that are in transition states");
   }
   
+  static class TableDirFilter implements PathFilter {
+
+    @Override
+    public boolean accept(Path path) {
+      // skip the region servers' log dirs && version file
+      // HBASE-1112 want to sperate the log dirs from table's data dirs by a special character.
+      String pathname = path.getName();
+      return !pathname.startsWith("log_") && !pathname.equals(VERSION_FILE_NAME);
+    }
+    
+  }
+  
+  static class RegionDirFilter implements PathFilter {
+
+    @Override
+    public boolean accept(Path path) { 
+      return !path.getName().equals(HREGION_COMPACTIONDIR_NAME);
+    }
+    
+  }
+  
+  /**
+   * @return the rough number of the regions on fs
+   * Note: this method simply counts the regions on fs by accumulating all the dirs 
+   * in each table dir (${HBASE_ROOT}/$TABLE) and skipping logfiles, compaction dirs.
+   * @throws IOException 
+   */
+  public int countRegionsOnFS() throws IOException {
+    int regions = 0;
+    
+    FileStatus[] tableDirs = 
+      master.fs.listStatus(master.rootdir, new TableDirFilter());
+    
+    FileStatus[] regionDirs;
+    RegionDirFilter rdf = new RegionDirFilter();
+    for(FileStatus tabledir : tableDirs) {
+      if(tabledir.isDir()) {
+        regionDirs = master.fs.listStatus(tabledir.getPath(), rdf);
+        regions += regionDirs.length;
+      }
+    }
+    
+    return regions;
+  }
+  
   /**
    * @return Read-only map of online regions.
    */

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=735837&r1=735836&r2=735837&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java Mon Jan
19 13:43:48 2009
@@ -632,7 +632,7 @@
    * @return compaction directory for the passed in <code>dir</code>
    */
   static Path getCompactionDir(final Path dir) {
-   return new Path(dir, "compaction.dir");
+   return new Path(dir, HREGION_COMPACTIONDIR_NAME);
   }
 
   /*

Modified: hadoop/hbase/trunk/src/webapps/master/master.jsp
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/webapps/master/master.jsp?rev=735837&r1=735836&r2=735837&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/webapps/master/master.jsp (original)
+++ hadoop/hbase/trunk/src/webapps/master/master.jsp Mon Jan 19 13:43:48 2009
@@ -46,6 +46,7 @@
 <tr><td>Hadoop Compiled</td><td><%= org.apache.hadoop.util.VersionInfo.getDate()
%>, <%= org.apache.hadoop.util.VersionInfo.getUser() %></td><td>When
Hadoop version was compiled and by whom</td></tr>
 <tr><td>HBase Root Directory</td><td><%= master.getRootDir().toString()
%></td><td>Location of HBase home directory</td></tr>
 <tr><td>Load average</td><td><%= master.getAverageLoad() %></td><td>Average
load across all region servers. Naive computation.</td></tr>
+<tr><td>Regions On FS</td><td><%= master.countRegionsOnFS() %></td><td>The
Number of regions on FileSystem. Rough count.</td></tr>
 </table>
 
 <h2>Catalog Tables</h2>



Mime
View raw message