@InterfaceAudience.Public @InterfaceStability.Evolving 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).
|
Modifier and Type | Field and Description |
---|---|
LocalHBaseCluster |
hbaseCluster |
conf, initialClusterStatus
Constructor and Description |
---|
MiniHBaseCluster(Configuration conf,
int numRegionServers)
Start a MiniHBaseCluster.
|
MiniHBaseCluster(Configuration conf,
int numMasters,
int numRegionServers)
Start a MiniHBaseCluster.
|
MiniHBaseCluster(Configuration conf,
int numMasters,
int numRegionServers,
Class<? extends 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(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.
|
List<HRegion> |
findRegionsForTable(TableName tableName) |
void |
flushcache()
Call flushCache on all regions on all participating regionservers.
|
void |
flushcache(TableName tableName)
Call flushCache on all regions of the specified table.
|
AdminProtos.AdminService.BlockingInterface |
getAdminProtocol(ServerName serverName)
Returns an AdminProtocol interface to the regionserver
|
ClientProtos.ClientService.BlockingInterface |
getClientProtocol(ServerName serverName)
Returns a ClientProtocol interface to the regionserver
|
ClusterStatus |
getClusterStatus()
Returns a ClusterStatus for this HBase cluster.
|
Configuration |
getConfiguration() |
List<JVMClusterUtil.MasterThread> |
getLiveMasterThreads() |
List<JVMClusterUtil.RegionServerThread> |
getLiveRegionServerThreads() |
HMaster |
getMaster()
Returns the current active master, if available.
|
HMaster |
getMaster(int serverNumber)
Returns the master at the specified index, if available.
|
MasterProtos.MasterService.BlockingInterface |
getMasterAdminService()
Returns the current active master, if available.
|
protected int |
getMasterIndex(ServerName serverName) |
JVMClusterUtil.MasterThread |
getMasterThread()
Returns the current active master thread, if available.
|
List<JVMClusterUtil.MasterThread> |
getMasterThreads() |
List<HRegion> |
getRegions(byte[] tableName) |
List<HRegion> |
getRegions(TableName tableName) |
HRegionServer |
getRegionServer(int serverNumber)
Grab a numbered region server of your choice.
|
protected int |
getRegionServerIndex(ServerName serverName) |
List<JVMClusterUtil.RegionServerThread> |
getRegionServerThreads() |
ServerName |
getServerHoldingRegion(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() |
void |
join()
Wait for Mini HBase Cluster to shut down.
|
void |
killAll()
Do a simulated kill all masters and regionservers.
|
void |
killMaster(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(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 |
shutdown()
Shut down the mini HBase cluster
|
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.
|
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.
|
JVMClusterUtil.MasterThread |
stopMaster(int serverNumber)
Shut down the specified master cleanly
|
JVMClusterUtil.MasterThread |
stopMaster(int serverNumber,
boolean shutdownFS)
Shut down the specified master cleanly
|
void |
stopMaster(ServerName serverName)
Stops the given master, by attempting a gradual stop.
|
JVMClusterUtil.RegionServerThread |
stopRegionServer(int serverNumber)
Shut down the specified region server cleanly
|
JVMClusterUtil.RegionServerThread |
stopRegionServer(int serverNumber,
boolean shutdownFS)
Shut down the specified region server cleanly
|
void |
stopRegionServer(ServerName serverName)
Stops the given region server, by attempting a gradual stop.
|
boolean |
waitForActiveAndReadyMaster(long timeout)
Blocks until there is an active master and that master has completed
initialization.
|
void |
waitForMasterToStop(ServerName serverName,
long timeout)
Wait for the specified master to stop the thread / process.
|
void |
waitForRegionServerToStop(ServerName serverName,
long timeout)
Wait for the specified region server 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, getInitialClusterStatus, getServerHoldingMeta, isDistributedCluster, restoreClusterStatus, restoreInitialStatus, setConf, waitForActiveAndReadyMaster, waitForDatanodesRegistered, waitForNamenodeAvailable, waitForRegionServerToStart
public LocalHBaseCluster hbaseCluster
public MiniHBaseCluster(Configuration conf, int numRegionServers) throws IOException, InterruptedException
conf
- Configuration to be used for clusternumRegionServers
- initial number of region servers to start.IOException
InterruptedException
public MiniHBaseCluster(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.IOException
InterruptedException
public MiniHBaseCluster(Configuration conf, int numMasters, int numRegionServers, Class<? extends HMaster> masterClass, Class<? extends MiniHBaseCluster.MiniHBaseClusterRegionServer> regionserverClass) throws IOException, InterruptedException
IOException
InterruptedException
public Configuration getConfiguration()
public void startRegionServer(String hostname, int port) throws IOException
HBaseCluster
startRegionServer
in class HBaseCluster
hostname
- the hostname to start the regionserver onIOException
- if something goes wrongpublic void killRegionServer(ServerName serverName) throws IOException
HBaseCluster
killRegionServer
in class HBaseCluster
IOException
- if something goes wrongpublic void stopRegionServer(ServerName serverName) throws IOException
HBaseCluster
stopRegionServer
in class HBaseCluster
IOException
- if something goes wrongpublic void waitForRegionServerToStop(ServerName serverName, long timeout) throws IOException
HBaseCluster
waitForRegionServerToStop
in class HBaseCluster
IOException
- if something goes wrong or timeout occurspublic void startMaster(String hostname, int port) throws IOException
HBaseCluster
startMaster
in class HBaseCluster
hostname
- the hostname to start the master onIOException
- if something goes wrongpublic void killMaster(ServerName serverName) throws IOException
HBaseCluster
killMaster
in class HBaseCluster
IOException
- if something goes wrongpublic void stopMaster(ServerName serverName) throws IOException
HBaseCluster
stopMaster
in class HBaseCluster
IOException
- if something goes wrongpublic void waitForMasterToStop(ServerName serverName, long timeout) throws IOException
HBaseCluster
waitForMasterToStop
in class HBaseCluster
IOException
- if something goes wrong or timeout occurspublic JVMClusterUtil.RegionServerThread startRegionServer() throws IOException
IOException
public String abortRegionServer(int serverNumber)
serverNumber
- Used as index into a list.public JVMClusterUtil.RegionServerThread stopRegionServer(int serverNumber)
serverNumber
- Used as index into a list.public 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 JVMClusterUtil.MasterThread startMaster() throws IOException
IOException
public MasterProtos.MasterService.BlockingInterface getMasterAdminService()
getMasterAdminService
in class HBaseCluster
public HMaster getMaster()
public JVMClusterUtil.MasterThread getMasterThread()
public HMaster getMaster(int serverNumber)
public String abortMaster(int serverNumber)
serverNumber
- Used as index into a list.public JVMClusterUtil.MasterThread stopMaster(int serverNumber)
serverNumber
- Used as index into a list.public 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 HBaseCluster
timeout
- the timeout limit in msInterruptedException
IOException
public List<JVMClusterUtil.MasterThread> getMasterThreads()
public List<JVMClusterUtil.MasterThread> getLiveMasterThreads()
public void join()
public void shutdown() throws IOException
shutdown
in class HBaseCluster
IOException
public void close() throws IOException
HBaseCluster
close
in interface Closeable
close
in interface AutoCloseable
close
in class HBaseCluster
IOException
HBaseCluster.shutdown()
public ClusterStatus getClusterStatus() throws IOException
HBaseCluster
getClusterStatus
in class HBaseCluster
IOException
HBaseCluster.getInitialClusterStatus()
public void flushcache() throws IOException
IOException
public void flushcache(TableName tableName) throws IOException
IOException
public void compact(boolean major) throws IOException
IOException
public void compact(TableName tableName, boolean major) throws IOException
IOException
public List<JVMClusterUtil.RegionServerThread> getRegionServerThreads()
public List<JVMClusterUtil.RegionServerThread> getLiveRegionServerThreads()
public HRegionServer getRegionServer(int serverNumber)
serverNumber
- 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 ServerName getServerHoldingRegion(TableName tn, byte[] regionName) throws IOException
HBaseCluster
getServerHoldingRegion
in class HBaseCluster
tn
- Table name that has the region.regionName
- Name of the region in bytesIOException
public long countServedRegions()
public void killAll()
public void waitUntilShutDown()
HBaseCluster
waitUntilShutDown
in class HBaseCluster
protected int getRegionServerIndex(ServerName serverName)
protected int getMasterIndex(ServerName serverName)
public AdminProtos.AdminService.BlockingInterface getAdminProtocol(ServerName serverName) throws IOException
HBaseCluster
getAdminProtocol
in class HBaseCluster
IOException
public ClientProtos.ClientService.BlockingInterface getClientProtocol(ServerName serverName) throws IOException
HBaseCluster
getClientProtocol
in class HBaseCluster
IOException