-
Notifications
You must be signed in to change notification settings - Fork 6
RESTful interaction
mhausenblas edited this page Oct 29, 2012
·
4 revisions
First make sure HBase's Startgate is running (from your HBase directory):
$ ./bin/hbase rest start -p 9191
12/10/29 14:29:26 INFO util.VersionInfo: HBase 0.94.2
12/10/29 14:29:26 INFO util.VersionInfo: Subversion https://svn.apache.org/repos/asf/hbase/branches/0.94 -r 1395367
12/10/29 14:29:26 INFO util.VersionInfo: Compiled by jenkins on Sun Oct 7 19:11:01 UTC 2012
12/10/29 14:29:26 INFO jvm.JvmMetrics: Initializing JVM Metrics with processName=rest, sessionId=main
12/10/29 14:29:26 INFO hbase.metrics: new MBeanInfo
12/10/29 14:29:26 INFO mortbay.log: Logging to org.slf4j.impl.Log4jLoggerAdapter(org.mortbay.log) via org.mortbay.log.Slf4jLog
2012-10-29 14:29:26.620 java[22215:1903] Unable to load realm info from SCDynamicStore
12/10/29 14:29:26 INFO mortbay.log: jetty-6.1.26
12/10/29 14:29:26 INFO mortbay.log: Started [email protected]:9191
Then, using httpie or curl you can interact with HBase as follows.
Explore a table's schema:
$ http http://localhost:9191/rdf/schema
HTTP/1.1 200 OK
Cache-Control: no-cache
Content-Encoding: gzip
Content-Length: 250
Content-Type: text/plain
{
NAME = > 'rdf', IS_META = > 'false', IS_ROOT = > 'false', COLUMNS = > [{
NAME = > 'G', BLOCKSIZE = > '65536', BLOOMFILTER = > 'NONE', MIN_VERSIONS = > '0', KEEP_DELETED_CELLS = > 'false', ENCODE_ON_DISK = > 'true', BLOCKCACHE = > 'true', COMPRESSION = > 'NONE', VERSIONS = > '3', REPLICATION_SCOPE = > '0', TTL = > '2147483647', DATA_BLOCK_ENCODING = > 'NONE', IN_MEMORY = > 'false'
}, {
NAME = > 'O', BLOCKSIZE = > '65536', BLOOMFILTER = > 'NONE', MIN_VERSIONS = > '0', KEEP_DELETED_CELLS = > 'false', ENCODE_ON_DISK = > 'true', BLOCKCACHE = > 'true', COMPRESSION = > 'NONE', VERSIONS = > '3', REPLICATION_SCOPE = > '0', TTL = > '2147483647', DATA_BLOCK_ENCODING = > 'NONE', IN_MEMORY = > 'false'
}, {
NAME = > 'P', BLOCKSIZE = > '65536', BLOOMFILTER = > 'NONE', MIN_VERSIONS = > '0', KEEP_DELETED_CELLS = > 'false', ENCODE_ON_DISK = > 'true', BLOCKCACHE = > 'true', COMPRESSION = > 'NONE', VERSIONS = > '3', REPLICATION_SCOPE = > '0', TTL = > '2147483647', DATA_BLOCK_ENCODING = > 'NONE', IN_MEMORY = > 'false'
}]
}
To retrieve a row by its key (for example http://mhausenblas.info/#i
):
$ http http://localhost:9191/rdf/http%3A%2F%2Fmhausenblas.info%2F%23i Accept:application/json
HTTP/1.1 200 OK
Content-Encoding: gzip
Content-Type: application/json
Transfer-Encoding: chunked
{
"Row": [
{
"Cell": [
{
"$": "aHR0cDovL2V4YW1wbGUub3Jn",
"column": "Rzo=",
"timestamp": 1351372113753
},
{
"$": "aHR0cDovL3NjaGVtYS5vcmcvUGVyc29u",
"column": "Tzox",
"timestamp": 1351372247689
},
{
"$": "aHR0cDovL3htbG5zLmNvbS9mb2FmLzAuMS9QZXJzb24=",
"column": "Tzoy",
"timestamp": 1351372555296
},
{
"$": "TWljaGFlbA==",
"column": "Tzoz",
"timestamp": 1351373497310
},
{
"$": "aHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zI3R5cGU=",
"column": "UDox",
"timestamp": 1351372243242
},
{
"$": "aHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zI3R5cGU=",
"column": "UDoy",
"timestamp": 1351372547894
},
{
"$": "aHR0cDovL3d3dy53My5vcmcvMjAwMC8wMS9yZGYtc2NoZW1hI2xhYmVs",
"column": "UDoz",
"timestamp": 1351373490159
}
],
"key": "aHR0cDovL21oYXVzZW5ibGFzLmluZm8vI2k="
}
]
}