@InterfaceAudience.Public public abstract class HBaseCluster extends Object implements Closeable, org.apache.hadoop.conf.Configurable
HBaseCluster unifies the way tests interact with the cluster, so that the same test can be run against a mini-cluster during unit test execution, or a distributed cluster having tens/hundreds of nodes during execution of integration tests.
HBaseCluster exposes client-side public interfaces to tests, so that tests does not assume running in a particular mode. Not all the tests are suitable to be run on an actual cluster, and some tests will still need to mock stuff and introspect internal state. For those use cases from unit tests, or if more control is needed, you can use the subclasses directly. In that sense, this class does not abstract away every interface that MiniHBaseCluster or DistributedHBaseCluster provide.
Modifier and Type | Field and Description |
---|---|
protected org.apache.hadoop.conf.Configuration |
conf |
protected org.apache.hadoop.hbase.ClusterMetrics |
initialClusterStatus
the status of the cluster before we begin
|
(package private) static org.slf4j.Logger |
LOG |
Constructor and Description |
---|
HBaseCluster(org.apache.hadoop.conf.Configuration conf)
Construct an HBaseCluster
|
Modifier and Type | Method and Description |
---|---|
abstract void |
close()
Closes all the resources held open for this cluster.
|
abstract org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService.BlockingInterface |
getAdminProtocol(org.apache.hadoop.hbase.ServerName serverName)
Returns an AdminProtocol interface to the regionserver
|
abstract org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ClientService.BlockingInterface |
getClientProtocol(org.apache.hadoop.hbase.ServerName serverName)
Returns a ClientProtocol interface to the regionserver
|
abstract org.apache.hadoop.hbase.ClusterMetrics |
getClusterMetrics()
Returns a ClusterMetrics for this HBase cluster.
|
org.apache.hadoop.conf.Configuration |
getConf() |
org.apache.hadoop.hbase.ClusterMetrics |
getInitialClusterMetrics()
Returns a ClusterStatus for this HBase cluster as observed at the starting of the HBaseCluster
|
abstract org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MasterService.BlockingInterface |
getMasterAdminService()
Returns an
MasterService.BlockingInterface to the active master |
org.apache.hadoop.hbase.ServerName |
getServerHoldingMeta()
Get the ServerName of region server serving the first hbase:meta region
|
abstract org.apache.hadoop.hbase.ServerName |
getServerHoldingRegion(org.apache.hadoop.hbase.TableName tn,
byte[] regionName)
Get the ServerName of region server serving the specified region
|
boolean |
isDistributedCluster() |
abstract boolean |
isKilledRS(org.apache.hadoop.hbase.ServerName serverName)
Keeping track of killed servers and being able to check if a particular server was killed makes
it possible to do fault tolerance testing for dead servers in a deterministic way.
|
abstract void |
killDataNode(org.apache.hadoop.hbase.ServerName serverName)
Kills the datanode process if this is a distributed cluster, otherwise, this causes master to
exit doing basic clean up only.
|
abstract void |
killMaster(org.apache.hadoop.hbase.ServerName serverName)
Kills the master process if this is a distributed cluster, otherwise, this causes master to
exit doing basic clean up only.
|
abstract void |
killNameNode(org.apache.hadoop.hbase.ServerName serverName)
Kills the namenode process if this is a distributed cluster, otherwise, this causes master to
exit doing basic clean up only.
|
abstract void |
killRegionServer(org.apache.hadoop.hbase.ServerName serverName)
Kills the region server process if this is a distributed cluster, otherwise this causes the
region server to exit doing basic clean up only.
|
abstract void |
killZkNode(org.apache.hadoop.hbase.ServerName serverName)
Kills the zookeeper node process if this is a distributed cluster, otherwise, this causes
master to exit doing basic clean up only.
|
boolean |
restoreClusterMetrics(org.apache.hadoop.hbase.ClusterMetrics desiredStatus)
Restores the cluster to given state if this is a real cluster, otherwise does nothing.
|
boolean |
restoreInitialStatus()
Restores the cluster to it's initial state if this is a real cluster, otherwise does nothing.
|
abstract void |
resumeRegionServer(org.apache.hadoop.hbase.ServerName serverName)
Resume the region server
|
void |
setConf(org.apache.hadoop.conf.Configuration conf) |
abstract void |
shutdown()
Shut down the HBase cluster
|
abstract void |
startDataNode(org.apache.hadoop.hbase.ServerName serverName)
Starts a new datanode on the given hostname or if this is a mini/local cluster, silently logs
warning message.
|
abstract void |
startMaster(String hostname,
int port)
Starts a new master on the given hostname or if this is a mini/local cluster, starts a master
locally.
|
abstract void |
startNameNode(org.apache.hadoop.hbase.ServerName serverName)
Starts a new namenode on the given hostname or if this is a mini/local cluster, silently logs
warning message.
|
abstract void |
startRegionServer(String hostname,
int port)
Starts a new region server on the given hostname or if this is a mini/local cluster, starts a
region server locally.
|
abstract void |
startZkNode(String hostname,
int port)
Starts a new zookeeper node on the given hostname or if this is a mini/local cluster, silently
logs warning message.
|
abstract void |
stopDataNode(org.apache.hadoop.hbase.ServerName serverName)
Stops the datanode if this is a distributed cluster, otherwise silently logs warning message.
|
abstract void |
stopMaster(org.apache.hadoop.hbase.ServerName serverName)
Stops the given master, by attempting a gradual stop.
|
abstract void |
stopNameNode(org.apache.hadoop.hbase.ServerName serverName)
Stops the namenode if this is a distributed cluster, otherwise silently logs warning message.
|
abstract void |
stopRegionServer(org.apache.hadoop.hbase.ServerName serverName)
Stops the given region server, by attempting a gradual stop.
|
abstract void |
stopZkNode(org.apache.hadoop.hbase.ServerName serverName)
Stops the region zookeeper if this is a distributed cluster, otherwise silently logs warning
message.
|
abstract void |
suspendRegionServer(org.apache.hadoop.hbase.ServerName serverName)
Suspend the region server
|
boolean |
waitForActiveAndReadyMaster()
Blocks until there is an active master and that master has completed initialization.
|
abstract boolean |
waitForActiveAndReadyMaster(long timeout)
Blocks until there is an active master and that master has completed initialization.
|
void |
waitForDatanodesRegistered(int nbDN) |
abstract void |
waitForDataNodeToStart(org.apache.hadoop.hbase.ServerName serverName,
long timeout)
Wait for the specified datanode to join the cluster
|
abstract void |
waitForDataNodeToStop(org.apache.hadoop.hbase.ServerName serverName,
long timeout)
Wait for the specified datanode to stop the thread / process.
|
abstract void |
waitForMasterToStop(org.apache.hadoop.hbase.ServerName serverName,
long timeout)
Wait for the specified master to stop the thread / process.
|
void |
waitForNamenodeAvailable()
Wait for the namenode.
|
abstract void |
waitForNameNodeToStart(org.apache.hadoop.hbase.ServerName serverName,
long timeout)
Wait for the specified namenode to join the cluster
|
abstract void |
waitForNameNodeToStop(org.apache.hadoop.hbase.ServerName serverName,
long timeout)
Wait for the specified namenode to stop
|
void |
waitForRegionServerToStart(String hostname,
int port,
long timeout)
Wait for the specified region server to join the cluster
|
abstract void |
waitForRegionServerToStop(org.apache.hadoop.hbase.ServerName serverName,
long timeout)
Wait for the specified region server to stop the thread / process.
|
abstract void |
waitForZkNodeToStart(org.apache.hadoop.hbase.ServerName serverName,
long timeout)
Wait for the specified zookeeper node to join the cluster
|
abstract void |
waitForZkNodeToStop(org.apache.hadoop.hbase.ServerName serverName,
long timeout)
Wait for the specified zookeeper node to stop the thread / process.
|
abstract void |
waitUntilShutDown()
Wait for HBase Cluster to shut down.
|
static final org.slf4j.Logger LOG
protected org.apache.hadoop.conf.Configuration conf
protected org.apache.hadoop.hbase.ClusterMetrics initialClusterStatus
public HBaseCluster(org.apache.hadoop.conf.Configuration conf)
conf
- Configuration to be used for clusterpublic void setConf(org.apache.hadoop.conf.Configuration conf)
setConf
in interface org.apache.hadoop.conf.Configurable
public org.apache.hadoop.conf.Configuration getConf()
getConf
in interface org.apache.hadoop.conf.Configurable
public abstract org.apache.hadoop.hbase.ClusterMetrics getClusterMetrics() throws IOException
IOException
getInitialClusterMetrics()
public org.apache.hadoop.hbase.ClusterMetrics getInitialClusterMetrics() throws IOException
IOException
public abstract org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MasterService.BlockingInterface getMasterAdminService() throws IOException
MasterService.BlockingInterface
to the active masterIOException
public abstract org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService.BlockingInterface getAdminProtocol(org.apache.hadoop.hbase.ServerName serverName) throws IOException
IOException
public abstract org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ClientService.BlockingInterface getClientProtocol(org.apache.hadoop.hbase.ServerName serverName) throws IOException
IOException
public abstract void startRegionServer(String hostname, int port) throws IOException
hostname
- the hostname to start the regionserver onIOException
- if something goes wrongpublic abstract void killRegionServer(org.apache.hadoop.hbase.ServerName serverName) throws IOException
IOException
- if something goes wrongpublic abstract boolean isKilledRS(org.apache.hadoop.hbase.ServerName serverName)
public abstract void stopRegionServer(org.apache.hadoop.hbase.ServerName serverName) throws IOException
IOException
- if something goes wrongpublic void waitForRegionServerToStart(String hostname, int port, long timeout) throws IOException
IOException
- if something goes wrong or timeout occurspublic abstract void waitForRegionServerToStop(org.apache.hadoop.hbase.ServerName serverName, long timeout) throws IOException
IOException
- if something goes wrong or timeout occurspublic abstract void suspendRegionServer(org.apache.hadoop.hbase.ServerName serverName) throws IOException
serverName
- the hostname to suspend the regionserver onIOException
- if something goes wrongpublic abstract void resumeRegionServer(org.apache.hadoop.hbase.ServerName serverName) throws IOException
serverName
- the hostname to resume the regionserver onIOException
- if something goes wrongpublic abstract void startZkNode(String hostname, int port) throws IOException
hostname
- the hostname to start the regionserver onIOException
- if something goes wrongpublic abstract void killZkNode(org.apache.hadoop.hbase.ServerName serverName) throws IOException
IOException
- if something goes wrongpublic abstract void stopZkNode(org.apache.hadoop.hbase.ServerName serverName) throws IOException
IOException
- if something goes wrongpublic abstract void waitForZkNodeToStart(org.apache.hadoop.hbase.ServerName serverName, long timeout) throws IOException
IOException
- if something goes wrong or timeout occurspublic abstract void waitForZkNodeToStop(org.apache.hadoop.hbase.ServerName serverName, long timeout) throws IOException
IOException
- if something goes wrong or timeout occurspublic abstract void startDataNode(org.apache.hadoop.hbase.ServerName serverName) throws IOException
IOException
- if something goes wrongpublic abstract void killDataNode(org.apache.hadoop.hbase.ServerName serverName) throws IOException
IOException
- if something goes wrongpublic abstract void stopDataNode(org.apache.hadoop.hbase.ServerName serverName) throws IOException
IOException
- if something goes wrongpublic abstract void waitForDataNodeToStart(org.apache.hadoop.hbase.ServerName serverName, long timeout) throws IOException
IOException
- if something goes wrong or timeout occurspublic abstract void waitForDataNodeToStop(org.apache.hadoop.hbase.ServerName serverName, long timeout) throws IOException
IOException
- if something goes wrong or timeout occurspublic abstract void startNameNode(org.apache.hadoop.hbase.ServerName serverName) throws IOException
IOException
- if something goes wrongpublic abstract void killNameNode(org.apache.hadoop.hbase.ServerName serverName) throws IOException
IOException
- if something goes wrongpublic abstract void stopNameNode(org.apache.hadoop.hbase.ServerName serverName) throws IOException
IOException
- if something goes wrongpublic abstract void waitForNameNodeToStart(org.apache.hadoop.hbase.ServerName serverName, long timeout) throws IOException
IOException
- if something goes wrong or timeout occurspublic abstract void waitForNameNodeToStop(org.apache.hadoop.hbase.ServerName serverName, long timeout) throws IOException
IOException
- if something goes wrong or timeout occurspublic abstract void startMaster(String hostname, int port) throws IOException
hostname
- the hostname to start the master onIOException
- if something goes wrongpublic abstract void killMaster(org.apache.hadoop.hbase.ServerName serverName) throws IOException
IOException
- if something goes wrongpublic abstract void stopMaster(org.apache.hadoop.hbase.ServerName serverName) throws IOException
IOException
- if something goes wrongpublic abstract void waitForMasterToStop(org.apache.hadoop.hbase.ServerName serverName, long timeout) throws IOException
IOException
- if something goes wrong or timeout occurspublic boolean waitForActiveAndReadyMaster() throws IOException
IOException
- if something goes wrong or timeout occurspublic abstract boolean waitForActiveAndReadyMaster(long timeout) throws IOException
timeout
- the timeout limit in msIOException
public abstract void waitUntilShutDown() throws IOException
IOException
public abstract void shutdown() throws IOException
IOException
public boolean restoreInitialStatus() throws IOException
IOException
public boolean restoreClusterMetrics(org.apache.hadoop.hbase.ClusterMetrics desiredStatus) throws IOException
IOException
public org.apache.hadoop.hbase.ServerName getServerHoldingMeta() throws IOException
IOException
public abstract org.apache.hadoop.hbase.ServerName getServerHoldingRegion(org.apache.hadoop.hbase.TableName tn, byte[] regionName) throws IOException
regionName
- Name of the region in bytestn
- Table name that has the region.IOException
public boolean isDistributedCluster()
public abstract void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
shutdown()
public void waitForNamenodeAvailable() throws InterruptedException
InterruptedException
public void waitForDatanodesRegistered(int nbDN) throws Exception
Exception
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.