You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by 梁爽 <ls...@gmail.com> on 2010/03/25 10:27:58 UTC
About URL character escape in HBase Rest Servlet
Hi,
I'm using hadoop 0.20.1 and hbase 0.20.3. I have stargate running in
tomcat and use apache as a proxy, and it works fine.
But here is the problem.
Some of my row key have special character like '/'.
If I request http://hostname/hbase-service/someTableName/someKey, it
returns the data.
But the someKey might be "aaa/bbb/ccc.xml".
So I request http://hostname/hbase-service/someTableName/aaa/bbb/ccc.xml,
it not work of course.
If I escape '/', and use
http://hostname/hbase-service/someTableName/aaa%2Fbbb%2Fccc.xml, it
still not working.
So my question is there some other rule to escape any reserved
character in my url.
Thanks in advance!
Shuang Liang
Re: About URL character escape in HBase Rest Servlet
Posted by 梁爽 <ls...@gmail.com>.
Hi Andrew,
Here you can see I have two rows in my test table:
hbase(main):003:0> get 'testTable', 'row1'
COLUMN CELL
colFami1:col1 timestamp=1269484846077, value=value2
colFami1:col2 timestamp=1269503636424, value=testVal1
2 row(s) in 0.0100 seconds
hbase(main):007:0> get 'testTable', 'aaaa/bbbb/cccc.xml'
COLUMN CELL
colFami1:col1 timestamp=1269505604555, value=testData
1 row(s) in 0.0180 seconds
Then I use curl for testing:
This works:
$ curl http://localhost:8080/hbase/testTable/row1
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><CellSet><Row
key="cm93MQ=="><Cell timestamp="1269484846077"
column="Y29sRmFtaTE6Y29sMQ==">dmFsdWUy</Cell><Cell
timestamp="1267508585590"
column="Y29sRmFtaTE6Y29sMQ==">dGVzdFZhbA==</Cell><Cell
timestamp="1269503636424"
column="Y29sRmFtaTE6Y29sMg==">dGVzdFZhbDE=</Cell></Row></CellSet>
This got nothing, even no 404.
$ curl http://localhost:8080/hbase/testTable/aaaa%2Fbbbb%2Fcccc.xml
And I check the log of my tomcat, no exceptions.(You may check the
attached tomcat log yourself.)
I also provide the directory tree and web.xml.
Thanks,
Shuang Liang
2010/3/25 Andrew Purtell <ap...@apache.org>:
> 梁爽,
>
>> I'm using hadoop 0.20.1 and hbase 0.20.3. I have stargate
>> running in tomcat and use apache as a proxy
>> But here is the problem.
>> Some of my row key have special character like '/'.
>
> Can you provide more detail? Anything in the Stargate log? Or Tomcat log? Or Apache log?
>
> We have a simple unit test that checks this:
>
> public void testURLEncodedKey() throws IOException, JAXBException {
> String encodedKey = URLEncoder.encode("http://www.google.com/",
> HConstants.UTF8_ENCODING);
> Response response;
> response = putValueXML(TABLE, encodedKey, COLUMN_1, VALUE_1);
> assertEquals(response.getCode(), 200);
> response = putValuePB(TABLE, encodedKey, COLUMN_2, VALUE_2);
> assertEquals(response.getCode(), 200);
> checkValuePB(TABLE, encodedKey, COLUMN_1, VALUE_1);
> checkValueXML(TABLE, encodedKey, COLUMN_2, VALUE_2);
> }
>
> The above test encodes '/' as %2F and passes. But this test hosts the Stargate servlet in a Jetty container. It does not test what might happen with Tomcat and/or a httpd proxy. Without more information it's hard to know what might be going on.
>
> Best regards,
>
> - Andy
>
>
>
>
>
>
Re: About URL character escape in HBase Rest Servlet
Posted by Andrew Purtell <ap...@apache.org>.
梁爽,
> I'm using hadoop 0.20.1 and hbase 0.20.3. I have stargate
> running in tomcat and use apache as a proxy
> But here is the problem.
> Some of my row key have special character like '/'.
Can you provide more detail? Anything in the Stargate log? Or Tomcat log? Or Apache log?
We have a simple unit test that checks this:
public void testURLEncodedKey() throws IOException, JAXBException {
String encodedKey = URLEncoder.encode("http://www.google.com/",
HConstants.UTF8_ENCODING);
Response response;
response = putValueXML(TABLE, encodedKey, COLUMN_1, VALUE_1);
assertEquals(response.getCode(), 200);
response = putValuePB(TABLE, encodedKey, COLUMN_2, VALUE_2);
assertEquals(response.getCode(), 200);
checkValuePB(TABLE, encodedKey, COLUMN_1, VALUE_1);
checkValueXML(TABLE, encodedKey, COLUMN_2, VALUE_2);
}
The above test encodes '/' as %2F and passes. But this test hosts the Stargate servlet in a Jetty container. It does not test what might happen with Tomcat and/or a httpd proxy. Without more information it's hard to know what might be going on.
Best regards,
- Andy