org.apache.hadoop.hbase.ipc
Interface HMasterInterface

All Superinterfaces:
VersionedProtocol
All Known Implementing Classes:
HMaster, HMasterCommandLine.LocalHMaster

public interface HMasterInterface
extends VersionedProtocol

Clients interact with the HMasterInterface to gain access to meta-level HBase functionality, like finding an HRegionServer and creating/destroying tables.

NOTE: if you change the interface, you must change the RPC version number in HBaseRPCProtocolVersion


Field Summary
static long VERSION
          This Interfaces' version.
 
Method Summary
 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. The force is unused.Use assign(byte[])
 boolean balance()
          Run the balancer.
 boolean balanceSwitch(boolean b)
          Turn the load balancer on or off.
 void createTable(HTableDescriptor desc, byte[][] splitKeys)
          Creates a new table asynchronously.
 void deleteColumn(byte[] tableName, byte[] columnName)
          Deletes a column from the specified table.
 void deleteSnapshot(HSnapshotDescription snapshot)
           
 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.
 Pair<Integer,Integer> getAlterStatus(byte[] tableName)
          Used by the client to get the number of regions that have received the updated schema
 ClusterStatus getClusterStatus()
          Return cluster status.
 List<HSnapshotDescription> getCompletedSnapshots()
           
 HTableDescriptor[] getHTableDescriptors()
          Get array of all HTDs.
 HTableDescriptor[] getHTableDescriptors(List<String> tableNames)
          Get array of HTDs for requested tables.
 boolean isMasterRunning()
           
 boolean isRestoreSnapshotDone(HSnapshotDescription request)
           
 boolean isSnapshotDone(HSnapshotDescription snapshot)
           
 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)
          Offline a region from the assignment manager's in-memory state.
 void restoreSnapshot(HSnapshotDescription request)
           
 void shutdown()
          Shutdown an HBase cluster.
 long snapshot(HSnapshotDescription snapshot)
           
 void stopMaster()
          Stop HBase Master only.
 boolean synchronousBalanceSwitch(boolean b)
          Turn the load balancer on or off.
 void unassign(byte[] regionName, boolean force)
          Unassign a region from current hosting regionserver.
 
Methods inherited from interface org.apache.hadoop.hbase.ipc.VersionedProtocol
getProtocolSignature, getProtocolVersion
 

Field Detail

VERSION

static final long VERSION
This Interfaces' version. Version changes when the Interface changes.

See Also:
Constant Field Values
Method Detail

isMasterRunning

boolean isMasterRunning()
Returns:
true if master is available

createTable

void createTable(HTableDescriptor desc,
                 byte[][] splitKeys)
                 throws IOException
Creates a new table asynchronously. If splitKeys are specified, then the table will be created with an initial set of multiple regions. If splitKeys is null, the table will be created with a single region.

Parameters:
desc - table descriptor
splitKeys -
Throws:
IOException

deleteTable

void deleteTable(byte[] tableName)
                 throws IOException
Deletes a table

Parameters:
tableName - table to delete
Throws:
IOException - e

getAlterStatus

Pair<Integer,Integer> getAlterStatus(byte[] tableName)
                                     throws IOException
Used by the client to get the number of regions that have received the updated schema

Parameters:
tableName -
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

addColumn

void addColumn(byte[] tableName,
               HColumnDescriptor column)
               throws IOException
Adds a column to the specified table

Parameters:
tableName - table to modify
column - column descriptor
Throws:
IOException - e

modifyColumn

void modifyColumn(byte[] tableName,
                  HColumnDescriptor descriptor)
                  throws IOException
Modifies an existing column on the specified table

Parameters:
tableName - table name
descriptor - new column descriptor
Throws:
IOException - e

deleteColumn

void deleteColumn(byte[] tableName,
                  byte[] columnName)
                  throws IOException
Deletes a column from the specified table. Table must be disabled.

Parameters:
tableName - table to alter
columnName - column family to remove
Throws:
IOException - e

enableTable

void enableTable(byte[] tableName)
                 throws IOException
Puts the table on-line (only needed if table has been previously taken offline)

Parameters:
tableName - table to enable
Throws:
IOException - e

disableTable

void disableTable(byte[] tableName)
                  throws IOException
Take table offline

Parameters:
tableName - table to take offline
Throws:
IOException - e

modifyTable

void modifyTable(byte[] tableName,
                 HTableDescriptor htd)
                 throws IOException
Modify a table's metadata

Parameters:
tableName - table to modify
htd - new descriptor for table
Throws:
IOException - e

shutdown

void shutdown()
              throws IOException
Shutdown an HBase cluster.

Throws:
IOException - e

stopMaster

void stopMaster()
                throws IOException
Stop HBase Master only. Does not shutdown the cluster.

Throws:
IOException - e

getClusterStatus

ClusterStatus getClusterStatus()
Return cluster status.

Returns:
status object
Throws:
IOException

move

void move(byte[] encodedRegionName,
          byte[] destServerName)
          throws UnknownRegionException
Move the region r to dest.

Parameters:
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.
Throws:
UnknownRegionException - Thrown if we can't find a region named encodedRegionName

assign

void assign(byte[] regionName,
            boolean force)
            throws IOException
Deprecated. The force is unused.Use assign(byte[])

Assign a region to a server chosen at random.

Parameters:
regionName - Region to assign. Will use existing RegionPlan if one found.
force - If true, will force the assignment.
Throws:
IOException

assign

void assign(byte[] regionName)
            throws IOException
Assign a region to a server chosen at random.

Parameters:
regionName - Region to assign. Will use existing RegionPlan if one found.
Throws:
IOException

unassign

void unassign(byte[] regionName,
              boolean force)
              throws IOException
Unassign a region from current hosting regionserver. Region will then be assigned to a regionserver chosen at random. Region could be reassigned back to the same server. Use move(byte[], byte[]) if you want to control the region movement.

Parameters:
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.
Throws:
IOException

offline

void offline(byte[] regionName)
             throws IOException
Offline a region from the assignment manager's in-memory state. The region should be in a closed state and there will be no attempt to automatically reassign the region as in unassign. This is a special method, and should only be used by experts or hbck.

Parameters:
regionName - Region to offline. Will clear any existing RegionPlan if one found.
Throws:
IOException

balance

boolean balance()
Run the balancer. Will run the balancer and if regions to move, it will go ahead and do the reassignments. Can NOT run for various reasons. Check logs.

Returns:
True if balancer ran and was able to tell the region servers to unassign all the regions to balance (the re-assignment itself is async), false otherwise.

balanceSwitch

boolean balanceSwitch(boolean b)
Turn the load balancer on or off.

Parameters:
b - If true, enable balancer. If false, disable balancer.
Returns:
Previous balancer value

synchronousBalanceSwitch

boolean synchronousBalanceSwitch(boolean b)
Turn the load balancer on or off. It waits until current balance() call, if outstanding, to return.

Parameters:
b - If true, enable balancer. If false, disable balancer.
Returns:
Previous balancer value

getHTableDescriptors

HTableDescriptor[] getHTableDescriptors()
                                        throws IOException
Get array of all HTDs.

NOTE: This interface up to and including 0.94.8 included a getHTableDescriptors which did not throw IOE. Adding and deleting checked exceptions declared as thrown by a method does not break binary compatibility, so rolling restart scenarios will work; however, it will break contract compatibility possibly requiring source code changes upon next recompilation.

Returns:
array of HTableDescriptor
Throws:
IOException

getHTableDescriptors

HTableDescriptor[] getHTableDescriptors(List<String> tableNames)
                                        throws IOException
Get array of HTDs for requested tables.

NOTE: This interface up to and including 0.94.8 included a getHTableDescriptors which did not throw IOE. Adding and deleting checked exceptions declared as thrown by a method does not break binary compatibility, so rolling restart scenarios will work; however, it will break contract compatibility possibly requiring source code changes upon next recompilation.

Parameters:
tableNames -
Returns:
array of HTableDescriptor
Throws:
IOException

execCoprocessor

ExecResult execCoprocessor(Exec call)
                           throws IOException
Executes a single CoprocessorProtocol method using the registered protocol handlers. CoprocessorProtocol implementations must be registered via the MasterServices.registerProtocol(Class, CoprocessorProtocol) method before they are available.

Parameters:
call - an Exec instance identifying the protocol, method name, and parameters for the method invocation
Returns:
an ExecResult instance containing the region name of the invocation and the return value
Throws:
IOException - if no registered protocol handler is found or an error occurs during the invocation
See Also:
MasterServices.registerProtocol(Class, CoprocessorProtocol)

snapshot

long snapshot(HSnapshotDescription snapshot)
              throws IOException
Throws:
IOException

getCompletedSnapshots

List<HSnapshotDescription> getCompletedSnapshots()
                                                 throws IOException
Throws:
IOException

deleteSnapshot

void deleteSnapshot(HSnapshotDescription snapshot)
                    throws IOException
Throws:
IOException

isSnapshotDone

boolean isSnapshotDone(HSnapshotDescription snapshot)
                       throws IOException
Throws:
IOException

restoreSnapshot

void restoreSnapshot(HSnapshotDescription request)
                     throws IOException
Throws:
IOException

isRestoreSnapshotDone

boolean isRestoreSnapshotDone(HSnapshotDescription request)
                              throws IOException
Throws:
IOException


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