Class HBaseCluster

java.lang.Object
org.apache.hadoop.hbase.HBaseCluster
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.hadoop.conf.Configurable
Direct Known Subclasses:
MiniHBaseCluster

@Public @Deprecated public abstract class HBaseCluster extends Object implements Closeable, org.apache.hadoop.conf.Configurable
Deprecated.
since 3.0.0, will be removed in 4.0.0. Use TestingHBaseCluster instead.
This class defines methods that can help with managing HBase clusters from unit tests and system tests. There are 3 types of cluster deployments:
  • MiniHBaseCluster: each server is run in the same JVM in separate threads, used by unit tests
  • DistributedHBaseCluster: the cluster is pre-deployed, system and integration tests can interact with the cluster.
  • ProcessBasedLocalHBaseCluster: each server is deployed locally but in separate JVMs.

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.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.apache.hadoop.conf.Configuration
    Deprecated.
     
    protected ClusterMetrics
    Deprecated.
    the status of the cluster before we begin
    (package private) static final org.slf4j.Logger
    Deprecated.
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    HBaseCluster(org.apache.hadoop.conf.Configuration conf)
    Deprecated.
    Construct an HBaseCluster
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    Deprecated.
    Closes all the resources held open for this cluster.
    Deprecated.
    Returns a ClusterMetrics for this HBase cluster.
    org.apache.hadoop.conf.Configuration
    Deprecated.
     
    Deprecated.
    Returns a ClusterStatus for this HBase cluster as observed at the starting of the HBaseCluster
    Deprecated.
    Get the ServerName of region server serving the first hbase:meta region
    abstract ServerName
    getServerHoldingRegion(TableName tn, byte[] regionName)
    Deprecated.
    Get the ServerName of region server serving the specified region
    boolean
    Deprecated.
     
    abstract boolean
    isKilledRS(ServerName serverName)
    Deprecated.
    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
    Deprecated.
    Kills the datanode process if this is a distributed cluster, otherwise, this causes master to exit doing basic clean up only.
    abstract void
    killMaster(ServerName serverName)
    Deprecated.
    Kills the master process if this is a distributed cluster, otherwise, this causes master to exit doing basic clean up only.
    abstract void
    Deprecated.
    Kills the namenode process if this is a distributed cluster, otherwise, this causes master to exit doing basic clean up only.
    abstract void
    Deprecated.
    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(ServerName serverName)
    Deprecated.
    Kills the zookeeper node process if this is a distributed cluster, otherwise, this causes master to exit doing basic clean up only.
    boolean
    Deprecated.
    Restores the cluster to given state if this is a real cluster, otherwise does nothing.
    boolean
    Deprecated.
    Restores the cluster to it's initial state if this is a real cluster, otherwise does nothing.
    abstract void
    Deprecated.
    Resume the region server
    void
    setConf(org.apache.hadoop.conf.Configuration conf)
    Deprecated.
     
    abstract void
    Deprecated.
    Shut down the HBase cluster
    abstract void
    Deprecated.
    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)
    Deprecated.
    Starts a new master on the given hostname or if this is a mini/local cluster, starts a master locally.
    abstract void
    Deprecated.
    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)
    Deprecated.
    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)
    Deprecated.
    Starts a new zookeeper node on the given hostname or if this is a mini/local cluster, silently logs warning message.
    abstract void
    Deprecated.
    Stops the datanode if this is a distributed cluster, otherwise silently logs warning message.
    abstract void
    stopMaster(ServerName serverName)
    Deprecated.
    Stops the given master, by attempting a gradual stop.
    abstract void
    Deprecated.
    Stops the namenode if this is a distributed cluster, otherwise silently logs warning message.
    abstract void
    Deprecated.
    Stops the given region server, by attempting a gradual stop.
    abstract void
    stopZkNode(ServerName serverName)
    Deprecated.
    Stops the region zookeeper if this is a distributed cluster, otherwise silently logs warning message.
    abstract void
    Deprecated.
    Suspend the region server
    boolean
    Deprecated.
    Blocks until there is an active master and that master has completed initialization.
    abstract boolean
    Deprecated.
    Blocks until there is an active master and that master has completed initialization.
    void
    Deprecated.
     
    abstract void
    waitForDataNodeToStart(ServerName serverName, long timeout)
    Deprecated.
    Wait for the specified datanode to join the cluster
    abstract void
    waitForDataNodeToStop(ServerName serverName, long timeout)
    Deprecated.
    Wait for the specified datanode to stop the thread / process.
    abstract void
    waitForMasterToStop(ServerName serverName, long timeout)
    Deprecated.
    Wait for the specified master to stop the thread / process.
    void
    Deprecated.
    Wait for the namenode.
    abstract void
    waitForNameNodeToStart(ServerName serverName, long timeout)
    Deprecated.
    Wait for the specified namenode to join the cluster
    abstract void
    waitForNameNodeToStop(ServerName serverName, long timeout)
    Deprecated.
    Wait for the specified namenode to stop
    void
    waitForRegionServerToStart(String hostname, int port, long timeout)
    Deprecated.
    Wait for the specified region server to join the cluster
    abstract void
    waitForRegionServerToStop(ServerName serverName, long timeout)
    Deprecated.
    Wait for the specified region server to stop the thread / process.
    abstract void
    waitForZkNodeToStart(ServerName serverName, long timeout)
    Deprecated.
    Wait for the specified zookeeper node to join the cluster
    abstract void
    waitForZkNodeToStop(ServerName serverName, long timeout)
    Deprecated.
    Wait for the specified zookeeper node to stop the thread / process.
    abstract void
    Deprecated.
    Wait for HBase Cluster to shut down.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LOG

      static final org.slf4j.Logger LOG
      Deprecated.
    • conf

      protected org.apache.hadoop.conf.Configuration conf
      Deprecated.
    • initialClusterStatus

      Deprecated.
      the status of the cluster before we begin
  • Constructor Details

    • HBaseCluster

      public HBaseCluster(org.apache.hadoop.conf.Configuration conf)
      Deprecated.
      Construct an HBaseCluster
      Parameters:
      conf - Configuration to be used for cluster
  • Method Details

    • setConf

      public void setConf(org.apache.hadoop.conf.Configuration conf)
      Deprecated.
      Specified by:
      setConf in interface org.apache.hadoop.conf.Configurable
    • getConf

      public org.apache.hadoop.conf.Configuration getConf()
      Deprecated.
      Specified by:
      getConf in interface org.apache.hadoop.conf.Configurable
    • getClusterMetrics

      public abstract ClusterMetrics getClusterMetrics() throws IOException
      Deprecated.
      Returns a ClusterMetrics for this HBase cluster.
      Throws:
      IOException
      See Also:
    • getInitialClusterMetrics

      Deprecated.
      Returns a ClusterStatus for this HBase cluster as observed at the starting of the HBaseCluster
      Throws:
      IOException
    • startRegionServer

      public abstract void startRegionServer(String hostname, int port) throws IOException
      Deprecated.
      Starts a new region server on the given hostname or if this is a mini/local cluster, starts a region server locally.
      Parameters:
      hostname - the hostname to start the regionserver on
      Throws:
      IOException - if something goes wrong
    • killRegionServer

      public abstract void killRegionServer(ServerName serverName) throws IOException
      Deprecated.
      Kills the region server process if this is a distributed cluster, otherwise this causes the region server to exit doing basic clean up only.
      Throws:
      IOException - if something goes wrong
    • isKilledRS

      public abstract boolean isKilledRS(ServerName serverName)
      Deprecated.
      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. A concrete example of such case is - killing servers and waiting for all regions of a particular table to be assigned. We can check for server column in META table and that its value is not one of the killed servers.
    • stopRegionServer

      public abstract void stopRegionServer(ServerName serverName) throws IOException
      Deprecated.
      Stops the given region server, by attempting a gradual stop.
      Throws:
      IOException - if something goes wrong
    • waitForRegionServerToStart

      public void waitForRegionServerToStart(String hostname, int port, long timeout) throws IOException
      Deprecated.
      Wait for the specified region server to join the cluster
      Throws:
      IOException - if something goes wrong or timeout occurs
    • waitForRegionServerToStop

      public abstract void waitForRegionServerToStop(ServerName serverName, long timeout) throws IOException
      Deprecated.
      Wait for the specified region server to stop the thread / process.
      Throws:
      IOException - if something goes wrong or timeout occurs
    • suspendRegionServer

      public abstract void suspendRegionServer(ServerName serverName) throws IOException
      Deprecated.
      Suspend the region server
      Parameters:
      serverName - the hostname to suspend the regionserver on
      Throws:
      IOException - if something goes wrong
    • resumeRegionServer

      public abstract void resumeRegionServer(ServerName serverName) throws IOException
      Deprecated.
      Resume the region server
      Parameters:
      serverName - the hostname to resume the regionserver on
      Throws:
      IOException - if something goes wrong
    • startZkNode

      public abstract void startZkNode(String hostname, int port) throws IOException
      Deprecated.
      Starts a new zookeeper node on the given hostname or if this is a mini/local cluster, silently logs warning message.
      Parameters:
      hostname - the hostname to start the regionserver on
      Throws:
      IOException - if something goes wrong
    • killZkNode

      public abstract void killZkNode(ServerName serverName) throws IOException
      Deprecated.
      Kills the zookeeper node process if this is a distributed cluster, otherwise, this causes master to exit doing basic clean up only.
      Throws:
      IOException - if something goes wrong
    • stopZkNode

      public abstract void stopZkNode(ServerName serverName) throws IOException
      Deprecated.
      Stops the region zookeeper if this is a distributed cluster, otherwise silently logs warning message.
      Throws:
      IOException - if something goes wrong
    • waitForZkNodeToStart

      public abstract void waitForZkNodeToStart(ServerName serverName, long timeout) throws IOException
      Deprecated.
      Wait for the specified zookeeper node to join the cluster
      Throws:
      IOException - if something goes wrong or timeout occurs
    • waitForZkNodeToStop

      public abstract void waitForZkNodeToStop(ServerName serverName, long timeout) throws IOException
      Deprecated.
      Wait for the specified zookeeper node to stop the thread / process.
      Throws:
      IOException - if something goes wrong or timeout occurs
    • startDataNode

      public abstract void startDataNode(ServerName serverName) throws IOException
      Deprecated.
      Starts a new datanode on the given hostname or if this is a mini/local cluster, silently logs warning message.
      Throws:
      IOException - if something goes wrong
    • killDataNode

      public abstract void killDataNode(ServerName serverName) throws IOException
      Deprecated.
      Kills the datanode process if this is a distributed cluster, otherwise, this causes master to exit doing basic clean up only.
      Throws:
      IOException - if something goes wrong
    • stopDataNode

      public abstract void stopDataNode(ServerName serverName) throws IOException
      Deprecated.
      Stops the datanode if this is a distributed cluster, otherwise silently logs warning message.
      Throws:
      IOException - if something goes wrong
    • waitForDataNodeToStart

      public abstract void waitForDataNodeToStart(ServerName serverName, long timeout) throws IOException
      Deprecated.
      Wait for the specified datanode to join the cluster
      Throws:
      IOException - if something goes wrong or timeout occurs
    • waitForDataNodeToStop

      public abstract void waitForDataNodeToStop(ServerName serverName, long timeout) throws IOException
      Deprecated.
      Wait for the specified datanode to stop the thread / process.
      Throws:
      IOException - if something goes wrong or timeout occurs
    • startNameNode

      public abstract void startNameNode(ServerName serverName) throws IOException
      Deprecated.
      Starts a new namenode on the given hostname or if this is a mini/local cluster, silently logs warning message.
      Throws:
      IOException - if something goes wrong
    • killNameNode

      public abstract void killNameNode(ServerName serverName) throws IOException
      Deprecated.
      Kills the namenode process if this is a distributed cluster, otherwise, this causes master to exit doing basic clean up only.
      Throws:
      IOException - if something goes wrong
    • stopNameNode

      public abstract void stopNameNode(ServerName serverName) throws IOException
      Deprecated.
      Stops the namenode if this is a distributed cluster, otherwise silently logs warning message.
      Throws:
      IOException - if something goes wrong
    • waitForNameNodeToStart

      public abstract void waitForNameNodeToStart(ServerName serverName, long timeout) throws IOException
      Deprecated.
      Wait for the specified namenode to join the cluster
      Throws:
      IOException - if something goes wrong or timeout occurs
    • waitForNameNodeToStop

      public abstract void waitForNameNodeToStop(ServerName serverName, long timeout) throws IOException
      Deprecated.
      Wait for the specified namenode to stop
      Throws:
      IOException - if something goes wrong or timeout occurs
    • startMaster

      public abstract void startMaster(String hostname, int port) throws IOException
      Deprecated.
      Starts a new master on the given hostname or if this is a mini/local cluster, starts a master locally.
      Parameters:
      hostname - the hostname to start the master on
      Throws:
      IOException - if something goes wrong
    • killMaster

      public abstract void killMaster(ServerName serverName) throws IOException
      Deprecated.
      Kills the master process if this is a distributed cluster, otherwise, this causes master to exit doing basic clean up only.
      Throws:
      IOException - if something goes wrong
    • stopMaster

      public abstract void stopMaster(ServerName serverName) throws IOException
      Deprecated.
      Stops the given master, by attempting a gradual stop.
      Throws:
      IOException - if something goes wrong
    • waitForMasterToStop

      public abstract void waitForMasterToStop(ServerName serverName, long timeout) throws IOException
      Deprecated.
      Wait for the specified master to stop the thread / process.
      Throws:
      IOException - if something goes wrong or timeout occurs
    • waitForActiveAndReadyMaster

      public boolean waitForActiveAndReadyMaster() throws IOException
      Deprecated.
      Blocks until there is an active master and that master has completed initialization.
      Returns:
      true if an active master becomes available. false if there are no masters left.
      Throws:
      IOException - if something goes wrong or timeout occurs
    • waitForActiveAndReadyMaster

      public abstract boolean waitForActiveAndReadyMaster(long timeout) throws IOException
      Deprecated.
      Blocks until there is an active master and that master has completed initialization.
      Parameters:
      timeout - the timeout limit in ms
      Returns:
      true if an active master becomes available. false if there are no masters left.
      Throws:
      IOException
    • waitUntilShutDown

      public abstract void waitUntilShutDown() throws IOException
      Deprecated.
      Wait for HBase Cluster to shut down.
      Throws:
      IOException
    • shutdown

      public abstract void shutdown() throws IOException
      Deprecated.
      Shut down the HBase cluster
      Throws:
      IOException
    • restoreInitialStatus

      public boolean restoreInitialStatus() throws IOException
      Deprecated.
      Restores the cluster to it's initial state if this is a real cluster, otherwise does nothing. This is a best effort restore. If the servers are not reachable, or insufficient permissions, etc. restoration might be partial.
      Returns:
      whether restoration is complete
      Throws:
      IOException
    • restoreClusterMetrics

      public boolean restoreClusterMetrics(ClusterMetrics desiredStatus) throws IOException
      Deprecated.
      Restores the cluster to given state if this is a real cluster, otherwise does nothing. This is a best effort restore. If the servers are not reachable, or insufficient permissions, etc. restoration might be partial.
      Returns:
      whether restoration is complete
      Throws:
      IOException
    • getServerHoldingMeta

      Deprecated.
      Get the ServerName of region server serving the first hbase:meta region
      Throws:
      IOException
    • getServerHoldingRegion

      public abstract ServerName getServerHoldingRegion(TableName tn, byte[] regionName) throws IOException
      Deprecated.
      Get the ServerName of region server serving the specified region
      Parameters:
      regionName - Name of the region in bytes
      tn - Table name that has the region.
      Returns:
      ServerName that hosts the region or null
      Throws:
      IOException
    • isDistributedCluster

      public boolean isDistributedCluster()
      Deprecated.
      Returns:
      whether we are interacting with a distributed cluster as opposed to an in-process mini/local cluster.
    • close

      public abstract void close() throws IOException
      Deprecated.
      Closes all the resources held open for this cluster. Note that this call does not shutdown the cluster.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
      See Also:
    • waitForNamenodeAvailable

      Deprecated.
      Wait for the namenode.
      Throws:
      InterruptedException
    • waitForDatanodesRegistered

      public void waitForDatanodesRegistered(int nbDN) throws Exception
      Deprecated.
      Throws:
      Exception