HBASE-4105 Stargate does not support json and gzip in parallel

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1150190 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew Kyle Purtell 2011-07-23 19:04:08 +00:00
parent 81897bd47f
commit 4b21f2e32b
3 changed files with 33 additions and 13 deletions

View File

@ -169,6 +169,8 @@ Release 0.91.0 - Unreleased
HBASE-4118 method regionserver.MemStore#updateColumnValue: the check for
qualifier and family is missing (N Keywal via Ted Yu)
HBASE-4127 Don't modify table's name away in HBaseAdmin
HBASE-4105 Stargate does not support Content-Type: application/json and
Content-Encoding: gzip in parallel
IMPROVEMENTS
HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack)

View File

@ -29,7 +29,7 @@ import javax.servlet.http.HttpServletResponseWrapper;
public class GZIPResponseWrapper extends HttpServletResponseWrapper {
private HttpServletResponse response;
private GZIPResponseStream os;
private ServletOutputStream os;
private PrintWriter writer;
private boolean compress = true;
@ -40,6 +40,7 @@ public class GZIPResponseWrapper extends HttpServletResponseWrapper {
@Override
public void setStatus(int status) {
super.setStatus(status);
if (status < 200 || status >= 300) {
compress = false;
}
@ -76,8 +77,8 @@ public class GZIPResponseWrapper extends HttpServletResponseWrapper {
if (writer != null) {
writer.flush();
}
if (os != null) {
os.finish();
if (os != null && (os instanceof GZIPResponseStream)) {
((GZIPResponseStream)os).finish();
} else {
getResponse().flushBuffer();
}
@ -86,8 +87,8 @@ public class GZIPResponseWrapper extends HttpServletResponseWrapper {
@Override
public void reset() {
super.reset();
if (os != null) {
os.resetBuffer();
if (os != null && (os instanceof GZIPResponseStream)) {
((GZIPResponseStream)os).resetBuffer();
}
writer = null;
os = null;
@ -97,8 +98,8 @@ public class GZIPResponseWrapper extends HttpServletResponseWrapper {
@Override
public void resetBuffer() {
super.resetBuffer();
if (os != null) {
os.resetBuffer();
if (os != null && (os instanceof GZIPResponseStream)) {
((GZIPResponseStream)os).resetBuffer();
}
writer = null;
os = null;
@ -124,14 +125,14 @@ public class GZIPResponseWrapper extends HttpServletResponseWrapper {
@Override
public ServletOutputStream getOutputStream() throws IOException {
if (!response.isCommitted() && compress) {
if (os == null) {
os = new GZIPResponseStream(response);
if (!response.isCommitted() && compress) {
os = (ServletOutputStream)new GZIPResponseStream(response);
} else {
os = response.getOutputStream();
}
}
return os;
} else {
return response.getOutputStream();
}
}
@Override

View File

@ -132,4 +132,21 @@ public class TestGzipFilter {
contentEncoding = response.getHeader("Content-Encoding");
assertTrue(contentEncoding == null || !contentEncoding.contains("gzip"));
}
@Test
public void testScannerResultCodes() throws Exception {
Header[] headers = new Header[3];
headers[0] = new Header("Content-Type", Constants.MIMETYPE_XML);
headers[1] = new Header("Accept", Constants.MIMETYPE_JSON);
headers[2] = new Header("Accept-Encoding", "gzip");
Response response = client.post("/" + TABLE + "/scanner", headers,
"<Scanner/>".getBytes());
assertEquals(response.getCode(), 201);
String scannerUrl = response.getLocation();
assertNotNull(scannerUrl);
response = client.get(scannerUrl);
assertEquals(response.getCode(), 200);
response = client.get(scannerUrl);
assertEquals(response.getCode(), 204);
}
}