Package org.apache.hadoop.hbase
Class LocalHBaseCluster
java.lang.Object
org.apache.hadoop.hbase.LocalHBaseCluster
This class creates a single process HBase cluster. One thread is created for a master and one per
region server. Call
startup()
to start the cluster running and shutdown()
to
close it all down. join()
the cluster is you want to wait on shutdown completion.
Runs master on port 16000 by default. Because we can't just kill the process -- not till HADOOP-1700 gets fixed and even then.... -- we need to be able to find the master with a remote client to run shutdown. To use a port other than 16000, set the hbase.master to a value of 'local:PORT': that is 'local', not 'localhost', and the port number the master should use instead of 16000.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
private final org.apache.hadoop.conf.Configuration
private static final int
static final String
local modestatic final String
'local:'private static final org.slf4j.Logger
private final List<JVMClusterUtil.MasterThread>
private final Class<? extends HRegionServer>
private final List<JVMClusterUtil.RegionServerThread>
-
Constructor Summary
ConstructorDescriptionLocalHBaseCluster
(org.apache.hadoop.conf.Configuration conf) Constructor.LocalHBaseCluster
(org.apache.hadoop.conf.Configuration conf, int noRegionServers) Constructor.LocalHBaseCluster
(org.apache.hadoop.conf.Configuration conf, int noMasters, int noRegionServers) Constructor.LocalHBaseCluster
(org.apache.hadoop.conf.Configuration conf, int noMasters, int noAlwaysStandByMasters, int noRegionServers, Class<? extends HMaster> masterClass, Class<? extends HRegionServer> regionServerClass) Constructor.LocalHBaseCluster
(org.apache.hadoop.conf.Configuration conf, int noMasters, int noRegionServers, Class<? extends HMaster> masterClass, Class<? extends HRegionServer> regionServerClass) -
Method Summary
Modifier and TypeMethodDescriptionaddMaster
(org.apache.hadoop.conf.Configuration c, int index) addRegionServer
(org.apache.hadoop.conf.Configuration config, int index) addRegionServer
(org.apache.hadoop.conf.Configuration config, int index, User user) Gets the current active master, if available.org.apache.hadoop.conf.Configuration
Returns the Configuration used by this LocalHBaseClustergetMaster
(int serverNumber) Returns the HMaster threadgetMasterImplementation
(org.apache.hadoop.conf.Configuration conf) Returns Read-only list of master threads.getRegionServer
(int serverNumber) Returns region serverprivate static Class<? extends HRegionServer>
getRegionServerImplementation
(org.apache.hadoop.conf.Configuration conf) Returns Read-only list of region server threads.static boolean
isLocal
(org.apache.hadoop.conf.Configuration c) void
join()
Wait for Mini HBase Cluster to shut down.static void
Test things basically work.void
shutdown()
Shut down the mini HBase clustervoid
startup()
Start the cluster.waitOnMaster
(int serverNumber) Wait for the specified master to stop.waitOnMaster
(JVMClusterUtil.MasterThread masterThread) Wait for the specified master to stop.waitOnRegionServer
(int serverNumber) Wait for the specified region server to stop.Wait for the specified region server to stop.
-
Field Details
-
LOG
-
masterThreads
-
regionThreads
-
DEFAULT_NO
- See Also:
-
LOCAL
local mode- See Also:
-
LOCAL_COLON
'local:'- See Also:
-
ASSIGN_RANDOM_PORTS
- See Also:
-
conf
-
masterClass
-
regionServerClass
-
-
Constructor Details
-
LocalHBaseCluster
Constructor.- Throws:
IOException
-
LocalHBaseCluster
public LocalHBaseCluster(org.apache.hadoop.conf.Configuration conf, int noRegionServers) throws IOException Constructor.- Parameters:
conf
- Configuration to use. Post construction has the master's address.noRegionServers
- Count of regionservers to start.- Throws:
IOException
-
LocalHBaseCluster
public LocalHBaseCluster(org.apache.hadoop.conf.Configuration conf, int noMasters, int noRegionServers) throws IOException Constructor.- Parameters:
conf
- Configuration to use. Post construction has the active master address.noMasters
- Count of masters to start.noRegionServers
- Count of regionservers to start.- Throws:
IOException
-
LocalHBaseCluster
public LocalHBaseCluster(org.apache.hadoop.conf.Configuration conf, int noMasters, int noRegionServers, Class<? extends HMaster> masterClass, Class<? extends HRegionServer> regionServerClass) throws IOException - Throws:
IOException
-
LocalHBaseCluster
public LocalHBaseCluster(org.apache.hadoop.conf.Configuration conf, int noMasters, int noAlwaysStandByMasters, int noRegionServers, Class<? extends HMaster> masterClass, Class<? extends HRegionServer> regionServerClass) throws IOException Constructor.- Parameters:
conf
- Configuration to use. Post construction has the master's address.noMasters
- Count of masters to start.noRegionServers
- Count of regionservers to start.- Throws:
IOException
-
-
Method Details
-
getRegionServerImplementation
private static Class<? extends HRegionServer> getRegionServerImplementation(org.apache.hadoop.conf.Configuration conf) -
getMasterImplementation
private static Class<? extends HMaster> getMasterImplementation(org.apache.hadoop.conf.Configuration conf) -
addRegionServer
- Throws:
IOException
-
addRegionServer
public JVMClusterUtil.RegionServerThread addRegionServer(org.apache.hadoop.conf.Configuration config, int index) throws IOException - Throws:
IOException
-
addRegionServer
public JVMClusterUtil.RegionServerThread addRegionServer(org.apache.hadoop.conf.Configuration config, int index, User user) throws IOException, InterruptedException - Throws:
IOException
InterruptedException
-
addMaster
- Throws:
IOException
-
addMaster
public JVMClusterUtil.MasterThread addMaster(org.apache.hadoop.conf.Configuration c, int index) throws IOException - Throws:
IOException
-
addMaster
public JVMClusterUtil.MasterThread addMaster(org.apache.hadoop.conf.Configuration c, int index, User user) throws IOException, InterruptedException - Throws:
IOException
InterruptedException
-
getRegionServer
Returns region server -
getRegionServers
Returns Read-only list of region server threads. -
getLiveRegionServers
- Returns:
- List of running servers (Some servers may have been killed or aborted during lifetime of cluster; these servers are not included in this list).
-
getConfiguration
Returns the Configuration used by this LocalHBaseCluster -
waitOnRegionServer
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.
-
waitOnRegionServer
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.
-
getMaster
Returns the HMaster thread -
getActiveMaster
Gets the current active master, if available. If no active master, returns null.- Returns:
- the HMaster for the active master
-
getMasters
Returns Read-only list of master threads. -
getLiveMasters
- Returns:
- List of running master servers (Some servers may have been killed or aborted during lifetime of cluster; these servers are not included in this list).
-
waitOnMaster
Wait for the specified master to stop. Removes this thread from list of running threads.- Returns:
- Name of master that just went down.
-
waitOnMaster
Wait for the specified master to stop. Removes this thread from list of running threads.- Returns:
- Name of master that just went down.
-
join
Wait for Mini HBase Cluster to shut down. Presumes you've already calledshutdown()
. -
startup
Start the cluster.- Throws:
IOException
-
shutdown
Shut down the mini HBase cluster -
isLocal
- Parameters:
c
- Configuration to check.- Returns:
- True if a 'local' address in hbase.master value.
-
main
Test things basically work.- Throws:
IOException
-