HBASE-2013 Add useful helpers to HBaseTestingUtility.java (Lars George
via J-D) git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@889453 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7aab1fbc64
commit
0db51718ce
|
@ -222,6 +222,8 @@ Release 0.21.0 - Unreleased
|
||||||
(Lars George and J-D via Stack)
|
(Lars George and J-D via Stack)
|
||||||
HBASE-2027 HConnectionManager.HBASE_INSTANCES leaks TableServers
|
HBASE-2027 HConnectionManager.HBASE_INSTANCES leaks TableServers
|
||||||
(Dave Latham via Stack)
|
(Dave Latham via Stack)
|
||||||
|
HBASE-2013 Add useful helpers to HBaseTestingUtility.java (Lars George
|
||||||
|
via J-D)
|
||||||
|
|
||||||
NEW FEATURES
|
NEW FEATURES
|
||||||
HBASE-1901 "General" partitioner for "hbase-48" bulk (behind the api, write
|
HBASE-1901 "General" partitioner for "hbase-48" bulk (behind the api, write
|
||||||
|
|
|
@ -35,7 +35,6 @@ import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.hbase.client.Delete;
|
import org.apache.hadoop.hbase.client.Delete;
|
||||||
import org.apache.hadoop.hbase.client.HBaseAdmin;
|
import org.apache.hadoop.hbase.client.HBaseAdmin;
|
||||||
import org.apache.hadoop.hbase.client.HConnection;
|
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.HTable;
|
||||||
import org.apache.hadoop.hbase.client.Put;
|
import org.apache.hadoop.hbase.client.Put;
|
||||||
import org.apache.hadoop.hbase.client.Result;
|
import org.apache.hadoop.hbase.client.Result;
|
||||||
|
@ -70,7 +69,8 @@ public class HBaseTestingUtility {
|
||||||
private MiniHBaseCluster hbaseCluster = null;
|
private MiniHBaseCluster hbaseCluster = null;
|
||||||
private MiniMRCluster mrCluster = null;
|
private MiniMRCluster mrCluster = null;
|
||||||
private File clusterTestBuildDir = null;
|
private File clusterTestBuildDir = null;
|
||||||
|
private HBaseAdmin hbaseAdmin = null;
|
||||||
|
|
||||||
/** System property key to get test directory value.
|
/** System property key to get test directory value.
|
||||||
*/
|
*/
|
||||||
public static final String TEST_DIRECTORY_KEY = "test.build.data";
|
public static final String TEST_DIRECTORY_KEY = "test.build.data";
|
||||||
|
@ -511,10 +511,68 @@ public class HBaseTestingUtility {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the HBase cluster
|
* Get the HBase cluster.
|
||||||
|
*
|
||||||
* @return hbase cluster
|
* @return hbase cluster
|
||||||
*/
|
*/
|
||||||
public MiniHBaseCluster getHbaseCluster() {
|
public MiniHBaseCluster getHBaseCluster() {
|
||||||
return hbaseCluster;
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -59,7 +59,7 @@ public class TestZooKeeper {
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
conf = TEST_UTIL.getConfiguration();
|
conf = TEST_UTIL.getConfiguration();
|
||||||
cluster = TEST_UTIL.getHbaseCluster();
|
cluster = TEST_UTIL.getHBaseCluster();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue