org.apache.hadoop.hbase.master
Class HMaster

java.lang.Object
  extended by org.apache.hadoop.hbase.util.HasThread
      extended by org.apache.hadoop.hbase.master.HMaster
All Implemented Interfaces:
Runnable, Abortable, MasterServices, MasterAdminProtos.MasterAdminService.BlockingInterface, MasterMonitorProtos.MasterMonitorService.BlockingInterface, RegionServerStatusProtos.RegionServerStatusService.BlockingInterface, Server, Stoppable
Direct Known Subclasses:
HMasterCommandLine.LocalHMaster

@InterfaceAudience.Private
public class HMaster
extends HasThread
implements MasterMonitorProtos.MasterMonitorService.BlockingInterface, MasterAdminProtos.MasterAdminService.BlockingInterface, RegionServerStatusProtos.RegionServerStatusService.BlockingInterface, MasterServices, Server

HMaster is the "master server" for HBase. An HBase cluster has one active master. If many masters are started, all compete. Whichever wins goes on to run the cluster. All others park themselves in their constructor until master or cluster shutdown or until the active master loses its lease in zookeeper. Thereafter, all running master jostle to take over master role.

The Master can be asked shutdown the cluster. See shutdown(). In this case it will tell all regionservers to go down and then wait on them all reporting in that they are down. This master will then shut itself down.

You can also shutdown just this master. Call stopMaster().

See Also:
Watcher

Field Summary
static String MASTER
           
 
Constructor Summary
HMaster(org.apache.hadoop.conf.Configuration conf)
          Initializes the HMaster.
 
Method Summary
 void abort(String msg, Throwable t)
           
 MasterAdminProtos.AddColumnResponse addColumn(com.google.protobuf.RpcController controller, MasterAdminProtos.AddColumnRequest req)
           
 void addColumn(TableName tableName, HColumnDescriptor column)
          Add a new column to an existing table
 void assignRegion(HRegionInfo hri)
           
 MasterAdminProtos.AssignRegionResponse assignRegion(com.google.protobuf.RpcController controller, MasterAdminProtos.AssignRegionRequest req)
           
 boolean balance()
           
 MasterAdminProtos.BalanceResponse balance(com.google.protobuf.RpcController c, MasterAdminProtos.BalanceRequest request)
           
 boolean balanceSwitch(boolean b)
           
 void checkTableModifiable(TableName tableName)
          Check table is modifiable; i.e.
static HMaster constructMaster(Class<? extends HMaster> masterClass, org.apache.hadoop.conf.Configuration conf)
          Utility for constructing an instance of the passed HMaster class.
protected  RegionServerStatusProtos.RegionServerStartupResponse.Builder createConfigurationSubset()
           
 void createNamespace(NamespaceDescriptor descriptor)
          Create a new namespace
 MasterAdminProtos.CreateNamespaceResponse createNamespace(com.google.protobuf.RpcController controller, MasterAdminProtos.CreateNamespaceRequest request)
           
 void createTable(HTableDescriptor hTableDescriptor, byte[][] splitKeys)
          Create a table using the given table definition.
 MasterAdminProtos.CreateTableResponse createTable(com.google.protobuf.RpcController controller, MasterAdminProtos.CreateTableRequest req)
           
 MasterAdminProtos.DeleteColumnResponse deleteColumn(com.google.protobuf.RpcController controller, MasterAdminProtos.DeleteColumnRequest req)
           
 void deleteColumn(TableName tableName, byte[] columnName)
          Delete a column from an existing table
 MasterAdminProtos.DeleteNamespaceResponse deleteNamespace(com.google.protobuf.RpcController controller, MasterAdminProtos.DeleteNamespaceRequest request)
           
 void deleteNamespace(String name)
          Delete an existing namespace.
 MasterAdminProtos.DeleteSnapshotResponse deleteSnapshot(com.google.protobuf.RpcController controller, MasterAdminProtos.DeleteSnapshotRequest request)
          Execute Delete Snapshot operation.
 MasterAdminProtos.DeleteTableResponse deleteTable(com.google.protobuf.RpcController controller, MasterAdminProtos.DeleteTableRequest request)
           
 void deleteTable(TableName tableName)
          Delete a table
 MasterAdminProtos.DisableTableResponse disableTable(com.google.protobuf.RpcController controller, MasterAdminProtos.DisableTableRequest request)
           
 void disableTable(TableName tableName)
          Disable an existing table
 void dispatchMergingRegions(HRegionInfo region_a, HRegionInfo region_b, boolean forcible)
          Merge two regions.
 MasterAdminProtos.DispatchMergingRegionsResponse dispatchMergingRegions(com.google.protobuf.RpcController controller, MasterAdminProtos.DispatchMergingRegionsRequest request)
           
 MasterAdminProtos.EnableCatalogJanitorResponse enableCatalogJanitor(com.google.protobuf.RpcController c, MasterAdminProtos.EnableCatalogJanitorRequest req)
           
 MasterAdminProtos.EnableTableResponse enableTable(com.google.protobuf.RpcController controller, MasterAdminProtos.EnableTableRequest request)
           
 void enableTable(TableName tableName)
          Enable an existing table
 ClientProtos.CoprocessorServiceResponse execMasterService(com.google.protobuf.RpcController controller, ClientProtos.CoprocessorServiceRequest request)
           
 ActiveMasterManager getActiveMasterManager()
           
 AssignmentManager getAssignmentManager()
           
 double getAverageLoad()
          Compute the average load across all region servers.
 CatalogTracker getCatalogTracker()
           
 String getClusterId()
           
 ClusterStatus getClusterStatus()
           
 MasterMonitorProtos.GetClusterStatusResponse getClusterStatus(com.google.protobuf.RpcController controller, MasterMonitorProtos.GetClusterStatusRequest req)
           
 MasterAdminProtos.ListSnapshotResponse getCompletedSnapshots(com.google.protobuf.RpcController controller, MasterAdminProtos.ListSnapshotRequest request)
          List the currently available/stored snapshots.
 org.apache.hadoop.conf.Configuration getConfiguration()
           
 MasterCoprocessorHost getCoprocessorHost()
           
 String[] getCoprocessors()
           
 ExecutorService getExecutorService()
           
 HFileCleaner getHFileCleaner()
           
 InfoServer getInfoServer()
           
 RegionServerStatusProtos.GetLastFlushedSequenceIdResponse getLastFlushedSequenceId(com.google.protobuf.RpcController controller, RegionServerStatusProtos.GetLastFlushedSequenceIdRequest request)
           
static String getLoadedCoprocessors()
          The set of loaded coprocessors is stored in a static set.
 long getMasterActiveTime()
           
 MasterAddressTracker getMasterAddressManager()
           
 MasterFileSystem getMasterFileSystem()
           
 long getMasterStartTime()
           
 MasterAdminProtos.GetNamespaceDescriptorResponse getNamespaceDescriptor(com.google.protobuf.RpcController controller, MasterAdminProtos.GetNamespaceDescriptorRequest request)
           
 NamespaceDescriptor getNamespaceDescriptor(String name)
          Get a namespace descriptor by name
 MemoryBoundedLogMessageBuffer getRegionServerFatalLogBuffer()
           
 MasterMonitorProtos.GetSchemaAlterStatusResponse getSchemaAlterStatus(com.google.protobuf.RpcController controller, MasterMonitorProtos.GetSchemaAlterStatusRequest req)
          Get the number of regions of the table that have been updated by the alter.
 ServerManager getServerManager()
           
 ServerName getServerName()
           
 SnapshotManager getSnapshotManagerForTesting()
          Exposed for TESTING!
 TableDescriptors getTableDescriptors()
           
 MasterMonitorProtos.GetTableDescriptorsResponse getTableDescriptors(com.google.protobuf.RpcController controller, MasterMonitorProtos.GetTableDescriptorsRequest req)
          Get list of TableDescriptors for requested tables.
 TableLockManager getTableLockManager()
           
 MasterMonitorProtos.GetTableNamesResponse getTableNames(com.google.protobuf.RpcController controller, MasterMonitorProtos.GetTableNamesRequest req)
          Get list of userspace table names
 ZooKeeperWatcher getZooKeeper()
           
 ZooKeeperWatcher getZooKeeperWatcher()
          Get the ZK wrapper object - needed by master_jsp.java
 boolean isAborted()
           
 boolean isActiveMaster()
          Report whether this master is currently the active master or not.
 MasterAdminProtos.IsCatalogJanitorEnabledResponse isCatalogJanitorEnabled(com.google.protobuf.RpcController c, MasterAdminProtos.IsCatalogJanitorEnabledRequest req)
           
 boolean isInitializationStartsMetaRegionAssignment()
          Report whether this master has started initialization and is about to do meta region assignment
 boolean isInitialized()
          Report whether this master has completed with its initialization and is ready.
 boolean isMasterRunning()
           
 MasterProtos.IsMasterRunningResponse isMasterRunning(com.google.protobuf.RpcController c, MasterProtos.IsMasterRunningRequest req)
           
 MasterAdminProtos.IsRestoreSnapshotDoneResponse isRestoreSnapshotDone(com.google.protobuf.RpcController controller, MasterAdminProtos.IsRestoreSnapshotDoneRequest request)
          Returns the status of the requested snapshot restore/clone operation.
 boolean isServerShutdownHandlerEnabled()
          ServerShutdownHandlerEnabled is set false before completing assignMeta to prevent processing of ServerShutdownHandler.
 MasterAdminProtos.IsSnapshotDoneResponse isSnapshotDone(com.google.protobuf.RpcController controller, MasterAdminProtos.IsSnapshotDoneRequest request)
          Checks if the specified snapshot is done.
 boolean isStopped()
           
 List<NamespaceDescriptor> listNamespaceDescriptors()
          List available namespace descriptors
 MasterAdminProtos.ListNamespaceDescriptorsResponse listNamespaceDescriptors(com.google.protobuf.RpcController controller, MasterAdminProtos.ListNamespaceDescriptorsRequest request)
           
 MasterAdminProtos.ListTableDescriptorsByNamespaceResponse listTableDescriptorsByNamespace(com.google.protobuf.RpcController controller, MasterAdminProtos.ListTableDescriptorsByNamespaceRequest request)
           
 List<HTableDescriptor> listTableDescriptorsByNamespace(String name)
          Get list of table descriptors by namespace
 MasterAdminProtos.ListTableNamesByNamespaceResponse listTableNamesByNamespace(com.google.protobuf.RpcController controller, MasterAdminProtos.ListTableNamesByNamespaceRequest request)
           
 List<TableName> listTableNamesByNamespace(String name)
          Get list of table names by namespace
static void main(String[] args)
           
 MasterAdminProtos.ModifyColumnResponse modifyColumn(com.google.protobuf.RpcController controller, MasterAdminProtos.ModifyColumnRequest req)
           
 void modifyColumn(TableName tableName, HColumnDescriptor descriptor)
          Modify the column descriptor of an existing column in an existing table
 void modifyNamespace(NamespaceDescriptor descriptor)
          Modify an existing namespace
 MasterAdminProtos.ModifyNamespaceResponse modifyNamespace(com.google.protobuf.RpcController controller, MasterAdminProtos.ModifyNamespaceRequest request)
           
 MasterAdminProtos.ModifyTableResponse modifyTable(com.google.protobuf.RpcController controller, MasterAdminProtos.ModifyTableRequest req)
           
 void modifyTable(TableName tableName, HTableDescriptor descriptor)
          Modify the descriptor of an existing table
 MasterAdminProtos.MoveRegionResponse moveRegion(com.google.protobuf.RpcController controller, MasterAdminProtos.MoveRegionRequest req)
           
 MasterAdminProtos.OfflineRegionResponse offlineRegion(com.google.protobuf.RpcController controller, MasterAdminProtos.OfflineRegionRequest request)
          Offline specified region from master's in-memory state.
 RegionServerStatusProtos.RegionServerReportResponse regionServerReport(com.google.protobuf.RpcController controller, RegionServerStatusProtos.RegionServerReportRequest request)
           
 RegionServerStatusProtos.RegionServerStartupResponse regionServerStartup(com.google.protobuf.RpcController controller, RegionServerStatusProtos.RegionServerStartupRequest request)
           
 boolean registerService(com.google.protobuf.Service instance)
          Registers a new protocol buffer Service subclass as a master coprocessor endpoint.
 RegionServerStatusProtos.ReportRSFatalErrorResponse reportRSFatalError(com.google.protobuf.RpcController controller, RegionServerStatusProtos.ReportRSFatalErrorRequest request)
           
 MasterAdminProtos.RestoreSnapshotResponse restoreSnapshot(com.google.protobuf.RpcController controller, MasterAdminProtos.RestoreSnapshotRequest request)
          Execute Restore/Clone snapshot operation.
 void run()
          Main processing loop for the HMaster.
 MasterAdminProtos.CatalogScanResponse runCatalogScan(com.google.protobuf.RpcController c, MasterAdminProtos.CatalogScanRequest req)
           
 MasterAdminProtos.SetBalancerRunningResponse setBalancerRunning(com.google.protobuf.RpcController controller, MasterAdminProtos.SetBalancerRunningRequest req)
           
 void setCatalogJanitorEnabled(boolean b)
          Switch for the background CatalogJanitor thread.
 void shutdown()
           
 MasterAdminProtos.ShutdownResponse shutdown(com.google.protobuf.RpcController controller, MasterAdminProtos.ShutdownRequest request)
           
 MasterAdminProtos.TakeSnapshotResponse snapshot(com.google.protobuf.RpcController controller, MasterAdminProtos.TakeSnapshotRequest request)
          Triggers an asynchronous attempt to take a snapshot.
protected  void startCatalogJanitorChore()
          Useful for testing purpose also where we have master restart scenarios.
protected  void startNamespaceJanitorChore()
          Useful for testing purpose also where we have master restart scenarios.
 void stop(String why)
           
 void stopMaster()
           
 MasterAdminProtos.StopMasterResponse stopMaster(com.google.protobuf.RpcController controller, MasterAdminProtos.StopMasterRequest request)
           
 boolean switchBalancer(boolean b, org.apache.hadoop.hbase.master.HMaster.BalanceSwitchMode mode)
          Assigns balancer switch according to BalanceSwitchMode
 boolean synchronousBalanceSwitch(boolean b)
           
 MasterAdminProtos.UnassignRegionResponse unassignRegion(com.google.protobuf.RpcController controller, MasterAdminProtos.UnassignRegionRequest req)
           
 
Methods inherited from class org.apache.hadoop.hbase.util.HasThread
getName, getThread, interrupt, isAlive, isInterrupted, join, join, join, setDaemon, setName, setPriority, setUncaughtExceptionHandler, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MASTER

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

HMaster

public HMaster(org.apache.hadoop.conf.Configuration conf)
        throws IOException,
               org.apache.zookeeper.KeeperException,
               InterruptedException
Initializes the HMaster. The steps are as follows:

  1. Initialize HMaster RPC and address
  2. Connect to ZooKeeper.

Remaining steps of initialization occur in run() so that they run in their own thread rather than within the context of the constructor.

Throws:
InterruptedException
IOException
org.apache.zookeeper.KeeperException
Method Detail

run

public void run()
Main processing loop for the HMaster.
  1. Block until becoming active master
  2. Finish initialization via finishInitialization(MonitoredTask)
  3. Enter loop until we are stopped
  4. Stop services and perform cleanup once stopped

Specified by:
run in interface Runnable
Specified by:
run in class HasThread

startCatalogJanitorChore

protected void startCatalogJanitorChore()
Useful for testing purpose also where we have master restart scenarios.


startNamespaceJanitorChore

protected void startNamespaceJanitorChore()
Useful for testing purpose also where we have master restart scenarios.


getTableDescriptors

public TableDescriptors getTableDescriptors()
Specified by:
getTableDescriptors in interface MasterServices
Returns:
Return table descriptors implementation.

getInfoServer

public InfoServer getInfoServer()
Returns:
InfoServer object. Maybe null.

getConfiguration

public org.apache.hadoop.conf.Configuration getConfiguration()
Specified by:
getConfiguration in interface Server

getServerManager

public ServerManager getServerManager()
Specified by:
getServerManager in interface MasterServices
Returns:
Master's ServerManager instance.

getExecutorService

public ExecutorService getExecutorService()
Specified by:
getExecutorService in interface MasterServices
Returns:
Master's instance of ExecutorService

getMasterFileSystem

public MasterFileSystem getMasterFileSystem()
Specified by:
getMasterFileSystem in interface MasterServices
Returns:
Master's filesystem MasterFileSystem utility class.

getZooKeeperWatcher

public ZooKeeperWatcher getZooKeeperWatcher()
Get the ZK wrapper object - needed by master_jsp.java

Returns:
the zookeeper wrapper

getActiveMasterManager

public ActiveMasterManager getActiveMasterManager()

getMasterAddressManager

public MasterAddressTracker getMasterAddressManager()

regionServerStartup

public RegionServerStatusProtos.RegionServerStartupResponse regionServerStartup(com.google.protobuf.RpcController controller,
                                                                                RegionServerStatusProtos.RegionServerStartupRequest request)
                                                                         throws com.google.protobuf.ServiceException
Specified by:
regionServerStartup in interface RegionServerStatusProtos.RegionServerStatusService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

createConfigurationSubset

protected RegionServerStatusProtos.RegionServerStartupResponse.Builder createConfigurationSubset()
Returns:
Subset of configuration to pass initializing regionservers: e.g. the filesystem to use and root directory to use.

getLastFlushedSequenceId

public RegionServerStatusProtos.GetLastFlushedSequenceIdResponse getLastFlushedSequenceId(com.google.protobuf.RpcController controller,
                                                                                          RegionServerStatusProtos.GetLastFlushedSequenceIdRequest request)
                                                                                   throws com.google.protobuf.ServiceException
Specified by:
getLastFlushedSequenceId in interface RegionServerStatusProtos.RegionServerStatusService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

regionServerReport

public RegionServerStatusProtos.RegionServerReportResponse regionServerReport(com.google.protobuf.RpcController controller,
                                                                              RegionServerStatusProtos.RegionServerReportRequest request)
                                                                       throws com.google.protobuf.ServiceException
Specified by:
regionServerReport in interface RegionServerStatusProtos.RegionServerStatusService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

reportRSFatalError

public RegionServerStatusProtos.ReportRSFatalErrorResponse reportRSFatalError(com.google.protobuf.RpcController controller,
                                                                              RegionServerStatusProtos.ReportRSFatalErrorRequest request)
                                                                       throws com.google.protobuf.ServiceException
Specified by:
reportRSFatalError in interface RegionServerStatusProtos.RegionServerStatusService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

isMasterRunning

public boolean isMasterRunning()

isMasterRunning

public MasterProtos.IsMasterRunningResponse isMasterRunning(com.google.protobuf.RpcController c,
                                                            MasterProtos.IsMasterRunningRequest req)
                                                     throws com.google.protobuf.ServiceException
Specified by:
isMasterRunning in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Specified by:
isMasterRunning in interface MasterMonitorProtos.MasterMonitorService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

runCatalogScan

public MasterAdminProtos.CatalogScanResponse runCatalogScan(com.google.protobuf.RpcController c,
                                                            MasterAdminProtos.CatalogScanRequest req)
                                                     throws com.google.protobuf.ServiceException
Specified by:
runCatalogScan in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

enableCatalogJanitor

public MasterAdminProtos.EnableCatalogJanitorResponse enableCatalogJanitor(com.google.protobuf.RpcController c,
                                                                           MasterAdminProtos.EnableCatalogJanitorRequest req)
                                                                    throws com.google.protobuf.ServiceException
Specified by:
enableCatalogJanitor in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

isCatalogJanitorEnabled

public MasterAdminProtos.IsCatalogJanitorEnabledResponse isCatalogJanitorEnabled(com.google.protobuf.RpcController c,
                                                                                 MasterAdminProtos.IsCatalogJanitorEnabledRequest req)
                                                                          throws com.google.protobuf.ServiceException
Specified by:
isCatalogJanitorEnabled in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

balance

public boolean balance()
                throws HBaseIOException
Throws:
HBaseIOException

balance

public MasterAdminProtos.BalanceResponse balance(com.google.protobuf.RpcController c,
                                                 MasterAdminProtos.BalanceRequest request)
                                          throws com.google.protobuf.ServiceException
Specified by:
balance in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

switchBalancer

public boolean switchBalancer(boolean b,
                              org.apache.hadoop.hbase.master.HMaster.BalanceSwitchMode mode)
                       throws IOException
Assigns balancer switch according to BalanceSwitchMode

Parameters:
b - new balancer switch
mode - BalanceSwitchMode
Returns:
old balancer switch
Throws:
IOException

synchronousBalanceSwitch

public boolean synchronousBalanceSwitch(boolean b)
                                 throws IOException
Throws:
IOException

balanceSwitch

public boolean balanceSwitch(boolean b)
                      throws IOException
Throws:
IOException

setBalancerRunning

public MasterAdminProtos.SetBalancerRunningResponse setBalancerRunning(com.google.protobuf.RpcController controller,
                                                                       MasterAdminProtos.SetBalancerRunningRequest req)
                                                                throws com.google.protobuf.ServiceException
Specified by:
setBalancerRunning in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

setCatalogJanitorEnabled

public void setCatalogJanitorEnabled(boolean b)
Switch for the background CatalogJanitor thread. Used for testing. The thread will continue to run. It will just be a noop if disabled.

Parameters:
b - If false, the catalog janitor won't do anything.

dispatchMergingRegions

public MasterAdminProtos.DispatchMergingRegionsResponse dispatchMergingRegions(com.google.protobuf.RpcController controller,
                                                                               MasterAdminProtos.DispatchMergingRegionsRequest request)
                                                                        throws com.google.protobuf.ServiceException
Specified by:
dispatchMergingRegions in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

dispatchMergingRegions

public void dispatchMergingRegions(HRegionInfo region_a,
                                   HRegionInfo region_b,
                                   boolean forcible)
                            throws IOException
Description copied from interface: MasterServices
Merge two regions. The real implementation is on the regionserver, master just move the regions together and send MERGE RPC to regionserver

Specified by:
dispatchMergingRegions in interface MasterServices
Parameters:
region_a - region to merge
region_b - region to merge
forcible - true if do a compulsory merge, otherwise we will only merge two adjacent regions
Throws:
IOException

moveRegion

public MasterAdminProtos.MoveRegionResponse moveRegion(com.google.protobuf.RpcController controller,
                                                       MasterAdminProtos.MoveRegionRequest req)
                                                throws com.google.protobuf.ServiceException
Specified by:
moveRegion in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

createTable

public void createTable(HTableDescriptor hTableDescriptor,
                        byte[][] splitKeys)
                 throws IOException
Description copied from interface: MasterServices
Create a table using the given table definition.

Specified by:
createTable in interface MasterServices
Parameters:
hTableDescriptor - The table definition
splitKeys - Starting row keys for the initial table regions. If null a single region is created.
Throws:
IOException

createTable

public MasterAdminProtos.CreateTableResponse createTable(com.google.protobuf.RpcController controller,
                                                         MasterAdminProtos.CreateTableRequest req)
                                                  throws com.google.protobuf.ServiceException
Specified by:
createTable in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

deleteTable

public void deleteTable(TableName tableName)
                 throws IOException
Description copied from interface: MasterServices
Delete a table

Specified by:
deleteTable in interface MasterServices
Parameters:
tableName - The table name
Throws:
IOException

deleteTable

public MasterAdminProtos.DeleteTableResponse deleteTable(com.google.protobuf.RpcController controller,
                                                         MasterAdminProtos.DeleteTableRequest request)
                                                  throws com.google.protobuf.ServiceException
Specified by:
deleteTable in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

getSchemaAlterStatus

public MasterMonitorProtos.GetSchemaAlterStatusResponse getSchemaAlterStatus(com.google.protobuf.RpcController controller,
                                                                             MasterMonitorProtos.GetSchemaAlterStatusRequest req)
                                                                      throws com.google.protobuf.ServiceException
Get the number of regions of the table that have been updated by the alter.

Specified by:
getSchemaAlterStatus in interface MasterMonitorProtos.MasterMonitorService.BlockingInterface
Returns:
Pair indicating the number of regions updated Pair.getFirst is the regions that are yet to be updated Pair.getSecond is the total number of regions of the table
Throws:
IOException
com.google.protobuf.ServiceException

addColumn

public void addColumn(TableName tableName,
                      HColumnDescriptor column)
               throws IOException
Description copied from interface: MasterServices
Add a new column to an existing table

Specified by:
addColumn in interface MasterServices
Parameters:
tableName - The table name
column - The column definition
Throws:
IOException

addColumn

public MasterAdminProtos.AddColumnResponse addColumn(com.google.protobuf.RpcController controller,
                                                     MasterAdminProtos.AddColumnRequest req)
                                              throws com.google.protobuf.ServiceException
Specified by:
addColumn in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

modifyColumn

public void modifyColumn(TableName tableName,
                         HColumnDescriptor descriptor)
                  throws IOException
Description copied from interface: MasterServices
Modify the column descriptor of an existing column in an existing table

Specified by:
modifyColumn in interface MasterServices
Parameters:
tableName - The table name
descriptor - The updated column definition
Throws:
IOException

modifyColumn

public MasterAdminProtos.ModifyColumnResponse modifyColumn(com.google.protobuf.RpcController controller,
                                                           MasterAdminProtos.ModifyColumnRequest req)
                                                    throws com.google.protobuf.ServiceException
Specified by:
modifyColumn in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

deleteColumn

public void deleteColumn(TableName tableName,
                         byte[] columnName)
                  throws IOException
Description copied from interface: MasterServices
Delete a column from an existing table

Specified by:
deleteColumn in interface MasterServices
Parameters:
tableName - The table name
columnName - The column name
Throws:
IOException

deleteColumn

public MasterAdminProtos.DeleteColumnResponse deleteColumn(com.google.protobuf.RpcController controller,
                                                           MasterAdminProtos.DeleteColumnRequest req)
                                                    throws com.google.protobuf.ServiceException
Specified by:
deleteColumn in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

enableTable

public void enableTable(TableName tableName)
                 throws IOException
Description copied from interface: MasterServices
Enable an existing table

Specified by:
enableTable in interface MasterServices
Parameters:
tableName - The table name
Throws:
IOException

enableTable

public MasterAdminProtos.EnableTableResponse enableTable(com.google.protobuf.RpcController controller,
                                                         MasterAdminProtos.EnableTableRequest request)
                                                  throws com.google.protobuf.ServiceException
Specified by:
enableTable in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

disableTable

public void disableTable(TableName tableName)
                  throws IOException
Description copied from interface: MasterServices
Disable an existing table

Specified by:
disableTable in interface MasterServices
Parameters:
tableName - The table name
Throws:
IOException

disableTable

public MasterAdminProtos.DisableTableResponse disableTable(com.google.protobuf.RpcController controller,
                                                           MasterAdminProtos.DisableTableRequest request)
                                                    throws com.google.protobuf.ServiceException
Specified by:
disableTable in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

modifyTable

public void modifyTable(TableName tableName,
                        HTableDescriptor descriptor)
                 throws IOException
Description copied from interface: MasterServices
Modify the descriptor of an existing table

Specified by:
modifyTable in interface MasterServices
Parameters:
tableName - The table name
descriptor - The updated table descriptor
Throws:
IOException

modifyTable

public MasterAdminProtos.ModifyTableResponse modifyTable(com.google.protobuf.RpcController controller,
                                                         MasterAdminProtos.ModifyTableRequest req)
                                                  throws com.google.protobuf.ServiceException
Specified by:
modifyTable in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

checkTableModifiable

public void checkTableModifiable(TableName tableName)
                          throws IOException,
                                 TableNotFoundException,
                                 TableNotDisabledException
Description copied from interface: MasterServices
Check table is modifiable; i.e. exists and is offline.

Specified by:
checkTableModifiable in interface MasterServices
Parameters:
tableName - Name of table to check.
Throws:
TableNotDisabledException
TableNotFoundException
IOException

getClusterStatus

public MasterMonitorProtos.GetClusterStatusResponse getClusterStatus(com.google.protobuf.RpcController controller,
                                                                     MasterMonitorProtos.GetClusterStatusRequest req)
                                                              throws com.google.protobuf.ServiceException
Specified by:
getClusterStatus in interface MasterMonitorProtos.MasterMonitorService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

getClusterStatus

public ClusterStatus getClusterStatus()
Returns:
cluster status

getClusterId

public String getClusterId()

getLoadedCoprocessors

public static String getLoadedCoprocessors()
The set of loaded coprocessors is stored in a static set. Since it's statically allocated, it does not require that HMaster's cpHost be initialized prior to accessing it.

Returns:
a String representation of the set of names of the loaded coprocessors.

getMasterStartTime

public long getMasterStartTime()
Returns:
timestamp in millis when HMaster was started.

getMasterActiveTime

public long getMasterActiveTime()
Returns:
timestamp in millis when HMaster became the active master.

getCoprocessors

public String[] getCoprocessors()
Returns:
array of coprocessor SimpleNames.

abort

public void abort(String msg,
                  Throwable t)
Specified by:
abort in interface Abortable

getZooKeeper

public ZooKeeperWatcher getZooKeeper()
Specified by:
getZooKeeper in interface Server

getCoprocessorHost

public MasterCoprocessorHost getCoprocessorHost()
Specified by:
getCoprocessorHost in interface MasterServices
Returns:
Master's instance of MasterCoprocessorHost

getServerName

public ServerName getServerName()
Specified by:
getServerName in interface Server

getCatalogTracker

public CatalogTracker getCatalogTracker()
Specified by:
getCatalogTracker in interface Server

getAssignmentManager

public AssignmentManager getAssignmentManager()
Specified by:
getAssignmentManager in interface MasterServices
Returns:
Master's instance of the AssignmentManager

getTableLockManager

public TableLockManager getTableLockManager()
Specified by:
getTableLockManager in interface MasterServices
Returns:
Master's instance of TableLockManager

getRegionServerFatalLogBuffer

public MemoryBoundedLogMessageBuffer getRegionServerFatalLogBuffer()

shutdown

public void shutdown()

shutdown

public MasterAdminProtos.ShutdownResponse shutdown(com.google.protobuf.RpcController controller,
                                                   MasterAdminProtos.ShutdownRequest request)
                                            throws com.google.protobuf.ServiceException
Specified by:
shutdown in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

stopMaster

public void stopMaster()

stopMaster

public MasterAdminProtos.StopMasterResponse stopMaster(com.google.protobuf.RpcController controller,
                                                       MasterAdminProtos.StopMasterRequest request)
                                                throws com.google.protobuf.ServiceException
Specified by:
stopMaster in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

stop

public void stop(String why)
Specified by:
stop in interface Stoppable

isStopped

public boolean isStopped()
Specified by:
isStopped in interface Stoppable

isAborted

public boolean isAborted()
Specified by:
isAborted in interface Abortable

isActiveMaster

public boolean isActiveMaster()
Report whether this master is currently the active master or not. If not active master, we are parked on ZK waiting to become active. This method is used for testing.

Returns:
true if active master, false if not.

isInitialized

public boolean isInitialized()
Report whether this master has completed with its initialization and is ready. If ready, the master is also the active master. A standby master is never ready. This method is used for testing.

Specified by:
isInitialized in interface MasterServices
Returns:
true if master is ready to go, false if not.

isServerShutdownHandlerEnabled

public boolean isServerShutdownHandlerEnabled()
ServerShutdownHandlerEnabled is set false before completing assignMeta to prevent processing of ServerShutdownHandler.

Specified by:
isServerShutdownHandlerEnabled in interface MasterServices
Returns:
true if assignMeta has completed;

isInitializationStartsMetaRegionAssignment

public boolean isInitializationStartsMetaRegionAssignment()
Report whether this master has started initialization and is about to do meta region assignment

Returns:
true if master is in initialization & about to assign META regions

assignRegion

public MasterAdminProtos.AssignRegionResponse assignRegion(com.google.protobuf.RpcController controller,
                                                           MasterAdminProtos.AssignRegionRequest req)
                                                    throws com.google.protobuf.ServiceException
Specified by:
assignRegion in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

assignRegion

public void assignRegion(HRegionInfo hri)

unassignRegion

public MasterAdminProtos.UnassignRegionResponse unassignRegion(com.google.protobuf.RpcController controller,
                                                               MasterAdminProtos.UnassignRegionRequest req)
                                                        throws com.google.protobuf.ServiceException
Specified by:
unassignRegion in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

getTableDescriptors

public MasterMonitorProtos.GetTableDescriptorsResponse getTableDescriptors(com.google.protobuf.RpcController controller,
                                                                           MasterMonitorProtos.GetTableDescriptorsRequest req)
                                                                    throws com.google.protobuf.ServiceException
Get list of TableDescriptors for requested tables.

Specified by:
getTableDescriptors in interface MasterMonitorProtos.MasterMonitorService.BlockingInterface
Parameters:
controller - Unused (set to null).
req - GetTableDescriptorsRequest that contains: - tableNames: requested tables, or if empty, all are requested
Returns:
GetTableDescriptorsResponse
Throws:
com.google.protobuf.ServiceException

getTableNames

public MasterMonitorProtos.GetTableNamesResponse getTableNames(com.google.protobuf.RpcController controller,
                                                               MasterMonitorProtos.GetTableNamesRequest req)
                                                        throws com.google.protobuf.ServiceException
Get list of userspace table names

Specified by:
getTableNames in interface MasterMonitorProtos.MasterMonitorService.BlockingInterface
Parameters:
controller - Unused (set to null).
req - GetTableNamesRequest
Returns:
GetTableNamesResponse
Throws:
com.google.protobuf.ServiceException

getAverageLoad

public double getAverageLoad()
Compute the average load across all region servers. Currently, this uses a very naive computation - just uses the number of regions being served, ignoring stats about number of requests.

Returns:
the average load

offlineRegion

public MasterAdminProtos.OfflineRegionResponse offlineRegion(com.google.protobuf.RpcController controller,
                                                             MasterAdminProtos.OfflineRegionRequest request)
                                                      throws com.google.protobuf.ServiceException
Offline specified region from master's in-memory state. It will not attempt to reassign the region as in unassign. This is a special method that should be used by experts or hbck.

Specified by:
offlineRegion in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

registerService

public boolean registerService(com.google.protobuf.Service instance)
Description copied from interface: MasterServices
Registers a new protocol buffer Service subclass as a master coprocessor endpoint.

Only a single instance may be registered for a given Service subclass (the instances are keyed on Descriptors.ServiceDescriptor.getFullName(). After the first registration, subsequent calls with the same service name will fail with a return value of false.

Specified by:
registerService in interface MasterServices
Parameters:
instance - the Service subclass instance to expose as a coprocessor endpoint
Returns:
true if the registration was successful, false otherwise

execMasterService

public ClientProtos.CoprocessorServiceResponse execMasterService(com.google.protobuf.RpcController controller,
                                                                 ClientProtos.CoprocessorServiceRequest request)
                                                          throws com.google.protobuf.ServiceException
Specified by:
execMasterService in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

constructMaster

public static HMaster constructMaster(Class<? extends HMaster> masterClass,
                                      org.apache.hadoop.conf.Configuration conf)
Utility for constructing an instance of the passed HMaster class.

Parameters:
masterClass -
conf -
Returns:
HMaster instance.

main

public static void main(String[] args)
See Also:
HMasterCommandLine

getHFileCleaner

public HFileCleaner getHFileCleaner()

getSnapshotManagerForTesting

public SnapshotManager getSnapshotManagerForTesting()
Exposed for TESTING!

Returns:
the underlying snapshot manager

snapshot

public MasterAdminProtos.TakeSnapshotResponse snapshot(com.google.protobuf.RpcController controller,
                                                       MasterAdminProtos.TakeSnapshotRequest request)
                                                throws com.google.protobuf.ServiceException
Triggers an asynchronous attempt to take a snapshot.

Specified by:
snapshot in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

getCompletedSnapshots

public MasterAdminProtos.ListSnapshotResponse getCompletedSnapshots(com.google.protobuf.RpcController controller,
                                                                    MasterAdminProtos.ListSnapshotRequest request)
                                                             throws com.google.protobuf.ServiceException
List the currently available/stored snapshots. Any in-progress snapshots are ignored

Specified by:
getCompletedSnapshots in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

deleteSnapshot

public MasterAdminProtos.DeleteSnapshotResponse deleteSnapshot(com.google.protobuf.RpcController controller,
                                                               MasterAdminProtos.DeleteSnapshotRequest request)
                                                        throws com.google.protobuf.ServiceException
Execute Delete Snapshot operation.

Specified by:
deleteSnapshot in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Returns:
DeleteSnapshotResponse (a protobuf wrapped void) if the snapshot existed and was deleted properly.
Throws:
com.google.protobuf.ServiceException - wrapping SnapshotDoesNotExistException if specified snapshot did not exist.

isSnapshotDone

public MasterAdminProtos.IsSnapshotDoneResponse isSnapshotDone(com.google.protobuf.RpcController controller,
                                                               MasterAdminProtos.IsSnapshotDoneRequest request)
                                                        throws com.google.protobuf.ServiceException
Checks if the specified snapshot is done.

Specified by:
isSnapshotDone in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Returns:
true if the snapshot is in file system ready to use, false if the snapshot is in the process of completing
Throws:
com.google.protobuf.ServiceException - wrapping UnknownSnapshotException if invalid snapshot, or a wrapped HBaseSnapshotException with progress failure reason.

restoreSnapshot

public MasterAdminProtos.RestoreSnapshotResponse restoreSnapshot(com.google.protobuf.RpcController controller,
                                                                 MasterAdminProtos.RestoreSnapshotRequest request)
                                                          throws com.google.protobuf.ServiceException
Execute Restore/Clone snapshot operation.

If the specified table exists a "Restore" is executed, replacing the table schema and directory data with the content of the snapshot. The table must be disabled, or a UnsupportedOperationException will be thrown.

If the table doesn't exist a "Clone" is executed, a new table is created using the schema at the time of the snapshot, and the content of the snapshot.

The restore/clone operation does not require copying HFiles. Since HFiles are immutable the table can point to and use the same files as the original one.

Specified by:
restoreSnapshot in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

isRestoreSnapshotDone

public MasterAdminProtos.IsRestoreSnapshotDoneResponse isRestoreSnapshotDone(com.google.protobuf.RpcController controller,
                                                                             MasterAdminProtos.IsRestoreSnapshotDoneRequest request)
                                                                      throws com.google.protobuf.ServiceException
Returns the status of the requested snapshot restore/clone operation. This method is not exposed to the user, it is just used internally by HBaseAdmin to verify if the restore is completed. No exceptions are thrown if the restore is not running, the result will be "done".

Specified by:
isRestoreSnapshotDone in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Returns:
done true if the restore/clone operation is completed.
Throws:
com.google.protobuf.ServiceException - if the operation failed.

modifyNamespace

public MasterAdminProtos.ModifyNamespaceResponse modifyNamespace(com.google.protobuf.RpcController controller,
                                                                 MasterAdminProtos.ModifyNamespaceRequest request)
                                                          throws com.google.protobuf.ServiceException
Specified by:
modifyNamespace in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

createNamespace

public MasterAdminProtos.CreateNamespaceResponse createNamespace(com.google.protobuf.RpcController controller,
                                                                 MasterAdminProtos.CreateNamespaceRequest request)
                                                          throws com.google.protobuf.ServiceException
Specified by:
createNamespace in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

deleteNamespace

public MasterAdminProtos.DeleteNamespaceResponse deleteNamespace(com.google.protobuf.RpcController controller,
                                                                 MasterAdminProtos.DeleteNamespaceRequest request)
                                                          throws com.google.protobuf.ServiceException
Specified by:
deleteNamespace in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

getNamespaceDescriptor

public MasterAdminProtos.GetNamespaceDescriptorResponse getNamespaceDescriptor(com.google.protobuf.RpcController controller,
                                                                               MasterAdminProtos.GetNamespaceDescriptorRequest request)
                                                                        throws com.google.protobuf.ServiceException
Specified by:
getNamespaceDescriptor in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

listNamespaceDescriptors

public MasterAdminProtos.ListNamespaceDescriptorsResponse listNamespaceDescriptors(com.google.protobuf.RpcController controller,
                                                                                   MasterAdminProtos.ListNamespaceDescriptorsRequest request)
                                                                            throws com.google.protobuf.ServiceException
Specified by:
listNamespaceDescriptors in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

listTableDescriptorsByNamespace

public MasterAdminProtos.ListTableDescriptorsByNamespaceResponse listTableDescriptorsByNamespace(com.google.protobuf.RpcController controller,
                                                                                                 MasterAdminProtos.ListTableDescriptorsByNamespaceRequest request)
                                                                                          throws com.google.protobuf.ServiceException
Specified by:
listTableDescriptorsByNamespace in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

listTableNamesByNamespace

public MasterAdminProtos.ListTableNamesByNamespaceResponse listTableNamesByNamespace(com.google.protobuf.RpcController controller,
                                                                                     MasterAdminProtos.ListTableNamesByNamespaceRequest request)
                                                                              throws com.google.protobuf.ServiceException
Specified by:
listTableNamesByNamespace in interface MasterAdminProtos.MasterAdminService.BlockingInterface
Throws:
com.google.protobuf.ServiceException

createNamespace

public void createNamespace(NamespaceDescriptor descriptor)
                     throws IOException
Description copied from interface: MasterServices
Create a new namespace

Specified by:
createNamespace in interface MasterServices
Parameters:
descriptor - descriptor which describes the new namespace
Throws:
IOException

modifyNamespace

public void modifyNamespace(NamespaceDescriptor descriptor)
                     throws IOException
Description copied from interface: MasterServices
Modify an existing namespace

Specified by:
modifyNamespace in interface MasterServices
Parameters:
descriptor - descriptor which updates the existing namespace
Throws:
IOException

deleteNamespace

public void deleteNamespace(String name)
                     throws IOException
Description copied from interface: MasterServices
Delete an existing namespace. Only empty namespaces (no tables) can be removed.

Specified by:
deleteNamespace in interface MasterServices
Parameters:
name - namespace name
Throws:
IOException

getNamespaceDescriptor

public NamespaceDescriptor getNamespaceDescriptor(String name)
                                           throws IOException
Description copied from interface: MasterServices
Get a namespace descriptor by name

Specified by:
getNamespaceDescriptor in interface MasterServices
Parameters:
name - name of namespace descriptor
Returns:
A descriptor
Throws:
IOException

listNamespaceDescriptors

public List<NamespaceDescriptor> listNamespaceDescriptors()
                                                   throws IOException
Description copied from interface: MasterServices
List available namespace descriptors

Specified by:
listNamespaceDescriptors in interface MasterServices
Returns:
A descriptor
Throws:
IOException

listTableDescriptorsByNamespace

public List<HTableDescriptor> listTableDescriptorsByNamespace(String name)
                                                       throws IOException
Description copied from interface: MasterServices
Get list of table descriptors by namespace

Specified by:
listTableDescriptorsByNamespace in interface MasterServices
Parameters:
name - namespace name
Returns:
descriptors
Throws:
IOException

listTableNamesByNamespace

public List<TableName> listTableNamesByNamespace(String name)
                                          throws IOException
Description copied from interface: MasterServices
Get list of table names by namespace

Specified by:
listTableNamesByNamespace in interface MasterServices
Parameters:
name - namespace name
Returns:
table names
Throws:
IOException


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