Package org.apache.hadoop.hbase.testing
Class TestingHBaseClusterImpl
java.lang.Object
org.apache.hadoop.hbase.testing.TestingHBaseClusterImpl
- All Implemented Interfaces:
TestingHBaseCluster
-
Field Summary
Modifier and TypeFieldDescriptionprivate final ExecutorService
private final String
private final String
private boolean
private boolean
private final StartTestingClusterOption
private final HBaseTestingUtil
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGet 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.private int
getMasterIndex
(ServerName serverName) 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.private int
getRegionServerIndex
(ServerName serverName) boolean
Return whether the cluster is running.boolean
Return whether the hbase cluster is running.private void
join
(Thread thread, CompletableFuture<?> future) 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.
-
Field Details
-
util
-
option
-
externalDfsUri
-
externalZkConnectString
-
executor
-
miniClusterRunning
-
miniHBaseClusterRunning
-
-
Constructor Details
-
TestingHBaseClusterImpl
-
-
Method Details
-
getConf
Description copied from interface:TestingHBaseCluster
Get configuration of this cluster. You could use the returnedConfiguration
to createConnection
for accessing the testing cluster.- Specified by:
getConf
in interfaceTestingHBaseCluster
-
getRegionServerIndex
-
getMasterIndex
-
join
-
stopMaster
Description copied from interface:TestingHBaseCluster
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.- Specified by:
stopMaster
in interfaceTestingHBaseCluster
- Throws:
Exception
-
stopRegionServer
Description copied from interface:TestingHBaseCluster
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.- Specified by:
stopRegionServer
in interfaceTestingHBaseCluster
- Throws:
Exception
-
stopHBaseCluster
Description copied from interface:TestingHBaseCluster
Stop the hbase cluster. You need to callTestingHBaseCluster.start()
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.- Specified by:
stopHBaseCluster
in interfaceTestingHBaseCluster
- Throws:
Exception
-
startHBaseCluster
Description copied from interface:TestingHBaseCluster
Start the hbase cluster. This is used to start the hbase cluster again after you callTestingHBaseCluster.stopHBaseCluster()
. If the cluster is already running or you have not calledTestingHBaseCluster.start()
yet, anIllegalStateException
will be thrown.- Specified by:
startHBaseCluster
in interfaceTestingHBaseCluster
- Throws:
Exception
-
start
Description copied from interface:TestingHBaseCluster
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 calledTestingHBaseCluster.stop()
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.- Specified by:
start
in interfaceTestingHBaseCluster
- Throws:
Exception
-
stop
Description copied from interface:TestingHBaseCluster
Stop the whole mini cluster, including zookeeper cluster, dfs cluster and hbase cluster. You can only call this method after callingTestingHBaseCluster.start()
, otherwise anIllegalStateException
will be thrown.- Specified by:
stop
in interfaceTestingHBaseCluster
- Throws:
Exception
-
isHBaseClusterRunning
Description copied from interface:TestingHBaseCluster
Return whether the hbase cluster is running.- Specified by:
isHBaseClusterRunning
in interfaceTestingHBaseCluster
-
isClusterRunning
Description copied from interface:TestingHBaseCluster
Return whether the cluster is running. Notice that, this only means you have calledTestingHBaseCluster.start()
and have not calledTestingHBaseCluster.stop()
yet. If you want to make sure the hbase cluster is running, useTestingHBaseCluster.isHBaseClusterRunning()
.- Specified by:
isClusterRunning
in interfaceTestingHBaseCluster
-
startMaster
Description copied from interface:TestingHBaseCluster
Start a new master with localhost and random port.- Specified by:
startMaster
in interfaceTestingHBaseCluster
- Throws:
Exception
-
startMaster
Description copied from interface:TestingHBaseCluster
Start a new master bind on the given host and port.- Specified by:
startMaster
in interfaceTestingHBaseCluster
- Throws:
Exception
-
startRegionServer
Description copied from interface:TestingHBaseCluster
Start a new region server with localhost and random port.- Specified by:
startRegionServer
in interfaceTestingHBaseCluster
- Throws:
Exception
-
startRegionServer
Description copied from interface:TestingHBaseCluster
Start a new region server bind on the given host and port.- Specified by:
startRegionServer
in interfaceTestingHBaseCluster
- Throws:
Exception
-
getActiveMasterAddress
Description copied from interface:TestingHBaseCluster
Get the address of active master if there is one.- Specified by:
getActiveMasterAddress
in interfaceTestingHBaseCluster
-
getBackupMasterAddresses
Description copied from interface:TestingHBaseCluster
Get all the backup master addresses.- Specified by:
getBackupMasterAddresses
in interfaceTestingHBaseCluster
-
getRegionServerAddresses
Description copied from interface:TestingHBaseCluster
Get all the region server addresses.- Specified by:
getRegionServerAddresses
in interfaceTestingHBaseCluster
-
getRegion
Description copied from interface:TestingHBaseCluster
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.- Specified by:
getRegion
in interfaceTestingHBaseCluster
-
getOnlineRegionsInterface
Description copied from interface:TestingHBaseCluster
Get the server sideOnlineRegions
interface for the specific region server. You could list the addresses of all the region server through theTestingHBaseCluster.getRegionServerAddresses()
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.- Specified by:
getOnlineRegionsInterface
in interfaceTestingHBaseCluster
-