在上一篇关于Hbase Rest API的文章中介绍了如何查询数据,本章将介绍其Hbase Admin的功能。
?
语法:GET /version
?
范例:curl http://localhost:8000/version
?
输出结果:
{"@Stargate":"0.0.1","@OS":"Linux 2.6.18-128.1.6.el5.centos.plusxen amd64","@
JVM":"Sun Microsystems Inc. 1.6.0_13-11.3-b02","@Jetty":"6.1.14","@Jersey":"1
.1.0-ea"}
?
语法:GET /version/cluster
?
范例:curl -H "Accept: application/json" http://localhost:8000/version/cluster
?
输出结果:"0.20.0"
?
相当于HBaseAdmin.getClusterStatus().getHBaseVersion()
?
语法:GET /status/cluster
?
范例:curl -H "Accept: application/json" http://localhost:8000/status/cluster
?
相当于HBaseAdmin.getClusterStatus()
?
语法:GET /
?
范例:curl -H "Accept: application/json" http://localhost:8000/
?
输出结果:{"table":[{"name":"table1"},{"name":"table2"}]}
?
相当于HBaseAdmin.listTableNames()
?
语法:GET /<table>/schema
?
范例:curl -H "Accept: application/json" http://localhost:8000/table1/schema
?
输出结果:
{ NAME=> ‘table1‘, IS_META => ‘false‘, COLUMNS => [ { NAME => ‘C‘, DATA_BLOCK_ENCODING => ‘NONE‘, BLOOMFILTER => ‘ROW‘, REPLICATION_SCOPE => ‘0‘, VERSIONS => ‘1‘, COMPRESSION => ‘NONE‘, MIN_VERSIONS => ‘0‘, TTL => ‘2147483647‘, KEEP_DELETED_CELLS => ‘FALSE‘, BLOCKSIZE => ‘65536‘, IN_MEMORY => ‘false‘, BLOCKCACHE => ‘true‘ }, { NAME => ‘M‘, DATA_BLOCK_ENCODING => ‘NONE‘, BLOOMFILTER => ‘ROW‘, REPLICATION_SCOPE => ‘0‘, VERSIONS => ‘1‘, COMPRESSION => ‘NONE‘, MIN_VERSIONS => ‘0‘, TTL => ‘2147483647‘, KEEP_DELETED_CELLS => ‘FALSE‘, BLOCKSIZE => ‘65536‘, IN_MEMORY => ‘false‘, BLOCKCACHE => ‘true‘ } ] }
?
相当于HBaseAdmin.getTableDescriptor(TableName.valueOf("table1"))
?
语法:
PUT /<table>/schema
POST /<table>/schema
?
PUT完全替换表结构,POST只是更新或者新增column family(跟本次更新无关的cf仍然保留)
?
语法:GET /<table>/regions
?
范例:curl -H "Accept: application/json" http://localhost:8000/table1/regions
?
输出结果:
pf_entity,,1436346991071.fce2165af7b49f1dd0995ddd535d3a6f. [
? id=1436346991071
? startKey=‘‘
? endKey=‘‘
? location=‘bd02:21003‘
]
?
相当于HBaseAdmin.getTableRegions(TableName.valueOf("table1"))
?
?
?
原文:http://kane-xie.iteye.com/blog/2228967