Search in sources :

Example 1 with StreamingOutput

use of org.apache.hbase.thirdparty.javax.ws.rs.core.StreamingOutput in project hbase by apache.

the class TableScanResource method getProtobuf.

@GET
@Produces({ Constants.MIMETYPE_PROTOBUF, Constants.MIMETYPE_PROTOBUF_IETF })
public Response getProtobuf(@Context final UriInfo uriInfo, @HeaderParam("Accept") final String contentType) {
    if (LOG.isTraceEnabled()) {
        LOG.trace("GET " + uriInfo.getAbsolutePath() + " as " + MIMETYPE_BINARY);
    }
    servlet.getMetrics().incrementRequests(1);
    try {
        int fetchSize = this.servlet.getConfiguration().getInt(Constants.SCAN_FETCH_SIZE, 10);
        StreamingOutput stream = new ProtobufStreamingOutput(this.results, contentType, userRequestedLimit, fetchSize);
        servlet.getMetrics().incrementSucessfulScanRequests(1);
        ResponseBuilder response = Response.ok(stream);
        response.header("content-type", contentType);
        return response.build();
    } catch (Exception exp) {
        servlet.getMetrics().incrementFailedScanRequests(1);
        processException(exp);
        LOG.warn(exp.toString(), exp);
        return null;
    }
}
Also used : StreamingOutput(org.apache.hbase.thirdparty.javax.ws.rs.core.StreamingOutput) ResponseBuilder(org.apache.hbase.thirdparty.javax.ws.rs.core.Response.ResponseBuilder) IOException(java.io.IOException) Produces(org.apache.hbase.thirdparty.javax.ws.rs.Produces) GET(org.apache.hbase.thirdparty.javax.ws.rs.GET)

Aggregations

IOException (java.io.IOException)1 GET (org.apache.hbase.thirdparty.javax.ws.rs.GET)1 Produces (org.apache.hbase.thirdparty.javax.ws.rs.Produces)1 ResponseBuilder (org.apache.hbase.thirdparty.javax.ws.rs.core.Response.ResponseBuilder)1 StreamingOutput (org.apache.hbase.thirdparty.javax.ws.rs.core.StreamingOutput)1