Package org.apache.hadoop.hbase.testing
Interface TestingHBaseCluster
- All Known Implementing Classes:
TestingHBaseClusterImpl
A mini hbase cluster used for testing.
It will also start the necessary zookeeper cluster and dfs cluster. But we will not provide
methods for controlling the zookeeper cluster and dfs cluster, as end users do not need to test
the HBase behavior when these systems are broken.
The implementation is not required to be thread safe, so do not call different methods
concurrently.
-
Method Summary
Modifier and TypeMethodDescriptionstatic TestingHBaseCluster
create
(TestingHBaseClusterOption option) Create aTestingHBaseCluster
.Get the address of active master if there is one.Get all the backup master addresses.org.apache.hadoop.conf.Configuration
getConf()
Get configuration of this cluster.getOnlineRegionsInterface
(ServerName serverName) Get the server sideOnlineRegions
interface for the specific region server.getRegion
(RegionInfo regionInfo) Get the server sideRegion
interface for the specific region.Get all the region server addresses.boolean
Return whether the cluster is running.boolean
Return whether the hbase cluster is running.void
start()
Start the whole mini cluster, including zookeeper cluster, dfs cluster and hbase cluster.void
Start the hbase cluster.void
Start a new master with localhost and random port.void
startMaster
(String hostname, int port) Start a new master bind on the given host and port.void
Start a new region server with localhost and random port.void
startRegionServer
(String hostname, int port) Start a new region server bind on the given host and port.void
stop()
Stop the whole mini cluster, including zookeeper cluster, dfs cluster and hbase cluster.void
Stop the hbase cluster.stopMaster
(ServerName serverName) Stop the given master.stopRegionServer
(ServerName serverName) Stop the given region server.
-
Method Details
-
getConf
org.apache.hadoop.conf.Configuration getConf()Get configuration of this cluster. You could use the returnedConfiguration
to createConnection
for accessing the testing cluster. -
startMaster
Start a new master with localhost and random port.- Throws:
Exception
-
startMaster
Start a new master bind on the given host and port.- Throws:
Exception
-
stopMaster
Stop the given master. Wait on the returnedCompletableFuture
to wait on the master quit. The differences comparing toAdmin.stopMaster()
is that first, we could also stop backup masters here, second, this method does not always fail since we do not use rpc to stop the master.- Throws:
Exception
-
startRegionServer
Start a new region server with localhost and random port.- Throws:
Exception
-
startRegionServer
Start a new region server bind on the given host and port.- Throws:
Exception
-
stopRegionServer
Stop the given region server. Wait on the returnedCompletableFuture
to wait on the master quit. The difference comparing toAdmin.stopMaster()
is that this method does not always fail since we do not use rpc to stop the region server.- Throws:
Exception
-
stopHBaseCluster
Stop the hbase cluster. You need to callstart()
first before calling this method, otherwise anIllegalStateException
will be thrown. If the hbase is not running because you have already stopped the cluster, anIllegalStateException
will be thrown too.- Throws:
Exception
-
startHBaseCluster
Start the hbase cluster. This is used to start the hbase cluster again after you callstopHBaseCluster()
. If the cluster is already running or you have not calledstart()
yet, anIllegalStateException
will be thrown.- Throws:
Exception
-
isHBaseClusterRunning
boolean isHBaseClusterRunning()Return whether the hbase cluster is running. -
start
Start the whole mini cluster, including zookeeper cluster, dfs cluster and hbase cluster. You can only call this method once at the beginning, unless you have calledstop()
to shutdown the cluster completely, and then you can call this method to start the whole cluster again. AnIllegalStateException
will be thrown if you call this method incorrectly.- Throws:
Exception
-
getActiveMasterAddress
Get the address of active master if there is one. -
getBackupMasterAddresses
Get all the backup master addresses. -
getRegionServerAddresses
Get all the region server addresses. -
getRegion
Get the server sideRegion
interface for the specific region. This is used for CPs to test something which can only be accessed at server side, such as tags. -
getOnlineRegionsInterface
@LimitedPrivate("Coprocesssor") Optional<OnlineRegions> getOnlineRegionsInterface(ServerName serverName) Get the server sideOnlineRegions
interface for the specific region server. You could list the addresses of all the region server through thegetRegionServerAddresses()
method. This is used for CPs to test something which can only be accessed at server side, such as tags. And also you could use the returned interface to get all regions on this region server, etc. -
isClusterRunning
boolean isClusterRunning()Return whether the cluster is running. Notice that, this only means you have calledstart()
and have not calledstop()
yet. If you want to make sure the hbase cluster is running, useisHBaseClusterRunning()
. -
stop
Stop the whole mini cluster, including zookeeper cluster, dfs cluster and hbase cluster. You can only call this method after callingstart()
, otherwise anIllegalStateException
will be thrown.- Throws:
Exception
-
create
Create aTestingHBaseCluster
. You need to callstart()
of the returnedTestingHBaseCluster
to actually start the mini testing cluster.
-