The examples below illustrate the set of basic operations with HBase instance using Stargate REST API.
Use following link to get more more details about HBase/Stargate API: http://wiki.apache.org/hadoop/Hbase/Stargate
Image Removed.
...
Code Block |
---|
% curl -ik -u guest:guest-password\
-H "Accept: application/json"\
-X GET 'https://localhost:8443/gateway/sandbox/hbase/api/v1/version'
|
Get version information regarding the HBase cluster backing the Stargate instance
...
Code Block |
---|
% curl -ik -u guest:guest-password\
-H "Accept: text/xml"\
-X GET 'https://localhost:8443/gateway/sandbox/hbase/api/v1/version/cluster'
|
Get detailed status on the HBase cluster backing the Stargate instance.
...
Code Block |
---|
% curl -ik -u guest:guest-password\
-H "Accept: text/xml"\
-X GET 'https://localhost:8443/gateway/sandbox/hbase/api/v1/status/cluster'
|
Get the list of available tables.
...
Code Block |
---|
% curl -ik -u guest:guest-password\
-H "Accept: text/xml"\
-X GET 'https://localhost:8443/gateway/sandbox/hbase/api/v1'
|
Create table with two column families using xml input
Code Block |
---|
% curl -ik -u guest:guest-password\
-H "Accept: text/xml" -H "Content-Type: text/xml"\
-d '<?xml version="1.0" encoding="UTF-8"?><TableSchema name="table1"><ColumnSchema name="family1"/><ColumnSchema name="family2"/></TableSchema>'\
-X PUT 'https://localhost:8443/gateway/sandbox/hbase/api/v1/table1/schema'
|
Create table with two column families using JSON input
Code Block |
---|
% curl -ik -u guest:guest-password\
-H "Accept: application/json" -H "Content-Type: application/json"\
-d '{"name":"table2","ColumnSchema":[{"name":"family3"},{"name":"family4"}]}'\
-X PUT 'https://localhost:8443/gateway/sandbox/hbase/api/v1/table2/schema'
|
Get table metadata
Code Block |
---|
% curl -ik -u guest:guest-password\
-H "Accept: text/xml"\
-X GET 'https://localhost:8443/gateway/sandbox/hbase/api/v1/table1/regions'
|
Insert single row table
Code Block |
---|
% curl -ik -u guest:guest-password\
-H "Content-Type: text/xml"\
-H "Accept: text/xml"\
-d '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><CellSet><Row key="cm93MQ=="><Cell column="ZmFtaWx5MTpjb2wx" >dGVzdA==</Cell></Row></CellSet>'\
-X POST 'https://localhost:8443/gateway/sandbox/hbase/api/v1/table1/row1'
|
Insert multiple rows into table
Code Block |
---|
% curl -ik -u guest:guest-password\
-H "Content-Type: text/xml"\
-H "Accept: text/xml"\
-d '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><CellSet><Row key="cm93MA=="><Cell column=" ZmFtaWx5Mzpjb2x1bW4x" >dGVzdA==</Cell></Row><Row key="cm93MQ=="><Cell column=" ZmFtaWx5NDpjb2x1bW4x" >dGVzdA==</Cell></Row></CellSet>'\
-X POST 'https://localhost:8443/gateway/sandbox/hbase/api/v1/table2/false-row-key'
|
Get all data from table
...
Code Block |
---|
% curl -ik -u guest:guest-password\
-H "Accept: text/xml"\
-X GET 'https://localhost:8443/gateway/sandbox/hbase/api/v1/table1/*'
|
Execute cell or row query
...
Code Block |
---|
% curl -ik -u guest:guest-password\
-H "Accept: text/xml"\
-X GET 'https://localhost:8443/gateway/sandbox/hbase/api/v1/table1/row1/family1:col1'
|
...
Code Block |
---|
% curl -ik -u guest:guest-password\
-H "Accept: text/xml"\
-X DELETE 'https://localhost:8443/gateway/sandbox/hbase/api/v1/table2/row0'
|
Delete column family from row
Code Block |
---|
% curl -ik -u guest:guest-password\
-H "Accept: text/xml"\
-X DELETE 'https://localhost:8443/gateway/sandbox/hbase/api/v1/table2/row0/family3'
|
Delete specific column from row
Code Block |
---|
% curl -ik -u guest:guest-password\
-H "Accept: text/xml"\
-X DELETE 'https://localhost:8443/gateway/sandbox/hbase/api/v1/table2/row0/family3'
|
Create scanner
...
Code Block |
---|
% curl -ik -u guest:guest-password\
-H "Content-Type: text/xml"\
-d '<Scanner batch="1"/>'\
-X PUT 'https://localhost:8443/gateway/sandbox/hbase/api/v1/table1/scanner'
|
Get the values of the next cells found by the scanner
Code Block |
---|
% curl -ik -u guest:guest-password\
-H "Accept: application/json"\
-X GET 'https://localhost:8443/gateway/sandbox/hbase/api/v1/table1/scanner/13705290446328cff5ed'
|
...
Code Block |
---|
% curl -ik -u guest:guest-password\
-H "Accept: text/xml"\
-X DELETE 'https://localhost:8443/gateway/sandbox/hbase/api/v1/table1/scanner/13705290446328cff5ed'
|
...
Code Block |
---|
% curl -ik -u guest:guest-password\
-X DELETE 'https://localhost:8443/gateway/sandbox/hbase/api/v1/table1/schema'
|