@InterfaceAudience.Public public class MiniHBaseCluster extends HBaseCluster
| Modifier and Type | Class and Description |
|---|---|
static class |
MiniHBaseCluster.MiniHBaseClusterRegionServer
Subclass so can get at protected methods (none at moment).
|
(package private) static class |
MiniHBaseCluster.SingleFileSystemShutdownThread
Alternate shutdown hook.
|
| Modifier and Type | Field and Description |
|---|---|
org.apache.hadoop.hbase.LocalHBaseCluster |
hbaseCluster |
private static int |
index |
private static org.slf4j.Logger |
LOG |
conf, initialClusterStatus| Constructor and 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 numRegionServers,
Class<? extends org.apache.hadoop.hbase.master.HMaster> masterClass,
Class<? extends MiniHBaseCluster.MiniHBaseClusterRegionServer> regionserverClass)
Start a MiniHBaseCluster.
|
MiniHBaseCluster(org.apache.hadoop.conf.Configuration conf,
int numMasters,
int numRegionServers,
List<Integer> rsPorts,
Class<? extends org.apache.hadoop.hbase.master.HMaster> masterClass,
Class<? extends MiniHBaseCluster.MiniHBaseClusterRegionServer> regionserverClass) |
| Modifier and Type | Method and Description |
|---|---|
String |
abortMaster(int serverNumber)
Cause a master to exit without shutting down entire cluster.
|
String |
abortRegionServer(int serverNumber)
Cause a region server to exit doing basic clean up only on its way out.
|
void |
close()
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 |
countServedRegions()
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 |
flushcache()
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 |
getClusterMetrics()
Returns a ClusterMetrics for this HBase cluster.
|
org.apache.hadoop.hbase.ClusterStatus |
getClusterStatus()
Deprecated.
As of release 2.0.0, this will be removed in HBase 3.0.0
Use
getClusterMetrics() instead. |
org.apache.hadoop.conf.Configuration |
getConfiguration() |
List<org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread> |
getLiveMasterThreads() |
List<org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread> |
getLiveRegionServerThreads() |
org.apache.hadoop.hbase.master.HMaster |
getMaster()
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 |
getMasterAdminService()
Returns the current active master, if available.
|
protected int |
getMasterIndex(org.apache.hadoop.hbase.ServerName serverName) |
org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread |
getMasterThread()
Returns the current active master thread, if available.
|
List<org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread> |
getMasterThreads() |
int |
getNumLiveRegionServers() |
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> |
getRegionServerThreads() |
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 |
getServerWithMeta() |
private void |
init(int nMasterNodes,
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 |
join()
Wait for Mini HBase Cluster to shut down.
|
void |
killAll()
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 |
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 |
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.
|
void |
shutdown()
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.
|
org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread |
startMaster()
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.
|
org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread |
startRegionServer()
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.
|
org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread |
startRegionServerAndWait(long timeout)
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.
|
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.
|
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.
|
boolean |
waitForActiveAndReadyMaster(long timeout)
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 |
waitForMasterToStop(org.apache.hadoop.hbase.ServerName serverName,
long timeout)
Wait for the specified master to stop the thread / process.
|
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.
|
String |
waitOnMaster(int serverNumber)
Wait for the specified master to stop.
|
String |
waitOnRegionServer(int serverNumber)
Wait for the specified region server to stop.
|
void |
waitUntilShutDown()
Wait for HBase Cluster to shut down.
|
getConf, getInitialClusterMetrics, getServerHoldingMeta, isDistributedCluster, restoreClusterMetrics, restoreInitialStatus, setConf, waitForActiveAndReadyMaster, waitForDatanodesRegistered, waitForNamenodeAvailable, waitForRegionServerToStartprivate static final org.slf4j.Logger LOG
public org.apache.hadoop.hbase.LocalHBaseCluster hbaseCluster
private static int index
public MiniHBaseCluster(org.apache.hadoop.conf.Configuration conf, int numRegionServers) throws IOException, InterruptedException
conf - Configuration to be used for clusternumRegionServers - initial number of region servers to start.IOExceptionInterruptedExceptionpublic MiniHBaseCluster(org.apache.hadoop.conf.Configuration conf, int numMasters, int numRegionServers) throws IOException, InterruptedException
conf - Configuration to be used for clusternumMasters - initial number of masters to start.numRegionServers - initial number of region servers to start.IOExceptionInterruptedExceptionpublic 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) throws IOException, InterruptedException
conf - Configuration to be used for clusternumMasters - initial number of masters to start.numRegionServers - initial number of region servers to start.IOExceptionInterruptedExceptionpublic MiniHBaseCluster(org.apache.hadoop.conf.Configuration conf, int numMasters, int numRegionServers, List<Integer> rsPorts, Class<? extends org.apache.hadoop.hbase.master.HMaster> masterClass, Class<? extends MiniHBaseCluster.MiniHBaseClusterRegionServer> regionserverClass) throws IOException, InterruptedException
rsPorts - Ports that RegionServer should use; pass ports if you want to test cluster
restart where for sure the regionservers come up on same address+port (but
just with different startcode); by default mini hbase clusters choose new
arbitrary ports on each cluster start.IOExceptionInterruptedExceptionpublic org.apache.hadoop.conf.Configuration getConfiguration()
private void init(int nMasterNodes, int nRegionNodes, List<Integer> rsPorts, Class<? extends org.apache.hadoop.hbase.master.HMaster> masterClass, Class<? extends MiniHBaseCluster.MiniHBaseClusterRegionServer> regionserverClass) throws IOException, InterruptedException
IOExceptionInterruptedExceptionpublic void startRegionServer(String hostname, int port) throws IOException
HBaseClusterstartRegionServer in class HBaseClusterhostname - the hostname to start the regionserver onIOException - if something goes wrongpublic void killRegionServer(org.apache.hadoop.hbase.ServerName serverName) throws IOException
HBaseClusterkillRegionServer in class HBaseClusterIOException - if something goes wrongpublic boolean isKilledRS(org.apache.hadoop.hbase.ServerName serverName)
HBaseClusterisKilledRS in class HBaseClusterpublic void stopRegionServer(org.apache.hadoop.hbase.ServerName serverName) throws IOException
HBaseClusterstopRegionServer in class HBaseClusterIOException - if something goes wrongpublic void waitForRegionServerToStop(org.apache.hadoop.hbase.ServerName serverName, long timeout) throws IOException
HBaseClusterwaitForRegionServerToStop in class HBaseClusterIOException - if something goes wrong or timeout occurspublic void startZkNode(String hostname, int port) throws IOException
HBaseClusterstartZkNode in class HBaseClusterhostname - the hostname to start the regionserver onIOException - if something goes wrongpublic void killZkNode(org.apache.hadoop.hbase.ServerName serverName) throws IOException
HBaseClusterkillZkNode in class HBaseClusterIOException - if something goes wrongpublic void stopZkNode(org.apache.hadoop.hbase.ServerName serverName) throws IOException
HBaseClusterstopZkNode in class HBaseClusterIOException - if something goes wrongpublic void waitForZkNodeToStart(org.apache.hadoop.hbase.ServerName serverName, long timeout) throws IOException
HBaseClusterwaitForZkNodeToStart in class HBaseClusterIOException - if something goes wrong or timeout occurspublic void waitForZkNodeToStop(org.apache.hadoop.hbase.ServerName serverName, long timeout) throws IOException
HBaseClusterwaitForZkNodeToStop in class HBaseClusterIOException - if something goes wrong or timeout occurspublic void startDataNode(org.apache.hadoop.hbase.ServerName serverName) throws IOException
HBaseClusterstartDataNode in class HBaseClusterIOException - if something goes wrongpublic void killDataNode(org.apache.hadoop.hbase.ServerName serverName) throws IOException
HBaseClusterkillDataNode in class HBaseClusterIOException - if something goes wrongpublic void stopDataNode(org.apache.hadoop.hbase.ServerName serverName) throws IOException
HBaseClusterstopDataNode in class HBaseClusterIOException - if something goes wrongpublic void waitForDataNodeToStart(org.apache.hadoop.hbase.ServerName serverName, long timeout) throws IOException
HBaseClusterwaitForDataNodeToStart in class HBaseClusterIOException - if something goes wrong or timeout occurspublic void waitForDataNodeToStop(org.apache.hadoop.hbase.ServerName serverName, long timeout) throws IOException
HBaseClusterwaitForDataNodeToStop in class HBaseClusterIOException - if something goes wrong or timeout occurspublic void startMaster(String hostname, int port) throws IOException
HBaseClusterstartMaster in class HBaseClusterhostname - the hostname to start the master onIOException - if something goes wrongpublic void killMaster(org.apache.hadoop.hbase.ServerName serverName) throws IOException
HBaseClusterkillMaster in class HBaseClusterIOException - if something goes wrongpublic void stopMaster(org.apache.hadoop.hbase.ServerName serverName) throws IOException
HBaseClusterstopMaster in class HBaseClusterIOException - if something goes wrongpublic void waitForMasterToStop(org.apache.hadoop.hbase.ServerName serverName, long timeout) throws IOException
HBaseClusterwaitForMasterToStop in class HBaseClusterIOException - if something goes wrong or timeout occurspublic org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread startRegionServer() throws IOException
IOExceptionpublic org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread startRegionServerAndWait(long timeout) throws IOException
IOExceptionpublic String abortRegionServer(int serverNumber)
serverNumber - Used as index into a list.public org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread stopRegionServer(int serverNumber)
serverNumber - Used as index into a list.public org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread stopRegionServer(int serverNumber, boolean shutdownFS)
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.public String waitOnRegionServer(int serverNumber)
serverNumber - public org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread startMaster() throws IOException
IOExceptionpublic org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.MasterService.BlockingInterface getMasterAdminService()
getMasterAdminService in class HBaseClusterpublic org.apache.hadoop.hbase.master.HMaster getMaster()
public org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread getMasterThread()
public org.apache.hadoop.hbase.master.HMaster getMaster(int serverNumber)
public String abortMaster(int serverNumber)
serverNumber - Used as index into a list.public org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread stopMaster(int serverNumber)
serverNumber - Used as index into a list.public org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread stopMaster(int serverNumber, boolean shutdownFS)
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.public String waitOnMaster(int serverNumber)
serverNumber - public boolean waitForActiveAndReadyMaster(long timeout) throws IOException
waitForActiveAndReadyMaster in class HBaseClustertimeout - the timeout limit in msInterruptedExceptionIOExceptionpublic List<org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread> getMasterThreads()
public List<org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread> getLiveMasterThreads()
public void join()
public void shutdown() throws IOException
shutdown in class HBaseClusterIOExceptionpublic void close() throws IOException
HBaseClusterclose in interface Closeableclose in interface AutoCloseableclose in class HBaseClusterIOExceptionHBaseCluster.shutdown()@Deprecated public org.apache.hadoop.hbase.ClusterStatus getClusterStatus() throws IOException
getClusterMetrics() instead.IOExceptionpublic org.apache.hadoop.hbase.ClusterMetrics getClusterMetrics() throws IOException
HBaseClustergetClusterMetrics in class HBaseClusterIOExceptionHBaseCluster.getInitialClusterMetrics()private void executeFlush(org.apache.hadoop.hbase.regionserver.HRegion region) throws IOException
IOExceptionpublic void flushcache() throws IOException
IOExceptionpublic void flushcache(org.apache.hadoop.hbase.TableName tableName) throws IOException
IOExceptionpublic void compact(boolean major) throws IOException
IOExceptionpublic void compact(org.apache.hadoop.hbase.TableName tableName, boolean major) throws IOException
IOExceptionpublic int getNumLiveRegionServers()
public List<org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread> getRegionServerThreads()
public List<org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread> getLiveRegionServerThreads()
public org.apache.hadoop.hbase.regionserver.HRegionServer getRegionServer(int serverNumber)
serverNumber - public org.apache.hadoop.hbase.regionserver.HRegionServer getRegionServer(org.apache.hadoop.hbase.ServerName serverName)
public List<org.apache.hadoop.hbase.regionserver.HRegion> getRegions(byte[] tableName)
public List<org.apache.hadoop.hbase.regionserver.HRegion> getRegions(org.apache.hadoop.hbase.TableName tableName)
public int getServerWithMeta()
getRegionServerThreads()
of HRS carrying regionName. Returns -1 if none found.public int getServerWith(byte[] regionName)
regionName - Name of the region in bytesgetRegionServerThreads()
of HRS carrying hbase:meta. Returns -1 if none found.public org.apache.hadoop.hbase.ServerName getServerHoldingRegion(org.apache.hadoop.hbase.TableName tn, byte[] regionName) throws IOException
HBaseClustergetServerHoldingRegion in class HBaseClustertn - Table name that has the region.regionName - Name of the region in bytesIOExceptionpublic long countServedRegions()
public void killAll()
public void waitUntilShutDown()
HBaseClusterwaitUntilShutDown in class HBaseClusterpublic List<org.apache.hadoop.hbase.regionserver.HRegion> findRegionsForTable(org.apache.hadoop.hbase.TableName tableName)
protected int getRegionServerIndex(org.apache.hadoop.hbase.ServerName serverName)
protected int getMasterIndex(org.apache.hadoop.hbase.ServerName serverName)
public org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService.BlockingInterface getAdminProtocol(org.apache.hadoop.hbase.ServerName serverName) throws IOException
HBaseClustergetAdminProtocol in class HBaseClusterIOExceptionpublic org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ClientService.BlockingInterface getClientProtocol(org.apache.hadoop.hbase.ServerName serverName) throws IOException
HBaseClustergetClientProtocol in class HBaseClusterIOExceptionCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.