org.apache.hadoop.hbase
Class HMaster

java.lang.Object
  extended by java.lang.Thread
      extended by org.apache.hadoop.hbase.HMaster
All Implemented Interfaces:
Runnable, HConstants, HMasterInterface, HMasterRegionInterface, 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
static class HMaster.MetaRegion
           
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static String MASTER
           
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_VERSIONS, COL_REGIONINFO, COL_REGIONINFO_ARRAY, COL_SERVER, COL_SPLITA, COL_SPLITB, COL_STARTCODE, COLUMN_FAMILY, COLUMN_FAMILY_ARRAY, COLUMN_FAMILY_STR, DEFAULT_HBASE_DIR, DEFAULT_HOST, DEFAULT_MASTER_ADDRESS, DEFAULT_MASTER_INFOPORT, DEFAULT_MAX_FILE_SIZE, DEFAULT_REGION_SERVER_CLASS, DEFAULT_REGIONSERVER_ADDRESS, DEFAULT_REGIONSERVER_INFOPORT, EMPTY_START_ROW, EMPTY_TEXT, HBASE_DIR, HREGION_LOGDIR_NAME, HREGION_OLDLOGFILE_NAME, HREGIONDIR_PREFIX, LATEST_TIMESTAMP, MASTER_ADDRESS, META_TABLE_NAME, REGION_SERVER_CLASS, REGIONSERVER_ADDRESS, ROOT_TABLE_NAME, THREAD_WAKE_FREQUENCY, UTF8_ENCODING
 
Fields inherited from interface org.apache.hadoop.hbase.HMasterInterface
versionID
 
Fields inherited from interface org.apache.hadoop.hbase.HMasterRegionInterface
versionID
 
Constructor Summary
HMaster(Configuration conf)
          Build the HMaster out of a raw configuration item.
HMaster(Path dir, HServerAddress address, Configuration conf)
          Build the HMaster
 
Method Summary
 void addColumn(Text tableName, HColumnDescriptor column)
          Adds a column to the specified table
protected  boolean checkFileSystem()
          Checks to see if the file system is still accessible.
protected  MapWritable createConfigurationSubset()
           
 void createTable(HTableDescriptor desc)
          Creates a new table
 void deleteColumn(Text tableName, Text columnName)
          Deletes a column from the specified table
 void deleteTable(Text tableName)
          Deletes a table
 void disableTable(Text tableName)
          Take table offline
protected static void doMain(String[] args, Class<? extends HMaster> masterClass)
           
 void enableTable(Text tableName)
          Puts the table on-line (only needed if table has been previously taken offline)
 HServerAddress findRootRegion()
          Get the location of the root region
 HServerAddress getMasterAddress()
           
 Map<Text,HMaster.MetaRegion> getOnlineMetaRegions()
           
 long getProtocolVersion(String protocol, long clientVersion)
          Return protocol version corresponding to protocol interface.
 Path getRootDir()
           
 HServerAddress getRootRegionLocation()
           
 Map<String,HServerLoad> getServersToLoad()
           
 Map<String,HServerInfo> getServersToServerInfo()
           
 boolean isMasterRunning()
          
static void main(String[] args)
          Main program
 HMsg[] regionServerReport(HServerInfo serverInfo, HMsg[] msgs)
          Called to renew lease, tell master what the region server is doing and to receive new instructions from the master
 MapWritable regionServerStartup(HServerInfo serverInfo)
          Called when a region server first starts
 void run()
          Main processing loop
 void shutdown()
          Shutdown an HBase cluster.
 
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 Sleeper sleeper

MASTER

public static final String MASTER
See Also:
Constant Field Values
Constructor Detail

HMaster

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

Parameters:
conf - - Configuration object
Throws:
IOException

HMaster

public HMaster(Path dir,
               HServerAddress address,
               Configuration conf)
        throws IOException
Build the HMaster

Parameters:
dir - base directory
address - server address and port number
conf - configuration
Throws:
IOException
Method Detail

getProtocolVersion

public long getProtocolVersion(String protocol,
                               long clientVersion)
                        throws IOException
Return protocol version corresponding to protocol interface.

Specified by:
getProtocolVersion in interface VersionedProtocol
Parameters:
protocol - The classname of the protocol interface
clientVersion - The version of the protocol that the client speaks
Returns:
the version that the server will speak
Throws:
IOException

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

getRootRegionLocation

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

getOnlineMetaRegions

public Map<Text,HMaster.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 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 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)
                          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
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(Text tableName)
                 throws IOException
Deletes a table

Specified by:
deleteTable in interface HMasterInterface
Throws:
IOException

addColumn

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

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

deleteColumn

public void deleteColumn(Text tableName,
                         Text columnName)
                  throws IOException
Deletes a column from the specified table

Specified by:
deleteColumn in interface HMasterInterface
Throws:
IOException

enableTable

public void enableTable(Text 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(Text tableName)
                  throws IOException
Take table offline

Specified by:
disableTable 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

doMain

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

main

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

Parameters:
args -


Copyright © 2006 The Apache Software Foundation