From 16dabbf45f417fbd71e8d7ac4743317fc22ecb50 Mon Sep 17 00:00:00 2001 From: Guangxu Cheng Date: Fri, 25 Aug 2017 00:36:09 +0800 Subject: [PATCH] HBASE-18647 Parameter cacheBlocks does not take effect in REST API for scan --- .../java/org/apache/hadoop/hbase/rest/Constants.java | 1 + .../org/apache/hadoop/hbase/rest/TableResource.java | 5 ++--- .../apache/hadoop/hbase/rest/TableScanResource.java | 19 ++++++++----------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/Constants.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/Constants.java index 54ce117..9e1a224 100644 --- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/Constants.java +++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/Constants.java @@ -70,6 +70,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"; diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/TableResource.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/TableResource.java index 126328f..2127dad 100644 --- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/TableResource.java +++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/TableResource.java @@ -122,9 +122,7 @@ public class TableResource extends ResourceBase { @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="REC_CATCH_EXCEPTION") @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, @@ -134,7 +132,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 { @@ -204,6 +202,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 (Exception exp) { servlet.getMetrics().incrementFailedScanRequests(1); diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/TableScanResource.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/TableScanResource.java index 5cc2c7b..3effc01 100644 --- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/TableScanResource.java +++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/TableScanResource.java @@ -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 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); -- 1.9.5.msysgit.0