Java APIs

HBase adopts the same APIs as those of Apache HBase. For details, visit http://hbase.apache.org/apidocs/index.html.

Newly Added or Modified APIs

  • org.apache.hadoop.hbase.Cell of HBase 0.98.3 rather than org.apache.hadoop.hbase.KeyValue of HBase 0.94 is recommended as the key-value data object.
  • It is recommended that HConnection connection = HConnectionManager.createConnection(conf) be used to create a connection pool in HBase 0.98.3. The HTablePool is abandoned.
  • For details about the new EndPoint API, visit http://hbase.apache.org/book/cp.html.
  • The isReversed() and setReversed(boolean reversed) reversed scan methods are added to org.apache.hadoop.hbase.client.Scan.
  • For details about API changes from HBase 0.98 to HBase 1.0, visit https://issues.apache.org/jira/browse/hbase-10602.
  • org.apache.hadoop.hbase.mapreduce rather than org.apache.hadoop.hbase.mapred is recommended for HBase 1.0.
  • For details about the version, visit https://blogs.apache.org/hbase/entry/start_of_a_new_era.
  • New APIs added to obtain HBase replication metrics
    Table 1 org.apache.hadoop.hbase.client.replication.ReplicationAdmin

    Method

    Description

    getSourceMetricsSummary(String id)

    Parameter type: String

    The source metric summary of the peer ID needs to be obtained.

    Return type: Map<String, String>

    Returned: A map, where the key is the RegionServer name and the value is the source cluster metric summary of the specified peer ID. Summary metrics are sizeOfLogToReplicate and timeForLogToReplicate.

    getSourceMetrics(String id)

    Parameter type: String

    The source metric summary of the peer ID needs to be obtained.

    Return type: Map<String, String>

    Returned: A map, where the key is the RegionServer name and the value is the source cluster metric of the specified peer ID.

    getSinkMetrics()

    Return type: Map<String, String>

    Returned: A map, where the key is the RegionServer name and the value is the source cluster sink metric of the specified peer ID.

    getPeerSinkMetrics(String id)

    Parameter type: String

    The source metric summary of the peer ID needs to be obtained.

    Return type: Map<String, String>

    Returned: A map, where the key is the RegionServer name and the value is the source cluster sink metric of the specified peer ID.

    All methods return a Map, where the key is "RegionServer name (IP/Host)" and the value is the string containing all the metrics in format of 'Metric Name'='Metric Value' [, 'Metric Name'= 'Metric Value']*.

    Example: SizeOfHFileRefsQueue=0, AgeOfLastShippedOp=0

    Table 2 org.apache.hadoop.hbase.replication.ReplicationLoadSource

    Method

    Description

    getPeerID()

    Return type: String

    Returned: peer cluster ID

    getAgeOfLastShippedOp()

    Return type: long

    Returned: milliseconds that the last successful replication request lasts

    getSizeOfLogQueue()

    Return type: long

    Returned: write-ahead logs (WALs) waiting for replication in the queue

    getTimeStampOfLastShippedOp()

    Return type: long

    Returned: timestamp of the last successful replication request

    getReplicationLag()

    Return type: long

    Returned: interval between current time and the time of the last successful replication request

    getShippedOps()

    Return type: long

    Returned: total number of data ops transferred

    getShippedBytes()

    Return type: long

    Returned: total number of data bytes transferred

    getShippedBatches()

    Return type: long

    Returned: total number of data batches transferred

    getLogReadInBytes()

    Return type: long

    Returned: total number of bytes read from WAL

    getLogEditsRead()

    Return type: long

    Returned: total number of edits read from WAL

    getSizeOfLogToReplicate()

    Return type: long

    Returned: total size of WALs waiting to be replicated in the queue

    getTimeForLogToReplicate()

    Return type: long

    Returned: seconds spent in replicating WALs in the queue

    getShippedHFiles()

    Return type: long

    Returned: total number of HFiles transferred

    getSizeOfHFileRefsQueue()

    Return type: long

    Returned: total number of HFiles waiting to be replicated

    getLogEditsFiltered()

    Return type: long

    Returned: total number of WAL edits filtered

    getFailedReplicationAttempts()

    Return type: long

    Returned: times failed to replicate data for a single request

    Table 3 org.apache.hadoop.hbase.replication.ReplicationLoadSink

    Method

    Description

    getAgeOfLastAppliedOp()

    Return type: long

    Returned: milliseconds that the last successful applied WAL edits last

    getTimeStampsOfLastAppliedOp()

    Return type: long

    Returned: timestamp of the last successful applied WAL edit

    getAppliedBatches()

    Return type: long

    Returned: total number of data batches applied

    getAppliedOps()

    Return type: long

    Returned: total number of data ops applied

    getAppliedHFiles()

    Return type: long

    Returned: total number of HFiles applied

    The new API OF Replication Admin obtains the metric values from HMaster. Each RegionServer reports status to HMaster at every heartbeat interval, which is 3 seconds by default. Therefore, this API reports the latest metric value at the last heartbeat by using the RegionServer.

    If you need the latest metric value, use the JMX API provided by the RegionServer.

  • 1.3.1 (MRS 1.6) API Changes
    Table 4 API removed from org.apache.hadoop.hbase.client.Admin

    Method

    Description

    compactMob()

    Return type: void

    ACL client APIs are enhanced to query the permissions based on the namespace, table name, column family, and column qualifier of a specific user. The client can also validate whether the specified user has permissions to perform operations on the mentioned table, column family, or column qualifier.

    Table 5 org.apache.hadoop.hbase.security.access.AccessControlClient

    Method

    Description

    getUserPermissions(Connection connection, String tableRegex, String userName)

    • Parameter type: Connection

      HBase cluster connection

    • Parameter type: String

      Table name pattern, based on the permissions to be retrieved. If the value of tableRegex is null, the global permission is used. If the value of tableRegex contains @, the namespace permission is used. Otherwise, the table permission will be retrieved. tableRegex can be a regular expression of a table or namespace.

    • Parameter type: String

      Name of the user whose permissions will be filtered. If username is left blank, all user permissions will be retrieved.

    Return type: List<UserPermission>

    Returned: List of user permissions

    getUserPermissions(Connection connection, String tableRegex, byte[] columnFamily)

    • Parameter type: Connection

      HBase cluster connection

    • Parameter type: String

      Table name pattern, based on the permissions to be retrieved. The table name cannot be null, empty, or a namespace name.

    • Parameter type: byte[]

      Column family, based on the permissions to be retrieved. If columnFamily is left blank, all column family permissions will be retrieved.

    Return type: List<UserPermission>

    Returned: List of user permissions

    getUserPermissions(Connection connection, String tableRegex, byte[] columnFamily, String userName)

    • Parameter type: Connection

      HBase cluster connection

    • Parameter type: String

      Table name pattern, based on the permissions to be retrieved. The table name cannot be null, empty, or a namespace name.

    • Parameter type: byte[]

      Column family, based on the permissions to be retrieved. If columnFamily is left blank, all column family permissions will be retrieved.

    • Parameter type: String

      Name of the user whose permissions will be filtered. If username is left blank, all user permissions will be retrieved.

    Return type: List<UserPermission>

    Returned: List of user permissions

    getUserPermissions(Connection connection, String tableRegex, byte[] columnFamily, byte[] columnQualifier)

    • Parameter type: Connection

      HBase cluster connection

    • Parameter type: String

      Table name pattern, based on the permissions to be retrieved. The table name cannot be null, empty, or a namespace name.

    • Parameter type: byte[]

      Column family, based on the permissions to be retrieved. If columnFamily is left blank, all column family permissions will be retrieved.

    • Parameter type: byte[]

      Column qualifier, based on the permissions to be retrieved. If columnQualifier is left blank, all column qualifier permissions will be retrieved.

    Return type: List<UserPermission>

    Returned: List of user permissions

    getUserPermissions(Connection connection, String tableRegex, byte[] columnFamily, byte[] columnQualifier, String userName)

    • Parameter type: Connection

      HBase cluster connection

    • Parameter type: String

      Table name pattern, based on the permissions to be retrieved. The table name cannot be null, empty, or a namespace name.

    • Parameter type: byte[]

      Column family, based on the permissions to be retrieved. If columnFamily is left blank, all column family permissions will be retrieved.

    • Parameter type: byte[]

      Column qualifier, based on the permissions to be retrieved. If columnQualifier is left blank, all column qualifier permissions will be retrieved.

    • Parameter type: String

      Name of the user whose permissions will be filtered. If username is left blank, all user permissions will be retrieved.

    Return type: List<UserPermission>

    Returned: List of user permissions

    hasPermission(Connection connection, String tableName, String columnFamily,

    String columnQualifier, String userName, Permission.Action... actions)

    Verify whether the specified user has permissions to perform operations on the mentioned table, column family, or column qualifier.

    • Parameter type: Connection

      HBase cluster connection

    • Parameter type: String

      Table name. The table name cannot be null or empty.

    • Parameter type: String

      Column family. If columnFamily is left blank, the verification is performed for tables.

    • Parameter type: String

      Column qualifier. If columnQualifier is left blank, the verification is performed for tables and column families. If columnFamily is transferred as null or empty, the value of columnQualifier will not be considered.

    • Parameter type: String

      Name of the user whose permissions will be filtered. If username is left blank, all user permissions will be retrieved.

    • Parameter type: Permission.Action

      Actions that the specified user wants to perform on the table, column family, or column qualifier

    hasPermission(Connection connection, String tableName, byte[] columnFamily,

    byte[] columnQualifier, String userName, Permission.Action... actions)

    Verify whether the specified user has permissions to perform operations on the mentioned table, column family, or column qualifier.

    • Parameter type: Connection

      HBase cluster connection

    • Parameter type: String

      Table name. The table name cannot be null or empty.

    • Parameter type: byte[]

      Column family. If columnFamily is left blank, the verification is performed for tables.

    • Parameter type: byte[]

      Column qualifier. If columnQualifier is left blank, the verification is performed for tables and column families. If columnFamily is transferred as null or empty, the value of columnQualifier will not be considered.

    • Parameter type: String

      Name of the user whose permissions will be filtered. If username is left blank, all user permissions will be retrieved.

    • Parameter type: Action

      Actions that the specified user wants to perform on the table, column family, or column qualifier

  • 1.3.1 (MRS 1.7) API Changes
    • Added HIndex API
    Table 6 org.apache.hadoop.hbase.hindex.client.HIndexAdmin

    Method

    Description

    addIndices(TableName tablename,TableIndices tableIndices)

    Parameter: TableName

    Name of the table to which the user wants to add a specified index.

    Parameter: TableIndices

    Table index to be added to the table

    Return type: void

    addIndicesWithData(TableName tablename,TableIndices tableIndices)

    Parameter: TableName

    Name of the table to which the user wants to add a specified index

    Parameter: TableIndices

    Table index to be added to the table

    Return type: void

    dropIndices(TableName tableName,List <String> list)

    Parameter: TableName

    Name of the table from which the user wants to delete an index

    Parameter: List<String>

    Contains the list of indexes to be deleted.

    Return type: void

    dropIndicesWithData(TableName tableName,List <String> list)

    Parameter: TableName

    Name of the table from which the user wants to delete a specified index

    Parameter: List<String>

    Contains the list of indexes to be deleted.

    Return type: void

    disableIndices(TableName tableName,List <String> list)

    Parameter: TableName

    Name of the table for which the user wants to disable a specified index

    Parameter: List<String>

    Contains the list of indexes to be disabled.

    Return type: void

    enableIndices(TableName tableName,List <String> list)

    Parameter: TableName

    Name of the table for which the user wants to enable a specified index

    Parameter: List<String>

    Contains the list of indexes to be enabled.

    Return type: void

    listIndices(TableName tableName)

    Parameter: TableName

    Name of the table for which the user wants to list all indexes

    Return type: List <Pair <HIndexSpecification,IndexState >>

    Return: A secondary index list is returned. The first element is the index specification, and the second element is the current state of the index.

  • 2.1.1 (MRS 2.x) API Changes
    Removed APIs
    Table 7 APIs removed from org.apache.hadoop.hbase.client.Admin

    Method

    Description

    compactMob(final TableName tableName)

    Return type: void

    Parameter type: TableName

    compactMob(final TableName tableName, final byte[] columnFamily)

    Return type: void

    Parameter type: TableName, byte[]

    majorCompactMob ( org.apache.hadoop.hbase.TableName tableName )

    Return type: void

    Parameter type: TableName

    majorCompactMob ( org.apache.hadoop.hbase.TableName tableName, byte[ ] columnFamily)

    Return type: void

    Parameter type: TableName, byte[]

    isAclEnable ( )

    Return type: boolean

    isNamespaceAvailable ( String nameOfNamespace )

    Return type: boolean

    multiSplit ( byte[ ] regionName, byte[ ][ ] splitKeys)

    Return type: void

    multiSplitSync ( byte[ ] regionName, byte[ ][ ] splitKeys)

    Return type: void

    Table 8 APIs removed from org.apache.hadoop.hbase.client.Put

    Method

    Description

    add ( byte[ ] family, byte[ ] qualifier, byte[ ] value )

    Return type: Put

    Parameter type: byte[]

    add ( byte[ ] family, byte[ ] qualifier, long ts, byte[ ] value )

    Return type: Put

    Parameter type: byte[]

    add ( byte[ ] family, java.nio.ByteBuffer qualifier, long ts, java.nio.ByteBuffer value )

    Return type: Put

    Parameter type: byte[]

    setWriteToWAL ( boolean write )

    Return type: Put

    Parameter type: boolean

    Table 9 APIs removed from org.apache.hadoop.hbase.security.token.TokenUtil

    Method

    Description

    obtainToken ( org.apache.hadoop.conf.Configuration conf )

    Return type: Token<AuthenticationTokenIdentifier>

    Parameter type: Configuration

    Added APIs
    Table 10 APIs added to org.apache.hadoop.hbase.client.Admin

    Method

    Description

    decommissionRegionServers ( java.util.List<org.apache.hadoop.hbase.ServerName> servers, boolean offload)

    Return type: void

    Parameter type: List<ServerName>, boolean

    Mark the RegionServer in the list as the decommissioned state. If offload is set to true, the regions of the RegionServer are allocated to other RegionServers. If offload is set to false, the regions of the current RegionServer are not re-allocated, and no new region is allocated to the RegionServer.

    listDecommissionedRegionServers ( )

    Return type: List<ServerName>

    The decommissioned RegionServers in the current cluster are listed.

    recommissionRegionServer ( org.apache.hadoop.hbase.ServerName server, java.util.List<byte[ ]> encodedRegionNames)

    Return type: void

    Parameter type: ServerName, byte[]

    Recommission the imported decommissioned RegionServers.