Author: jdcryans
Date: Mon Apr 18 21:39:47 2011
New Revision: 1094773
URL: http://svn.apache.org/viewvc?rev=1094773&view=rev
Log:
Fix for HBASE-3767
Re-adding getCurrentNrHRS in HTable as test were relying on it,
will be different in trunk.
Modified:
hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HTable.java
Modified:
hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HTable.java
URL:
http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HTable.java?rev=1094773&r1=1094772&r2=1094773&view=diff
==============================================================================
---
hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HTable.java
(original)
+++
hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HTable.java
Mon Apr 18 21:39:47 2011
@@ -54,6 +54,8 @@ import org.apache.hadoop.hbase.client.Me
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.hbase.util.Writables;
+import org.apache.hadoop.hbase.zookeeper.ZKUtil;
+import org.apache.zookeeper.KeeperException;
/**
* Used to communicate with a single HBase table.
@@ -194,6 +196,21 @@ public class HTable implements HTableInt
((ThreadPoolExecutor)this.pool).allowCoreThreadTimeOut(true);
}
+ /**
+ * @return the number of region servers that are currently running
+ * @throws IOException if a remote or network exception occurs
+ */
+ public int getCurrentNrHRS() throws IOException {
+ try {
+ // We go to zk rather than to master to get count of regions to avoid
+ // HTable having a Master dependency. See HBase-2828
+ return ZKUtil.getNumberOfChildren(this.connection.getZooKeeperWatcher(),
+ this.connection.getZooKeeperWatcher().rsZNode);
+ } catch (KeeperException ke) {
+ throw new IOException("Unexpected ZooKeeper exception", ke);
+ }
+ }
+
public Configuration getConfiguration() {
return configuration;
}