org.apache.hadoop.hbase
Class LocalHBaseCluster

java.lang.Object
  extended by org.apache.hadoop.hbase.LocalHBaseCluster

public class LocalHBaseCluster
extends Object

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 60000 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 60000, 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 60000.


Field Summary
static String LOCAL
          local mode
static String LOCAL_COLON
          'local:'
 
Constructor Summary
LocalHBaseCluster(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 noRegionServers, Class<? extends HMaster> masterClass, Class<? extends HRegionServer> regionServerClass)
          Constructor.
 
Method Summary
 JVMClusterUtil.MasterThread addMaster()
           
 JVMClusterUtil.MasterThread addMaster(org.apache.hadoop.conf.Configuration c, int index)
           
 JVMClusterUtil.MasterThread addMaster(org.apache.hadoop.conf.Configuration c, int index, User user)
           
 JVMClusterUtil.RegionServerThread addRegionServer()
           
 JVMClusterUtil.RegionServerThread addRegionServer(org.apache.hadoop.conf.Configuration config, int index)
           
 JVMClusterUtil.RegionServerThread addRegionServer(org.apache.hadoop.conf.Configuration config, int index, User user)
           
 HMaster getActiveMaster()
          Gets the current active master, if available.
 List<JVMClusterUtil.MasterThread> getLiveMasters()
           
 List<JVMClusterUtil.RegionServerThread> getLiveRegionServers()
           
 HMaster getMaster(int serverNumber)
           
 List<JVMClusterUtil.MasterThread> getMasters()
           
 HRegionServer getRegionServer(int serverNumber)
           
 List<JVMClusterUtil.RegionServerThread> getRegionServers()
           
static boolean isLocal(org.apache.hadoop.conf.Configuration c)
           
 void join()
          Wait for Mini HBase Cluster to shut down.
static void main(String[] args)
          Test things basically work.
 void shutdown()
          Shut down the mini HBase cluster
 void startup()
          Start the cluster.
 String waitOnMaster(int serverNumber)
          Wait for the specified master to stop Removes this thread from list of running threads.
 String waitOnMaster(JVMClusterUtil.MasterThread masterThread)
          Wait for the specified master to stop Removes this thread from list of running threads.
 String waitOnRegionServer(int serverNumber)
          Wait for the specified region server to stop Removes this thread from list of running threads.
 String waitOnRegionServer(JVMClusterUtil.RegionServerThread rst)
          Wait for the specified region server to stop Removes this thread from list of running threads.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCAL

public static final String LOCAL
local mode

See Also:
Constant Field Values

LOCAL_COLON

public static final String LOCAL_COLON
'local:'

See Also:
Constant Field Values
Constructor Detail

LocalHBaseCluster

public LocalHBaseCluster(org.apache.hadoop.conf.Configuration conf)
                  throws IOException
Constructor.

Parameters:
conf -
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
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.
masterClass -
regionServerClass -
Throws:
IOException
Method Detail

addRegionServer

public JVMClusterUtil.RegionServerThread addRegionServer()
                                                  throws IOException
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

public JVMClusterUtil.MasterThread addMaster()
                                      throws IOException
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

public HRegionServer getRegionServer(int serverNumber)
Parameters:
serverNumber -
Returns:
region server

getRegionServers

public List<JVMClusterUtil.RegionServerThread> getRegionServers()
Returns:
Read-only list of region server threads.

getLiveRegionServers

public List<JVMClusterUtil.RegionServerThread> 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).

waitOnRegionServer

public String waitOnRegionServer(int serverNumber)
Wait for the specified region server to stop Removes this thread from list of running threads.

Parameters:
serverNumber -
Returns:
Name of region server that just went down.

waitOnRegionServer

public String waitOnRegionServer(JVMClusterUtil.RegionServerThread rst)
Wait for the specified region server to stop Removes this thread from list of running threads.

Parameters:
rst -
Returns:
Name of region server that just went down.

getMaster

public HMaster getMaster(int serverNumber)
Parameters:
serverNumber -
Returns:
the HMaster thread

getActiveMaster

public HMaster getActiveMaster()
Gets the current active master, if available. If no active master, returns null.

Returns:
the HMaster for the active master

getMasters

public List<JVMClusterUtil.MasterThread> getMasters()
Returns:
Read-only list of master threads.

getLiveMasters

public List<JVMClusterUtil.MasterThread> 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

public String waitOnMaster(int serverNumber)
Wait for the specified master to stop Removes this thread from list of running threads.

Parameters:
serverNumber -
Returns:
Name of master that just went down.

waitOnMaster

public String waitOnMaster(JVMClusterUtil.MasterThread masterThread)
Wait for the specified master to stop Removes this thread from list of running threads.

Parameters:
masterThread -
Returns:
Name of master that just went down.

join

public void join()
Wait for Mini HBase Cluster to shut down. Presumes you've already called shutdown().


startup

public void startup()
Start the cluster.


shutdown

public void shutdown()
Shut down the mini HBase cluster


isLocal

public static boolean isLocal(org.apache.hadoop.conf.Configuration c)
Parameters:
c - Configuration to check.
Returns:
True if a 'local' address in hbase.master value.

main

public static void main(String[] args)
                 throws IOException
Test things basically work.

Parameters:
args -
Throws:
IOException


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.