hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r963826 - in /hbase/trunk: CHANGES.txt src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java src/main/java/org/apache/hadoop/hbase/client/HTable.java src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWrapper.java
Date Tue, 13 Jul 2010 19:21:36 GMT
Author: stack
Date: Tue Jul 13 19:21:36 2010
New Revision: 963826

URL: http://svn.apache.org/viewvc?rev=963826&view=rev
Log:
HBASE-2828 HTable unnecessarily coupled with HMaster

Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTable.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWrapper.java

Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=963826&r1=963825&r2=963826&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Tue Jul 13 19:21:36 2010
@@ -757,7 +757,9 @@ Release 0.21.0 - Unreleased
    HBASE-2786  TestHLog.testSplit hangs (Nicolas Spiegelberg via JD)
    HBASE-2790  Purge apache-forrest from TRUNK
    HBASE-2793  Add ability to extract a specified list of versions of a column 
-   	       in a single roundtrip (Kannan via Ryan)
+               in a single roundtrip (Kannan via Ryan)
+   HBASE-2828  HTable unnecessarily coupled with HMaster
+               (Nicolas Spiegelberg via Stack)
 
   NEW FEATURES
    HBASE-1961  HBase EC2 scripts

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java?rev=963826&r1=963825&r2=963826&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java Tue Jul 13 19:21:36
2010
@@ -49,7 +49,11 @@ import java.util.Map;
 import java.util.NavigableMap;
 
 /**
- * Provides administrative functions for HBase
+ * Provides an interface to manage HBase database table metadata + general 
+ * administrative functions.  Use HBaseAdmin to create, drop, list, enable and 
+ * disable tables. Use it also to add and drop table column families. 
+ * 
+ * See {@link HTable} to add, update, and delete data from an individual table.
  */
 public class HBaseAdmin {
   private final Log LOG = LogFactory.getLog(this.getClass().getName());

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTable.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTable.java?rev=963826&r1=963825&r2=963826&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTable.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTable.java Tue Jul 13 19:21:36
2010
@@ -57,11 +57,13 @@ import java.io.DataOutput;
 
 /**
  * Used to communicate with a single HBase table.
- * <p>
+ * 
  * This class is not thread safe for writes.
  * Gets, puts, and deletes take out a row lock for the duration
  * of their operation.  Scans (currently) do not respect
  * row locking.
+ * 
+ * See {@link HBaseAdmin} to create, drop, list, enable and disable tables.
  */
 public class HTable implements HTableInterface {
   private final HConnection connection;
@@ -167,9 +169,11 @@ public class HTable implements HTableInt
    * @return the number of region servers that are currently running
    * @throws IOException if a remote or network exception occurs
    */
-  private int getCurrentNrHRS() throws IOException {
-    HBaseAdmin admin = new HBaseAdmin(this.configuration);
-    return admin.getClusterStatus().getServers();
+  int getCurrentNrHRS() throws IOException {
+    return HConnectionManager
+      .getClientZooKeeperWatcher(this.configuration)
+      .getZooKeeperWrapper()
+      .getRSDirectoryCount();
   }
 
   // For multiput

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWrapper.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWrapper.java?rev=963826&r1=963825&r2=963826&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWrapper.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWrapper.java Tue
Jul 13 19:21:36 2010
@@ -748,6 +748,21 @@ public class ZooKeeperWrapper implements
       LOG.warn("<" + instanceName + ">" + "Failed to delete " + rsZNode + " znodes
in ZooKeeper: " + e);
     }
   }
+  
+  /**
+   * @return the number of region server znodes in the RS directory
+   */
+  public int getRSDirectoryCount() { 
+    Stat stat = null;
+    try {
+      stat = zooKeeper.exists(rsZNode, false);
+    } catch (KeeperException e) {
+      LOG.warn("Problem getting stats for " + rsZNode, e);
+    } catch (InterruptedException e) {
+      LOG.warn("Problem getting stats for " + rsZNode, e);
+    }
+    return (stat != null) ? stat.getNumChildren() : 0;
+  }
 
   private boolean checkExistenceOf(String path) {
     Stat stat = null;



Mime
View raw message