public class HBaseAdmin extends Object implements Abortable, Closeable
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 and Description |
---|
HBaseAdmin(org.apache.hadoop.conf.Configuration c)
Constructor
|
HBaseAdmin(HConnection connection)
Constructor for externally managed HConnections.
|
Modifier and Type | Method and Description |
---|---|
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 |
balancer()
Invoke the balancer.
|
boolean |
balanceSwitch(boolean b)
Deprecated.
use setBalancerRunning(boolean, boolean) instead
|
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(String snapshotName,
String 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.
|
<T extends CoprocessorProtocol> |
coprocessorProxy(Class<T> protocol)
Creates and returns a proxy to the CoprocessorProtocol instance running in the
master.
|
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 |
deleteSnapshot(byte[] snapshotName)
Delete an existing snapshot.
|
void |
deleteSnapshot(String snapshotName)
Delete an existing snapshot.
|
void |
deleteTable(byte[] tableName)
Deletes a table.
|
void |
deleteTable(String 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 |
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) |
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.
|
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) |
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 |
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.
|
ClusterStatus |
getClusterStatus() |
CompactionRequest.CompactionState |
getCompactionState(byte[] tableNameOrRegionName)
Get the current compaction state of a table or region.
|
CompactionRequest.CompactionState |
getCompactionState(String tableNameOrRegionName)
Get the current compaction state of a table or region.
|
org.apache.hadoop.conf.Configuration |
getConfiguration() |
HConnection |
getConnection() |
HMasterInterface |
getMaster()
Deprecated.
Master is an implementation detail for HBaseAdmin.
Deprecated in HBase 0.94
|
String[] |
getMasterCoprocessors() |
HTableDescriptor |
getTableDescriptor(byte[] tableName)
Method for getting the tableDescriptor
|
HTableDescriptor[] |
getTableDescriptors(List<String> tableNames)
Get tableDescriptors
|
String[] |
getTableNames()
List all of the names of userspace tables.
|
String[] |
getTableNames(Pattern pattern)
List all of the names of userspace tables matching the given pattern
|
String[] |
getTableNames(String regex)
List all of the names of userspace tables matching the given regex
|
List<HRegionInfo> |
getTableRegions(byte[] tableName)
get the regions of a given table.
|
boolean |
isAborted()
Check if the server or client was aborted.
|
boolean |
isMasterRunning() |
boolean |
isSnapshotFinished(HBaseProtos.SnapshotDescription snapshot)
Check the current state of the passed snapshot.
|
boolean |
isTableAvailable(byte[] tableName) |
boolean |
isTableAvailable(String tableName) |
boolean |
isTableDisabled(byte[] tableName) |
boolean |
isTableDisabled(String tableName) |
boolean |
isTableEnabled(byte[] tableName) |
boolean |
isTableEnabled(String tableName) |
List<HBaseProtos.SnapshotDescription> |
listSnapshots()
List completed snapshots.
|
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.
|
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 |
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 |
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 |
restoreSnapshot(byte[] snapshotName)
Restore the specified snapshot on the original table.
|
void |
restoreSnapshot(String snapshotName)
Restore the specified snapshot on the original table.
|
byte[][] |
rollHLogWriter(String serverName)
Roll the log writer.
|
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)
Take a snapshot for the given table.
|
void |
snapshot(HBaseProtos.SnapshotDescription snapshot)
Take a snapshot and wait for the server to complete that snapshot (blocking).
|
void |
snapshot(String snapshotName,
String tableName)
Create a timestamp consistent snapshot for the given table.
|
void |
snapshot(String snapshotName,
String tableName,
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) |
long |
takeSnapshotAsync(HBaseProtos.SnapshotDescription snapshot)
Take a snapshot without waiting for the server to complete that snapshot (asynchronous)
|
void |
unassign(byte[] regionName,
boolean force)
Unassign a region from current hosting regionserver.
|
public HBaseAdmin(org.apache.hadoop.conf.Configuration c) throws MasterNotRunningException, ZooKeeperConnectionException
c
- Configuration objectMasterNotRunningException
- if the master is not runningZooKeeperConnectionException
- if unable to connect to zookeeperpublic HBaseAdmin(HConnection connection) throws MasterNotRunningException, ZooKeeperConnectionException
connection
- The HConnection instance to useMasterNotRunningException
- if the master is not runningZooKeeperConnectionException
- if unable to connect to zookeeperpublic void abort(String why, Throwable e)
Abortable
public boolean isAborted()
Abortable
public HConnection getConnection()
@Deprecated public HMasterInterface getMaster() throws MasterNotRunningException, ZooKeeperConnectionException
MasterNotRunningException
- if the master is not runningZooKeeperConnectionException
- 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[] listTables(Pattern pattern) throws IOException
pattern
- The compiled regular expression to match againstIOException
- if a remote or network exception occurslistTables()
public HTableDescriptor[] listTables(String regex) throws IOException
regex
- The regular expression to match againstIOException
- if a remote or network exception occurslistTables(java.util.regex.Pattern)
public String[] getTableNames() throws IOException
IOException
- if a remote or network exception occurspublic String[] getTableNames(Pattern pattern) throws IOException
pattern
- The compiled regular expression to match againstIOException
- if a remote or network exception occurspublic String[] getTableNames(String regex) throws IOException
regex
- The regular expression to match againstIOException
- if a remote or network exception occurspublic HTableDescriptor getTableDescriptor(byte[] tableName) throws TableNotFoundException, IOException
tableName
- as a byte []TableNotFoundException
IOException
- if a remote or network exception occurspublic void createTable(HTableDescriptor desc) throws IOException
desc
- table descriptor for tableIllegalArgumentException
- if the table name is reservedMasterNotRunningException
- if master is not runningTableExistsException
- 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 createIllegalArgumentException
- if the table name is reservedMasterNotRunningException
- if master is not runningTableExistsException
- 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 tableIllegalArgumentException
- 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 runningTableExistsException
- 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 tableIllegalArgumentException
- Bad table name, if the split keys
are repeated and if the split key has empty byte array.MasterNotRunningException
- if master is not runningTableExistsException
- 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 deleteIOException
- if a remote or network exception occurspublic void deleteTable(byte[] tableName) throws IOException
tableName
- name of table to deleteIOException
- if a remote or network exception occurspublic HTableDescriptor[] deleteTables(String regex) throws IOException
listTables(java.lang.String)
and
deleteTable(byte[])
regex
- The regular expression to match table names againstIOException
deleteTables(java.util.regex.Pattern)
,
deleteTable(java.lang.String)
public HTableDescriptor[] deleteTables(Pattern pattern) throws IOException
listTables(java.util.regex.Pattern)
and
deleteTable(byte[])
pattern
- The pattern to match table names againstIOException
public void enableTable(String tableName) throws IOException
IOException
public void enableTable(byte[] tableName) throws IOException
enableTableAsync(byte[])
and isTableEnabled(byte[])
instead.
The table has to be in disabled state for it to be enabled.tableName
- name of the tableIOException
- 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.isTableEnabled(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 HTableDescriptor[] enableTables(String regex) throws IOException
listTables(java.lang.String)
and
enableTable(byte[])
regex
- The regular expression to match table names againstIOException
enableTables(java.util.regex.Pattern)
,
enableTable(java.lang.String)
public HTableDescriptor[] enableTables(Pattern pattern) throws IOException
listTables(java.util.regex.Pattern)
and
enableTable(byte[])
pattern
- The pattern to match table names againstIOException
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 tableIOException
- 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.
The table has to be in enabled state for it to be disabled.tableName
- IOException
- There could be couple types of IOException
TableNotFoundException means the table doesn't exist.
TableNotEnabledException means the table isn't in enabled state.public HTableDescriptor[] disableTables(String regex) throws IOException
listTables(java.lang.String)
and
disableTable(byte[])
regex
- The regular expression to match table names againstIOException
disableTables(java.util.regex.Pattern)
,
disableTable(java.lang.String)
public HTableDescriptor[] disableTables(Pattern pattern) throws IOException
listTables(java.util.regex.Pattern)
and
disableTable(byte[])
pattern
- The pattern to match table names againstIOException
public boolean isTableEnabled(String tableName) throws IOException
tableName
- name of table to checkIOException
- if a remote or network exception occurspublic boolean isTableEnabled(byte[] tableName) throws IOException
tableName
- name of table to checkIOException
- if a remote or network exception occurspublic boolean isTableDisabled(String tableName) throws IOException
tableName
- name of table to checkIOException
- if a remote or network exception occurspublic boolean isTableDisabled(byte[] tableName) throws IOException
tableName
- name of table to checkIOException
- if a remote or network exception occurspublic boolean isTableAvailable(byte[] tableName) throws IOException
tableName
- name of table to checkIOException
- if a remote or network exception occurspublic boolean isTableAvailable(String tableName) throws IOException
tableName
- name of table to checkIOException
- if a remote or network exception occurspublic Pair<Integer,Integer> getAlterStatus(byte[] tableName) throws IOException
tableName
- name of the table to get the status ofIOException
- 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 addedIOException
- 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 addedIOException
- if a remote or network exception occurspublic void deleteColumn(String tableName, String columnName) throws IOException
tableName
- name of tablecolumnName
- name of column to be deletedIOException
- if a remote or network exception occurspublic void deleteColumn(byte[] tableName, byte[] columnName) throws IOException
tableName
- name of tablecolumnName
- name of column to be deletedIOException
- if a remote or network exception occurspublic void modifyColumn(String tableName, HColumnDescriptor descriptor) throws IOException
tableName
- name of tabledescriptor
- new column descriptor to useIOException
- if a remote or network exception occurspublic void modifyColumn(byte[] tableName, HColumnDescriptor descriptor) throws IOException
tableName
- name of tabledescriptor
- new column descriptor to useIOException
- if a remote or network exception occurspublic void closeRegion(String regionname, String serverName) throws IOException
regionname
- region name to closeserverName
- 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 serverName) throws IOException
regionname
- region name to closeserverName
- The servername of the regionserver. If passed null we
will use servername found in the .META. table. A server name
is made of host, port and startcode. Here is an example:
host187.example.com,60020,1289493121758
IOException
- if a remote or network exception occurspublic boolean closeRegionWithEncodedRegionName(String encodedRegionName, String serverName) throws IOException
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
IOException
- if a remote or network exception occurspublic void closeRegion(ServerName sn, HRegionInfo hri) throws IOException
sn
- hri
- IOException
public void flush(String tableNameOrRegionName) throws IOException, InterruptedException
tableNameOrRegionName
- table or region to flushIOException
- if a remote or network exception occursInterruptedException
public void flush(byte[] tableNameOrRegionName) throws IOException, InterruptedException
tableNameOrRegionName
- table or region to flushIOException
- if a remote or network exception occursInterruptedException
public void compact(String tableNameOrRegionName) throws IOException, InterruptedException
tableNameOrRegionName
- table or region to compactIOException
- if a remote or network exception occursInterruptedException
public void compact(byte[] tableNameOrRegionName) throws IOException, InterruptedException
tableNameOrRegionName
- table or region to compactIOException
- if a remote or network exception occursInterruptedException
public void compact(String tableOrRegionName, String columnFamily) throws IOException, InterruptedException
tableOrRegionName
- table or region to compactcolumnFamily
- column family within a table or regionIOException
- if a remote or network exception occursInterruptedException
public void compact(byte[] tableNameOrRegionName, byte[] columnFamily) throws IOException, InterruptedException
tableNameOrRegionName
- table or region to compactcolumnFamily
- column family within a table or regionIOException
- if a remote or network exception occursInterruptedException
public void majorCompact(String tableNameOrRegionName) throws IOException, InterruptedException
tableNameOrRegionName
- table or region to major compactIOException
- if a remote or network exception occursInterruptedException
public void majorCompact(byte[] tableNameOrRegionName) throws IOException, InterruptedException
tableNameOrRegionName
- table or region to major compactIOException
- if a remote or network exception occursInterruptedException
public void majorCompact(String tableNameOrRegionName, String columnFamily) throws IOException, InterruptedException
tableNameOrRegionName
- table or region to major compactcolumnFamily
- column family within a table or regionIOException
- if a remote or network exception occursInterruptedException
public void majorCompact(byte[] tableNameOrRegionName, byte[] columnFamily) throws IOException, InterruptedException
tableNameOrRegionName
- table or region to major compactcolumnFamily
- column family within a table or regionIOException
- if a remote or network exception occursInterruptedException
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) throws MasterNotRunningException, ZooKeeperConnectionException, IOException
regionName
- Region name to 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. If results in double assignment
use hbck -fix to resolve. To be used by experts).MasterNotRunningException
ZooKeeperConnectionException
IOException
@Deprecated public boolean balanceSwitch(boolean b) throws MasterNotRunningException, ZooKeeperConnectionException
b
- If true, enable balancer. If false, disable balancer.MasterNotRunningException
ZooKeeperConnectionException
public boolean setBalancerRunning(boolean on, boolean synchronous) throws MasterNotRunningException, ZooKeeperConnectionException
on
- If true, enable balancer. If false, disable balancer.synchronous
- If true, it waits until current balance() call, if outstanding, to return.MasterNotRunningException
ZooKeeperConnectionException
public boolean balancer() throws MasterNotRunningException, ZooKeeperConnectionException
MasterNotRunningException
ZooKeeperConnectionException
public void split(String tableNameOrRegionName) throws IOException, InterruptedException
tableNameOrRegionName
- table or region to splitIOException
- if a remote or network exception occursInterruptedException
public void split(byte[] tableNameOrRegionName) throws IOException, InterruptedException
tableNameOrRegionName
- table to region to splitIOException
- if a remote or network exception occursInterruptedException
public void split(String tableNameOrRegionName, String splitPoint) throws IOException, InterruptedException
IOException
InterruptedException
public void split(byte[] tableNameOrRegionName, byte[] splitPoint) throws IOException, InterruptedException
tableNameOrRegionName
- table to region to splitsplitPoint
- the explicit position to split onIOException
- if a remote or network exception occursInterruptedException
- interrupt exception occurredpublic void modifyTable(byte[] tableName, HTableDescriptor htd) throws IOException
tableName
- name of table.htd
- modified description of the tableIOException
- 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(String hostnamePort) throws IOException
hostnamePort
- Hostname and port delimited by a :
as in
example.org:1234
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 configurationMasterNotRunningException
- if the master is not runningZooKeeperConnectionException
- if unable to connect to zookeeperpublic List<HRegionInfo> getTableRegions(byte[] tableName) throws IOException
tableName
- the name of the tableHRegionInfo
.IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public HTableDescriptor[] getTableDescriptors(List<String> tableNames) throws IOException
tableNames
- List of table namesIOException
- if a remote or network exception occurspublic byte[][] rollHLogWriter(String serverName) throws IOException, FailedLogCloseException
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
HRegionInfo.getEncodedName()
IOException
- if a remote or network exception occursFailedLogCloseException
public String[] getMasterCoprocessors()
public CompactionRequest.CompactionState getCompactionState(String tableNameOrRegionName) throws IOException, InterruptedException
tableNameOrRegionName
- table or region to major compactIOException
- if a remote or network exception occursInterruptedException
public CompactionRequest.CompactionState getCompactionState(byte[] tableNameOrRegionName) throws IOException, InterruptedException
tableNameOrRegionName
- table or region to major compactIOException
- if a remote or network exception occursInterruptedException
public <T extends CoprocessorProtocol> T coprocessorProxy(Class<T> protocol)
protocol
- The class or interface defining the remote protocolpublic void snapshot(String snapshotName, String tableName) throws IOException, SnapshotCreationException, IllegalArgumentException
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
HTableDescriptor.isLegalTableName(byte[])
.
snapshotName
- name of the snapshot to be createdtableName
- name of the table for which snapshot is createdIOException
- if a remote or network exception occursSnapshotCreationException
- if snapshot creation failedIllegalArgumentException
- if the snapshot request is formatted incorrectlypublic void snapshot(byte[] snapshotName, byte[] tableName) throws IOException, SnapshotCreationException, IllegalArgumentException
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
HTableDescriptor.isLegalTableName(byte[])
.
snapshotName
- name of the snapshot to be createdtableName
- name of the table for which snapshot is createdIOException
- if a remote or network exception occursSnapshotCreationException
- if snapshot creation failedIllegalArgumentException
- if the snapshot request is formatted incorrectlypublic void snapshot(String snapshotName, String tableName, HBaseProtos.SnapshotDescription.Type type) throws IOException, SnapshotCreationException, IllegalArgumentException
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
HTableDescriptor.isLegalTableName(byte[])
.
snapshotName
- name to give the snapshot on the filesystem. Must be unique from all other
snapshots stored on the clustertableName
- name of the table to snapshottype
- type of snapshot to takeIOException
- we fail to reach the masterSnapshotCreationException
- if snapshot creation failedIllegalArgumentException
- if the snapshot request is formatted incorrectlypublic void snapshot(HBaseProtos.SnapshotDescription snapshot) throws IOException, SnapshotCreationException, IllegalArgumentException
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
HTableDescriptor.isLegalTableName(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.
snapshot
- snapshot to takeIOException
- or we lose contact with the master.SnapshotCreationException
- if snapshot failed to be takenIllegalArgumentException
- if the snapshot request is formatted incorrectlypublic long takeSnapshotAsync(HBaseProtos.SnapshotDescription snapshot) throws IOException, SnapshotCreationException
Only a single snapshot should be taken at a time, or results may be undefined.
snapshot
- snapshot to takeIOException
- if the snapshot did not succeed or we lose contact with the master.SnapshotCreationException
- if snapshot creation failedIllegalArgumentException
- if the snapshot request is formatted incorrectlypublic boolean isSnapshotFinished(HBaseProtos.SnapshotDescription snapshot) throws IOException, HBaseSnapshotException, UnknownSnapshotException
There are three possible states:
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
.
snapshot
- description of the snapshot to checkIOException
- if we have a network issueHBaseSnapshotException
- if the snapshot failedUnknownSnapshotException
- if the requested snapshot is unknownpublic void restoreSnapshot(byte[] snapshotName) throws IOException, RestoreSnapshotException
snapshotName
- name of the snapshot to restoreIOException
- if a remote or network exception occursRestoreSnapshotException
- if snapshot failed to be restoredIllegalArgumentException
- if the restore request is formatted incorrectlypublic void restoreSnapshot(String snapshotName) throws IOException, RestoreSnapshotException
snapshotName
- name of the snapshot to restoreIOException
- if a remote or network exception occursRestoreSnapshotException
- if snapshot failed to be restoredIllegalArgumentException
- if the restore request is formatted incorrectlypublic void cloneSnapshot(byte[] snapshotName, byte[] tableName) throws IOException, TableExistsException, RestoreSnapshotException, InterruptedException
snapshotName
- name of the snapshot to be clonedtableName
- name of the table where the snapshot will be restoredIOException
- if a remote or network exception occursTableExistsException
- if table to be created already existsRestoreSnapshotException
- if snapshot failed to be clonedIllegalArgumentException
- if the specified table has not a valid nameInterruptedException
public void cloneSnapshot(String snapshotName, String tableName) throws IOException, TableExistsException, RestoreSnapshotException, InterruptedException
snapshotName
- name of the snapshot to be clonedtableName
- name of the table where the snapshot will be restoredIOException
- if a remote or network exception occursTableExistsException
- if table to be created already existsRestoreSnapshotException
- if snapshot failed to be clonedIllegalArgumentException
- if the specified table has not a valid nameInterruptedException
public List<HBaseProtos.SnapshotDescription> listSnapshots() throws IOException
IOException
- if a network error occurspublic void deleteSnapshot(byte[] snapshotName) throws IOException
snapshotName
- name of the snapshotIOException
- if a remote or network exception occurspublic void deleteSnapshot(String snapshotName) throws IOException
snapshotName
- name of the snapshotIOException
- if a remote or network exception occursCopyright © 2014 The Apache Software Foundation. All Rights Reserved.