public class HMaster extends HasThread implements HMasterInterface, HMasterRegionInterface, MasterServices, Server
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()
.
HMasterInterface
,
HMasterRegionInterface
,
Watcher
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
MASTER |
VERSION
VERSION
Constructor and Description |
---|
HMaster(org.apache.hadoop.conf.Configuration conf)
Initializes the HMaster.
|
Modifier and Type | Method and Description |
---|---|
void |
abort(java.lang.String msg,
java.lang.Throwable t)
Abort the server or client.
|
void |
addColumn(byte[] tableName,
HColumnDescriptor column)
Adds a column to the specified table
|
void |
assign(byte[] regionName)
Assign a region to a server chosen at random.
|
void |
assign(byte[] regionName,
boolean force)
Deprecated.
|
void |
assignRegion(HRegionInfo hri) |
boolean |
balance()
Run the balancer.
|
boolean |
balanceSwitch(boolean b)
Turn the load balancer on or off.
|
void |
checkTableModifiable(byte[] tableName)
Check table is modifiable; i.e.
|
void |
clearFromTransition(HRegionInfo hri) |
static HMaster |
constructMaster(java.lang.Class<? extends HMaster> masterClass,
org.apache.hadoop.conf.Configuration conf)
Utility for constructing an instance of the passed HMaster class.
|
protected org.apache.hadoop.io.MapWritable |
createConfigurationSubset() |
void |
createTable(HTableDescriptor hTableDescriptor,
byte[][] splitKeys)
Creates a new table asynchronously.
|
void |
deleteColumn(byte[] tableName,
byte[] c)
Deletes a column from the specified table.
|
void |
deleteSnapshot(HSnapshotDescription request)
Execute Delete Snapshot operation.
|
void |
deleteTable(byte[] tableName)
Deletes a table
|
void |
disableTable(byte[] tableName)
Take table offline
|
void |
enableTable(byte[] tableName)
Puts the table on-line (only needed if table has been previously taken offline)
|
ExecResult |
execCoprocessor(Exec call)
Executes a single
CoprocessorProtocol
method using the registered protocol handlers. |
ActiveMasterManager |
getActiveMasterManager() |
Pair<java.lang.Integer,java.lang.Integer> |
getAlterStatus(byte[] tableName)
Get the number of regions of the table that have been updated by the alter.
|
AssignmentManager |
getAssignmentManager() |
double |
getAverageLoad()
Compute the average load across all region servers.
|
CatalogTracker |
getCatalogTracker() |
java.lang.String |
getClusterId() |
ClusterStatus |
getClusterStatus()
Return cluster status.
|
java.util.List<HSnapshotDescription> |
getCompletedSnapshots()
List the currently available/stored snapshots.
|
org.apache.hadoop.conf.Configuration |
getConfiguration()
Gets the configuration object for this server.
|
MasterCoprocessorHost |
getCoprocessorHost() |
java.lang.String[] |
getCoprocessors() |
ExecutorService |
getExecutorService() |
HFileCleaner |
getHFileCleaner()
Exposed for Testing!
|
HTableDescriptor[] |
getHTableDescriptors()
Get all table descriptors
|
HTableDescriptor[] |
getHTableDescriptors(java.util.List<java.lang.String> tableNames)
Get HTD array for given tables
|
InfoServer |
getInfoServer() |
static java.lang.String |
getLoadedCoprocessors()
The set of loaded coprocessors is stored in a static set.
|
long |
getMasterActiveTime() |
MasterFileSystem |
getMasterFileSystem() |
long |
getMasterStartTime() |
ProtocolSignature |
getProtocolSignature(java.lang.String protocol,
long version,
int clientMethodsHashCode)
Return protocol version corresponding to protocol interface.
|
long |
getProtocolVersion(java.lang.String protocol,
long clientVersion)
Return protocol version corresponding to protocol interface.
|
MemoryBoundedLogMessageBuffer |
getRegionServerFatalLogBuffer() |
int |
getRegionServerInfoPort(ServerName sn) |
ServerManager |
getServerManager() |
ServerName |
getServerName() |
SnapshotManager |
getSnapshotManagerForTesting()
Exposed for TESTING!
|
TableDescriptors |
getTableDescriptors() |
java.lang.String[] |
getTableNames()
Return all table names.
|
ZooKeeperWatcher |
getZooKeeper()
Gets the ZooKeeper instance for this server.
|
ZooKeeperWatcher |
getZooKeeperWatcher()
Get the ZK wrapper object - needed by master_jsp.java
|
boolean |
isAborted()
Check if the server or client was aborted.
|
boolean |
isActiveMaster()
Report whether this master is currently the active master or not.
|
boolean |
isInitializationStartsMetaRegoinAssignment()
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() |
boolean |
isRestoreSnapshotDone(HSnapshotDescription request)
Returns the status of the requested snapshot restore/clone operation.
|
boolean |
isServerShutdownHandlerEnabled()
ServerShutdownHandlerEnabled is set false before completing
assignRootAndMeta to prevent processing of ServerShutdownHandler.
|
boolean |
isSnapshotDone(HSnapshotDescription request)
Checks if the specified snapshot is done.
|
boolean |
isStopped() |
static void |
main(java.lang.String[] args) |
void |
modifyColumn(byte[] tableName,
HColumnDescriptor descriptor)
Modifies an existing column on the specified table
|
void |
modifyTable(byte[] tableName,
HTableDescriptor htd)
Modify a table's metadata
|
void |
move(byte[] encodedRegionName,
byte[] destServerName)
Move the region
r to dest . |
void |
offline(byte[] regionName)
Special method, only used by hbck.
|
void |
regionServerReport(byte[] sn,
HServerLoad hsl) |
org.apache.hadoop.io.MapWritable |
regionServerStartup(int port,
long serverStartCode,
long serverCurrentTime)
Called when a region server first starts.
|
<T extends CoprocessorProtocol> |
registerProtocol(java.lang.Class<T> protocol,
T handler)
Registers a new CoprocessorProtocol subclass and instance to
be available for handling
execCoprocessor(org.apache.hadoop.hbase.client.coprocessor.Exec) calls. |
void |
reportRSFatalError(byte[] sn,
java.lang.String errorText)
Called by a region server to report a fatal error that is causing
it to abort.
|
void |
restoreSnapshot(HSnapshotDescription request)
Execute Restore/Clone snapshot operation.
|
void |
run()
Main processing loop for the HMaster.
|
void |
setCatalogJanitorEnabled(boolean b)
Switch for the background CatalogJanitor thread.
|
boolean |
shouldSplitMetaSeparately() |
void |
shutdown()
Shutdown an HBase cluster.
|
long |
snapshot(HSnapshotDescription request)
Triggers an asynchronous attempt to take a snapshot.
|
protected void |
startCatalogJanitorChore()
Useful for testing purpose also where we have
master restart scenarios.
|
void |
stop(java.lang.String why)
Stop this service.
|
void |
stopMaster()
Stop HBase Master only.
|
boolean |
switchBalancer(boolean b,
org.apache.hadoop.hbase.master.HMaster.BalanceSwitchMode mode)
Assigns balancer switch according to BalanceSwitchMode
|
boolean |
synchronousBalanceSwitch(boolean b)
Turn the load balancer on or off.
|
void |
unassign(byte[] regionName,
boolean force)
Unassign a region from current hosting regionserver.
|
getName, getThread, interrupt, isAlive, isInterrupted, join, join, join, setDaemon, setName, setPriority, setUncaughtExceptionHandler, start
public static final java.lang.String MASTER
public HMaster(org.apache.hadoop.conf.Configuration conf) throws java.io.IOException, org.apache.zookeeper.KeeperException, java.lang.InterruptedException
Remaining steps of initialization occur in run()
so that they
run in their own thread rather than within the context of the constructor.
java.lang.InterruptedException
java.io.IOException
org.apache.zookeeper.KeeperException
public void run()
protected void startCatalogJanitorChore()
public ProtocolSignature getProtocolSignature(java.lang.String protocol, long version, int clientMethodsHashCode) throws java.io.IOException
VersionedProtocol
getProtocolSignature
in interface VersionedProtocol
protocol
- The classname of the protocol interfaceversion
- The version of the protocol that the client speaksclientMethodsHashCode
- the hashcode of client protocol methodsjava.io.IOException
for a default implementation
public long getProtocolVersion(java.lang.String protocol, long clientVersion)
VersionedProtocol
getProtocolVersion
in interface VersionedProtocol
protocol
- The classname of the protocol interfaceclientVersion
- The version of the protocol that the client speakspublic TableDescriptors getTableDescriptors()
getTableDescriptors
in interface MasterServices
public InfoServer getInfoServer()
public org.apache.hadoop.conf.Configuration getConfiguration()
Server
getConfiguration
in interface Server
public ServerManager getServerManager()
getServerManager
in interface MasterServices
ServerManager
instance.public ExecutorService getExecutorService()
getExecutorService
in interface MasterServices
ExecutorService
public MasterFileSystem getMasterFileSystem()
getMasterFileSystem
in interface MasterServices
MasterFileSystem
utility class.public ZooKeeperWatcher getZooKeeperWatcher()
public ActiveMasterManager getActiveMasterManager()
public org.apache.hadoop.io.MapWritable regionServerStartup(int port, long serverStartCode, long serverCurrentTime) throws java.io.IOException
HMasterRegionInterface
regionServerStartup
in interface HMasterRegionInterface
port
- Port number this regionserver is up on.serverStartCode
- This servers' startcode.serverCurrentTime
- The current time of the region server in msjava.io.IOException
- eprotected org.apache.hadoop.io.MapWritable createConfigurationSubset()
public void regionServerReport(byte[] sn, HServerLoad hsl) throws java.io.IOException
regionServerReport
in interface HMasterRegionInterface
sn
- ServerName.getVersionedBytes()
hsl
- Server load.java.io.IOException
public void reportRSFatalError(byte[] sn, java.lang.String errorText)
HMasterRegionInterface
reportRSFatalError
in interface HMasterRegionInterface
sn
- ServerName.getVersionedBytes()
errorText
- informative text to expose in the master logs and UIpublic boolean isMasterRunning()
isMasterRunning
in interface HMasterInterface
public boolean balance()
HMasterInterface
balance
in interface HMasterInterface
public boolean switchBalancer(boolean b, org.apache.hadoop.hbase.master.HMaster.BalanceSwitchMode mode)
b
- new balancer switchmode
- BalanceSwitchModepublic boolean synchronousBalanceSwitch(boolean b)
HMasterInterface
synchronousBalanceSwitch
in interface HMasterInterface
b
- If true, enable balancer. If false, disable balancer.public boolean balanceSwitch(boolean b)
HMasterInterface
balanceSwitch
in interface HMasterInterface
b
- If true, enable balancer. If false, disable balancer.public void setCatalogJanitorEnabled(boolean b)
b
- If false, the catalog janitor won't do anything.public void move(byte[] encodedRegionName, byte[] destServerName) throws UnknownRegionException
HMasterInterface
r
to dest
.move
in interface HMasterInterface
encodedRegionName
- The encoded region name; i.e. the hash that makes
up the region name suffix: e.g. if regionname is
TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396.
,
then the encoded region name is: 527db22f95c8a9e0116f0cc13c680396
.destServerName
- The servername of the destination regionserver. If
passed the empty byte array we'll assign to a random server. A server name
is made of host, port and startcode. Here is an example:
host187.example.com,60020,1289493121758
.UnknownRegionException
- Thrown if we can't find a region named
encodedRegionName
public void createTable(HTableDescriptor hTableDescriptor, byte[][] splitKeys) throws java.io.IOException
HMasterInterface
createTable
in interface HMasterInterface
createTable
in interface MasterServices
hTableDescriptor
- table descriptorsplitKeys
- Starting row keys for the initial table regions. If null
a single region is created.java.io.IOException
public void deleteTable(byte[] tableName) throws java.io.IOException
HMasterInterface
deleteTable
in interface HMasterInterface
deleteTable
in interface MasterServices
tableName
- table to deletejava.io.IOException
- epublic Pair<java.lang.Integer,java.lang.Integer> getAlterStatus(byte[] tableName) throws java.io.IOException
getAlterStatus
in interface HMasterInterface
java.io.IOException
public void addColumn(byte[] tableName, HColumnDescriptor column) throws java.io.IOException
HMasterInterface
addColumn
in interface HMasterInterface
addColumn
in interface MasterServices
tableName
- table to modifycolumn
- column descriptorjava.io.IOException
- epublic void modifyColumn(byte[] tableName, HColumnDescriptor descriptor) throws java.io.IOException
HMasterInterface
modifyColumn
in interface HMasterInterface
modifyColumn
in interface MasterServices
tableName
- table namedescriptor
- new column descriptorjava.io.IOException
- epublic void deleteColumn(byte[] tableName, byte[] c) throws java.io.IOException
HMasterInterface
deleteColumn
in interface HMasterInterface
deleteColumn
in interface MasterServices
tableName
- table to alterc
- column family to removejava.io.IOException
- epublic void enableTable(byte[] tableName) throws java.io.IOException
HMasterInterface
enableTable
in interface HMasterInterface
enableTable
in interface MasterServices
tableName
- table to enablejava.io.IOException
- epublic void disableTable(byte[] tableName) throws java.io.IOException
HMasterInterface
disableTable
in interface HMasterInterface
disableTable
in interface MasterServices
tableName
- table to take offlinejava.io.IOException
- epublic void modifyTable(byte[] tableName, HTableDescriptor htd) throws java.io.IOException
HMasterInterface
modifyTable
in interface HMasterInterface
modifyTable
in interface MasterServices
tableName
- table to modifyhtd
- new descriptor for tablejava.io.IOException
- epublic void checkTableModifiable(byte[] tableName) throws java.io.IOException
MasterServices
checkTableModifiable
in interface MasterServices
tableName
- Name of table to check.java.io.IOException
public void clearFromTransition(HRegionInfo hri)
public ClusterStatus getClusterStatus()
HMasterInterface
getClusterStatus
in interface HMasterInterface
public java.lang.String getClusterId()
public static java.lang.String getLoadedCoprocessors()
public long getMasterStartTime()
public long getMasterActiveTime()
public int getRegionServerInfoPort(ServerName sn)
public java.lang.String[] getCoprocessors()
public void abort(java.lang.String msg, java.lang.Throwable t)
Abortable
public ZooKeeperWatcher getZooKeeper()
Server
getZooKeeper
in interface Server
public MasterCoprocessorHost getCoprocessorHost()
getCoprocessorHost
in interface MasterServices
public ServerName getServerName()
getServerName
in interface Server
public CatalogTracker getCatalogTracker()
getCatalogTracker
in interface Server
CatalogTracker
public AssignmentManager getAssignmentManager()
getAssignmentManager
in interface MasterServices
AssignmentManager
public MemoryBoundedLogMessageBuffer getRegionServerFatalLogBuffer()
public void shutdown()
HMasterInterface
shutdown
in interface HMasterInterface
public void stopMaster()
HMasterInterface
stopMaster
in interface HMasterInterface
public void stop(java.lang.String why)
Stoppable
public boolean isStopped()
isStopped
in interface Stoppable
Stoppable.stop(String)
has been closed.public boolean isAborted()
Abortable
public boolean isActiveMaster()
public boolean isInitialized()
public boolean isServerShutdownHandlerEnabled()
isServerShutdownHandlerEnabled
in interface MasterServices
public boolean shouldSplitMetaSeparately()
shouldSplitMetaSeparately
in interface MasterServices
public boolean isInitializationStartsMetaRegoinAssignment()
@Deprecated public void assign(byte[] regionName, boolean force) throws java.io.IOException
HMasterInterface
assign
in interface HMasterInterface
regionName
- Region to assign. Will use existing RegionPlan if one
found.force
- If true, will force the assignment.java.io.IOException
public void assign(byte[] regionName) throws java.io.IOException
HMasterInterface
assign
in interface HMasterInterface
regionName
- Region to assign. Will use existing RegionPlan if one found.java.io.IOException
public void assignRegion(HRegionInfo hri)
public void unassign(byte[] regionName, boolean force) throws java.io.IOException
HMasterInterface
HMasterInterface.move(byte[], byte[])
if you want
to control the region movement.unassign
in interface HMasterInterface
regionName
- Region to unassign. Will clear any existing RegionPlan
if one found.force
- If true, force unassign (Will remove region from
regions-in-transition too if present as well as from assigned regions --
radical!.If results in double assignment use hbck -fix to resolve.java.io.IOException
public HTableDescriptor[] getHTableDescriptors(java.util.List<java.lang.String> tableNames) throws java.io.IOException
getHTableDescriptors
in interface HMasterInterface
tableNames
- java.io.IOException
public <T extends CoprocessorProtocol> boolean registerProtocol(java.lang.Class<T> protocol, T handler)
MasterServices
execCoprocessor(org.apache.hadoop.hbase.client.coprocessor.Exec)
calls.
Only a single protocol type/handler combination may be registered.
After the first registration, subsequent calls with the same protocol type
will fail with a return value of false
.
registerProtocol
in interface MasterServices
T
- the protocol typeprotocol
- a CoprocessorProtocol
subinterface defining the
protocol methodshandler
- an instance implementing the interfacetrue
if the registration was successful, false
otherwisepublic ExecResult execCoprocessor(Exec call) throws java.io.IOException
HMasterInterface
CoprocessorProtocol
method using the registered protocol handlers.
CoprocessorProtocol
implementations must be registered via the
MasterServices.registerProtocol(Class, CoprocessorProtocol)
method before they are available.execCoprocessor
in interface HMasterInterface
call
- an Exec
instance identifying the protocol, method name,
and parameters for the method invocationExecResult
instance containing the region name of the
invocation and the return valuejava.io.IOException
- if no registered protocol handler is found or an error
occurs during the invocationMasterServices.registerProtocol(Class, CoprocessorProtocol)
public HTableDescriptor[] getHTableDescriptors() throws java.io.IOException
getHTableDescriptors
in interface HMasterInterface
java.io.IOException
public double getAverageLoad()
public void offline(byte[] regionName) throws java.io.IOException
offline
in interface HMasterInterface
regionName
- Region to offline. Will clear any existing RegionPlan
if one found.java.io.IOException
public static HMaster constructMaster(java.lang.Class<? extends HMaster> masterClass, org.apache.hadoop.conf.Configuration conf)
masterClass
- conf
- public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
HMasterCommandLine
public HFileCleaner getHFileCleaner()
public SnapshotManager getSnapshotManagerForTesting()
public long snapshot(HSnapshotDescription request) throws java.io.IOException
snapshot
in interface HMasterInterface
java.io.IOException
public java.util.List<HSnapshotDescription> getCompletedSnapshots() throws java.io.IOException
getCompletedSnapshots
in interface HMasterInterface
java.io.IOException
public void deleteSnapshot(HSnapshotDescription request) throws java.io.IOException
deleteSnapshot
in interface HMasterInterface
com.google.protobuf.ServiceException
- wrapping SnapshotDoesNotExistException if specified snapshot did not
exist.java.io.IOException
public boolean isSnapshotDone(HSnapshotDescription request) throws java.io.IOException
isSnapshotDone
in interface HMasterInterface
com.google.protobuf.ServiceException
- wrapping UnknownSnapshotException if invalid snapshot, or
a wrapped HBaseSnapshotException with progress failure reason.java.io.IOException
public void restoreSnapshot(HSnapshotDescription request) throws java.io.IOException
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.
restoreSnapshot
in interface HMasterInterface
java.io.IOException
public boolean isRestoreSnapshotDone(HSnapshotDescription request) throws java.io.IOException
isRestoreSnapshotDone
in interface HMasterInterface
RestoreSnapshotExcepton
- if the operation failed.java.io.IOException
public java.lang.String[] getTableNames() throws java.io.IOException
getTableNames
in interface HMasterInterface
java.io.IOException
- if an error occurred while getting the list of tablesCopyright © 2015 The Apache Software Foundation. All Rights Reserved.