org.apache.hadoop.hbase
Class LocalHBaseCluster

java.lang.Object
  extended by org.apache.hadoop.hbase.LocalHBaseCluster
All Implemented Interfaces:
HConstants

public class LocalHBaseCluster
extends Object
implements HConstants

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.

To make 'local' mode more responsive, make values such as hbase.regionserver.msginterval, hbase.master.meta.thread.rescanfrequency, and hbase.server.thread.wakefrequency a second or less.


Nested Class Summary
static class LocalHBaseCluster.RegionServerThread
          runs region servers
 
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.HConstants
HConstants.Modify
 
Field Summary
static String LOCAL
          local mode
static String LOCAL_COLON
          'local:'
 
Fields inherited from interface org.apache.hadoop.hbase.HConstants
ALL_VERSIONS, CATALOG_FAMILY, CATALOG_FAMILY_STR, CATALOG_HISTORIAN_FAMILY, CLUSTER_DISTRIBUTED, CLUSTER_IS_DISTRIBUTED, CLUSTER_IS_LOCAL, DEFAULT_HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE, DEFAULT_HOST, DEFAULT_MASTER_INFOPORT, DEFAULT_MASTER_PORT, DEFAULT_MAX_FILE_SIZE, DEFAULT_REGION_SERVER_CLASS, DEFAULT_REGIONSERVER_INFOPORT, DEFAULT_REGIONSERVER_PORT, DEFAULT_SIZE_RESERVATION_BLOCK, DEFAULT_ZOOKEEPER_PAUSE, DEFAULT_ZOOKEEPER_RETRIES, EMPTY_BYTE_ARRAY, EMPTY_END_ROW, EMPTY_START_ROW, FILE_SYSTEM_VERSION, FOREVER, HBASE_CLIENT_RETRIES_NUMBER_KEY, HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY, HBASE_DIR, HREGION_COMPACTIONDIR_NAME, HREGION_LOGDIR_NAME, HREGION_OLDLOGFILE_NAME, IN_MEMORY, LAST_ROW, LATEST_TIMESTAMP, LATEST_TIMESTAMP_BYTES, MAJOR_COMPACTION_PERIOD, MASTER_PORT, MAX_ROW_LENGTH, MAXIMUM_VALUE_LENGTH, META_ROW_DELIMITER, META_TABLE_NAME, NAME, NINES, REGION_IMPL, REGION_SERVER_CLASS, REGION_SERVER_IMPL, REGIONINFO_QUALIFIER, REGIONSERVER_PORT, RETRY_BACKOFF, ROOT_TABLE_NAME, SERVER_QUALIFIER, SPLITA_QUALIFIER, SPLITB_QUALIFIER, STARTCODE_QUALIFIER, THREAD_WAKE_FREQUENCY, UTF8_ENCODING, VERSION_FILE_NAME, VERSIONS, WEEK_IN_SECONDS, ZERO_L, ZEROES, ZOOKEEPER_CONFIG_NAME, ZOOKEEPER_PAUSE, ZOOKEEPER_QUORUM, ZOOKEEPER_RETRIES
 
Constructor Summary
LocalHBaseCluster(HBaseConfiguration conf)
          Constructor.
LocalHBaseCluster(HBaseConfiguration conf, int noRegionServers)
          Constructor.
 
Method Summary
 LocalHBaseCluster.RegionServerThread addRegionServer()
          Creates a region server.
 HMaster getMaster()
           
 HRegionServer getRegionServer(int serverNumber)
           
 List<LocalHBaseCluster.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
 String startup()
          Start the cluster.
 void threadDumpingJoin(Thread t)
           
 String waitOnRegionServer(int serverNumber)
          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(HBaseConfiguration conf)
                  throws IOException
Constructor.

Parameters:
conf -
Throws:
IOException

LocalHBaseCluster

public LocalHBaseCluster(HBaseConfiguration 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
Method Detail

addRegionServer

public LocalHBaseCluster.RegionServerThread addRegionServer()
                                                     throws IOException
Creates a region server. Call 'start' on the returned thread to make it run.

Returns:
Region server added.
Throws:
IOException

getRegionServer

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

getMaster

public HMaster getMaster()
Returns:
the HMaster thread

getRegionServers

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

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.

join

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


startup

public String startup()
Start the cluster.

Returns:
Address to use contacting master.

shutdown

public void shutdown()
Shut down the mini HBase cluster


threadDumpingJoin

public void threadDumpingJoin(Thread t)
                       throws InterruptedException
Parameters:
t -
Throws:
InterruptedException

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 © 2010 The Apache Software Foundation