org.apache.hadoop.hbase.master
Class HMaster

java.lang.Object
  extended by java.lang.Thread
      extended by org.apache.hadoop.hbase.master.HMaster
All Implemented Interfaces:
Runnable, HConstants, HMasterInterface, HMasterRegionInterface, org.apache.hadoop.ipc.VersionedProtocol

public class HMaster
extends Thread
implements HConstants, HMasterInterface, HMasterRegionInterface

HMaster is the "master server" for a HBase. There is only one HMaster for a single HBase deployment.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static String MASTER
          Name of master server
protected  Sleeper sleeper
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface org.apache.hadoop.hbase.HConstants
ALL_META_COLUMNS, ALL_VERSIONS, COL_REGIONINFO, COL_REGIONINFO_ARRAY, COL_SERVER, COL_SPLITA, COL_SPLITB, COL_STARTCODE, COLUMN_FAMILY, COLUMN_FAMILY_ARRAY, COLUMN_FAMILY_HISTORIAN, COLUMN_FAMILY_HISTORIAN_STR, COLUMN_FAMILY_STR, DEFAULT_CLIENT_RETRIES, DEFAULT_HOST, DEFAULT_MASTER_ADDRESS, DEFAULT_MASTER_INFOPORT, DEFAULT_MASTER_PORT, DEFAULT_MAX_FILE_SIZE, DEFAULT_REGION_SERVER_CLASS, DEFAULT_REGIONSERVER_ADDRESS, DEFAULT_REGIONSERVER_INFOPORT, DEFAULT_SIZE_RESERVATION_BLOCK, EMPTY_BYTE_ARRAY, EMPTY_END_ROW, EMPTY_START_ROW, FILE_SYSTEM_VERSION, FOREVER, HBASE_CLIENT_RETRIES_NUMBER_KEY, HBASE_DIR, HREGION_LOGDIR_NAME, HREGION_OLDLOGFILE_NAME, IN_MEMORY, LAST_ROW, LATEST_TIMESTAMP, MAJOR_COMPACTION_PERIOD, MASTER_ADDRESS, META_ROW_DELIMITER, META_TABLE_NAME, NAME, NINES, REGION_SERVER_CLASS, REGION_SERVER_IMPL, REGIONSERVER_ADDRESS, RETRY_BACKOFF, ROOT_TABLE_NAME, THREAD_WAKE_FREQUENCY, UTF8_ENCODING, VERSION_FILE_NAME, VERSIONS, ZERO_L, ZEROES
 
Fields inherited from interface org.apache.hadoop.hbase.ipc.HMasterInterface
versionID
 
Fields inherited from interface org.apache.hadoop.hbase.ipc.HMasterRegionInterface
versionID
 
Constructor Summary
HMaster(HBaseConfiguration conf)
          Build the HMaster out of a raw configuration item.
HMaster(org.apache.hadoop.fs.Path rd, HServerAddress address, HBaseConfiguration conf)
          Build the HMaster
 
Method Summary
 void addColumn(byte[] tableName, HColumnDescriptor column)
          Adds a column to the specified table
protected  boolean checkFileSystem()
          Checks to see if the file system is still accessible.
protected  org.apache.hadoop.io.MapWritable createConfigurationSubset()
           
 void createTable(HTableDescriptor desc)
          Creates a new table
 void deleteColumn(byte[] tableName, byte[] c)
          Deletes a column from the specified table
protected  void deleteEmptyMetaRows(HRegionInterface s, byte[] metaRegionName, List<byte[]> emptyRows)
           
 void deleteTable(byte[] tableName)
          Deletes a table
 void disableTable(byte[] tableName)
          Take table offline
protected static void doMain(String[] args, Class<? extends HMaster> masterClass)
           
 void enableTable(byte[] tableName)
          Puts the table on-line (only needed if table has been previously taken offline)
 HServerAddress findRootRegion()
          Get the location of the root region
 double getAverageLoad()
           
 HBaseConfiguration getConfiguration()
           
 InfoServer getInfoServer()
           
 HServerAddress getMasterAddress()
           
 Map<byte[],MetaRegion> getOnlineMetaRegions()
           
 long getProtocolVersion(String protocol, long clientVersion)
          
 org.apache.hadoop.fs.Path getRootDir()
           
 HServerAddress getRootRegionLocation()
           
 Map<String,HServerLoad> getServersToLoad()
           
 Map<String,HServerInfo> getServersToServerInfo()
           
 boolean isMasterRunning()
          
static void main(String[] args)
          Main program
 void modifyColumn(byte[] tableName, byte[] columnName, HColumnDescriptor descriptor)
          Modifies an existing column on the specified table
 void modifyTableMeta(byte[] tableName, HTableDescriptor desc)
          Modify a table's metadata
 HMsg[] regionServerReport(HServerInfo serverInfo, HMsg[] msgs, HRegionInfo[] mostLoadedRegions)
          Called to renew lease, tell master what the region server is doing and to receive new instructions from the master
 org.apache.hadoop.io.MapWritable regionServerStartup(HServerInfo serverInfo)
          Called when a region server first starts
 void run()
          Main processing loop
 void shutdown()
          Shutdown an HBase cluster.
 void waitForRootRegionLocation()
          Wait until root region is available
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sleeper

protected final Sleeper sleeper

MASTER

public static final String MASTER
Name of master server

See Also:
Constant Field Values
Constructor Detail

HMaster

public HMaster(HBaseConfiguration conf)
        throws IOException
Build the HMaster out of a raw configuration item.

Parameters:
conf - - Configuration object
Throws:
IOException

HMaster

public HMaster(org.apache.hadoop.fs.Path rd,
               HServerAddress address,
               HBaseConfiguration conf)
        throws IOException
Build the HMaster

Parameters:
rd - base directory of this HBase instance. Must be fully qualified so includes filesystem to use.
address - server address and port number
conf - configuration
Throws:
IOException
Method Detail

getProtocolVersion

public long getProtocolVersion(String protocol,
                               long clientVersion)
                        throws IOException

Specified by:
getProtocolVersion in interface org.apache.hadoop.ipc.VersionedProtocol
Throws:
IOException

getInfoServer

public InfoServer getInfoServer()
Returns:
InfoServer object

checkFileSystem

protected boolean checkFileSystem()
Checks to see if the file system is still accessible. If not, sets closed

Returns:
false if file system is not available

getMasterAddress

public HServerAddress getMasterAddress()
Returns:
HServerAddress of the master server

getRootDir

public org.apache.hadoop.fs.Path getRootDir()
Returns:
Hbase root dir.

getServersToServerInfo

public Map<String,HServerInfo> getServersToServerInfo()
Returns:
Read-only map of servers to serverinfo.

getServersToLoad

public Map<String,HServerLoad> getServersToLoad()
Returns:
Read-only map of servers to load.

getAverageLoad

public double getAverageLoad()
Returns:
The average load

getRootRegionLocation

public HServerAddress getRootRegionLocation()
Returns:
Location of the -ROOT- region.

waitForRootRegionLocation

public void waitForRootRegionLocation()
Wait until root region is available


getOnlineMetaRegions

public Map<byte[],MetaRegion> getOnlineMetaRegions()
Returns:
Read-only map of online regions.

run

public void run()
Main processing loop

Specified by:
run in interface Runnable
Overrides:
run in class Thread

regionServerStartup

public org.apache.hadoop.io.MapWritable regionServerStartup(HServerInfo serverInfo)
                                                     throws IOException
Called when a region server first starts

Specified by:
regionServerStartup in interface HMasterRegionInterface
Returns:
Configuration for the regionserver to use: e.g. filesystem, hbase rootdir, etc.
Throws:
IOException

createConfigurationSubset

protected org.apache.hadoop.io.MapWritable createConfigurationSubset()
Returns:
Subset of configuration to pass initializing regionservers: e.g. the filesystem to use and root directory to use.

regionServerReport

public HMsg[] regionServerReport(HServerInfo serverInfo,
                                 HMsg[] msgs,
                                 HRegionInfo[] mostLoadedRegions)
                          throws IOException
Called to renew lease, tell master what the region server is doing and to receive new instructions from the master

Specified by:
regionServerReport in interface HMasterRegionInterface
Parameters:
serverInfo - server's address and start code
msgs - things the region server wants to tell the master
mostLoadedRegions - Array of HRegionInfos that should contain the reporting server's most loaded regions. These are candidates for being rebalanced.
Returns:
instructions from the master to the region server
Throws:
IOException

isMasterRunning

public boolean isMasterRunning()

Specified by:
isMasterRunning in interface HMasterInterface
Returns:
true if master is available

shutdown

public void shutdown()
Shutdown an HBase cluster.

Specified by:
shutdown in interface HMasterInterface

createTable

public void createTable(HTableDescriptor desc)
                 throws IOException
Creates a new table

Specified by:
createTable in interface HMasterInterface
Parameters:
desc - table descriptor
Throws:
IOException

deleteTable

public void deleteTable(byte[] tableName)
                 throws IOException
Deletes a table

Specified by:
deleteTable in interface HMasterInterface
Throws:
IOException

addColumn

public void addColumn(byte[] tableName,
                      HColumnDescriptor column)
               throws IOException
Adds a column to the specified table

Specified by:
addColumn in interface HMasterInterface
column - column descriptor
Throws:
IOException

modifyColumn

public void modifyColumn(byte[] tableName,
                         byte[] columnName,
                         HColumnDescriptor descriptor)
                  throws IOException
Modifies an existing column on the specified table

Specified by:
modifyColumn in interface HMasterInterface
columnName - name of the column to edit
descriptor - new column descriptor
Throws:
IOException

deleteColumn

public void deleteColumn(byte[] tableName,
                         byte[] c)
                  throws IOException
Deletes a column from the specified table

Specified by:
deleteColumn in interface HMasterInterface
Throws:
IOException

enableTable

public void enableTable(byte[] tableName)
                 throws IOException
Puts the table on-line (only needed if table has been previously taken offline)

Specified by:
enableTable in interface HMasterInterface
Throws:
IOException

disableTable

public void disableTable(byte[] tableName)
                  throws IOException
Take table offline

Specified by:
disableTable in interface HMasterInterface
Throws:
IOException

modifyTableMeta

public void modifyTableMeta(byte[] tableName,
                            HTableDescriptor desc)
                     throws IOException
Modify a table's metadata

Specified by:
modifyTableMeta in interface HMasterInterface
Throws:
IOException

findRootRegion

public HServerAddress findRootRegion()
Get the location of the root region

Specified by:
findRootRegion in interface HMasterInterface
Returns:
address of server that serves the root region

getConfiguration

public HBaseConfiguration getConfiguration()
Returns:
Return configuration being used by this server.

deleteEmptyMetaRows

protected void deleteEmptyMetaRows(HRegionInterface s,
                                   byte[] metaRegionName,
                                   List<byte[]> emptyRows)

doMain

protected static void doMain(String[] args,
                             Class<? extends HMaster> masterClass)

main

public static void main(String[] args)
Main program

Parameters:
args -


Copyright © 2008 The Apache Software Foundation