Use external API to connect HBase
You can access Apache HBase through non-Java languages and custom protocols. ADH 3.1.2.1 includes HBase REST Server and HBase Thrift2 Server that can be enabled as described below. It is also possible to use C/C++ Apache HBase Client, Java Data Objects (JDO), Scala, and Jython to connect to the ADH HBase service in the same way as to the native Apache HBase version.
HBase REST Server
ADH includes the HBase REST Server that can be enabled during installation. In an installed cluster, run the Add HBase REST Server(s) cluster action to add the HBase REST Server component. See HBase service management via ADCM.
By default, HBase REST Server operates on the 60080
port. To change this value, set the hbase.rest.port
configuration parameter in ADCM UI. See Configuration parameters.
You can use the curl or wget tools to execute HTTP methods for accessing a REST server. Unless another method is specified for the current endpoint, utilize GET
requests for select queries, PUT
or POST
requests for creation or modifying, and DELETE
for deletion.
This article contains several examples of using endpoints. For information on all available endpoints, refer to Using REST Endpoints.
By default, the command output has a plain text format. To change the response format, add the Accept
header as follows:
-
for XML —
Accept: text/xml
; -
for JSON —
Accept: application/json
; -
for Protocol Buffers (data serialization protocol) —
Accept: application/x-protobuf
.
The following request returns cluster version in the XML format:
$ curl -vi -X GET -H "Accept: text/xml" "http://10.92.40.168:60080/version/cluster"
The result:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><ClusterVersion Version="2.2.7"/>
You can use endpoints to manage namespaces. The command below creates a namespace:
$ curl -vi -X POST "http://10.92.40.168:60080/namespaces/test_ns"
To delete the test_ns
namespace, execute the following command:
$ curl -vi -X DELETE "http://10.92.40.168:60080/namespaces/test_ns"
The code below creates a new table or replaces an existing table’s schema with the provided schema:
$ curl -vi -X POST \
-H "Accept: text/xml" \
-H "Content-Type: text/xml" \
-d '<?xml version="1.0" encoding="UTF-8"?><TableSchema name="users"><ColumnSchema name="cf" /></TableSchema>' \
"http://10.92.40.168:60080/users/schema"
Add a row to the users
table created above:
$ curl -vi -X PUT \
-H "Accept: text/xml" \
-H "Content-Type: text/xml" \
-d '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><CellSet><Row key="cm93MQ=="><Cell column="Y2Y6ZQo=">dmFsdWUx</Cell></Row></CellSet>' \
"http://10.92.40.168:60080/users/testrow"
The row, column qualifier, and value must be Base-64 encoded.
The code below deletes the users
table:
$ curl -vi -X DELETE -H "Accept: text/xml" "http://10.92.40.168:60080/users/schema"
HBase Thrift2 Server
You can add the HBase Thrift2 server component during cluster installation on the Add components step. It is also possible to use the Add Thrift2 Server(s) action to enable HBase Thrift2 server in the installed cluster. See HBase service management via ADCM.
Use configuration parameters listed in the table below to configure Thrift for secure authentication.
Parameter | Description |
---|---|
hbase.thrift.keytab.file |
Thrift Kerberos keytab |
hbase.thrift.kerberos.principal |
Thrift Kerberos principal |
hbase.thrift.security.qop |
Defines authentication, integrity, and confidentiality checking. Supported values:
|
HBase Thrift2 server operates on the 9090
port.