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, HBaseRPCProtocolVersion, 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. NOTE: This class extends Thread rather than Chore because the sleep time can be interrupted when there is something to do, rather than the Chore sleep time which is invariant.


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
 
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_HOST, DEFAULT_MASTER_ADDRESS, DEFAULT_MASTER_INFOPORT, DEFAULT_MASTER_PORT, DEFAULT_MAX_FILE_SIZE, DEFAULT_NUMBER_CONCURRENT_LOG_READS, DEFAULT_NUMBER_LOG_WRITER_THREAD, 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_COMPACTIONDIR_NAME, HREGION_LOGDIR_NAME, HREGION_OLDLOGFILE_NAME, IN_MEMORY, LAST_ROW, LATEST_TIMESTAMP, MAJOR_COMPACTION_PERIOD, MASTER_ADDRESS, MAX_ROW_LENGTH, META_ROW_DELIMITER, META_TABLE_NAME, MODIFY_CLOSE_REGION, MODIFY_TABLE_COMPACT, MODIFY_TABLE_FLUSH, MODIFY_TABLE_MAJOR_COMPACT, MODIFY_TABLE_SET_HTD, MODIFY_TABLE_SPLIT, NAME, NINES, REGION_SERVER_CLASS, REGION_SERVER_IMPL, REGIONSERVER_ADDRESS, RETRY_BACKOFF, ROOT_TABLE_NAME, THREAD_WAKE_FREQUENCY, UTF8_ENCODING, VERSION_FILE_NAME, VERSIONS, WEEK_IN_SECONDS, ZERO_L, ZEROES
 
Fields inherited from interface org.apache.hadoop.hbase.ipc.HBaseRPCProtocolVersion
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.
 int countRegionsOnFS()
           
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()
           
protected  RowResult getFromMETA(byte[] row, byte[][] columns)
          Get row from meta table.
 InfoServer getInfoServer()
           
 HServerAddress getMasterAddress()
           
 MasterMetrics getMetrics()
           
 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 modifyTable(byte[] tableName, int op, org.apache.hadoop.io.Writable[] args)
          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

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)
Specified by:
getProtocolVersion in interface org.apache.hadoop.ipc.VersionedProtocol

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

countRegionsOnFS

public int countRegionsOnFS()
Returns:
the number of regions on filesystem

getRootRegionLocation

public HServerAddress getRootRegionLocation()
Specified by:
getRootRegionLocation in interface HMasterRegionInterface
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)
Description copied from interface: HMasterRegionInterface
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.

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
Description copied from interface: HMasterRegionInterface
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()
Description copied from interface: HMasterInterface
Shutdown an HBase cluster.

Specified by:
shutdown in interface HMasterInterface

createTable

public void createTable(HTableDescriptor desc)
                 throws IOException
Description copied from interface: HMasterInterface
Creates a new table

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

deleteTable

public void deleteTable(byte[] tableName)
                 throws IOException
Description copied from interface: HMasterInterface
Deletes a table

Specified by:
deleteTable in interface HMasterInterface
Throws:
IOException

addColumn

public void addColumn(byte[] tableName,
                      HColumnDescriptor column)
               throws IOException
Description copied from interface: HMasterInterface
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
Description copied from interface: HMasterInterface
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
Description copied from interface: HMasterInterface
Deletes a column from the specified table

Specified by:
deleteColumn in interface HMasterInterface
Throws:
IOException

enableTable

public void enableTable(byte[] tableName)
                 throws IOException
Description copied from interface: HMasterInterface
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
Description copied from interface: HMasterInterface
Take table offline

Specified by:
disableTable in interface HMasterInterface
Throws:
IOException

getFromMETA

protected RowResult getFromMETA(byte[] row,
                                byte[][] columns)
                         throws IOException
Get row from meta table.

Parameters:
row -
columns -
Returns:
RowResult
Throws:
IOException

modifyTable

public void modifyTable(byte[] tableName,
                        int op,
                        org.apache.hadoop.io.Writable[] args)
                 throws IOException
Description copied from interface: HMasterInterface
Modify a table's metadata

Specified by:
modifyTable in interface HMasterInterface
Throws:
IOException

findRootRegion

public HServerAddress findRootRegion()
Description copied from interface: HMasterInterface
Get the location of the root region

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

getMetrics

public MasterMetrics getMetrics()
Returns:
Server metrics

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