@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, wait
create
private 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()
TestingHBaseCluster
Configuration
to create
Connection
for accessing the testing cluster.getConf
in interface TestingHBaseCluster
private int getRegionServerIndex(ServerName serverName)
private int getMasterIndex(ServerName serverName)
private void join(Thread thread, CompletableFuture<?> future)
public CompletableFuture<Void> stopMaster(ServerName serverName) throws Exception
TestingHBaseCluster
CompletableFuture
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 TestingHBaseCluster
Exception
public CompletableFuture<Void> stopRegionServer(ServerName serverName) throws Exception
TestingHBaseCluster
CompletableFuture
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 TestingHBaseCluster
Exception
public void stopHBaseCluster() throws Exception
TestingHBaseCluster
TestingHBaseCluster.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 TestingHBaseCluster
Exception
public void startHBaseCluster() throws Exception
TestingHBaseCluster
TestingHBaseCluster.stopHBaseCluster()
. If
the cluster is already running or you have not called TestingHBaseCluster.start()
yet, an
IllegalStateException
will be thrown.startHBaseCluster
in interface TestingHBaseCluster
Exception
public void start() throws Exception
TestingHBaseCluster
TestingHBaseCluster.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 TestingHBaseCluster
Exception
public void stop() throws Exception
TestingHBaseCluster
TestingHBaseCluster.start()
, otherwise an
IllegalStateException
will be thrown.stop
in interface TestingHBaseCluster
Exception
public boolean isHBaseClusterRunning()
TestingHBaseCluster
isHBaseClusterRunning
in interface TestingHBaseCluster
public boolean isClusterRunning()
TestingHBaseCluster
TestingHBaseCluster.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 TestingHBaseCluster
public void startMaster() throws Exception
TestingHBaseCluster
startMaster
in interface TestingHBaseCluster
Exception
public void startMaster(String hostname, int port) throws Exception
TestingHBaseCluster
startMaster
in interface TestingHBaseCluster
Exception
public void startRegionServer() throws Exception
TestingHBaseCluster
startRegionServer
in interface TestingHBaseCluster
Exception
public void startRegionServer(String hostname, int port) throws Exception
TestingHBaseCluster
startRegionServer
in interface TestingHBaseCluster
Exception
public Optional<ServerName> getActiveMasterAddress()
TestingHBaseCluster
getActiveMasterAddress
in interface TestingHBaseCluster
public List<ServerName> getBackupMasterAddresses()
TestingHBaseCluster
getBackupMasterAddresses
in interface TestingHBaseCluster
public List<ServerName> getRegionServerAddresses()
TestingHBaseCluster
getRegionServerAddresses
in interface TestingHBaseCluster
public Optional<Region> getRegion(RegionInfo regionInfo)
TestingHBaseCluster
Region
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 TestingHBaseCluster
public Optional<OnlineRegions> getOnlineRegionsInterface(ServerName serverName)
TestingHBaseCluster
OnlineRegions
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 TestingHBaseCluster
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.