|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hbase.client.HBaseAdmin
public class HBaseAdmin
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 |
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 |
assign(byte[] regionName,
boolean force)
|
boolean |
balancer()
Invoke the balancer. |
boolean |
balanceSwitch(boolean b)
Turn the load balancer on or off. |
static void |
checkHBaseAvailable(org.apache.hadoop.conf.Configuration conf)
Check to see if HBase is running. |
void |
closeRegion(byte[] regionname,
String hostAndPort)
Close a region. |
void |
closeRegion(HServerAddress hsa,
HRegionInfo hri)
|
void |
closeRegion(String regionname,
String hostAndPort)
Close a region. |
void |
compact(byte[] tableNameOrRegionName)
Compact a table or an individual region. |
void |
compact(String tableNameOrRegionName)
Compact a table or an individual region. |
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,
byte[] columnName)
Delete a column from a table. |
void |
deleteColumn(String tableName,
String columnName)
Delete a column from a table. |
void |
deleteTable(byte[] tableName)
Deletes a table. |
void |
deleteTable(String tableName)
Deletes a table. |
void |
disableTable(byte[] tableName)
Disable table and wait on completion. |
void |
disableTable(String tableName)
|
void |
disableTableAsync(byte[] tableName)
Starts the disable of a table. |
void |
disableTableAsync(String tableName)
|
void |
enableTable(byte[] tableName)
Enable a table. |
void |
enableTable(String tableName)
|
void |
enableTableAsync(byte[] tableName)
Brings a table on-line (enables it). |
void |
enableTableAsync(String tableName)
|
void |
flush(byte[] tableNameOrRegionName)
Flush a table or an individual region. |
void |
flush(String tableNameOrRegionName)
Flush a table or an individual region. |
ClusterStatus |
getClusterStatus()
|
org.apache.hadoop.conf.Configuration |
getConfiguration()
|
HConnection |
getConnection()
|
HMasterInterface |
getMaster()
Get a connection to the currently set master. |
HTableDescriptor |
getTableDescriptor(byte[] tableName)
Method for getting the tableDescriptor |
boolean |
isMasterRunning()
|
boolean |
isTableAvailable(byte[] tableName)
|
boolean |
isTableAvailable(String tableName)
|
boolean |
isTableDisabled(byte[] tableName)
|
boolean |
isTableDisabled(String tableName)
|
boolean |
isTableEnabled(byte[] tableName)
|
boolean |
isTableEnabled(String tableName)
|
HTableDescriptor[] |
listTables()
List all the userspace tables. |
void |
majorCompact(byte[] tableNameOrRegionName)
Major compact a table or an individual region. |
void |
majorCompact(String tableNameOrRegionName)
Major compact a table or an individual region. |
void |
modifyColumn(byte[] tableName,
byte[] columnName,
HColumnDescriptor descriptor)
Deprecated. The columnName is redundant. Use modifyColumn(byte[], HColumnDescriptor) |
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(String tableName,
String columnName,
HColumnDescriptor descriptor)
Deprecated. The columnName is redundant. Use addColumn(String, HColumnDescriptor) |
void |
modifyTable(byte[] tableName,
HTableDescriptor htd)
Modify an existing table, more IRB friendly version. |
void |
move(byte[] encodedRegionName,
byte[] destServerName)
Move the region r to dest . |
void |
shutdown()
Shuts down the HBase cluster |
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 |
stopMaster()
Shuts down the current HBase master only. |
void |
stopRegionServer(HServerAddress hsa)
Stop the designated regionserver. |
boolean |
tableExists(byte[] tableName)
|
boolean |
tableExists(String tableName)
|
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 |
---|
public HBaseAdmin(org.apache.hadoop.conf.Configuration c) throws MasterNotRunningException, ZooKeeperConnectionException
c
- Configuration object
MasterNotRunningException
- if the master is not running
ZooKeeperConnectionException
- if unable to connect to zookeeperMethod Detail |
---|
public void abort(String why, Throwable e)
Abortable
abort
in interface Abortable
why
- Why we're aborting.e
- Throwable that caused abort. Can be null.public HConnection getConnection()
public HMasterInterface getMaster() throws MasterNotRunningException, ZooKeeperConnectionException
MasterNotRunningException
- if the master is not running
ZooKeeperConnectionException
- if unable to connect to zookeeperpublic boolean isMasterRunning() throws MasterNotRunningException, ZooKeeperConnectionException
ZooKeeperConnectionException
MasterNotRunningException
public boolean tableExists(String tableName) throws IOException
tableName
- Table to check.
IOException
public boolean tableExists(byte[] tableName) throws IOException
tableName
- Table to check.
IOException
public HTableDescriptor[] listTables() throws IOException
IOException
- if a remote or network exception occurspublic HTableDescriptor getTableDescriptor(byte[] tableName) throws IOException
tableName
- as a byte []
IOException
- if a remote or network exception occurspublic void createTable(HTableDescriptor desc) throws IOException
desc
- table descriptor for table
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 occurspublic void createTable(HTableDescriptor desc, byte[] startKey, byte[] endKey, int numRegions) throws IOException
desc
- table descriptor for tablestartKey
- beginning of key rangeendKey
- end of key rangenumRegions
- the total number of regions to create
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
public void createTable(HTableDescriptor desc, byte[][] splitKeys) throws IOException
desc
- table descriptor for tablesplitKeys
- array of split keys for the initial regions of the table
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
public void createTableAsync(HTableDescriptor desc, byte[][] splitKeys) throws IOException
desc
- table descriptor for table
IllegalArgumentException
- Bad table name.
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
public void deleteTable(String tableName) throws IOException
tableName
- name of table to delete
IOException
- if a remote or network exception occurspublic void deleteTable(byte[] tableName) throws IOException
tableName
- name of table to delete
IOException
- if a remote or network exception occurspublic void enableTable(String tableName) throws IOException
IOException
public void enableTable(byte[] tableName) throws IOException
enableTableAsync(byte[])
and isTableEnabled(byte[])
instead.
tableName
- name of the table
IOException
- if a remote or network exception occursisTableEnabled(byte[])
,
disableTable(byte[])
,
enableTableAsync(byte[])
public void enableTableAsync(String tableName) throws IOException
IOException
public void enableTableAsync(byte[] tableName) throws IOException
isTableEnabled(byte[])
to learn when table is fully online. If
table is taking too long to online, check server logs.
tableName
-
IOException
public void disableTableAsync(String tableName) throws IOException
IOException
public void disableTableAsync(byte[] tableName) throws IOException
isTableDisabled(byte[])
to check for when disable completes.
If table is taking too long to online, check server logs.
tableName
- name of table
IOException
- if a remote or network exception occursisTableDisabled(byte[])
,
isTableEnabled(byte[])
public void disableTable(String tableName) throws IOException
IOException
public void disableTable(byte[] tableName) throws IOException
disableTableAsync(byte[])
and isTableDisabled(String)
instead.
tableName
-
IOException
public boolean isTableEnabled(String tableName) throws IOException
tableName
- name of table to check
IOException
- if a remote or network exception occurspublic boolean isTableEnabled(byte[] tableName) throws IOException
tableName
- name of table to check
IOException
- if a remote or network exception occurspublic boolean isTableDisabled(String tableName) throws IOException
tableName
- name of table to check
IOException
- if a remote or network exception occurspublic boolean isTableDisabled(byte[] tableName) throws IOException
tableName
- name of table to check
IOException
- if a remote or network exception occurspublic boolean isTableAvailable(byte[] tableName) throws IOException
tableName
- name of table to check
IOException
- if a remote or network exception occurspublic boolean isTableAvailable(String tableName) throws IOException
tableName
- name of table to check
IOException
- if a remote or network exception occurspublic void addColumn(String tableName, HColumnDescriptor column) throws IOException
tableName
- name of the table to add column tocolumn
- column descriptor of column to be added
IOException
- if a remote or network exception occurspublic void addColumn(byte[] tableName, HColumnDescriptor column) throws IOException
tableName
- name of the table to add column tocolumn
- column descriptor of column to be added
IOException
- if a remote or network exception occurspublic void deleteColumn(String tableName, String columnName) throws IOException
tableName
- name of tablecolumnName
- name of column to be deleted
IOException
- if a remote or network exception occurspublic void deleteColumn(byte[] tableName, byte[] columnName) throws IOException
tableName
- name of tablecolumnName
- name of column to be deleted
IOException
- if a remote or network exception occurspublic void modifyColumn(String tableName, String columnName, HColumnDescriptor descriptor) throws IOException
columnName
is redundant. Use addColumn(String, HColumnDescriptor)
tableName
- name of tablecolumnName
- name of column to be modifieddescriptor
- new column descriptor to use
IOException
- if a remote or network exception occurspublic void modifyColumn(String tableName, HColumnDescriptor descriptor) throws IOException
tableName
- name of tabledescriptor
- new column descriptor to use
IOException
- if a remote or network exception occurspublic void modifyColumn(byte[] tableName, byte[] columnName, HColumnDescriptor descriptor) throws IOException
columnName
is redundant. Use modifyColumn(byte[], HColumnDescriptor)
tableName
- name of tablecolumnName
- name of column to be modifieddescriptor
- new column descriptor to use
IOException
- if a remote or network exception occurspublic void modifyColumn(byte[] tableName, HColumnDescriptor descriptor) throws IOException
tableName
- name of tabledescriptor
- new column descriptor to use
IOException
- if a remote or network exception occurspublic void closeRegion(String regionname, String hostAndPort) throws IOException
regionname
- region name to closehostAndPort
- If supplied, we'll use this location rather than
the one currently in .META.
IOException
- if a remote or network exception occurspublic void closeRegion(byte[] regionname, String hostAndPort) throws IOException
regionname
- region name to closehostAndPort
- If supplied, we'll use this location rather than
the one currently in .META.
IOException
- if a remote or network exception occurspublic void closeRegion(HServerAddress hsa, HRegionInfo hri) throws IOException
IOException
public void flush(String tableNameOrRegionName) throws IOException, InterruptedException
tableNameOrRegionName
- table or region to flush
IOException
- if a remote or network exception occurs
InterruptedException
public void flush(byte[] tableNameOrRegionName) throws IOException, InterruptedException
tableNameOrRegionName
- table or region to flush
IOException
- if a remote or network exception occurs
InterruptedException
public void compact(String tableNameOrRegionName) throws IOException, InterruptedException
tableNameOrRegionName
- table or region to compact
IOException
- if a remote or network exception occurs
InterruptedException
public void compact(byte[] tableNameOrRegionName) throws IOException, InterruptedException
tableNameOrRegionName
- table or region to compact
IOException
- if a remote or network exception occurs
InterruptedException
public void majorCompact(String tableNameOrRegionName) throws IOException, InterruptedException
tableNameOrRegionName
- table or region to major compact
IOException
- if a remote or network exception occurs
InterruptedException
public void majorCompact(byte[] tableNameOrRegionName) throws IOException, InterruptedException
tableNameOrRegionName
- table or region to major compact
IOException
- if a remote or network exception occurs
InterruptedException
public void move(byte[] encodedRegionName, byte[] destServerName) throws UnknownRegionException, MasterNotRunningException, ZooKeeperConnectionException
r
to dest
.
encodedRegionName
- The encoded region name; i.e. the hash that makes
up the region name suffix: e.g. if regionname is
TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396.
,
then the encoded region name is: 527db22f95c8a9e0116f0cc13c680396
.destServerName
- The servername of the destination regionserver. If
passed the empty byte array we'll assign to a random server. A server name
is made of host, port and startcode. Here is an example:
host187.example.com,60020,1289493121758
.
UnknownRegionException
- Thrown if we can't find a region named
encodedRegionName
ZooKeeperConnectionException
MasterNotRunningException
public void assign(byte[] regionName, boolean force) throws MasterNotRunningException, ZooKeeperConnectionException, IOException
regionName
- Region name to assign.force
- True to force assign.
MasterNotRunningException
ZooKeeperConnectionException
IOException
public void unassign(byte[] regionName, boolean force) throws MasterNotRunningException, ZooKeeperConnectionException, IOException
move(byte[], byte[])
if you want
to control the region movement.
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).
MasterNotRunningException
ZooKeeperConnectionException
IOException
public boolean balanceSwitch(boolean b) throws MasterNotRunningException, ZooKeeperConnectionException
b
- If true, enable balancer. If false, disable balancer.
MasterNotRunningException
ZooKeeperConnectionException
public boolean balancer() throws MasterNotRunningException, ZooKeeperConnectionException
MasterNotRunningException
ZooKeeperConnectionException
public void split(String tableNameOrRegionName) throws IOException, InterruptedException
tableNameOrRegionName
- table or region to split
IOException
- if a remote or network exception occurs
InterruptedException
public void split(byte[] tableNameOrRegionName) throws IOException, InterruptedException
tableNameOrRegionName
- table to region to split
IOException
- if a remote or network exception occurs
InterruptedException
public void split(byte[] tableNameOrRegionName, byte[] splitPoint) throws IOException, InterruptedException
tableNameOrRegionName
- table to region to splitsplitPoint
- the explicit position to split on
IOException
- if a remote or network exception occurs
InterruptedException
- interrupt exception occurredpublic void modifyTable(byte[] tableName, HTableDescriptor htd) throws IOException
tableName
- name of table.htd
- modified description of the table
IOException
- if a remote or network exception occurspublic void shutdown() throws IOException
IOException
- if a remote or network exception occurspublic void stopMaster() throws IOException
IOException
- if a remote or network exception occursshutdown()
public void stopRegionServer(HServerAddress hsa) throws IOException
IOException
- if a remote or network exception occurspublic ClusterStatus getClusterStatus() throws IOException
IOException
- if a remote or network exception occurspublic org.apache.hadoop.conf.Configuration getConfiguration()
public static void checkHBaseAvailable(org.apache.hadoop.conf.Configuration conf) throws MasterNotRunningException, ZooKeeperConnectionException
conf
- system configuration
MasterNotRunningException
- if the master is not running
ZooKeeperConnectionException
- if unable to connect to zookeeper
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |