|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hbase.util.HasThread
org.apache.hadoop.hbase.master.HMaster
public class HMaster
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()
.
HMasterInterface
,
HMasterRegionInterface
,
Watcher
Field Summary | |
---|---|
static String |
MASTER
|
Fields inherited from interface org.apache.hadoop.hbase.ipc.HMasterInterface |
---|
VERSION |
Fields inherited from interface org.apache.hadoop.hbase.ipc.HMasterRegionInterface |
---|
VERSION |
Constructor Summary | |
---|---|
HMaster(org.apache.hadoop.conf.Configuration conf)
Initializes the HMaster. |
Method Summary | |
---|---|
void |
abort(String msg,
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(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 |
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) |
Pair<Integer,Integer> |
getAlterStatus(byte[] tableName)
Used by the client to get the number of regions that have received the updated schema |
AssignmentManager |
getAssignmentManager()
|
double |
getAverageLoad()
Compute the average load across all region servers. |
CatalogTracker |
getCatalogTracker()
|
String |
getClusterId()
|
ClusterStatus |
getClusterStatus()
Return cluster status. |
org.apache.hadoop.conf.Configuration |
getConfiguration()
Gets the configuration object for this server. |
MasterCoprocessorHost |
getCoprocessorHost()
|
String[] |
getCoprocessors()
|
ExecutorService |
getExecutorService()
|
HTableDescriptor[] |
getHTableDescriptors()
Get all table descriptors |
HTableDescriptor[] |
getHTableDescriptors(List<String> tableNames)
Get HTD array for given tables |
InfoServer |
getInfoServer()
|
static String |
getLoadedCoprocessors()
The set of loaded coprocessors is stored in a static set. |
long |
getMasterActiveTime()
|
MasterFileSystem |
getMasterFileSystem()
|
long |
getMasterStartTime()
|
ProtocolSignature |
getProtocolSignature(String protocol,
long version,
int clientMethodsHashCode)
Return protocol version corresponding to protocol interface. |
long |
getProtocolVersion(String protocol,
long clientVersion)
Return protocol version corresponding to protocol interface. |
MemoryBoundedLogMessageBuffer |
getRegionServerFatalLogBuffer()
|
ServerManager |
getServerManager()
|
ServerName |
getServerName()
|
TableDescriptors |
getTableDescriptors()
|
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 |
isInitialized()
Report whether this master has completed with its initialization and is ready. |
boolean |
isMasterRunning()
|
boolean |
isServerShutdownHandlerEnabled()
ServerShutdownHandlerEnabled is set false before completing assignRootAndMeta to prevent processing of ServerShutdownHandler. |
boolean |
isStopped()
|
static void |
main(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. |
void |
reportRSFatalError(byte[] sn,
String errorText)
Called by a region server to report a fatal error that is causing it to abort. |
void |
run()
Main processing loop for the HMaster. |
void |
setCatalogJanitorEnabled(boolean b)
Switch for the background CatalogJanitor thread. |
void |
shutdown()
Shutdown an HBase cluster. |
protected void |
splitLogAfterStartup(MasterFileSystem mfs)
Override to change master's splitLogAfterStartup. |
protected void |
startCatalogJanitorChore()
Useful for testing purpose also where we have master restart scenarios. |
void |
stop(String why)
Stop this service. |
void |
stopMaster()
Stop HBase Master only. |
void |
unassign(byte[] regionName,
boolean force)
Unassign a region from current hosting regionserver. |
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 |
---|
public static final String MASTER
Constructor Detail |
---|
public HMaster(org.apache.hadoop.conf.Configuration conf) throws IOException, org.apache.zookeeper.KeeperException, InterruptedException
Remaining steps of initialization occur in run()
so that they
run in their own thread rather than within the context of the constructor.
InterruptedException
IOException
org.apache.zookeeper.KeeperException
Method Detail |
---|
public void run()
run
in interface Runnable
run
in class HasThread
protected void startCatalogJanitorChore()
protected void splitLogAfterStartup(MasterFileSystem mfs)
mfs
- public ProtocolSignature getProtocolSignature(String protocol, long version, int clientMethodsHashCode) throws 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 methods
IOException
for a default implementation
public long getProtocolVersion(String protocol, long clientVersion)
VersionedProtocol
getProtocolVersion
in interface VersionedProtocol
protocol
- The classname of the protocol interfaceclientVersion
- The version of the protocol that the client speaks
public 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 org.apache.hadoop.io.MapWritable regionServerStartup(int port, long serverStartCode, long serverCurrentTime) throws 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 ms
IOException
- eprotected org.apache.hadoop.io.MapWritable createConfigurationSubset()
public void regionServerReport(byte[] sn, HServerLoad hsl) throws IOException
regionServerReport
in interface HMasterRegionInterface
sn
- ServerName.getVersionedBytes()
hsl
- Server load.
IOException
public void reportRSFatalError(byte[] sn, 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 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 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.
IOException
public void deleteTable(byte[] tableName) throws IOException
HMasterInterface
deleteTable
in interface HMasterInterface
tableName
- table to delete
IOException
- epublic Pair<Integer,Integer> getAlterStatus(byte[] tableName) throws IOException
HMasterInterface
getAlterStatus
in interface HMasterInterface
IOException
public void addColumn(byte[] tableName, HColumnDescriptor column) throws IOException
HMasterInterface
addColumn
in interface HMasterInterface
tableName
- table to modifycolumn
- column descriptor
IOException
- epublic void modifyColumn(byte[] tableName, HColumnDescriptor descriptor) throws IOException
HMasterInterface
modifyColumn
in interface HMasterInterface
tableName
- table namedescriptor
- new column descriptor
IOException
- epublic void deleteColumn(byte[] tableName, byte[] c) throws IOException
HMasterInterface
deleteColumn
in interface HMasterInterface
tableName
- table to alterc
- column family to remove
IOException
- epublic void enableTable(byte[] tableName) throws IOException
HMasterInterface
enableTable
in interface HMasterInterface
tableName
- table to enable
IOException
- epublic void disableTable(byte[] tableName) throws IOException
HMasterInterface
disableTable
in interface HMasterInterface
tableName
- table to take offline
IOException
- epublic void modifyTable(byte[] tableName, HTableDescriptor htd) throws IOException
HMasterInterface
modifyTable
in interface HMasterInterface
tableName
- table to modifyhtd
- new descriptor for table
IOException
- epublic void checkTableModifiable(byte[] tableName) throws IOException
MasterServices
checkTableModifiable
in interface MasterServices
tableName
- Name of table to check.
TableNotDisabledException
TableNotFoundException
IOException
public void clearFromTransition(HRegionInfo hri)
public ClusterStatus getClusterStatus()
HMasterInterface
getClusterStatus
in interface HMasterInterface
public String getClusterId()
public static String getLoadedCoprocessors()
public long getMasterStartTime()
public long getMasterActiveTime()
public String[] getCoprocessors()
public void abort(String msg, Throwable t)
Abortable
abort
in interface Abortable
msg
- Why we're aborting.t
- Throwable that caused abort. Can be null.public ZooKeeperWatcher getZooKeeper()
Server
getZooKeeper
in interface Server
public MasterCoprocessorHost getCoprocessorHost()
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(String why)
Stoppable
stop
in interface Stoppable
why
- Why we're stopping.public boolean isStopped()
isStopped
in interface Stoppable
Stoppable.stop(String)
has been closed.public boolean isAborted()
Abortable
isAborted
in interface Abortable
public boolean isActiveMaster()
public boolean isInitialized()
public boolean isServerShutdownHandlerEnabled()
isServerShutdownHandlerEnabled
in interface MasterServices
@Deprecated public void assign(byte[] regionName, boolean force) throws IOException
HMasterInterface
assign
in interface HMasterInterface
regionName
- Region to assign. Will use existing RegionPlan if one
found.force
- If true, will force the assignment.
IOException
public void assign(byte[] regionName) throws IOException
HMasterInterface
assign
in interface HMasterInterface
regionName
- Region to assign. Will use existing RegionPlan if one found.
IOException
public void assignRegion(HRegionInfo hri)
public void unassign(byte[] regionName, boolean force) throws 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.
IOException
public HTableDescriptor[] getHTableDescriptors(List<String> tableNames)
getHTableDescriptors
in interface HMasterInterface
tableNames
-
public HTableDescriptor[] getHTableDescriptors()
getHTableDescriptors
in interface HMasterInterface
public double getAverageLoad()
public void offline(byte[] regionName) throws IOException
offline
in interface HMasterInterface
regionName
- Region to offline. Will clear any existing RegionPlan
if one found.
IOException
public static HMaster constructMaster(Class<? extends HMaster> masterClass, org.apache.hadoop.conf.Configuration conf)
masterClass
- conf
-
public static void main(String[] args) throws Exception
Exception
HMasterCommandLine
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |