HBASE-18647 Parameter cacheBlocks does not take effect in REST API for scan

Signed-off-by: tedyu <yuzhihong@gmail.com>
This commit is contained in:
Guangxu Cheng 2017-08-22 11:29:32 +08:00 committed by tedyu
parent ec7bca1769
commit 08212e50ff
3 changed files with 11 additions and 14 deletions

View File

@ -78,6 +78,7 @@ public interface Constants {
String SCAN_FETCH_SIZE = "hbase.rest.scan.fetchsize";
String SCAN_FILTER = "filter";
String SCAN_REVERSED = "reversed";
String SCAN_CACHE_BLOCKS = "cacheblocks";
String CUSTOM_FILTERS = "hbase.rest.custom.filters";
String ROW_KEYS_PARAM_NAME = "row";

View File

@ -121,9 +121,7 @@ public class TableResource extends ResourceBase {
@Path("{scanspec: .*[*]$}")
public TableScanResource getScanResource(
final @Context UriInfo uriInfo,
final @PathParam("scanspec") String scanSpec,
final @HeaderParam("Accept") String contentType,
@DefaultValue(Integer.MAX_VALUE + "")
@QueryParam(Constants.SCAN_LIMIT) int userRequestedLimit,
@DefaultValue("") @QueryParam(Constants.SCAN_START_ROW) String startRow,
@ -133,7 +131,7 @@ public class TableResource extends ResourceBase {
@DefaultValue("-1") @QueryParam(Constants.SCAN_BATCH_SIZE) int batchSize,
@DefaultValue("0") @QueryParam(Constants.SCAN_START_TIME) long startTime,
@DefaultValue(Long.MAX_VALUE + "") @QueryParam(Constants.SCAN_END_TIME) long endTime,
@DefaultValue("true") @QueryParam(Constants.SCAN_BATCH_SIZE) boolean cacheBlocks,
@DefaultValue("true") @QueryParam(Constants.SCAN_CACHE_BLOCKS) boolean cacheBlocks,
@DefaultValue("false") @QueryParam(Constants.SCAN_REVERSED) boolean reversed,
@DefaultValue("") @QueryParam(Constants.SCAN_FILTER) String paramFilter) {
try {
@ -201,6 +199,7 @@ public class TableResource extends ResourceBase {
int fetchSize = this.servlet.getConfiguration().getInt(Constants.SCAN_FETCH_SIZE, 10);
tableScan.setCaching(fetchSize);
tableScan.setReversed(reversed);
tableScan.setCacheBlocks(cacheBlocks);
return new TableScanResource(hTable.getScanner(tableScan), userRequestedLimit);
} catch (IOException exp) {
servlet.getMetrics().incrementFailedScanRequests(1);

View File

@ -67,6 +67,9 @@ public class TableScanResource extends ResourceBase {
@GET
@Produces({ Constants.MIMETYPE_XML, Constants.MIMETYPE_JSON })
public CellSetModelStream get(final @Context UriInfo uriInfo) {
if (LOG.isTraceEnabled()) {
LOG.trace("GET " + uriInfo.getAbsolutePath());
}
servlet.getMetrics().incrementRequests(1);
final int rowsToSend = userRequestedLimit;
servlet.getMetrics().incrementSucessfulScanRequests(1);
@ -116,17 +119,11 @@ public class TableScanResource extends ResourceBase {
@Produces({ Constants.MIMETYPE_PROTOBUF, Constants.MIMETYPE_PROTOBUF_IETF })
public Response getProtobuf(
final @Context UriInfo uriInfo,
final @PathParam("scanspec") String scanSpec,
final @HeaderParam("Accept") String contentType,
@DefaultValue(Integer.MAX_VALUE + "") @QueryParam(Constants.SCAN_LIMIT) int userRequestedLimit,
@DefaultValue("") @QueryParam(Constants.SCAN_START_ROW) String startRow,
@DefaultValue("") @QueryParam(Constants.SCAN_END_ROW) String endRow,
@DefaultValue("column") @QueryParam(Constants.SCAN_COLUMN) List<String> column,
@DefaultValue("1") @QueryParam(Constants.SCAN_MAX_VERSIONS) int maxVersions,
@DefaultValue("-1") @QueryParam(Constants.SCAN_BATCH_SIZE) int batchSize,
@DefaultValue("0") @QueryParam(Constants.SCAN_START_TIME) long startTime,
@DefaultValue(Long.MAX_VALUE + "") @QueryParam(Constants.SCAN_END_TIME) long endTime,
@DefaultValue("true") @QueryParam(Constants.SCAN_BATCH_SIZE) boolean cacheBlocks) {
final @HeaderParam("Accept") 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);