You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by jd...@apache.org on 2009/12/10 23:56:51 UTC
svn commit: r889453 - in /hadoop/hbase/trunk: CHANGES.txt
src/test/org/apache/hadoop/hbase/HBaseTestingUtility.java
src/test/org/apache/hadoop/hbase/TestZooKeeper.java
Author: jdcryans
Date: Thu Dec 10 22:56:51 2009
New Revision: 889453
URL: http://svn.apache.org/viewvc?rev=889453&view=rev
Log:
HBASE-2013 Add useful helpers to HBaseTestingUtility.java (Lars George
via J-D)
Modified:
hadoop/hbase/trunk/CHANGES.txt
hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/HBaseTestingUtility.java
hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TestZooKeeper.java
Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=889453&r1=889452&r2=889453&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Thu Dec 10 22:56:51 2009
@@ -222,6 +222,8 @@
(Lars George and J-D via Stack)
HBASE-2027 HConnectionManager.HBASE_INSTANCES leaks TableServers
(Dave Latham via Stack)
+ HBASE-2013 Add useful helpers to HBaseTestingUtility.java (Lars George
+ via J-D)
NEW FEATURES
HBASE-1901 "General" partitioner for "hbase-48" bulk (behind the api, write
Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/HBaseTestingUtility.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/HBaseTestingUtility.java?rev=889453&r1=889452&r2=889453&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/HBaseTestingUtility.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/HBaseTestingUtility.java Thu Dec 10 22:56:51 2009
@@ -35,7 +35,6 @@
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HConnection;
-import org.apache.hadoop.hbase.client.HConnectionManager;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
@@ -70,7 +69,8 @@
private MiniHBaseCluster hbaseCluster = null;
private MiniMRCluster mrCluster = null;
private File clusterTestBuildDir = null;
-
+ private HBaseAdmin hbaseAdmin = null;
+
/** System property key to get test directory value.
*/
public static final String TEST_DIRECTORY_KEY = "test.build.data";
@@ -511,10 +511,68 @@
}
/**
- * Get the HBase cluster
+ * Get the HBase cluster.
+ *
* @return hbase cluster
*/
- public MiniHBaseCluster getHbaseCluster() {
+ public MiniHBaseCluster getHBaseCluster() {
return hbaseCluster;
}
+
+ /**
+ * Returns a HBaseAdmin instance.
+ *
+ * @return The HBaseAdmin instance.
+ * @throws MasterNotRunningException
+ */
+ public HBaseAdmin getHBaseAdmin() throws MasterNotRunningException {
+ if (hbaseAdmin == null) {
+ hbaseAdmin = new HBaseAdmin(getConfiguration());
+ }
+ return hbaseAdmin;
+ }
+
+ /**
+ * Closes the named region.
+ *
+ * @param regionName The region to close.
+ * @throws IOException
+ */
+ public void closeRegion(String regionName) throws IOException {
+ closeRegion(Bytes.toBytes(regionName));
+ }
+
+ /**
+ * Closes the named region.
+ *
+ * @param regionName The region to close.
+ * @throws IOException
+ */
+ public void closeRegion(byte[] regionName) throws IOException {
+ HBaseAdmin admin = getHBaseAdmin();
+ admin.closeRegion(regionName, (Object[]) null);
+ }
+
+ /**
+ * Closes the region containing the given row.
+ *
+ * @param row The row to find the containing region.
+ * @param table The table to find the region.
+ * @throws IOException
+ */
+ public void closeRegionByRow(String row, HTable table) throws IOException {
+ closeRegionByRow(Bytes.toBytes(row), table);
+ }
+
+ /**
+ * Closes the region containing the given row.
+ *
+ * @param row The row to find the containing region.
+ * @param table The table to find the region.
+ * @throws IOException
+ */
+ public void closeRegionByRow(byte[] row, HTable table) throws IOException {
+ HRegionLocation hrl = table.getRegionLocation(row);
+ closeRegion(hrl.getRegionInfo().getRegionName());
+ }
}
\ No newline at end of file
Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TestZooKeeper.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TestZooKeeper.java?rev=889453&r1=889452&r2=889453&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TestZooKeeper.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TestZooKeeper.java Thu Dec 10 22:56:51 2009
@@ -59,7 +59,7 @@
@Before
public void setUp() throws Exception {
conf = TEST_UTIL.getConfiguration();
- cluster = TEST_UTIL.getHbaseCluster();
+ cluster = TEST_UTIL.getHBaseCluster();
}
/**