org.apache.hadoop.hbase.client
Class HBaseAdmin

java.lang.Object
  extended by org.apache.hadoop.hbase.client.HBaseAdmin
All Implemented Interfaces:
Closeable, Abortable

@InterfaceAudience.Public
@InterfaceStability.Evolving
public class HBaseAdmin
extends Object
implements Abortable, Closeable

Provides an interface to manage HBase database table metadata + general administrative functions. Use HBaseAdmin to create, drop, list, enable and disable tables. Use it also to add and drop table column families.

See HTable to add, update, and delete data from an individual table.

Currently HBaseAdmin instances are not expected to be long-lived. For example, an HBaseAdmin instance will not ride over a Master restart.


Constructor Summary
HBaseAdmin(org.apache.hadoop.conf.Configuration c)
          Constructor.
HBaseAdmin(HConnection connection)
          Constructor for externally managed HConnections.
 
Method Summary
 void abort(String why, Throwable e)
          Abort the server or client.
 void addColumn(byte[] tableName, HColumnDescriptor column)
          Add a column to an existing table.
 void addColumn(String tableName, HColumnDescriptor column)
          Add a column to an existing table.
 void addColumn(TableName tableName, HColumnDescriptor column)
          Add a column to an existing table.
 void assign(byte[] regionName)
           
 boolean balancer()
          Invoke the balancer.
static void checkHBaseAvailable(org.apache.hadoop.conf.Configuration conf)
          Check to see if HBase is running.
 void cloneSnapshot(byte[] snapshotName, byte[] tableName)
          Create a new table by cloning the snapshot content.
 void cloneSnapshot(byte[] snapshotName, TableName tableName)
          Create a new table by cloning the snapshot content.
 void cloneSnapshot(String snapshotName, String tableName)
          Create a new table by cloning the snapshot content.
 void cloneSnapshot(String snapshotName, TableName tableName)
          Create a new table by cloning the snapshot content.
 void close()
           
 void closeRegion(byte[] regionname, String serverName)
          Close a region.
 void closeRegion(ServerName sn, HRegionInfo hri)
          Close a region.
 void closeRegion(String regionname, String serverName)
          Close a region.
 boolean closeRegionWithEncodedRegionName(String encodedRegionName, String serverName)
          For expert-admins.
 void compact(byte[] tableNameOrRegionName)
          Compact a table or an individual region.
 void compact(byte[] tableNameOrRegionName, byte[] columnFamily)
          Compact a column family within a table or region.
 void compact(String tableNameOrRegionName)
          Compact a table or an individual region.
 void compact(String tableOrRegionName, String columnFamily)
          Compact a column family within a table or region.
 void compactRegionServer(ServerName sn, boolean major)
          Compact all regions on the region server
 CoprocessorRpcChannel coprocessorService()
          Creates and returns a RpcChannel instance connected to the active master.
 CoprocessorRpcChannel coprocessorService(ServerName sn)
          Creates and returns a RpcChannel instance connected to the passed region server.
 void createNamespace(NamespaceDescriptor descriptor)
          Create a new namespace
 void createTable(HTableDescriptor desc)
          Creates a new table.
 void createTable(HTableDescriptor desc, byte[][] splitKeys)
          Creates a new table with an initial set of empty regions defined by the specified split keys.
 void createTable(HTableDescriptor desc, byte[] startKey, byte[] endKey, int numRegions)
          Creates a new table with the specified number of regions.
 void createTableAsync(HTableDescriptor desc, byte[][] splitKeys)
          Creates a new table but does not block and wait for it to come online.
 void deleteColumn(byte[] tableName, String columnName)
          Delete a column from a table.
 void deleteColumn(String tableName, String columnName)
          Delete a column from a table.
 void deleteColumn(TableName tableName, byte[] columnName)
          Delete a column from a table.
 void deleteNamespace(String name)
          Delete an existing namespace.
 void deleteSnapshot(byte[] snapshotName)
          Delete an existing snapshot.
 void deleteSnapshot(String snapshotName)
          Delete an existing snapshot.
 void deleteSnapshots(Pattern pattern)
          Delete existing snapshots whose names match the pattern passed.
 void deleteSnapshots(String regex)
          Delete existing snapshots whose names match the pattern passed.
 void deleteTable(byte[] tableName)
           
 void deleteTable(String tableName)
           
 void deleteTable(TableName tableName)
          Deletes a table.
 HTableDescriptor[] deleteTables(Pattern pattern)
          Delete tables matching the passed in pattern and wait on completion.
 HTableDescriptor[] deleteTables(String regex)
          Deletes tables matching the passed in pattern and wait on completion.
 void deleteTableSnapshots(Pattern tableNamePattern, Pattern snapshotNamePattern)
          Delete all existing snapshots matching the given table name regular expression and snapshot name regular expression.
 void deleteTableSnapshots(String tableNameRegex, String snapshotNameRegex)
          Delete all existing snapshots matching the given table name regular expression and snapshot name regular expression.
 void disableTable(byte[] tableName)
           
 void disableTable(String tableName)
           
 void disableTable(TableName tableName)
          Disable table and wait on completion.
 void disableTableAsync(byte[] tableName)
           
 void disableTableAsync(String tableName)
           
 void disableTableAsync(TableName tableName)
          Starts the disable of a table.
 HTableDescriptor[] disableTables(Pattern pattern)
          Disable tables matching the passed in pattern and wait on completion.
 HTableDescriptor[] disableTables(String regex)
          Disable tables matching the passed in pattern and wait on completion.
 boolean enableCatalogJanitor(boolean enable)
          Enable/Disable the catalog janitor
 void enableTable(byte[] tableName)
           
 void enableTable(String tableName)
           
 void enableTable(TableName tableName)
          Enable a table.
 void enableTableAsync(byte[] tableName)
           
 void enableTableAsync(String tableName)
           
 void enableTableAsync(TableName tableName)
          Brings a table on-line (enables it).
 HTableDescriptor[] enableTables(Pattern pattern)
          Enable tables matching the passed in pattern and wait on completion.
 HTableDescriptor[] enableTables(String regex)
          Enable tables matching the passed in pattern and wait on completion.
 void execProcedure(String signature, String instance, Map<String,String> props)
          Execute a distributed procedure on a cluster.
 void flush(byte[] tableNameOrRegionName)
          Flush a table or an individual region.
 void flush(String tableNameOrRegionName)
          Flush a table or an individual region.
 Pair<Integer,Integer> getAlterStatus(byte[] tableName)
          Get the status of alter command - indicates how many regions have received the updated schema Asynchronous operation.
 Pair<Integer,Integer> getAlterStatus(TableName tableName)
          Get the status of alter command - indicates how many regions have received the updated schema Asynchronous operation.
 ClusterStatus getClusterStatus()
           
 org.apache.hadoop.hbase.protobuf.generated.AdminProtos.GetRegionInfoResponse.CompactionState getCompactionState(byte[] tableNameOrRegionName)
          Get the current compaction state of a table or region.
 org.apache.hadoop.hbase.protobuf.generated.AdminProtos.GetRegionInfoResponse.CompactionState getCompactionState(String tableNameOrRegionName)
          Get the current compaction state of a table or region.
 org.apache.hadoop.conf.Configuration getConfiguration()
           
 HConnection getConnection()
           
 String[] getMasterCoprocessors()
           
 NamespaceDescriptor getNamespaceDescriptor(String name)
          Get a namespace descriptor by name
 List<HRegionInfo> getOnlineRegions(ServerName sn)
          Get all the online regions on a region server.
 List<SecurityCapability> getSecurityCapabilities()
          Return the set of supported security capabilities.
 HTableDescriptor getTableDescriptor(byte[] tableName)
           
 HTableDescriptor getTableDescriptor(TableName tableName)
          Method for getting the tableDescriptor
 HTableDescriptor[] getTableDescriptors(List<String> names)
          Get tableDescriptors
 HTableDescriptor[] getTableDescriptorsByTableName(List<TableName> tableNames)
          Get tableDescriptors
 String[] getTableNames()
          Deprecated. 
 String[] getTableNames(Pattern pattern)
          Deprecated. 
 String[] getTableNames(String regex)
          Deprecated. 
 List<HRegionInfo> getTableRegions(byte[] tableName)
           
 List<HRegionInfo> getTableRegions(TableName tableName)
          get the regions of a given table.
 boolean isAborted()
          Check if the server or client was aborted.
 boolean isBalancerEnabled()
          Query the state of the balancer from the Master.
 boolean isCatalogJanitorEnabled()
          Query on the catalog janitor state (Enabled/Disabled?)
 boolean isMasterRunning()
           
 boolean isProcedureFinished(String signature, String instance, Map<String,String> props)
          Check the current state of the specified procedure.
 boolean isSnapshotFinished(org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription snapshot)
          Check the current state of the passed snapshot.
 boolean isTableAvailable(byte[] tableName)
           
 boolean isTableAvailable(byte[] tableName, byte[][] splitKeys)
           
 boolean isTableAvailable(String tableName)
           
 boolean isTableAvailable(String tableName, byte[][] splitKeys)
           
 boolean isTableAvailable(TableName tableName)
           
 boolean isTableAvailable(TableName tableName, byte[][] splitKeys)
          Use this api to check if the table has been created with the specified number of splitkeys which was used while creating the given table.
 boolean isTableDisabled(byte[] tableName)
           
 boolean isTableDisabled(String tableName)
           
 boolean isTableDisabled(TableName tableName)
           
 boolean isTableEnabled(byte[] tableName)
           
 boolean isTableEnabled(String tableName)
           
 boolean isTableEnabled(TableName tableName)
           
 NamespaceDescriptor[] listNamespaceDescriptors()
          List available namespace descriptors
 List<org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription> listSnapshots()
          List completed snapshots.
 List<org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription> listSnapshots(Pattern pattern)
          List all the completed snapshots matching the given pattern.
 List<org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription> listSnapshots(String regex)
          List all the completed snapshots matching the given regular expression.
 HTableDescriptor[] listTableDescriptorsByNamespace(String name)
          Get list of table descriptors by namespace
 TableName[] listTableNames()
          List all of the names of userspace tables.
 TableName[] listTableNamesByNamespace(String name)
          Get list of table names by namespace
 HTableDescriptor[] listTables()
          List all the userspace tables.
 HTableDescriptor[] listTables(Pattern pattern)
          List all the userspace tables matching the given pattern.
 HTableDescriptor[] listTables(String regex)
          List all the userspace tables matching the given regular expression.
 List<org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription> listTableSnapshots(Pattern tableNamePattern, Pattern snapshotNamePattern)
          List all the completed snapshots matching the given table name regular expression and snapshot name regular expression.
 List<org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription> listTableSnapshots(String tableNameRegex, String snapshotNameRegex)
          List all the completed snapshots matching the given table name regular expression and snapshot name regular expression.
 void majorCompact(byte[] tableNameOrRegionName)
          Major compact a table or an individual region.
 void majorCompact(byte[] tableNameOrRegionName, byte[] columnFamily)
          Major compact a column family within a table or region.
 void majorCompact(String tableNameOrRegionName)
          Major compact a table or an individual region.
 void majorCompact(String tableNameOrRegionName, String columnFamily)
          Major compact a column family within a table or region.
 void mergeRegions(byte[] encodedNameOfRegionA, byte[] encodedNameOfRegionB, boolean forcible)
          Merge two regions.
 void modifyColumn(byte[] tableName, HColumnDescriptor descriptor)
          Modify an existing column family on a table.
 void modifyColumn(String tableName, HColumnDescriptor descriptor)
          Modify an existing column family on a table.
 void modifyColumn(TableName tableName, HColumnDescriptor descriptor)
          Modify an existing column family on a table.
 void modifyNamespace(NamespaceDescriptor descriptor)
          Modify an existing namespace
 void modifyTable(byte[] tableName, HTableDescriptor htd)
           
 void modifyTable(String tableName, HTableDescriptor htd)
           
 void modifyTable(TableName tableName, HTableDescriptor htd)
          Modify an existing table, more IRB friendly version.
 void move(byte[] encodedRegionName, byte[] destServerName)
          Move the region r to dest.
 void offline(byte[] regionName)
          Offline specified region from master's in-memory state.
 void restoreSnapshot(byte[] snapshotName)
          Restore the specified snapshot on the original table.
 void restoreSnapshot(byte[] snapshotName, boolean takeFailSafeSnapshot)
          Restore the specified snapshot on the original table.
 void restoreSnapshot(String snapshotName)
          Restore the specified snapshot on the original table.
 void restoreSnapshot(String snapshotName, boolean takeFailSafeSnapshot)
          Restore the specified snapshot on the original table.
 byte[][] rollHLogWriter(String serverName)
          Roll the log writer.
 int runCatalogScan()
          Ask for a scan of the catalog table
 boolean setBalancerRunning(boolean on, boolean synchronous)
          Turn the load balancer on or off.
 void shutdown()
          Shuts down the HBase cluster
 void snapshot(byte[] snapshotName, byte[] tableName)
           
 void snapshot(byte[] snapshotName, byte[] tableName, org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription.Type flushType)
          Create snapshot for the given table of given flush type.
 void snapshot(byte[] snapshotName, TableName tableName)
          public void snapshot(final String snapshotName, Create a timestamp consistent snapshot for the given table.
 void snapshot(org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription snapshot)
          Take a snapshot and wait for the server to complete that snapshot (blocking).
 void snapshot(String snapshotName, byte[] tableName, org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription.Type type)
           
 void snapshot(String snapshotName, String tableName)
           
 void snapshot(String snapshotName, String tableName, org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription.Type type)
           
 void snapshot(String snapshotName, TableName tableName)
          Take a snapshot for the given table.
 void snapshot(String snapshotName, TableName tableName, org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription.Type type)
          Create typed snapshot of the table.
 void split(byte[] tableNameOrRegionName)
          Split a table or an individual region.
 void split(byte[] tableNameOrRegionName, byte[] splitPoint)
          Split a table or an individual region.
 void split(String tableNameOrRegionName)
          Split a table or an individual region.
 void split(String tableNameOrRegionName, String splitPoint)
           
 void stopMaster()
          Shuts down the current HBase master only.
 void stopRegionServer(String hostnamePort)
          Stop the designated regionserver
 boolean tableExists(byte[] tableName)
           
 boolean tableExists(String tableName)
           
 boolean tableExists(TableName tableName)
           
 org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SnapshotResponse takeSnapshotAsync(org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription snapshot)
          Take a snapshot without waiting for the server to complete that snapshot (asynchronous)
 void truncateTable(TableName tableName, boolean preserveSplits)
          Truncate a table.
 void unassign(byte[] regionName, boolean force)
          Unassign a region from current hosting regionserver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HBaseAdmin

public HBaseAdmin(org.apache.hadoop.conf.Configuration c)
           throws MasterNotRunningException,
                  ZooKeeperConnectionException,
                  IOException
Constructor. See HBaseAdmin(HConnection connection)

Parameters:
c - Configuration object. Copied internally.
Throws:
MasterNotRunningException
ZooKeeperConnectionException
IOException

HBaseAdmin

public HBaseAdmin(HConnection connection)
           throws MasterNotRunningException,
                  ZooKeeperConnectionException
Constructor for externally managed HConnections. The connection to master will be created when required by admin functions.

Parameters:
connection - The HConnection instance to use
Throws:
MasterNotRunningException, - ZooKeeperConnectionException are not thrown anymore but kept into the interface for backward api compatibility
MasterNotRunningException
ZooKeeperConnectionException
Method Detail

abort

public void abort(String why,
                  Throwable e)
Description copied from interface: Abortable
Abort the server or client.

Specified by:
abort in interface Abortable
Parameters:
why - Why we're aborting.
e - Throwable that caused abort. Can be null.

isAborted

public boolean isAborted()
Description copied from interface: Abortable
Check if the server or client was aborted.

Specified by:
isAborted in interface Abortable
Returns:
true if the server or client was aborted, false otherwise

getConnection

public HConnection getConnection()
Returns:
HConnection used by this object.

isMasterRunning

public boolean isMasterRunning()
                        throws MasterNotRunningException,
                               ZooKeeperConnectionException
Returns:
- true if the master server is running. Throws an exception otherwise.
Throws:
ZooKeeperConnectionException
MasterNotRunningException

tableExists

public boolean tableExists(TableName tableName)
                    throws IOException
Parameters:
tableName - Table to check.
Returns:
True if table exists already.
Throws:
IOException

tableExists

public boolean tableExists(byte[] tableName)
                    throws IOException
Throws:
IOException

tableExists

public boolean tableExists(String tableName)
                    throws IOException
Throws:
IOException

listTables

public HTableDescriptor[] listTables()
                              throws IOException
List all the userspace tables. In other words, scan the hbase:meta table. If we wanted this to be really fast, we could implement a special catalog table that just contains table names and their descriptors. Right now, it only exists as part of the hbase:meta table's region info.

Returns:
- returns an array of HTableDescriptors
Throws:
IOException - if a remote or network exception occurs

listTables

public HTableDescriptor[] listTables(Pattern pattern)
                              throws IOException
List all the userspace tables matching the given pattern.

Parameters:
pattern - The compiled regular expression to match against
Returns:
- returns an array of HTableDescriptors
Throws:
IOException - if a remote or network exception occurs
See Also:
listTables()

listTables

public HTableDescriptor[] listTables(String regex)
                              throws IOException
List all the userspace tables matching the given regular expression.

Parameters:
regex - The regular expression to match against
Returns:
- returns an array of HTableDescriptors
Throws:
IOException - if a remote or network exception occurs
See Also:
listTables(java.util.regex.Pattern)

getTableNames

@Deprecated
public String[] getTableNames()
                       throws IOException
Deprecated. 

List all of the names of userspace tables.

Returns:
String[] table names
Throws:
IOException - if a remote or network exception occurs

getTableNames

@Deprecated
public String[] getTableNames(Pattern pattern)
                       throws IOException
Deprecated. 

List all of the names of userspace tables matching the given regular expression.

Parameters:
pattern - The regular expression to match against
Returns:
String[] table names
Throws:
IOException - if a remote or network exception occurs

getTableNames

@Deprecated
public String[] getTableNames(String regex)
                       throws IOException
Deprecated. 

List all of the names of userspace tables matching the given regular expression.

Parameters:
regex - The regular expression to match against
Returns:
String[] table names
Throws:
IOException - if a remote or network exception occurs

listTableNames

public TableName[] listTableNames()
                           throws IOException
List all of the names of userspace tables.

Returns:
TableName[] table names
Throws:
IOException - if a remote or network exception occurs

getTableDescriptor

public HTableDescriptor getTableDescriptor(TableName tableName)
                                    throws TableNotFoundException,
                                           IOException
Method for getting the tableDescriptor

Parameters:
tableName - as a byte []
Returns:
the tableDescriptor
Throws:
TableNotFoundException
IOException - if a remote or network exception occurs

getTableDescriptor

public HTableDescriptor getTableDescriptor(byte[] tableName)
                                    throws TableNotFoundException,
                                           IOException
Throws:
TableNotFoundException
IOException

createTable

public void createTable(HTableDescriptor desc)
                 throws IOException
Creates a new table. Synchronous operation.

Parameters:
desc - table descriptor for table
Throws:
IllegalArgumentException - if the table name is reserved
MasterNotRunningException - if master is not running
TableExistsException - if table already exists (If concurrent threads, the table may have been created between test-for-existence and attempt-at-creation).
IOException - if a remote or network exception occurs

createTable

public void createTable(HTableDescriptor desc,
                        byte[] startKey,
                        byte[] endKey,
                        int numRegions)
                 throws IOException
Creates a new table with the specified number of regions. The start key specified will become the end key of the first region of the table, and the end key specified will become the start key of the last region of the table (the first region has a null start key and the last region has a null end key). BigInteger math will be used to divide the key range specified into enough segments to make the required number of total regions. Synchronous operation.

Parameters:
desc - table descriptor for table
startKey - beginning of key range
endKey - end of key range
numRegions - the total number of regions to create
Throws:
IllegalArgumentException - if the table name is reserved
MasterNotRunningException - if master is not running
TableExistsException - if table already exists (If concurrent threads, the table may have been created between test-for-existence and attempt-at-creation).
IOException

createTable

public void createTable(HTableDescriptor desc,
                        byte[][] splitKeys)
                 throws IOException
Creates a new table with an initial set of empty regions defined by the specified split keys. The total number of regions created will be the number of split keys plus one. Synchronous operation. Note : Avoid passing empty split key.

Parameters:
desc - table descriptor for table
splitKeys - array of split keys for the initial regions of the table
Throws:
IllegalArgumentException - if the table name is reserved, if the split keys are repeated and if the split key has empty byte array.
MasterNotRunningException - if master is not running
TableExistsException - if table already exists (If concurrent threads, the table may have been created between test-for-existence and attempt-at-creation).
IOException

createTableAsync

public void createTableAsync(HTableDescriptor desc,
                             byte[][] splitKeys)
                      throws IOException
Creates a new table but does not block and wait for it to come online. Asynchronous operation. To check if the table exists, use isTableAvailable(org.apache.hadoop.hbase.TableName) -- it is not safe to create an HTable instance to this table before it is available. Note : Avoid passing empty split key.

Parameters:
desc - table descriptor for table
Throws:
IllegalArgumentException - Bad table name, if the split keys are repeated and if the split key has empty byte array.
MasterNotRunningException - if master is not running
TableExistsException - if table already exists (If concurrent threads, the table may have been created between test-for-existence and attempt-at-creation).
IOException

deleteTable

public void deleteTable(String tableName)
                 throws IOException
Throws:
IOException

deleteTable

public void deleteTable(byte[] tableName)
                 throws IOException
Throws:
IOException

deleteTable

public void deleteTable(TableName tableName)
                 throws IOException
Deletes a table. Synchronous operation.

Parameters:
tableName - name of table to delete
Throws:
IOException - if a remote or network exception occurs

deleteTables

public HTableDescriptor[] deleteTables(String regex)
                                throws IOException
Deletes tables matching the passed in pattern and wait on completion. Warning: Use this method carefully, there is no prompting and the effect is immediate. Consider using listTables(java.lang.String) and deleteTable(byte[])

Parameters:
regex - The regular expression to match table names against
Returns:
Table descriptors for tables that couldn't be deleted
Throws:
IOException
See Also:
deleteTables(java.util.regex.Pattern), deleteTable(java.lang.String)

deleteTables

public HTableDescriptor[] deleteTables(Pattern pattern)
                                throws IOException
Delete tables matching the passed in pattern and wait on completion. Warning: Use this method carefully, there is no prompting and the effect is immediate. Consider using listTables(java.util.regex.Pattern) and deleteTable(byte[])

Parameters:
pattern - The pattern to match table names against
Returns:
Table descriptors for tables that couldn't be deleted
Throws:
IOException

enableTable

public void enableTable(TableName tableName)
                 throws IOException
Enable a table. May timeout. Use enableTableAsync(byte[]) and isTableEnabled(byte[]) instead. The table has to be in disabled state for it to be enabled.

Parameters:
tableName - name of the table
Throws:
IOException - if a remote or network exception occurs There could be couple types of IOException TableNotFoundException means the table doesn't exist. TableNotDisabledException means the table isn't in disabled state.
See Also:
isTableEnabled(byte[]), disableTable(byte[]), enableTableAsync(byte[])

enableTable

public void enableTable(byte[] tableName)
                 throws IOException
Throws:
IOException

enableTable

public void enableTable(String tableName)
                 throws IOException
Throws:
IOException

enableTableAsync

public void enableTableAsync(TableName tableName)
                      throws IOException
Brings a table on-line (enables it). Method returns immediately though enable of table may take some time to complete, especially if the table is large (All regions are opened as part of enabling process). Check isTableEnabled(byte[]) to learn when table is fully online. If table is taking too long to online, check server logs.

Parameters:
tableName -
Throws:
IOException
Since:
0.90.0

enableTableAsync

public void enableTableAsync(byte[] tableName)
                      throws IOException
Throws:
IOException

enableTableAsync

public void enableTableAsync(String tableName)
                      throws IOException
Throws:
IOException

enableTables

public HTableDescriptor[] enableTables(String regex)
                                throws IOException
Enable tables matching the passed in pattern and wait on completion. Warning: Use this method carefully, there is no prompting and the effect is immediate. Consider using listTables(java.lang.String) and enableTable(byte[])

Parameters:
regex - The regular expression to match table names against
Throws:
IOException
See Also:
enableTables(java.util.regex.Pattern), enableTable(java.lang.String)

enableTables

public HTableDescriptor[] enableTables(Pattern pattern)
                                throws IOException
Enable tables matching the passed in pattern and wait on completion. Warning: Use this method carefully, there is no prompting and the effect is immediate. Consider using listTables(java.util.regex.Pattern) and enableTable(byte[])

Parameters:
pattern - The pattern to match table names against
Throws:
IOException

disableTableAsync

public void disableTableAsync(TableName tableName)
                       throws IOException
Starts the disable of a table. If it is being served, the master will tell the servers to stop serving it. This method returns immediately. The disable of a table can take some time if the table is large (all regions are closed as part of table disable operation). Call isTableDisabled(byte[]) to check for when disable completes. If table is taking too long to online, check server logs.

Parameters:
tableName - name of table
Throws:
IOException - if a remote or network exception occurs
Since:
0.90.0
See Also:
isTableDisabled(byte[]), isTableEnabled(byte[])

disableTableAsync

public void disableTableAsync(byte[] tableName)
                       throws IOException
Throws:
IOException

disableTableAsync

public void disableTableAsync(String tableName)
                       throws IOException
Throws:
IOException

disableTable

public void disableTable(TableName tableName)
                  throws IOException
Disable table and wait on completion. May timeout eventually. Use disableTableAsync(byte[]) and isTableDisabled(String) instead. The table has to be in enabled state for it to be disabled.

Parameters:
tableName -
Throws:
IOException - There could be couple types of IOException TableNotFoundException means the table doesn't exist. TableNotEnabledException means the table isn't in enabled state.

disableTable

public void disableTable(byte[] tableName)
                  throws IOException
Throws:
IOException

disableTable

public void disableTable(String tableName)
                  throws IOException
Throws:
IOException

disableTables

public HTableDescriptor[] disableTables(String regex)
                                 throws IOException
Disable tables matching the passed in pattern and wait on completion. Warning: Use this method carefully, there is no prompting and the effect is immediate. Consider using listTables(java.lang.String) and disableTable(byte[])

Parameters:
regex - The regular expression to match table names against
Returns:
Table descriptors for tables that couldn't be disabled
Throws:
IOException
See Also:
disableTables(java.util.regex.Pattern), disableTable(java.lang.String)

disableTables

public HTableDescriptor[] disableTables(Pattern pattern)
                                 throws IOException
Disable tables matching the passed in pattern and wait on completion. Warning: Use this method carefully, there is no prompting and the effect is immediate. Consider using listTables(java.util.regex.Pattern) and disableTable(byte[])

Parameters:
pattern - The pattern to match table names against
Returns:
Table descriptors for tables that couldn't be disabled
Throws:
IOException

isTableEnabled

public boolean isTableEnabled(TableName tableName)
                       throws IOException
Parameters:
tableName - name of table to check
Returns:
true if table is on-line
Throws:
IOException - if a remote or network exception occurs

isTableEnabled

public boolean isTableEnabled(byte[] tableName)
                       throws IOException
Throws:
IOException

isTableEnabled

public boolean isTableEnabled(String tableName)
                       throws IOException
Throws:
IOException

isTableDisabled

public boolean isTableDisabled(TableName tableName)
                        throws IOException
Parameters:
tableName - name of table to check
Returns:
true if table is off-line
Throws:
IOException - if a remote or network exception occurs

isTableDisabled

public boolean isTableDisabled(byte[] tableName)
                        throws IOException
Throws:
IOException

isTableDisabled

public boolean isTableDisabled(String tableName)
                        throws IOException
Throws:
IOException

isTableAvailable

public boolean isTableAvailable(TableName tableName)
                         throws IOException
Parameters:
tableName - name of table to check
Returns:
true if all regions of the table are available
Throws:
IOException - if a remote or network exception occurs

isTableAvailable

public boolean isTableAvailable(byte[] tableName)
                         throws IOException
Throws:
IOException

isTableAvailable

public boolean isTableAvailable(String tableName)
                         throws IOException
Throws:
IOException

isTableAvailable

public boolean isTableAvailable(TableName tableName,
                                byte[][] splitKeys)
                         throws IOException
Use this api to check if the table has been created with the specified number of splitkeys which was used while creating the given table. Note : If this api is used after a table's region gets splitted, the api may return false.

Parameters:
tableName - name of table to check
splitKeys - keys to check if the table has been created with all split keys
Throws:
IOException - if a remote or network excpetion occurs

isTableAvailable

public boolean isTableAvailable(byte[] tableName,
                                byte[][] splitKeys)
                         throws IOException
Throws:
IOException

isTableAvailable

public boolean isTableAvailable(String tableName,
                                byte[][] splitKeys)
                         throws IOException
Throws:
IOException

getAlterStatus

public Pair<Integer,Integer> getAlterStatus(TableName tableName)
                                     throws IOException
Get the status of alter command - indicates how many regions have received the updated schema Asynchronous operation.

Parameters:
tableName - TableName instance
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 - if a remote or network exception occurs

getAlterStatus

public Pair<Integer,Integer> getAlterStatus(byte[] tableName)
                                     throws IOException
Get the status of alter command - indicates how many regions have received the updated schema Asynchronous operation.

Parameters:
tableName - name of the table to get the status of
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 - if a remote or network exception occurs

addColumn

public void addColumn(byte[] tableName,
                      HColumnDescriptor column)
               throws IOException
Add a column to an existing table. Asynchronous operation.

Parameters:
tableName - name of the table to add column to
column - column descriptor of column to be added
Throws:
IOException - if a remote or network exception occurs

addColumn

public void addColumn(String tableName,
                      HColumnDescriptor column)
               throws IOException
Add a column to an existing table. Asynchronous operation.

Parameters:
tableName - name of the table to add column to
column - column descriptor of column to be added
Throws:
IOException - if a remote or network exception occurs

addColumn

public void addColumn(TableName tableName,
                      HColumnDescriptor column)
               throws IOException
Add a column to an existing table. Asynchronous operation.

Parameters:
tableName - name of the table to add column to
column - column descriptor of column to be added
Throws:
IOException - if a remote or network exception occurs

deleteColumn

public void deleteColumn(byte[] tableName,
                         String columnName)
                  throws IOException
Delete a column from a table. Asynchronous operation.

Parameters:
tableName - name of table
columnName - name of column to be deleted
Throws:
IOException - if a remote or network exception occurs

deleteColumn

public void deleteColumn(String tableName,
                         String columnName)
                  throws IOException
Delete a column from a table. Asynchronous operation.

Parameters:
tableName - name of table
columnName - name of column to be deleted
Throws:
IOException - if a remote or network exception occurs

deleteColumn

public void deleteColumn(TableName tableName,
                         byte[] columnName)
                  throws IOException
Delete a column from a table. Asynchronous operation.

Parameters:
tableName - name of table
columnName - name of column to be deleted
Throws:
IOException - if a remote or network exception occurs

modifyColumn

public void modifyColumn(String tableName,
                         HColumnDescriptor descriptor)
                  throws IOException
Modify an existing column family on a table. Asynchronous operation.

Parameters:
tableName - name of table
descriptor - new column descriptor to use
Throws:
IOException - if a remote or network exception occurs

modifyColumn

public void modifyColumn(byte[] tableName,
                         HColumnDescriptor descriptor)
                  throws IOException
Modify an existing column family on a table. Asynchronous operation.

Parameters:
tableName - name of table
descriptor - new column descriptor to use
Throws:
IOException - if a remote or network exception occurs

modifyColumn

public void modifyColumn(TableName tableName,
                         HColumnDescriptor descriptor)
                  throws IOException
Modify an existing column family on a table. Asynchronous operation.

Parameters:
tableName - name of table
descriptor - new column descriptor to use
Throws:
IOException - if a remote or network exception occurs

closeRegion

public void closeRegion(String regionname,
                        String serverName)
                 throws IOException
Close a region. For expert-admins. Runs close on the regionserver. The master will not be informed of the close.

Parameters:
regionname - region name to close
serverName - If supplied, we'll use this location rather than the one currently in hbase:meta
Throws:
IOException - if a remote or network exception occurs

closeRegion

public void closeRegion(byte[] regionname,
                        String serverName)
                 throws IOException
Close a region. For expert-admins Runs close on the regionserver. The master will not be informed of the close.

Parameters:
regionname - region name to close
serverName - The servername of the regionserver. If passed null we will use servername found in the hbase:meta table. A server name is made of host, port and startcode. Here is an example: host187.example.com,60020,1289493121758
Throws:
IOException - if a remote or network exception occurs

closeRegionWithEncodedRegionName

public boolean closeRegionWithEncodedRegionName(String encodedRegionName,
                                                String serverName)
                                         throws IOException
For expert-admins. Runs close on the regionserver. Closes a region based on the encoded region name. The region server name is mandatory. If the servername is provided then based on the online regions in the specified regionserver the specified region will be closed. The master will not be informed of the close. Note that the regionname is the encoded regionname.

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.
serverName - The servername of the regionserver. A server name is made of host, port and startcode. This is mandatory. Here is an example: host187.example.com,60020,1289493121758
Returns:
true if the region was closed, false if not.
Throws:
IOException - if a remote or network exception occurs

closeRegion

public void closeRegion(ServerName sn,
                        HRegionInfo hri)
                 throws IOException
Close a region. For expert-admins Runs close on the regionserver. The master will not be informed of the close.

Parameters:
sn -
hri -
Throws:
IOException

getOnlineRegions

public List<HRegionInfo> getOnlineRegions(ServerName sn)
                                   throws IOException
Get all the online regions on a region server.

Throws:
IOException

flush

public void flush(String tableNameOrRegionName)
           throws IOException,
                  InterruptedException
Flush a table or an individual region. Synchronous operation.

Parameters:
tableNameOrRegionName - table or region to flush
Throws:
IOException - if a remote or network exception occurs
InterruptedException

flush

public void flush(byte[] tableNameOrRegionName)
           throws IOException,
                  InterruptedException
Flush a table or an individual region. Synchronous operation.

Parameters:
tableNameOrRegionName - table or region to flush
Throws:
IOException - if a remote or network exception occurs
InterruptedException

compact

public void compact(String tableNameOrRegionName)
             throws IOException,
                    InterruptedException
Compact a table or an individual region. Asynchronous operation.

Parameters:
tableNameOrRegionName - table or region to compact
Throws:
IOException - if a remote or network exception occurs
InterruptedException

compact

public void compact(byte[] tableNameOrRegionName)
             throws IOException,
                    InterruptedException
Compact a table or an individual region. Asynchronous operation.

Parameters:
tableNameOrRegionName - table or region to compact
Throws:
IOException - if a remote or network exception occurs
InterruptedException

compact

public void compact(String tableOrRegionName,
                    String columnFamily)
             throws IOException,
                    InterruptedException
Compact a column family within a table or region. Asynchronous operation.

Parameters:
tableOrRegionName - table or region to compact
columnFamily - column family within a table or region
Throws:
IOException - if a remote or network exception occurs
InterruptedException

compact

public void compact(byte[] tableNameOrRegionName,
                    byte[] columnFamily)
             throws IOException,
                    InterruptedException
Compact a column family within a table or region. Asynchronous operation.

Parameters:
tableNameOrRegionName - table or region to compact
columnFamily - column family within a table or region
Throws:
IOException - if a remote or network exception occurs
InterruptedException

majorCompact

public void majorCompact(String tableNameOrRegionName)
                  throws IOException,
                         InterruptedException
Major compact a table or an individual region. Asynchronous operation.

Parameters:
tableNameOrRegionName - table or region to major compact
Throws:
IOException - if a remote or network exception occurs
InterruptedException

majorCompact

public void majorCompact(byte[] tableNameOrRegionName)
                  throws IOException,
                         InterruptedException
Major compact a table or an individual region. Asynchronous operation.

Parameters:
tableNameOrRegionName - table or region to major compact
Throws:
IOException - if a remote or network exception occurs
InterruptedException

majorCompact

public void majorCompact(String tableNameOrRegionName,
                         String columnFamily)
                  throws IOException,
                         InterruptedException
Major compact a column family within a table or region. Asynchronous operation.

Parameters:
tableNameOrRegionName - table or region to major compact
columnFamily - column family within a table or region
Throws:
IOException - if a remote or network exception occurs
InterruptedException

majorCompact

public void majorCompact(byte[] tableNameOrRegionName,
                         byte[] columnFamily)
                  throws IOException,
                         InterruptedException
Major compact a column family within a table or region. Asynchronous operation.

Parameters:
tableNameOrRegionName - table or region to major compact
columnFamily - column family within a table or region
Throws:
IOException - if a remote or network exception occurs
InterruptedException

compactRegionServer

public void compactRegionServer(ServerName sn,
                                boolean major)
                         throws IOException,
                                InterruptedException
Compact all regions on the region server

Parameters:
regionserver - the region server name
major - if it's major compaction
Throws:
IOException
InterruptedException

move

public void move(byte[] encodedRegionName,
                 byte[] destServerName)
          throws HBaseIOException,
                 MasterNotRunningException,
                 ZooKeeperConnectionException
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
ZooKeeperConnectionException
MasterNotRunningException
HBaseIOException

assign

public void assign(byte[] regionName)
            throws MasterNotRunningException,
                   ZooKeeperConnectionException,
                   IOException
Parameters:
regionName - Region name to assign.
Throws:
MasterNotRunningException
ZooKeeperConnectionException
IOException

unassign

public void unassign(byte[] regionName,
                     boolean force)
              throws MasterNotRunningException,
                     ZooKeeperConnectionException,
                     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. If results in double assignment use hbck -fix to resolve. To be used by experts).
Throws:
MasterNotRunningException
ZooKeeperConnectionException
IOException

offline

public void offline(byte[] regionName)
             throws IOException
Offline specified region from master's in-memory state. It will not attempt to reassign the region as in unassign. This API can be used when a region not served by any region server and still online as per Master's in memory state. If this API is incorrectly used on active region then master will loose track of that region. This is a special method that should be used by experts or hbck.

Parameters:
regionName - Region to offline.
Throws:
IOException

setBalancerRunning

public boolean setBalancerRunning(boolean on,
                                  boolean synchronous)
                           throws MasterNotRunningException,
                                  ZooKeeperConnectionException
Turn the load balancer on or off.

Parameters:
on - If true, enable balancer. If false, disable balancer.
synchronous - If true, it waits until current balance() call, if outstanding, to return.
Returns:
Previous balancer value
Throws:
MasterNotRunningException
ZooKeeperConnectionException

balancer

public boolean balancer()
                 throws MasterNotRunningException,
                        ZooKeeperConnectionException,
                        com.google.protobuf.ServiceException
Invoke 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, false otherwise.
Throws:
MasterNotRunningException
ZooKeeperConnectionException
com.google.protobuf.ServiceException

isBalancerEnabled

public boolean isBalancerEnabled()
                          throws com.google.protobuf.ServiceException,
                                 MasterNotRunningException
Query the state of the balancer from the Master. It's not a guarantee that the balancer is actually running this very moment, but that it will run.

Returns:
True if the balancer is enabled, false otherwise.
Throws:
com.google.protobuf.ServiceException
MasterNotRunningException

enableCatalogJanitor

public boolean enableCatalogJanitor(boolean enable)
                             throws com.google.protobuf.ServiceException,
                                    MasterNotRunningException
Enable/Disable the catalog janitor

Parameters:
enable - if true enables the catalog janitor
Returns:
the previous state
Throws:
com.google.protobuf.ServiceException
MasterNotRunningException

runCatalogScan

public int runCatalogScan()
                   throws com.google.protobuf.ServiceException,
                          MasterNotRunningException
Ask for a scan of the catalog table

Returns:
the number of entries cleaned
Throws:
com.google.protobuf.ServiceException
MasterNotRunningException

isCatalogJanitorEnabled

public boolean isCatalogJanitorEnabled()
                                throws com.google.protobuf.ServiceException,
                                       MasterNotRunningException
Query on the catalog janitor state (Enabled/Disabled?)

Throws:
com.google.protobuf.ServiceException
MasterNotRunningException

mergeRegions

public void mergeRegions(byte[] encodedNameOfRegionA,
                         byte[] encodedNameOfRegionB,
                         boolean forcible)
                  throws IOException
Merge two regions. Asynchronous operation.

Parameters:
encodedNameOfRegionA - encoded name of region a
encodedNameOfRegionB - encoded name of region b
forcible - true if do a compulsory merge, otherwise we will only merge two adjacent regions
Throws:
IOException

split

public void split(String tableNameOrRegionName)
           throws IOException,
                  InterruptedException
Split a table or an individual region. Asynchronous operation.

Parameters:
tableNameOrRegionName - table or region to split
Throws:
IOException - if a remote or network exception occurs
InterruptedException

split

public void split(byte[] tableNameOrRegionName)
           throws IOException,
                  InterruptedException
Split a table or an individual region. Implicitly finds an optimal split point. Asynchronous operation.

Parameters:
tableNameOrRegionName - table to region to split
Throws:
IOException - if a remote or network exception occurs
InterruptedException

split

public void split(String tableNameOrRegionName,
                  String splitPoint)
           throws IOException,
                  InterruptedException
Throws:
IOException
InterruptedException

split

public void split(byte[] tableNameOrRegionName,
                  byte[] splitPoint)
           throws IOException,
                  InterruptedException
Split a table or an individual region. Asynchronous operation.

Parameters:
tableNameOrRegionName - table to region to split
splitPoint - the explicit position to split on
Throws:
IOException - if a remote or network exception occurs
InterruptedException - interrupt exception occurred

modifyTable

public void modifyTable(TableName tableName,
                        HTableDescriptor htd)
                 throws IOException
Modify an existing table, more IRB friendly version. Asynchronous operation. This means that it may be a while before your schema change is updated across all of the table.

Parameters:
tableName - name of table.
htd - modified description of the table
Throws:
IOException - if a remote or network exception occurs

modifyTable

public void modifyTable(byte[] tableName,
                        HTableDescriptor htd)
                 throws IOException
Throws:
IOException

modifyTable

public void modifyTable(String tableName,
                        HTableDescriptor htd)
                 throws IOException
Throws:
IOException

shutdown

public void shutdown()
              throws IOException
Shuts down the HBase cluster

Throws:
IOException - if a remote or network exception occurs

stopMaster

public void stopMaster()
                throws IOException
Shuts down the current HBase master only. Does not shutdown the cluster.

Throws:
IOException - if a remote or network exception occurs
See Also:
shutdown()

stopRegionServer

public void stopRegionServer(String hostnamePort)
                      throws IOException
Stop the designated regionserver

Parameters:
hostnamePort - Hostname and port delimited by a : as in example.org:1234
Throws:
IOException - if a remote or network exception occurs

getClusterStatus

public ClusterStatus getClusterStatus()
                               throws IOException
Returns:
cluster status
Throws:
IOException - if a remote or network exception occurs

getConfiguration

public org.apache.hadoop.conf.Configuration getConfiguration()
Returns:
Configuration used by the instance.

createNamespace

public void createNamespace(NamespaceDescriptor descriptor)
                     throws IOException
Create a new namespace

Parameters:
descriptor - descriptor which describes the new namespace
Throws:
IOException

modifyNamespace

public void modifyNamespace(NamespaceDescriptor descriptor)
                     throws IOException
Modify an existing namespace

Parameters:
descriptor - descriptor which describes the new namespace
Throws:
IOException

deleteNamespace

public void deleteNamespace(String name)
                     throws IOException
Delete an existing namespace. Only empty namespaces (no tables) can be removed.

Parameters:
name - namespace name
Throws:
IOException

getNamespaceDescriptor

public NamespaceDescriptor getNamespaceDescriptor(String name)
                                           throws IOException
Get a namespace descriptor by name

Parameters:
name - name of namespace descriptor
Returns:
A descriptor
Throws:
IOException

listNamespaceDescriptors

public NamespaceDescriptor[] listNamespaceDescriptors()
                                               throws IOException
List available namespace descriptors

Returns:
List of descriptors
Throws:
IOException

listTableDescriptorsByNamespace

public HTableDescriptor[] listTableDescriptorsByNamespace(String name)
                                                   throws IOException
Get list of table descriptors by namespace

Parameters:
name - namespace name
Returns:
A descriptor
Throws:
IOException

listTableNamesByNamespace

public TableName[] listTableNamesByNamespace(String name)
                                      throws IOException
Get list of table names by namespace

Parameters:
name - namespace name
Returns:
The list of table names in the namespace
Throws:
IOException

checkHBaseAvailable

public static void checkHBaseAvailable(org.apache.hadoop.conf.Configuration conf)
                                throws MasterNotRunningException,
                                       ZooKeeperConnectionException,
                                       com.google.protobuf.ServiceException,
                                       IOException
Check to see if HBase is running. Throw an exception if not. We consider that HBase is running if ZooKeeper and Master are running.

Parameters:
conf - system configuration
Throws:
MasterNotRunningException - if the master is not running
ZooKeeperConnectionException - if unable to connect to zookeeper
com.google.protobuf.ServiceException
IOException

getTableRegions

public List<HRegionInfo> getTableRegions(TableName tableName)
                                  throws IOException
get the regions of a given table.

Parameters:
tableName - the name of the table
Returns:
Ordered list of HRegionInfo.
Throws:
IOException

getTableRegions

public List<HRegionInfo> getTableRegions(byte[] tableName)
                                  throws IOException
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Throws:
IOException

getTableDescriptorsByTableName

public HTableDescriptor[] getTableDescriptorsByTableName(List<TableName> tableNames)
                                                  throws IOException
Get tableDescriptors

Parameters:
tableNames - List of table names
Returns:
HTD[] the tableDescriptor
Throws:
IOException - if a remote or network exception occurs

getTableDescriptors

public HTableDescriptor[] getTableDescriptors(List<String> names)
                                       throws IOException
Get tableDescriptors

Parameters:
names - List of table names
Returns:
HTD[] the tableDescriptor
Throws:
IOException - if a remote or network exception occurs

rollHLogWriter

public byte[][] rollHLogWriter(String serverName)
                        throws IOException,
                               FailedLogCloseException
Roll the log writer. That is, start writing log messages to a new file.

Parameters:
serverName - The servername of the regionserver. A server name is made of host, port and startcode. This is mandatory. Here is an example: host187.example.com,60020,1289493121758
Returns:
If lots of logs, flush the returned regions so next time through we can clean logs. Returns null if nothing to flush. Names are actual region names as returned by HRegionInfo.getEncodedName()
Throws:
IOException - if a remote or network exception occurs
FailedLogCloseException

getMasterCoprocessors

public String[] getMasterCoprocessors()

getCompactionState

public org.apache.hadoop.hbase.protobuf.generated.AdminProtos.GetRegionInfoResponse.CompactionState getCompactionState(String tableNameOrRegionName)
                                                                                                                throws IOException,
                                                                                                                       InterruptedException
Get the current compaction state of a table or region. It could be in a major compaction, a minor compaction, both, or none.

Parameters:
tableNameOrRegionName - table or region to major compact
Returns:
the current compaction state
Throws:
IOException - if a remote or network exception occurs
InterruptedException

getCompactionState

public org.apache.hadoop.hbase.protobuf.generated.AdminProtos.GetRegionInfoResponse.CompactionState getCompactionState(byte[] tableNameOrRegionName)
                                                                                                                throws IOException,
                                                                                                                       InterruptedException
Get the current compaction state of a table or region. It could be in a major compaction, a minor compaction, both, or none.

Parameters:
tableNameOrRegionName - table or region to major compact
Returns:
the current compaction state
Throws:
IOException - if a remote or network exception occurs
InterruptedException

snapshot

public void snapshot(String snapshotName,
                     TableName tableName)
              throws IOException,
                     SnapshotCreationException,
                     IllegalArgumentException
Take a snapshot for the given table. If the table is enabled, a FLUSH-type snapshot will be taken. If the table is disabled, an offline snapshot is taken.

Snapshots are considered unique based on the name of the snapshot. Attempts to take a snapshot with the same name (even a different type or with different parameters) will fail with a SnapshotCreationException indicating the duplicate naming.

Snapshot names follow the same naming constraints as tables in HBase. See TableName.isLegalFullyQualifiedTableName(byte[]).

Parameters:
snapshotName - name of the snapshot to be created
tableName - name of the table for which snapshot is created
Throws:
IOException - if a remote or network exception occurs
SnapshotCreationException - if snapshot creation failed
IllegalArgumentException - if the snapshot request is formatted incorrectly

snapshot

public void snapshot(String snapshotName,
                     String tableName)
              throws IOException,
                     SnapshotCreationException,
                     IllegalArgumentException
Throws:
IOException
SnapshotCreationException
IllegalArgumentException

snapshot

public void snapshot(byte[] snapshotName,
                     byte[] tableName,
                     org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription.Type flushType)
              throws IOException,
                     SnapshotCreationException,
                     IllegalArgumentException
Create snapshot for the given table of given flush type.

Snapshots are considered unique based on the name of the snapshot. Attempts to take a snapshot with the same name (even a different type or with different parameters) will fail with a SnapshotCreationException indicating the duplicate naming.

Snapshot names follow the same naming constraints as tables in HBase.

Parameters:
snapshotName - name of the snapshot to be created
tableName - name of the table for which snapshot is created
flushType - if the snapshot should be taken without flush memstore first
Throws:
IOException - if a remote or network exception occurs
SnapshotCreationException - if snapshot creation failed
IllegalArgumentException - if the snapshot request is formatted incorrectly

snapshot

public void snapshot(byte[] snapshotName,
                     TableName tableName)
              throws IOException,
                     SnapshotCreationException,
                     IllegalArgumentException
public void snapshot(final String snapshotName, Create a timestamp consistent snapshot for the given table. final byte[] tableName) throws IOException,

Snapshots are considered unique based on the name of the snapshot. Attempts to take a snapshot with the same name (even a different type or with different parameters) will fail with a SnapshotCreationException indicating the duplicate naming.

Snapshot names follow the same naming constraints as tables in HBase.

Parameters:
snapshotName - name of the snapshot to be created
tableName - name of the table for which snapshot is created
Throws:
IOException - if a remote or network exception occurs
SnapshotCreationException - if snapshot creation failed
IllegalArgumentException - if the snapshot request is formatted incorrectly

snapshot

public void snapshot(byte[] snapshotName,
                     byte[] tableName)
              throws IOException,
                     SnapshotCreationException,
                     IllegalArgumentException
Throws:
IOException
SnapshotCreationException
IllegalArgumentException

snapshot

public void snapshot(String snapshotName,
                     TableName tableName,
                     org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription.Type type)
              throws IOException,
                     SnapshotCreationException,
                     IllegalArgumentException
Create typed snapshot of the table.

Snapshots are considered unique based on the name of the snapshot. Attempts to take a snapshot with the same name (even a different type or with different parameters) will fail with a SnapshotCreationException indicating the duplicate naming.

Snapshot names follow the same naming constraints as tables in HBase. See TableName.isLegalFullyQualifiedTableName(byte[]).

Parameters:
snapshotName - name to give the snapshot on the filesystem. Must be unique from all other snapshots stored on the cluster
tableName - name of the table to snapshot
type - type of snapshot to take
Throws:
IOException - we fail to reach the master
SnapshotCreationException - if snapshot creation failed
IllegalArgumentException - if the snapshot request is formatted incorrectly

snapshot

public void snapshot(String snapshotName,
                     String tableName,
                     org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription.Type type)
              throws IOException,
                     SnapshotCreationException,
                     IllegalArgumentException
Throws:
IOException
SnapshotCreationException
IllegalArgumentException

snapshot

public void snapshot(String snapshotName,
                     byte[] tableName,
                     org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription.Type type)
              throws IOException,
                     SnapshotCreationException,
                     IllegalArgumentException
Throws:
IOException
SnapshotCreationException
IllegalArgumentException

snapshot

public void snapshot(org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription snapshot)
              throws IOException,
                     SnapshotCreationException,
                     IllegalArgumentException
Take a snapshot and wait for the server to complete that snapshot (blocking).

Only a single snapshot should be taken at a time for an instance of HBase, or results may be undefined (you can tell multiple HBase clusters to snapshot at the same time, but only one at a time for a single cluster).

Snapshots are considered unique based on the name of the snapshot. Attempts to take a snapshot with the same name (even a different type or with different parameters) will fail with a SnapshotCreationException indicating the duplicate naming.

Snapshot names follow the same naming constraints as tables in HBase. See TableName.isLegalFullyQualifiedTableName(byte[]).

You should probably use snapshot(String, String) or snapshot(byte[], byte[]) unless you are sure about the type of snapshot that you want to take.

Parameters:
snapshot - snapshot to take
Throws:
IOException - or we lose contact with the master.
SnapshotCreationException - if snapshot failed to be taken
IllegalArgumentException - if the snapshot request is formatted incorrectly

takeSnapshotAsync

public org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SnapshotResponse takeSnapshotAsync(org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription snapshot)
                                                                                           throws IOException,
                                                                                                  SnapshotCreationException
Take a snapshot without waiting for the server to complete that snapshot (asynchronous)

Only a single snapshot should be taken at a time, or results may be undefined.

Parameters:
snapshot - snapshot to take
Returns:
response from the server indicating the max time to wait for the snapshot
Throws:
IOException - if the snapshot did not succeed or we lose contact with the master.
SnapshotCreationException - if snapshot creation failed
IllegalArgumentException - if the snapshot request is formatted incorrectly

isSnapshotFinished

public boolean isSnapshotFinished(org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription snapshot)
                           throws IOException,
                                  HBaseSnapshotException,
                                  UnknownSnapshotException
Check the current state of the passed snapshot.

There are three possible states:

  1. running - returns false
  2. finished - returns true
  3. finished with error - throws the exception that caused the snapshot to fail

The cluster only knows about the most recent snapshot. Therefore, if another snapshot has been run/started since the snapshot your are checking, you will recieve an UnknownSnapshotException.

Parameters:
snapshot - description of the snapshot to check
Returns:
true if the snapshot is completed, false if the snapshot is still running
Throws:
IOException - if we have a network issue
HBaseSnapshotException - if the snapshot failed
UnknownSnapshotException - if the requested snapshot is unknown

restoreSnapshot

public void restoreSnapshot(byte[] snapshotName)
                     throws IOException,
                            RestoreSnapshotException
Restore the specified snapshot on the original table. (The table must be disabled) If the "hbase.snapshot.restore.take.failsafe.snapshot" configuration property is set to true, a snapshot of the current table is taken before executing the restore operation. In case of restore failure, the failsafe snapshot will be restored. If the restore completes without problem the failsafe snapshot is deleted.

Parameters:
snapshotName - name of the snapshot to restore
Throws:
IOException - if a remote or network exception occurs
RestoreSnapshotException - if snapshot failed to be restored
IllegalArgumentException - if the restore request is formatted incorrectly

restoreSnapshot

public void restoreSnapshot(String snapshotName)
                     throws IOException,
                            RestoreSnapshotException
Restore the specified snapshot on the original table. (The table must be disabled) If the "hbase.snapshot.restore.take.failsafe.snapshot" configuration property is set to true, a snapshot of the current table is taken before executing the restore operation. In case of restore failure, the failsafe snapshot will be restored. If the restore completes without problem the failsafe snapshot is deleted.

Parameters:
snapshotName - name of the snapshot to restore
Throws:
IOException - if a remote or network exception occurs
RestoreSnapshotException - if snapshot failed to be restored
IllegalArgumentException - if the restore request is formatted incorrectly

restoreSnapshot

public void restoreSnapshot(byte[] snapshotName,
                            boolean takeFailSafeSnapshot)
                     throws IOException,
                            RestoreSnapshotException
Restore the specified snapshot on the original table. (The table must be disabled) If 'takeFailSafeSnapshot' is set to true, a snapshot of the current table is taken before executing the restore operation. In case of restore failure, the failsafe snapshot will be restored. If the restore completes without problem the failsafe snapshot is deleted. The failsafe snapshot name is configurable by using the property "hbase.snapshot.restore.failsafe.name".

Parameters:
snapshotName - name of the snapshot to restore
takeFailSafeSnapshot - true if the failsafe snapshot should be taken
Throws:
IOException - if a remote or network exception occurs
RestoreSnapshotException - if snapshot failed to be restored
IllegalArgumentException - if the restore request is formatted incorrectly

restoreSnapshot

public void restoreSnapshot(String snapshotName,
                            boolean takeFailSafeSnapshot)
                     throws IOException,
                            RestoreSnapshotException
Restore the specified snapshot on the original table. (The table must be disabled) If 'takeFailSafeSnapshot' is set to true, a snapshot of the current table is taken before executing the restore operation. In case of restore failure, the failsafe snapshot will be restored. If the restore completes without problem the failsafe snapshot is deleted. The failsafe snapshot name is configurable by using the property "hbase.snapshot.restore.failsafe.name".

Parameters:
snapshotName - name of the snapshot to restore
takeFailSafeSnapshot - true if the failsafe snapshot should be taken
Throws:
IOException - if a remote or network exception occurs
RestoreSnapshotException - if snapshot failed to be restored
IllegalArgumentException - if the restore request is formatted incorrectly

cloneSnapshot

public void cloneSnapshot(byte[] snapshotName,
                          byte[] tableName)
                   throws IOException,
                          TableExistsException,
                          RestoreSnapshotException,
                          InterruptedException
Create a new table by cloning the snapshot content.

Parameters:
snapshotName - name of the snapshot to be cloned
tableName - name of the table where the snapshot will be restored
Throws:
IOException - if a remote or network exception occurs
TableExistsException - if table to be created already exists
RestoreSnapshotException - if snapshot failed to be cloned
IllegalArgumentException - if the specified table has not a valid name
InterruptedException

cloneSnapshot

public void cloneSnapshot(byte[] snapshotName,
                          TableName tableName)
                   throws IOException,
                          TableExistsException,
                          RestoreSnapshotException,
                          InterruptedException
Create a new table by cloning the snapshot content.

Parameters:
snapshotName - name of the snapshot to be cloned
tableName - name of the table where the snapshot will be restored
Throws:
IOException - if a remote or network exception occurs
TableExistsException - if table to be created already exists
RestoreSnapshotException - if snapshot failed to be cloned
IllegalArgumentException - if the specified table has not a valid name
InterruptedException

cloneSnapshot

public void cloneSnapshot(String snapshotName,
                          String tableName)
                   throws IOException,
                          TableExistsException,
                          RestoreSnapshotException,
                          InterruptedException
Create a new table by cloning the snapshot content.

Parameters:
snapshotName - name of the snapshot to be cloned
tableName - name of the table where the snapshot will be restored
Throws:
IOException - if a remote or network exception occurs
TableExistsException - if table to be created already exists
RestoreSnapshotException - if snapshot failed to be cloned
IllegalArgumentException - if the specified table has not a valid name
InterruptedException

cloneSnapshot

public void cloneSnapshot(String snapshotName,
                          TableName tableName)
                   throws IOException,
                          TableExistsException,
                          RestoreSnapshotException,
                          InterruptedException
Create a new table by cloning the snapshot content.

Parameters:
snapshotName - name of the snapshot to be cloned
tableName - name of the table where the snapshot will be restored
Throws:
IOException - if a remote or network exception occurs
TableExistsException - if table to be created already exists
RestoreSnapshotException - if snapshot failed to be cloned
IllegalArgumentException - if the specified table has not a valid name
InterruptedException

execProcedure

public void execProcedure(String signature,
                          String instance,
                          Map<String,String> props)
                   throws IOException
Execute a distributed procedure on a cluster.

Parameters:
signature - A distributed procedure is uniquely identified by its signature (default the root ZK node name of the procedure).
instance - The instance name of the procedure. For some procedures, this parameter is optional.
props - Property/Value pairs of properties passing to the procedure
Throws:
IOException

isProcedureFinished

public boolean isProcedureFinished(String signature,
                                   String instance,
                                   Map<String,String> props)
                            throws IOException
Check the current state of the specified procedure.

There are three possible states:

  1. running - returns false
  2. finished - returns true
  3. finished with error - throws the exception that caused the procedure to fail

Parameters:
signature - The signature that uniquely identifies a procedure
instance - The instance name of the procedure
props - Property/Value pairs of properties passing to the procedure
Returns:
true if the specified procedure is finished successfully, false if it is still running
Throws:
IOException - if the specified procedure finished with error

listSnapshots

public List<org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription> listSnapshots()
                                                                                               throws IOException
List completed snapshots.

Returns:
a list of snapshot descriptors for completed snapshots
Throws:
IOException - if a network error occurs

listSnapshots

public List<org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription> listSnapshots(String regex)
                                                                                               throws IOException
List all the completed snapshots matching the given regular expression.

Parameters:
regex - The regular expression to match against
Returns:
- returns a List of SnapshotDescription
Throws:
IOException - if a remote or network exception occurs

listSnapshots

public List<org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription> listSnapshots(Pattern pattern)
                                                                                               throws IOException
List all the completed snapshots matching the given pattern.

Parameters:
pattern - The compiled regular expression to match against
Returns:
- returns a List of SnapshotDescription
Throws:
IOException - if a remote or network exception occurs

listTableSnapshots

public List<org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription> listTableSnapshots(String tableNameRegex,
                                                                                                           String snapshotNameRegex)
                                                                                                    throws IOException
List all the completed snapshots matching the given table name regular expression and snapshot name regular expression.

Parameters:
tableNameRegex - The table name regular expression to match against
snapshotNameRegex - The snapshot name regular expression to match against
Returns:
returns a List of completed SnapshotDescription
Throws:
IOException - if a remote or network exception occurs

listTableSnapshots

public List<org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription> listTableSnapshots(Pattern tableNamePattern,
                                                                                                           Pattern snapshotNamePattern)
                                                                                                    throws IOException
List all the completed snapshots matching the given table name regular expression and snapshot name regular expression.

Parameters:
tableNamePattern - The compiled table name regular expression to match against
snapshotNamePattern - The compiled snapshot name regular expression to match against
Returns:
returns a List of completed SnapshotDescription
Throws:
IOException - if a remote or network exception occurs

deleteSnapshot

public void deleteSnapshot(byte[] snapshotName)
                    throws IOException
Delete an existing snapshot.

Parameters:
snapshotName - name of the snapshot
Throws:
IOException - if a remote or network exception occurs

deleteSnapshot

public void deleteSnapshot(String snapshotName)
                    throws IOException
Delete an existing snapshot.

Parameters:
snapshotName - name of the snapshot
Throws:
IOException - if a remote or network exception occurs

deleteSnapshots

public void deleteSnapshots(String regex)
                     throws IOException
Delete existing snapshots whose names match the pattern passed.

Parameters:
regex - The regular expression to match against
Throws:
IOException - if a remote or network exception occurs

deleteSnapshots

public void deleteSnapshots(Pattern pattern)
                     throws IOException
Delete existing snapshots whose names match the pattern passed.

Parameters:
pattern - pattern for names of the snapshot to match
Throws:
IOException - if a remote or network exception occurs

deleteTableSnapshots

public void deleteTableSnapshots(String tableNameRegex,
                                 String snapshotNameRegex)
                          throws IOException
Delete all existing snapshots matching the given table name regular expression and snapshot name regular expression.

Parameters:
tableNameRegex - The table name regular expression to match against
snapshotNameRegex - The snapshot name regular expression to match against
Throws:
IOException - if a remote or network exception occurs

deleteTableSnapshots

public void deleteTableSnapshots(Pattern tableNamePattern,
                                 Pattern snapshotNamePattern)
                          throws IOException
Delete all existing snapshots matching the given table name regular expression and snapshot name regular expression.

Parameters:
tableNamePattern - The compiled table name regular expression to match against
snapshotNamePattern - The compiled snapshot name regular expression to match against
Throws:
IOException - if a remote or network exception occurs

coprocessorService

public CoprocessorRpcChannel coprocessorService()
Creates and returns a RpcChannel instance connected to the active master.

The obtained RpcChannel instance can be used to access a published coprocessor Service using standard protobuf service invocations:

 CoprocessorRpcChannel channel = myAdmin.coprocessorService();
 MyService.BlockingInterface service = MyService.newBlockingStub(channel);
 MyCallRequest request = MyCallRequest.newBuilder()
     ...
     .build();
 MyCallResponse response = service.myCall(null, request);
 

Returns:
A MasterCoprocessorRpcChannel instance

coprocessorService

public CoprocessorRpcChannel coprocessorService(ServerName sn)
Creates and returns a RpcChannel instance connected to the passed region server.

The obtained RpcChannel instance can be used to access a published coprocessor Service using standard protobuf service invocations:

 CoprocessorRpcChannel channel = myAdmin.coprocessorService(serverName);
 MyService.BlockingInterface service = MyService.newBlockingStub(channel);
 MyCallRequest request = MyCallRequest.newBuilder()
     ...
     .build();
 MyCallResponse response = service.myCall(null, request);
 

Parameters:
sn - the server name to which the endpoint call is made
Returns:
A RegionServerCoprocessorRpcChannel instance

truncateTable

public void truncateTable(TableName tableName,
                          boolean preserveSplits)
                   throws IOException
Truncate a table. Synchronous operation.

Parameters:
tableName - name of table to truncate
preserveSplits - True if the splits should be preserved
Throws:
IOException - if a remote or network exception occurs

getSecurityCapabilities

public List<SecurityCapability> getSecurityCapabilities()
                                                 throws IOException
Return the set of supported security capabilities.

Throws:
IOException
UnsupportedOperationException


Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.