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.
- 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 APIsTable 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.
- Currently, only the changes of common APIs for client operations in MRS 2.x compared with earlier version are listed.
- APIs used by HBase are the same as APIs of Apache HBase. For details about how to use the APIs, see http://hbase.apache.org/apidocs/index.html.
- MRS 2.x is consistent with Apache HBase 2.x. For details about the changes, see http://hbase.apache.org/book.html#_changes_of_note.
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.