Database Reference
In-Depth Information
The HBaseAdmin API
Just like the data deinition API or data manipulation with the client API, HBase also
provides the API for handling administrative tasks. The HBaseAdmin class provides
an interface to manage HBase database table metadata and general administrative
functions. Before using the administrative API, an instance of the HBaseAdmin class
needs to be created as follows:
HBaseAdmin(org.apache.hadoop.conf.Configurationconf)
The existing coniguration instance is passed as a parameter that provides details
about the cluster using the ZooKeeper quorum. The HBaseAdmin class unfolds the
following methods for administrative operations:
boolean isMasterRunning() : This returns true if the master server is
running; otherwise, it throws an exception.
HConnection getConnection() : This returns a connection instance to
the HBase master.
Configuration getConfiguration() : This returns the coniguration
used by the current instance. The HBaseAdmin instance can also be used
to modify the coniguration for a running HBaseAdmin instance.
close() : This closes all resources kept by the current HBaseAdmin instance.
This includes the connection to the remote servers.
Once the connection is established, HBase table-related calls can be used to create
a table as follows:
void createTable(HTableDescriptor desc)
The preceding command creates a new table synchronously by taking the
HTableDescriptor instance as a parameter.
void createTable(HTableDescriptor desc, byte[] startKey,byte[] endKey,
int numRegions)
The preceding command creates a new table with the speciied number of regions.
The start key speciied will become the end key of the irst region of the table,
and the end key speciied will become the start key of the last region of the table
(the irst region has a null start key and the last region has a null end key).
void createTable(HTableDescriptor desc, byte[][] splitKeys)
This creates a new table with an initial set of empty regions deined by the speciied
split keys synchronously. The total number of regions created will be the number of
split keys plus one.
void createTableAsync(HTableDescriptor desc, byte[][] splitKeys)
 
Search WWH ::




Custom Search