[ 
https://issues.apache.org/jira/browse/HADOOP-2068?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

stack updated HADOOP-2068:
--------------------------

    Attachment: rest.patch

First cut at RESTful interface.  Implements metainfo, gets, and scanners.  Does 
not yet support put.  Bunch of TODOs:

+ Returning results multipart/related is crippled by lack of support in the 
container; jetty has a MultipartResponse class but can't set properly qualified 
Content-Type with boundary and start parameters... they get stripped.  Need to 
figure out how to fix this (maybe jetty 6 does it better).
+ Need to agree on timestamp format to use (ISO8601?)
+ Need to fix HTable so it has table metadata; until then, you need to specify 
a column getting a scanner.

Here's some samples run against a simple table named 'x' with column family 
'x:' with following contents:

{code}
Hbase> select * from x;
+-------------------------+-------------------------+-------------------------+
| Row                     | Column                  | Cell                    |
+-------------------------+-------------------------+-------------------------+
| x                       | x:                      | xyz                     |
+-------------------------+-------------------------+-------------------------+
| xyz                     | x:abc                   | abc                     |
+-------------------------+-------------------------+-------------------------+
| xyz                     | x:xyz                   | xyzxyz                  |
+-------------------------+-------------------------+-------------------------+
3 row(s) in set (0.19 sec)
{code}

In below session I'm using curl.  Doesn't have DELETE and I fake PUT with the 
-T option uploading a file:

{code}
$ curl http://localhost:60010/api/
<?xml version="1.0" encoding="UTF-8"?>
<tables>
 <table>
x
 </table>

$ curl --header 'Accept: text/plain' http://localhost:60010/api/
x

$ curl --header 'Accept: text/plain' http://localhost:60010/api/x
name: x, families: {x:={name: x, max versions: 3, compression: NONE, in memory: 
false, max length: 2147483647, bloom filter: none}}

$ curl --header 'Accept: text/xml' http://localhost:60010/api/x
<?xml version="1.0" encoding="UTF-8"?>
<table>
 <name>
x
 </name>
 <columnfamilies>
  <columnfamily>
   <name>
x:
   </name>
   <compression>
NONE
   </compression>
   <bloomfilter>
NONE
   </bloomfilter>
   <max-versions>
3
   </max-versions>
   <maximum-cell-size>
2147483647
   </maximum-cell-size>
  </columnfamily>
 </columnfamilies>
</table>

$ curl --header 'Accept: text/xml' http://localhost:60010/api/x/regions
<?xml version="1.0" encoding="UTF-8"?>
<regions>
 <region/>

# only one region and its start key is null, the default table start key

$ curl --verbose --header 'Accept: text/xml' 
http://localhost:60010/api/x/scanner
* About to connect() to localhost port 60010
*   Trying ::1... * connected
* Connected to localhost (::1) port 60010
> GET /api/x/scanner HTTP/1.1
User-Agent: curl/7.13.1 (powerpc-apple-darwin8.0) libcurl/7.13.1 OpenSSL/0.9.7l 
zlib/1.2.3
Host: localhost:60010
Pragma: no-cache
Accept: text/xml

< HTTP/1.1 404 No+handler
< Date: Mon, 19 Nov 2007 23:22:23 GMT
< Server: Jetty/5.1.4 (Mac OS X/10.4.10 i386 java/1.5.0_07
< Content-Type: text/html
< Content-Length: 1228
<html>
<head>
<title>Error 404 No handler</title>
</head>
<body>
...

# Fails because currently you must specify a column name (To be fixed)

$ curl --verbose --header 'Accept: text/xml' -T /tmp/diff.txt 
http://localhost:60010/api/x/scanner?column=x:
* About to connect() to localhost port 60010
*   Trying ::1... * connected
* Connected to localhost (::1) port 60010
> PUT /api/x/scanner?column=x: HTTP/1.1
User-Agent: curl/7.13.1 (powerpc-apple-darwin8.0) libcurl/7.13.1 OpenSSL/0.9.7l 
zlib/1.2.3
Host: localhost:60010
Pragma: no-cache
Accept: text/xml
Content-Length: 7096
Expect: 100-continue

< HTTP/1.1 100 Continue
< HTTP/1.1 201 Created
< Date: Mon, 19 Nov 2007 23:23:33 GMT
< Server: Jetty/5.1.4 (Mac OS X/10.4.10 i386 java/1.5.0_07
< Location: //api /x/scanner/88316f77
< Content-Length: 0
* Connection #0 to host localhost left intact
* Closing connection #0

$ curl --verbose --header 'Accept: text/xml' -T /tmp/diff.txt 
http://localhost:60010/api/x/scanner/88316f77 
* About to connect() to localhost port 60010
*   Trying ::1... * connected
* Connected to localhost (::1) port 60010
> PUT /api/x/scanner/88316f77 HTTP/1.1
User-Agent: curl/7.13.1 (powerpc-apple-darwin8.0) libcurl/7.13.1 OpenSSL/0.9.7l 
zlib/1.2.3
Host: localhost:60010
Pragma: no-cache
Accept: text/xml
Content-Length: 7096
Expect: 100-continue

< HTTP/1.1 100 Continue
< HTTP/1.1 200 OK
< Date: Mon, 19 Nov 2007 23:23:56 GMT
< Server: Jetty/5.1.4 (Mac OS X/10.4.10 i386 java/1.5.0_07
< Content-Type: text/xml;charset=UTF-8
< Transfer-Encoding: chunked
<?xml version="1.0" encoding="UTF-8"?>
<row>
 <name>
x
 </name>
 <timestamp>
1195372581842
 </timestamp>
 <column>
  <name>
x:
  </name>
  <value>
eHl6
  </value>
 </column>
* Connection #0 to host localhost left intact
* Closing connection #0
</row>


$ curl --verbose --header 'Accept: multipart/related' -T /' -T /tmp/diff.txt 
http://localhost:60010/api/x/scanner/88316f77
* About to connect() to localhost port 60010
*   Trying ::1... * connected
* Connected to localhost (::1) port 60010
> PUT /api/x/scanner/88316f77 HTTP/1.1
User-Agent: curl/7.13.1 (powerpc-apple-darwin8.0) libcurl/7.13.1 OpenSSL/0.9.7l 
zlib/1.2.3
Host: localhost:60010
Pragma: no-cache
Accept: multipart/related
Content-Length: 7096
Expect: 100-continue

< HTTP/1.1 100 Continue
< HTTP/1.1 200 OK
< Date: Mon, 19 Nov 2007 23:24:26 GMT
< Server: Jetty/5.1.4 (Mac OS X/10.4.10 i386 java/1.5.0_07
< Content-Type: multipart/related
< Content-Length: 814
--org.mortbay.http.MultiPartResponse.boundary.f97mkcfm
Content-Type: application/octet-stream
Content-Description: row
Content-Transfer-Encoding: binary
Content-Length: 3

xyz
--org.mortbay.http.MultiPartResponse.boundary.f97mkcfm
Content-Type: application/octet-stream
Content-Description: timestamp
Content-Transfer-Encoding: binary
Content-Length: 13

1195372609009
--org.mortbay.http.MultiPartResponse.boundary.f97mkcfm
Content-Type: application/octet-stream
Content-Description: x:abc
Content-Transfer-Encoding: binary
Content-Length: 3

abc
--org.mortbay.http.MultiPartResponse.boundary.f97mkcfm
Content-Type: application/octet-stream
Content-Description: x:xyz
Content-Transfer-Encoding: binary
Content-Length: 6

xyzxyz
--org.mortbay.http.MultiPartResponse.boundary.f97mkcfm--
* Connection #0 to host localhost left intact
* Closing connection #0

$ curl --verbose --header 'Accept: multipart/related'  
http://localhost:60010/api/x/row/x           
* About to connect() to localhost port 60010
*   Trying ::1... * connected
* Connected to localhost (::1) port 60010
> GET /api/x/row/x HTTP/1.1
User-Agent: curl/7.13.1 (powerpc-apple-darwin8.0) libcurl/7.13.1 OpenSSL/0.9.7l 
zlib/1.2.3
Host: localhost:60010
Pragma: no-cache
Accept: multipart/related

< HTTP/1.1 200 OK
< Date: Mon, 19 Nov 2007 23:24:55 GMT
< Server: Jetty/5.1.4 (Mac OS X/10.4.10 i386 java/1.5.0_07
< Content-Type: multipart/related
< Content-Length: 240
--org.mortbay.http.MultiPartResponse.boundary.f97mkyj8
Content-Type: application/octet-stream
Content-Description: x:
Content-Transfer-Encoding: binary
Content-Length: 3

xyz
--org.mortbay.http.MultiPartResponse.boundary.f97mkyj8--
* Connection #0 to host localhost left intact
* Closing connection #0

$ curl --verbose --header  http://localhost:60010/api/x/row/x
curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information
durruti:~/Documents/checkouts/hadoop-trunk stack$ curl --verbose  
http://localhost:60010/api/x/row/x
* About to connect() to localhost port 60010
*   Trying ::1... * connected
* Connected to localhost (::1) port 60010
> GET /api/x/row/x HTTP/1.1
User-Agent: curl/7.13.1 (powerpc-apple-darwin8.0) libcurl/7.13.1 OpenSSL/0.9.7l 
zlib/1.2.3
Host: localhost:60010
Pragma: no-cache
Accept: */*

< HTTP/1.1 200 OK
< Date: Mon, 19 Nov 2007 23:25:22 GMT
< Server: Jetty/5.1.4 (Mac OS X/10.4.10 i386 java/1.5.0_07
< Content-Type: text/xml;charset=UTF-8
< Transfer-Encoding: chunked
<?xml version="1.0" encoding="UTF-8"?>
<row>
 <column>
  <name>
x:
  </name>
  <value>
eHl6
  </value>
 </column>
* Connection #0 to host localhost left intact
* Closing connection #0
</row>
{code}


> [hbase] RESTful interface
> -------------------------
>
>                 Key: HADOOP-2068
>                 URL: https://issues.apache.org/jira/browse/HADOOP-2068
>             Project: Hadoop
>          Issue Type: New Feature
>          Components: contrib/hbase
>            Reporter: stack
>            Priority: Minor
>         Attachments: rest.patch
>
>
> A RESTful interface would be one means of making hbase accessible to clients 
> that are not java.  It might look something like the below:
> + An HTTP GET of  http://MASTER:PORT/ outputs the master's attributes: online 
> meta regions, list of tables, etc.: i.e. what you see now when you go to 
> http://MASTER:PORT/master.jsp.
> + An HTTP GET of http://MASTER:PORT/TABLENAME: 200 if tables exists and 
> HTableDescription (mimetype: text/plain or text/xml) or 401 if no such table. 
>  HTTP DELETE would drop the table.  HTTP PUT would add one.
> + An HTTP GET of http://MASTER:PORT/TABLENAME/ROW: 200 if row exists and 401 
> if not.
> + An HTTP GET of http://MASTER:PORT/TABLENAME/ROW/COLUMNFAMILY: 
> HColumnDescriptor (mimetype: text/plain or text/xml) or 401 if no such table.
> + An HTTP GET of http://MASTER:PORT/TABLENAME/ROW/COLUMNNAME/: 200 and latest 
> version (mimetype: binary/octet-stream) or 401 if no such cell. HTTP DELETE 
> would delete the cell.  HTTP PUT would add a new version.
> + An HTTP GET of http://MASTER:PORT/TABLENAME/ROW/COLUMNNAME/TIMESTAMP: 200 
> (mimetype: binary/octet-stream) or 401 if no such cell. HTTP DELETE would 
> remove.  HTTP PUT would put this record.
> + Browser originally goes against master but master then redirects to the 
> hosting region server to serve, update, delete, etc. the addressed cell

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to