Class MiniHBaseCluster

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

@Public public class MiniHBaseCluster extends HBaseCluster
This class creates a single process HBase cluster. each server. The master uses the 'default' FileSystem. The RegionServers, if we are running on DistributedFilesystem, create a FileSystem instance each and will close down their instance on the way out.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Subclass so can get at protected methods (none at moment).
    (package private) static class 
    Alternate shutdown hook.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    org.apache.hadoop.hbase.LocalHBaseCluster
     
    private static int
     
    private static final org.slf4j.Logger
     

    Fields inherited from class org.apache.hadoop.hbase.HBaseCluster

    conf, initialClusterStatus
  • Constructor Summary

    Constructors
    Constructor
    Description
    MiniHBaseCluster(org.apache.hadoop.conf.Configuration conf, int numRegionServers)
    Start a MiniHBaseCluster.
    MiniHBaseCluster(org.apache.hadoop.conf.Configuration conf, int numMasters, int numRegionServers)
    Start a MiniHBaseCluster.
    MiniHBaseCluster(org.apache.hadoop.conf.Configuration conf, int numMasters, int numAlwaysStandByMasters, int numRegionServers, List<Integer> rsPorts, Class<? extends org.apache.hadoop.hbase.master.HMaster> masterClass, Class<? extends MiniHBaseCluster.MiniHBaseClusterRegionServer> regionserverClass)
     
    MiniHBaseCluster(org.apache.hadoop.conf.Configuration conf, int numMasters, int numRegionServers, Class<? extends org.apache.hadoop.hbase.master.HMaster> masterClass, Class<? extends MiniHBaseCluster.MiniHBaseClusterRegionServer> regionserverClass)
    Start a MiniHBaseCluster.
  • Method Summary

    Modifier and Type
    Method
    Description
    abortMaster(int serverNumber)
    Cause a master to exit without shutting down entire cluster.
    abortRegionServer(int serverNumber)
    Cause a region server to exit doing basic clean up only on its way out.
    void
    Closes all the resources held open for this cluster.
    void
    compact(boolean major)
    Call flushCache on all regions on all participating regionservers.
    void
    compact(org.apache.hadoop.hbase.TableName tableName, boolean major)
    Call flushCache on all regions of the specified table.
    long
    Counts the total numbers of regions being served by the currently online region servers by asking each how many regions they have.
    private void
    executeFlush(org.apache.hadoop.hbase.regionserver.HRegion region)
     
    List<org.apache.hadoop.hbase.regionserver.HRegion>
    findRegionsForTable(org.apache.hadoop.hbase.TableName tableName)
     
    void
    Call flushCache on all regions on all participating regionservers.
    void
    flushcache(org.apache.hadoop.hbase.TableName tableName)
    Call flushCache on all regions of the specified table.
    org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService.BlockingInterface
    getAdminProtocol(org.apache.hadoop.hbase.ServerName serverName)
    Returns an AdminProtocol interface to the regionserver
    org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ClientService.BlockingInterface
    getClientProtocol(org.apache.hadoop.hbase.ServerName serverName)
    Returns a ClientProtocol interface to the regionserver
    org.apache.hadoop.hbase.ClusterMetrics
    Returns a ClusterMetrics for this HBase cluster.
    org.apache.hadoop.hbase.ClusterStatus
    Deprecated.
    As of release 2.0.0, this will be removed in HBase 3.0.0 Use getClusterMetrics() instead.
    org.apache.hadoop.conf.Configuration
     
    List<org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread>
    Returns List of live master threads (skips the aborted and the killed)
    List<org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread>
    Returns List of live region server threads (skips the aborted and the killed)
    org.apache.hadoop.hbase.master.HMaster
    Returns the current active master, if available.
    org.apache.hadoop.hbase.master.HMaster
    getMaster(int serverNumber)
    Returns the master at the specified index, if available.
    org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MasterService.BlockingInterface
    Returns the current active master, if available.
    protected int
    getMasterIndex(org.apache.hadoop.hbase.ServerName serverName)
     
    org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread
    Returns the current active master thread, if available.
    List<org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread>
    Returns List of master threads.
    int
    Returns Number of live region servers in the cluster currently.
    List<org.apache.hadoop.hbase.regionserver.HRegion>
    getRegions(byte[] tableName)
     
    List<org.apache.hadoop.hbase.regionserver.HRegion>
    getRegions(org.apache.hadoop.hbase.TableName tableName)
     
    org.apache.hadoop.hbase.regionserver.HRegionServer
    getRegionServer(int serverNumber)
    Grab a numbered region server of your choice.
    org.apache.hadoop.hbase.regionserver.HRegionServer
    getRegionServer(org.apache.hadoop.hbase.ServerName serverName)
     
    protected int
    getRegionServerIndex(org.apache.hadoop.hbase.ServerName serverName)
     
    List<org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread>
     
    org.apache.hadoop.hbase.ServerName
    getServerHoldingRegion(org.apache.hadoop.hbase.TableName tn, byte[] regionName)
    Get the ServerName of region server serving the specified region
    int
    getServerWith(byte[] regionName)
    Get the location of the specified region
    int
     
    private void
    init(int nMasterNodes, int numAlwaysStandByMasters, int nRegionNodes, List<Integer> rsPorts, Class<? extends org.apache.hadoop.hbase.master.HMaster> masterClass, Class<? extends MiniHBaseCluster.MiniHBaseClusterRegionServer> regionserverClass)
     
    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.
    void
    Wait for Mini HBase Cluster to shut down.
    void
    Do a simulated kill all masters and regionservers.
    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.
    void
    killJournalNode(org.apache.hadoop.hbase.ServerName serverName)
    Kills the journalnode process if this is a distributed cluster, otherwise, this causes master to exit doing basic clean up only.
    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.
    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.
    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.
    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.
    org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread
    resumeRegionServer(int serverNumber)
    Resume the specified region server
    void
    resumeRegionServer(org.apache.hadoop.hbase.ServerName serverName)
    Resume the region server
    void
    Shut down the mini HBase cluster
    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.
    void
    startJournalNode(org.apache.hadoop.hbase.ServerName serverName)
    Starts a new journalnode on the given hostname or if this is a mini/local cluster, silently logs warning message.
    org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread
    Starts a master thread running
    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.
    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.
    org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread
    Starts a region server thread running
    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.
    private org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread
    startRegionServer(org.apache.hadoop.conf.Configuration configuration)
     
    org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread
    Starts a region server thread and waits until its processed by master.
    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.
    void
    stopDataNode(org.apache.hadoop.hbase.ServerName serverName)
    Stops the datanode if this is a distributed cluster, otherwise silently logs warning message.
    void
    stopJournalNode(org.apache.hadoop.hbase.ServerName serverName)
    Stops the journalnode if this is a distributed cluster, otherwise silently logs warning message.
    org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread
    stopMaster(int serverNumber)
    Shut down the specified master cleanly
    org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread
    stopMaster(int serverNumber, boolean shutdownFS)
    Shut down the specified master cleanly
    void
    stopMaster(org.apache.hadoop.hbase.ServerName serverName)
    Stops the given master, by attempting a gradual stop.
    void
    stopNameNode(org.apache.hadoop.hbase.ServerName serverName)
    Stops the namenode if this is a distributed cluster, otherwise silently logs warning message.
    org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread
    stopRegionServer(int serverNumber)
    Shut down the specified region server cleanly
    org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread
    stopRegionServer(int serverNumber, boolean shutdownFS)
    Shut down the specified region server cleanly
    void
    stopRegionServer(org.apache.hadoop.hbase.ServerName serverName)
    Stops the given region server, by attempting a gradual stop.
    void
    stopZkNode(org.apache.hadoop.hbase.ServerName serverName)
    Stops the region zookeeper if this is a distributed cluster, otherwise silently logs warning message.
    org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread
    suspendRegionServer(int serverNumber)
    Suspend the specified region server
    void
    suspendRegionServer(org.apache.hadoop.hbase.ServerName serverName)
    Suspend the region server
    boolean
    Blocks until there is an active master and that master has completed initialization.
    void
    waitForDataNodeToStart(org.apache.hadoop.hbase.ServerName serverName, long timeout)
    Wait for the specified datanode to join the cluster
    void
    waitForDataNodeToStop(org.apache.hadoop.hbase.ServerName serverName, long timeout)
    Wait for the specified datanode to stop the thread / process.
    void
    waitForJournalNodeToStart(org.apache.hadoop.hbase.ServerName serverName, long timeout)
    Wait for the specified journalnode to join the cluster
    void
    waitForJournalNodeToStop(org.apache.hadoop.hbase.ServerName serverName, long timeout)
    Wait for the specified journalnode to stop
    void
    waitForMasterToStop(org.apache.hadoop.hbase.ServerName serverName, long timeout)
    Wait for the specified master to stop the thread / process.
    void
    waitForNameNodeToStart(org.apache.hadoop.hbase.ServerName serverName, long timeout)
    Wait for the specified namenode to join the cluster
    void
    waitForNameNodeToStop(org.apache.hadoop.hbase.ServerName serverName, long timeout)
    Wait for the specified namenode to stop
    void
    waitForRegionServerToStop(org.apache.hadoop.hbase.ServerName serverName, long timeout)
    Wait for the specified region server to stop the thread / process.
    void
    waitForZkNodeToStart(org.apache.hadoop.hbase.ServerName serverName, long timeout)
    Wait for the specified zookeeper node to join the cluster
    void
    waitForZkNodeToStop(org.apache.hadoop.hbase.ServerName serverName, long timeout)
    Wait for the specified zookeeper node to stop the thread / process.
    waitOnMaster(int serverNumber)
    Wait for the specified master to stop.
    waitOnRegionServer(int serverNumber)
    Wait for the specified region server to stop.
    void
    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

      private static final org.slf4j.Logger LOG
    • hbaseCluster

      public org.apache.hadoop.hbase.LocalHBaseCluster hbaseCluster
    • index

      private static int index
  • Constructor Details

  • Method Details

    • getConfiguration

      public org.apache.hadoop.conf.Configuration getConfiguration()
    • init

      private void init(int nMasterNodes, int numAlwaysStandByMasters, int nRegionNodes, List<Integer> rsPorts, Class<? extends org.apache.hadoop.hbase.master.HMaster> masterClass, Class<? extends MiniHBaseCluster.MiniHBaseClusterRegionServer> regionserverClass) throws IOException, InterruptedException
      Throws:
      IOException
      InterruptedException
    • startRegionServer

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

      public void killRegionServer(org.apache.hadoop.hbase.ServerName serverName) throws IOException
      Description copied from class: HBaseCluster
      Kills the region server process if this is a distributed cluster, otherwise this causes the region server to exit doing basic clean up only.
      Specified by:
      killRegionServer in class HBaseCluster
      Throws:
      IOException - if something goes wrong
    • isKilledRS

      public boolean isKilledRS(org.apache.hadoop.hbase.ServerName serverName)
      Description copied from class: HBaseCluster
      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.
      Specified by:
      isKilledRS in class HBaseCluster
    • stopRegionServer

      public void stopRegionServer(org.apache.hadoop.hbase.ServerName serverName) throws IOException
      Description copied from class: HBaseCluster
      Stops the given region server, by attempting a gradual stop.
      Specified by:
      stopRegionServer in class HBaseCluster
      Throws:
      IOException - if something goes wrong
    • suspendRegionServer

      public void suspendRegionServer(org.apache.hadoop.hbase.ServerName serverName) throws IOException
      Description copied from class: HBaseCluster
      Suspend the region server
      Specified by:
      suspendRegionServer in class HBaseCluster
      Parameters:
      serverName - the hostname to suspend the regionserver on
      Throws:
      IOException - if something goes wrong
    • resumeRegionServer

      public void resumeRegionServer(org.apache.hadoop.hbase.ServerName serverName) throws IOException
      Description copied from class: HBaseCluster
      Resume the region server
      Specified by:
      resumeRegionServer in class HBaseCluster
      Parameters:
      serverName - the hostname to resume the regionserver on
      Throws:
      IOException - if something goes wrong
    • waitForRegionServerToStop

      public void waitForRegionServerToStop(org.apache.hadoop.hbase.ServerName serverName, long timeout) throws IOException
      Description copied from class: HBaseCluster
      Wait for the specified region server to stop the thread / process.
      Specified by:
      waitForRegionServerToStop in class HBaseCluster
      Throws:
      IOException - if something goes wrong or timeout occurs
    • startZkNode

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

      public void killZkNode(org.apache.hadoop.hbase.ServerName serverName) throws IOException
      Description copied from class: HBaseCluster
      Kills the zookeeper node process if this is a distributed cluster, otherwise, this causes master to exit doing basic clean up only.
      Specified by:
      killZkNode in class HBaseCluster
      Throws:
      IOException - if something goes wrong
    • stopZkNode

      public void stopZkNode(org.apache.hadoop.hbase.ServerName serverName) throws IOException
      Description copied from class: HBaseCluster
      Stops the region zookeeper if this is a distributed cluster, otherwise silently logs warning message.
      Specified by:
      stopZkNode in class HBaseCluster
      Throws:
      IOException - if something goes wrong
    • waitForZkNodeToStart

      public void waitForZkNodeToStart(org.apache.hadoop.hbase.ServerName serverName, long timeout) throws IOException
      Description copied from class: HBaseCluster
      Wait for the specified zookeeper node to join the cluster
      Specified by:
      waitForZkNodeToStart in class HBaseCluster
      Throws:
      IOException - if something goes wrong or timeout occurs
    • waitForZkNodeToStop

      public void waitForZkNodeToStop(org.apache.hadoop.hbase.ServerName serverName, long timeout) throws IOException
      Description copied from class: HBaseCluster
      Wait for the specified zookeeper node to stop the thread / process.
      Specified by:
      waitForZkNodeToStop in class HBaseCluster
      Throws:
      IOException - if something goes wrong or timeout occurs
    • startDataNode

      public void startDataNode(org.apache.hadoop.hbase.ServerName serverName) throws IOException
      Description copied from class: HBaseCluster
      Starts a new datanode on the given hostname or if this is a mini/local cluster, silently logs warning message.
      Specified by:
      startDataNode in class HBaseCluster
      Throws:
      IOException - if something goes wrong
    • killDataNode

      public void killDataNode(org.apache.hadoop.hbase.ServerName serverName) throws IOException
      Description copied from class: HBaseCluster
      Kills the datanode process if this is a distributed cluster, otherwise, this causes master to exit doing basic clean up only.
      Specified by:
      killDataNode in class HBaseCluster
      Throws:
      IOException - if something goes wrong
    • stopDataNode

      public void stopDataNode(org.apache.hadoop.hbase.ServerName serverName) throws IOException
      Description copied from class: HBaseCluster
      Stops the datanode if this is a distributed cluster, otherwise silently logs warning message.
      Specified by:
      stopDataNode in class HBaseCluster
      Throws:
      IOException - if something goes wrong
    • waitForDataNodeToStart

      public void waitForDataNodeToStart(org.apache.hadoop.hbase.ServerName serverName, long timeout) throws IOException
      Description copied from class: HBaseCluster
      Wait for the specified datanode to join the cluster
      Specified by:
      waitForDataNodeToStart in class HBaseCluster
      Throws:
      IOException - if something goes wrong or timeout occurs
    • waitForDataNodeToStop

      public void waitForDataNodeToStop(org.apache.hadoop.hbase.ServerName serverName, long timeout) throws IOException
      Description copied from class: HBaseCluster
      Wait for the specified datanode to stop the thread / process.
      Specified by:
      waitForDataNodeToStop in class HBaseCluster
      Throws:
      IOException - if something goes wrong or timeout occurs
    • startNameNode

      public void startNameNode(org.apache.hadoop.hbase.ServerName serverName) throws IOException
      Description copied from class: HBaseCluster
      Starts a new namenode on the given hostname or if this is a mini/local cluster, silently logs warning message.
      Specified by:
      startNameNode in class HBaseCluster
      Throws:
      IOException - if something goes wrong
    • killNameNode

      public void killNameNode(org.apache.hadoop.hbase.ServerName serverName) throws IOException
      Description copied from class: HBaseCluster
      Kills the namenode process if this is a distributed cluster, otherwise, this causes master to exit doing basic clean up only.
      Specified by:
      killNameNode in class HBaseCluster
      Throws:
      IOException - if something goes wrong
    • stopNameNode

      public void stopNameNode(org.apache.hadoop.hbase.ServerName serverName) throws IOException
      Description copied from class: HBaseCluster
      Stops the namenode if this is a distributed cluster, otherwise silently logs warning message.
      Specified by:
      stopNameNode in class HBaseCluster
      Throws:
      IOException - if something goes wrong
    • waitForNameNodeToStart

      public void waitForNameNodeToStart(org.apache.hadoop.hbase.ServerName serverName, long timeout) throws IOException
      Description copied from class: HBaseCluster
      Wait for the specified namenode to join the cluster
      Specified by:
      waitForNameNodeToStart in class HBaseCluster
      Throws:
      IOException - if something goes wrong or timeout occurs
    • waitForNameNodeToStop

      public void waitForNameNodeToStop(org.apache.hadoop.hbase.ServerName serverName, long timeout) throws IOException
      Description copied from class: HBaseCluster
      Wait for the specified namenode to stop
      Specified by:
      waitForNameNodeToStop in class HBaseCluster
      Throws:
      IOException - if something goes wrong or timeout occurs
    • startJournalNode

      public void startJournalNode(org.apache.hadoop.hbase.ServerName serverName)
      Description copied from class: HBaseCluster
      Starts a new journalnode on the given hostname or if this is a mini/local cluster, silently logs warning message.
      Specified by:
      startJournalNode in class HBaseCluster
    • killJournalNode

      public void killJournalNode(org.apache.hadoop.hbase.ServerName serverName)
      Description copied from class: HBaseCluster
      Kills the journalnode process if this is a distributed cluster, otherwise, this causes master to exit doing basic clean up only.
      Specified by:
      killJournalNode in class HBaseCluster
    • stopJournalNode

      public void stopJournalNode(org.apache.hadoop.hbase.ServerName serverName)
      Description copied from class: HBaseCluster
      Stops the journalnode if this is a distributed cluster, otherwise silently logs warning message.
      Specified by:
      stopJournalNode in class HBaseCluster
    • waitForJournalNodeToStart

      public void waitForJournalNodeToStart(org.apache.hadoop.hbase.ServerName serverName, long timeout)
      Description copied from class: HBaseCluster
      Wait for the specified journalnode to join the cluster
      Specified by:
      waitForJournalNodeToStart in class HBaseCluster
    • waitForJournalNodeToStop

      public void waitForJournalNodeToStop(org.apache.hadoop.hbase.ServerName serverName, long timeout)
      Description copied from class: HBaseCluster
      Wait for the specified journalnode to stop
      Specified by:
      waitForJournalNodeToStop in class HBaseCluster
    • startMaster

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

      public void killMaster(org.apache.hadoop.hbase.ServerName serverName) throws IOException
      Description copied from class: HBaseCluster
      Kills the master process if this is a distributed cluster, otherwise, this causes master to exit doing basic clean up only.
      Specified by:
      killMaster in class HBaseCluster
      Throws:
      IOException - if something goes wrong
    • stopMaster

      public void stopMaster(org.apache.hadoop.hbase.ServerName serverName) throws IOException
      Description copied from class: HBaseCluster
      Stops the given master, by attempting a gradual stop.
      Specified by:
      stopMaster in class HBaseCluster
      Throws:
      IOException - if something goes wrong
    • waitForMasterToStop

      public void waitForMasterToStop(org.apache.hadoop.hbase.ServerName serverName, long timeout) throws IOException
      Description copied from class: HBaseCluster
      Wait for the specified master to stop the thread / process.
      Specified by:
      waitForMasterToStop in class HBaseCluster
      Throws:
      IOException - if something goes wrong or timeout occurs
    • startRegionServer

      public org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread startRegionServer() throws IOException
      Starts a region server thread running
      Returns:
      New RegionServerThread
      Throws:
      IOException
    • startRegionServer

      private org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread startRegionServer(org.apache.hadoop.conf.Configuration configuration) throws IOException
      Throws:
      IOException
    • startRegionServerAndWait

      public org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread startRegionServerAndWait(long timeout) throws IOException
      Starts a region server thread and waits until its processed by master. Throws an exception when it can't start a region server or when the region server is not processed by master within the timeout.
      Returns:
      New RegionServerThread
      Throws:
      IOException
    • abortRegionServer

      public String abortRegionServer(int serverNumber)
      Cause a region server to exit doing basic clean up only on its way out.
      Parameters:
      serverNumber - Used as index into a list.
    • stopRegionServer

      public org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread stopRegionServer(int serverNumber)
      Shut down the specified region server cleanly
      Parameters:
      serverNumber - Used as index into a list.
      Returns:
      the region server that was stopped
    • stopRegionServer

      public org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread stopRegionServer(int serverNumber, boolean shutdownFS)
      Shut down the specified region server cleanly
      Parameters:
      serverNumber - Used as index into a list.
      shutdownFS - True is we are to shutdown the filesystem as part of this regionserver's shutdown. Usually we do but you do not want to do this if you are running multiple regionservers in a test and you shut down one before end of the test.
      Returns:
      the region server that was stopped
    • suspendRegionServer

      public org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread suspendRegionServer(int serverNumber)
      Suspend the specified region server
      Parameters:
      serverNumber - Used as index into a list.
    • resumeRegionServer

      public org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread resumeRegionServer(int serverNumber)
      Resume the specified region server
      Parameters:
      serverNumber - Used as index into a list.
    • waitOnRegionServer

      public String waitOnRegionServer(int serverNumber)
      Wait for the specified region server to stop. Removes this thread from list of running threads.
      Returns:
      Name of region server that just went down.
    • startMaster

      public org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread startMaster() throws IOException
      Starts a master thread running
      Returns:
      New RegionServerThread
      Throws:
      IOException
    • getMasterAdminService

      public org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MasterService.BlockingInterface getMasterAdminService()
      Returns the current active master, if available.
      Specified by:
      getMasterAdminService in class HBaseCluster
      Returns:
      the active HMaster, null if none is active.
    • getMaster

      public org.apache.hadoop.hbase.master.HMaster getMaster()
      Returns the current active master, if available.
      Returns:
      the active HMaster, null if none is active.
    • getMasterThread

      public org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread getMasterThread()
      Returns the current active master thread, if available.
      Returns:
      the active MasterThread, null if none is active.
    • getMaster

      public org.apache.hadoop.hbase.master.HMaster getMaster(int serverNumber)
      Returns the master at the specified index, if available.
      Returns:
      the active HMaster, null if none is active.
    • abortMaster

      public String abortMaster(int serverNumber)
      Cause a master to exit without shutting down entire cluster.
      Parameters:
      serverNumber - Used as index into a list.
    • stopMaster

      public org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread stopMaster(int serverNumber)
      Shut down the specified master cleanly
      Parameters:
      serverNumber - Used as index into a list.
      Returns:
      the region server that was stopped
    • stopMaster

      public org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread stopMaster(int serverNumber, boolean shutdownFS)
      Shut down the specified master cleanly
      Parameters:
      serverNumber - Used as index into a list.
      shutdownFS - True is we are to shutdown the filesystem as part of this master's shutdown. Usually we do but you do not want to do this if you are running multiple master in a test and you shut down one before end of the test.
      Returns:
      the master that was stopped
    • waitOnMaster

      public String waitOnMaster(int serverNumber)
      Wait for the specified master to stop. Removes this thread from list of running threads.
      Returns:
      Name of master that just went down.
    • waitForActiveAndReadyMaster

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

      public List<org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread> getMasterThreads()
      Returns List of master threads.
    • getLiveMasterThreads

      public List<org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread> getLiveMasterThreads()
      Returns List of live master threads (skips the aborted and the killed)
    • join

      public void join()
      Wait for Mini HBase Cluster to shut down.
    • shutdown

      public void shutdown() throws IOException
      Shut down the mini HBase cluster
      Specified by:
      shutdown in class HBaseCluster
      Throws:
      IOException
    • close

      public void close() throws IOException
      Description copied from class: HBaseCluster
      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
      Specified by:
      close in class HBaseCluster
      Throws:
      IOException
      See Also:
    • getClusterStatus

      @Deprecated public org.apache.hadoop.hbase.ClusterStatus getClusterStatus() throws IOException
      Deprecated.
      As of release 2.0.0, this will be removed in HBase 3.0.0 Use getClusterMetrics() instead.
      Throws:
      IOException
    • getClusterMetrics

      public org.apache.hadoop.hbase.ClusterMetrics getClusterMetrics() throws IOException
      Description copied from class: HBaseCluster
      Returns a ClusterMetrics for this HBase cluster.
      Specified by:
      getClusterMetrics in class HBaseCluster
      Throws:
      IOException
      See Also:
    • executeFlush

      private void executeFlush(org.apache.hadoop.hbase.regionserver.HRegion region) throws IOException
      Throws:
      IOException
    • flushcache

      public void flushcache() throws IOException
      Call flushCache on all regions on all participating regionservers.
      Throws:
      IOException
    • flushcache

      public void flushcache(org.apache.hadoop.hbase.TableName tableName) throws IOException
      Call flushCache on all regions of the specified table.
      Throws:
      IOException
    • compact

      public void compact(boolean major) throws IOException
      Call flushCache on all regions on all participating regionservers.
      Throws:
      IOException
    • compact

      public void compact(org.apache.hadoop.hbase.TableName tableName, boolean major) throws IOException
      Call flushCache on all regions of the specified table.
      Throws:
      IOException
    • getNumLiveRegionServers

      Returns Number of live region servers in the cluster currently.
    • getRegionServerThreads

      public List<org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread> getRegionServerThreads()
      Returns:
      List of region server threads. Does not return the master even though it is also a region server.
    • getLiveRegionServerThreads

      public List<org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread> getLiveRegionServerThreads()
      Returns List of live region server threads (skips the aborted and the killed)
    • getRegionServer

      public org.apache.hadoop.hbase.regionserver.HRegionServer getRegionServer(int serverNumber)
      Grab a numbered region server of your choice.
      Returns:
      region server
    • getRegionServer

      public org.apache.hadoop.hbase.regionserver.HRegionServer getRegionServer(org.apache.hadoop.hbase.ServerName serverName)
    • getRegions

      public List<org.apache.hadoop.hbase.regionserver.HRegion> getRegions(byte[] tableName)
    • getRegions

      public List<org.apache.hadoop.hbase.regionserver.HRegion> getRegions(org.apache.hadoop.hbase.TableName tableName)
    • getServerWithMeta

      public int getServerWithMeta()
      Returns:
      Index into List of getRegionServerThreads() of HRS carrying regionName. Returns -1 if none found.
    • getServerWith

      public int getServerWith(byte[] regionName)
      Get the location of the specified region
      Parameters:
      regionName - Name of the region in bytes
      Returns:
      Index into List of getRegionServerThreads() of HRS carrying hbase:meta. Returns -1 if none found.
    • getServerHoldingRegion

      public org.apache.hadoop.hbase.ServerName getServerHoldingRegion(org.apache.hadoop.hbase.TableName tn, byte[] regionName) throws IOException
      Description copied from class: HBaseCluster
      Get the ServerName of region server serving the specified region
      Specified by:
      getServerHoldingRegion in class HBaseCluster
      Parameters:
      tn - Table name that has the region.
      regionName - Name of the region in bytes
      Returns:
      ServerName that hosts the region or null
      Throws:
      IOException
    • countServedRegions

      public long countServedRegions()
      Counts the total numbers of regions being served by the currently online region servers by asking each how many regions they have. Does not look at hbase:meta at all. Count includes catalog tables.
      Returns:
      number of regions being served by all region servers
    • killAll

      public void killAll()
      Do a simulated kill all masters and regionservers. Useful when it is impossible to bring the mini-cluster back for clean shutdown.
    • waitUntilShutDown

      public void waitUntilShutDown()
      Description copied from class: HBaseCluster
      Wait for HBase Cluster to shut down.
      Specified by:
      waitUntilShutDown in class HBaseCluster
    • findRegionsForTable

      public List<org.apache.hadoop.hbase.regionserver.HRegion> findRegionsForTable(org.apache.hadoop.hbase.TableName tableName)
    • getRegionServerIndex

      protected int getRegionServerIndex(org.apache.hadoop.hbase.ServerName serverName)
    • getMasterIndex

      protected int getMasterIndex(org.apache.hadoop.hbase.ServerName serverName)
    • getAdminProtocol

      public org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService.BlockingInterface getAdminProtocol(org.apache.hadoop.hbase.ServerName serverName) throws IOException
      Description copied from class: HBaseCluster
      Returns an AdminProtocol interface to the regionserver
      Specified by:
      getAdminProtocol in class HBaseCluster
      Throws:
      IOException
    • getClientProtocol

      public org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ClientService.BlockingInterface getClientProtocol(org.apache.hadoop.hbase.ServerName serverName) throws IOException
      Description copied from class: HBaseCluster
      Returns a ClientProtocol interface to the regionserver
      Specified by:
      getClientProtocol in class HBaseCluster
      Throws:
      IOException