org.apache.hadoop.hbase
Class LocalHBaseCluster

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

public class LocalHBaseCluster
extends java.lang.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 java.lang.String LOCAL
          local mode
static java.lang.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, java.lang.Class<? extends HMaster> masterClass, java.lang.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.
 java.util.List<JVMClusterUtil.MasterThread> getLiveMasters()
           
 java.util.List<JVMClusterUtil.RegionServerThread> getLiveRegionServers()
           
 HMaster getMaster(int serverNumber)
           
 java.util.List<JVMClusterUtil.MasterThread> getMasters()
           
 HRegionServer getRegionServer(int serverNumber)
           
 java.util.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(java.lang.String[] args)
          Test things basically work.
 void shutdown()
          Shut down the mini HBase cluster
 void startup()
          Start the cluster.
 java.lang.String waitOnMaster(int serverNumber)
          Wait for the specified master to stop Removes this thread from list of running threads.
 java.lang.String waitOnMaster(JVMClusterUtil.MasterThread masterThread)
          Wait for the specified master to stop Removes this thread from list of running threads.
 java.lang.String waitOnRegionServer(int serverNumber)
          Wait for the specified region server to stop Removes this thread from list of running threads.
 java.lang.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 java.lang.String LOCAL
local mode

See Also:
Constant Field Values

LOCAL_COLON

public static final java.lang.String LOCAL_COLON
'local:'

See Also:
Constant Field Values
Constructor Detail

LocalHBaseCluster

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

Parameters:
conf -
Throws:
java.io.IOException

LocalHBaseCluster

public LocalHBaseCluster(org.apache.hadoop.conf.Configuration conf,
                         int noRegionServers)
                  throws java.io.IOException
Constructor.

Parameters:
conf - Configuration to use. Post construction has the master's address.
noRegionServers - Count of regionservers to start.
Throws:
java.io.IOException

LocalHBaseCluster

public LocalHBaseCluster(org.apache.hadoop.conf.Configuration conf,
                         int noMasters,
                         int noRegionServers)
                  throws java.io.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:
java.io.IOException

LocalHBaseCluster

public LocalHBaseCluster(org.apache.hadoop.conf.Configuration conf,
                         int noMasters,
                         int noRegionServers,
                         java.lang.Class<? extends HMaster> masterClass,
                         java.lang.Class<? extends HRegionServer> regionServerClass)
                  throws java.io.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:
java.io.IOException
Method Detail

addRegionServer

public JVMClusterUtil.RegionServerThread addRegionServer()
                                                  throws java.io.IOException
Throws:
java.io.IOException

addRegionServer

public JVMClusterUtil.RegionServerThread addRegionServer(org.apache.hadoop.conf.Configuration config,
                                                         int index)
                                                  throws java.io.IOException
Throws:
java.io.IOException

addRegionServer

public JVMClusterUtil.RegionServerThread addRegionServer(org.apache.hadoop.conf.Configuration config,
                                                         int index,
                                                         User user)
                                                  throws java.io.IOException,
                                                         java.lang.InterruptedException
Throws:
java.io.IOException
java.lang.InterruptedException

addMaster

public JVMClusterUtil.MasterThread addMaster()
                                      throws java.io.IOException
Throws:
java.io.IOException

addMaster

public JVMClusterUtil.MasterThread addMaster(org.apache.hadoop.conf.Configuration c,
                                             int index)
                                      throws java.io.IOException
Throws:
java.io.IOException

addMaster

public JVMClusterUtil.MasterThread addMaster(org.apache.hadoop.conf.Configuration c,
                                             int index,
                                             User user)
                                      throws java.io.IOException,
                                             java.lang.InterruptedException
Throws:
java.io.IOException
java.lang.InterruptedException

getRegionServer

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

getRegionServers

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

getLiveRegionServers

public java.util.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 java.lang.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 java.lang.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 java.util.List<JVMClusterUtil.MasterThread> getMasters()
Returns:
Read-only list of master threads.

getLiveMasters

public java.util.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 java.lang.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 java.lang.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(java.lang.String[] args)
                 throws java.io.IOException
Test things basically work.

Parameters:
args -
Throws:
java.io.IOException


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