@InterfaceAudience.Private class TestingHBaseClusterImpl extends Object implements TestingHBaseCluster
| Modifier and Type | Field and Description |
|---|---|
private ExecutorService |
executor |
private String |
externalDfsUri |
private String |
externalZkConnectString |
private boolean |
miniClusterRunning |
private boolean |
miniHBaseClusterRunning |
private StartMiniClusterOption |
option |
private HBaseTestingUtility |
util |
| Constructor and Description |
|---|
TestingHBaseClusterImpl(TestingHBaseClusterOption option) |
| Modifier and Type | Method and Description |
|---|---|
Optional<ServerName> |
getActiveMasterAddress()
Get the address of active master if there is one.
|
List<ServerName> |
getBackupMasterAddresses()
Get all the backup master addresses.
|
org.apache.hadoop.conf.Configuration |
getConf()
Get configuration of this cluster.
|
private int |
getMasterIndex(ServerName serverName) |
Optional<OnlineRegions> |
getOnlineRegionsInterface(ServerName serverName)
Get the server side
OnlineRegions interface for the specific region server. |
Optional<Region> |
getRegion(RegionInfo regionInfo)
Get the server side
Region interface for the specific region. |
List<ServerName> |
getRegionServerAddresses()
Get all the region server addresses.
|
private int |
getRegionServerIndex(ServerName serverName) |
boolean |
isClusterRunning()
Return whether the cluster is running.
|
boolean |
isHBaseClusterRunning()
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 |
startHBaseCluster()
Start the hbase cluster.
|
void |
startMaster()
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 |
startRegionServer()
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 |
stopHBaseCluster()
Stop the hbase cluster.
|
CompletableFuture<Void> |
stopMaster(ServerName serverName)
Stop the given master.
|
CompletableFuture<Void> |
stopRegionServer(ServerName serverName)
Stop the given region server.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreateprivate final HBaseTestingUtility util
private final StartMiniClusterOption option
private final String externalDfsUri
private final String externalZkConnectString
private final ExecutorService executor
private boolean miniClusterRunning
private boolean miniHBaseClusterRunning
TestingHBaseClusterImpl(TestingHBaseClusterOption option)
public org.apache.hadoop.conf.Configuration getConf()
TestingHBaseClusterConfiguration to create
Connection for accessing the testing cluster.getConf in interface TestingHBaseClusterprivate int getRegionServerIndex(ServerName serverName)
private int getMasterIndex(ServerName serverName)
private void join(Thread thread, CompletableFuture<?> future)
public CompletableFuture<Void> stopMaster(ServerName serverName) throws Exception
TestingHBaseClusterCompletableFuture to wait on the master quit. The differences
comparing to Admin.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.stopMaster in interface TestingHBaseClusterExceptionpublic CompletableFuture<Void> stopRegionServer(ServerName serverName) throws Exception
TestingHBaseClusterCompletableFuture to wait on the master quit. The difference
comparing to Admin.stopMaster() is that this method does
not always fail since we do not use rpc to stop the region server.stopRegionServer in interface TestingHBaseClusterExceptionpublic void stopHBaseCluster() throws Exception
TestingHBaseClusterTestingHBaseCluster.start() first before calling this method, otherwise an
IllegalStateException will be thrown. If the hbase is not running because you have
already stopped the cluster, an IllegalStateException will be thrown too.stopHBaseCluster in interface TestingHBaseClusterExceptionpublic void startHBaseCluster() throws Exception
TestingHBaseClusterTestingHBaseCluster.stopHBaseCluster(). If
the cluster is already running or you have not called TestingHBaseCluster.start() yet, an
IllegalStateException will be thrown.startHBaseCluster in interface TestingHBaseClusterExceptionpublic void start() throws Exception
TestingHBaseClusterTestingHBaseCluster.stop() to
shutdown the cluster completely, and then you can call this method to start the whole cluster
again. An IllegalStateException will be thrown if you call this method incorrectly.start in interface TestingHBaseClusterExceptionpublic void stop() throws Exception
TestingHBaseClusterTestingHBaseCluster.start(), otherwise an
IllegalStateException will be thrown.stop in interface TestingHBaseClusterExceptionpublic boolean isHBaseClusterRunning()
TestingHBaseClusterisHBaseClusterRunning in interface TestingHBaseClusterpublic boolean isClusterRunning()
TestingHBaseClusterTestingHBaseCluster.start() and have not called
TestingHBaseCluster.stop() yet. If you want to make sure the hbase cluster is running, use
TestingHBaseCluster.isHBaseClusterRunning().isClusterRunning in interface TestingHBaseClusterpublic void startMaster() throws Exception
TestingHBaseClusterstartMaster in interface TestingHBaseClusterExceptionpublic void startMaster(String hostname, int port) throws Exception
TestingHBaseClusterstartMaster in interface TestingHBaseClusterExceptionpublic void startRegionServer() throws Exception
TestingHBaseClusterstartRegionServer in interface TestingHBaseClusterExceptionpublic void startRegionServer(String hostname, int port) throws Exception
TestingHBaseClusterstartRegionServer in interface TestingHBaseClusterExceptionpublic Optional<ServerName> getActiveMasterAddress()
TestingHBaseClustergetActiveMasterAddress in interface TestingHBaseClusterpublic List<ServerName> getBackupMasterAddresses()
TestingHBaseClustergetBackupMasterAddresses in interface TestingHBaseClusterpublic List<ServerName> getRegionServerAddresses()
TestingHBaseClustergetRegionServerAddresses in interface TestingHBaseClusterpublic Optional<Region> getRegion(RegionInfo regionInfo)
TestingHBaseClusterRegion interface for the specific region.
This is used for CPs to test something which can only be accessed at server side, such as tags.getRegion in interface TestingHBaseClusterpublic Optional<OnlineRegions> getOnlineRegionsInterface(ServerName serverName)
TestingHBaseClusterOnlineRegions interface for the specific region server.
You could list the addresses of all the region server through the
TestingHBaseCluster.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.getOnlineRegionsInterface in interface TestingHBaseClusterCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.