org.apache.hadoop.hbase
Class HBaseAdmin

java.lang.Object
  extended by org.apache.hadoop.hbase.HBaseAdmin
All Implemented Interfaces:
HConstants

public class HBaseAdmin
extends Object
implements HConstants

Provides administrative functions for HBase


Field Summary
protected  HConnection connection
           
protected  org.apache.commons.logging.Log LOG
           
protected  HMasterInterface master
           
protected  int numRetries
           
protected  long pause
           
 
Fields inherited from interface org.apache.hadoop.hbase.HConstants
ALL_VERSIONS, COL_REGIONINFO, COL_REGIONINFO_ARRAY, COL_SERVER, COL_SPLITA, COL_SPLITB, COL_STARTCODE, COLUMN_FAMILY, COLUMN_FAMILY_ARRAY, COLUMN_FAMILY_STR, DEFAULT_HBASE_DIR, DEFAULT_HOST, DEFAULT_MASTER_ADDRESS, DEFAULT_MASTER_INFOPORT, DEFAULT_MAX_FILE_SIZE, DEFAULT_REGION_SERVER_CLASS, DEFAULT_REGIONSERVER_ADDRESS, DEFAULT_REGIONSERVER_INFOPORT, EMPTY_START_ROW, EMPTY_TEXT, HBASE_DIR, HREGION_LOGDIR_NAME, HREGION_OLDLOGFILE_NAME, HREGIONDIR_PREFIX, LATEST_TIMESTAMP, MASTER_ADDRESS, META_TABLE_NAME, REGION_SERVER_CLASS, REGIONSERVER_ADDRESS, ROOT_TABLE_NAME, THREAD_WAKE_FREQUENCY, UTF8_ENCODING
 
Constructor Summary
HBaseAdmin(Configuration conf)
          Constructor
 
Method Summary
 void addColumn(Text tableName, HColumnDescriptor column)
          Add a column to an existing table
protected  void checkReservedTableName(Text tableName)
           
 void createTable(HTableDescriptor desc)
          Creates a new table
 void createTableAsync(HTableDescriptor desc)
          Creates a new table but does not block and wait for it to come online.
 void deleteColumn(Text tableName, Text columnName)
          Delete a column from a table
 void deleteTable(Text tableName)
          Deletes a table
 void disableTable(Text tableName)
          Disables a table (takes it off-line) If it is being served, the master will tell the servers to stop serving it.
 void enableTable(Text tableName)
          Brings a table on-line (enables it)
 HMasterInterface getMaster()
           
 boolean isMasterRunning()
           
 HTableDescriptor[] listTables()
          List all the userspace tables.
 void shutdown()
          Shuts down the HBase instance
 boolean tableExists(Text tableName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected final org.apache.commons.logging.Log LOG

connection

protected final HConnection connection

pause

protected final long pause

numRetries

protected final int numRetries

master

protected volatile HMasterInterface master
Constructor Detail

HBaseAdmin

public HBaseAdmin(Configuration conf)
           throws MasterNotRunningException
Constructor

Parameters:
conf - Configuration object
Throws:
MasterNotRunningException
Method Detail

getMaster

public HMasterInterface getMaster()
                           throws MasterNotRunningException
Returns:
proxy connection to master server for this instance
Throws:
MasterNotRunningException

isMasterRunning

public boolean isMasterRunning()
Returns:
- true if the master server is running

tableExists

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

listTables

public HTableDescriptor[] listTables()
                              throws IOException
List all the userspace tables. In other words, scan the 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 META table's region info.

Returns:
- returns an array of HTableDescriptors
Throws:
IOException

createTable

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

Parameters:
desc - table descriptor for table
Throws:
IllegalArgumentException - if the table name is reserved
MasterNotRunningException - if master is not running
NoServerForRegionException - if root region is not being served
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)
                      throws IOException
Creates a new table but does not block and wait for it to come online.

Parameters:
desc - table descriptor for table
Throws:
IllegalArgumentException - if the table name is reserved
MasterNotRunningException - if master is not running
NoServerForRegionException - if root region is not being served
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(Text tableName)
                 throws IOException
Deletes a table

Parameters:
tableName - name of table to delete
Throws:
IOException

enableTable

public void enableTable(Text tableName)
                 throws IOException
Brings a table on-line (enables it)

Parameters:
tableName - name of the table
Throws:
IOException

disableTable

public void disableTable(Text tableName)
                  throws IOException
Disables a table (takes it off-line) If it is being served, the master will tell the servers to stop serving it.

Parameters:
tableName - name of table
Throws:
IOException

addColumn

public void addColumn(Text tableName,
                      HColumnDescriptor column)
               throws IOException
Add a column to an existing table

Parameters:
tableName - name of the table to add column to
column - column descriptor of column to be added
Throws:
IOException

deleteColumn

public void deleteColumn(Text tableName,
                         Text columnName)
                  throws IOException
Delete a column from a table

Parameters:
tableName - name of table
columnName - name of column to be deleted
Throws:
IOException

shutdown

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

Throws:
IOException

checkReservedTableName

protected void checkReservedTableName(Text tableName)


Copyright © 2006 The Apache Software Foundation