HBASE-10952 [REST] Let the user turn off block caching if desired
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1589318 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ff916906a3
commit
4bf297b2d9
|
@ -27,7 +27,9 @@ import org.apache.hadoop.classification.InterfaceStability;
|
|||
@InterfaceAudience.Public
|
||||
@InterfaceStability.Stable
|
||||
public interface Constants {
|
||||
String VERSION_STRING = "0.0.2";
|
||||
// All constants in a public interface are 'public static final'
|
||||
|
||||
String VERSION_STRING = "0.0.3";
|
||||
|
||||
int DEFAULT_MAX_AGE = 60 * 60 * 4; // 4 hours
|
||||
|
||||
|
@ -43,30 +45,32 @@ public interface Constants {
|
|||
|
||||
String CRLF = "\r\n";
|
||||
|
||||
static final String REST_KEYTAB_FILE = "hbase.rest.keytab.file";
|
||||
static final String REST_KERBEROS_PRINCIPAL = "hbase.rest.kerberos.principal";
|
||||
static final String REST_AUTHENTICATION_TYPE = "hbase.rest.authentication.type";
|
||||
static final String REST_AUTHENTICATION_PRINCIPAL =
|
||||
"hbase.rest.authentication.kerberos.principal";
|
||||
String REST_KEYTAB_FILE = "hbase.rest.keytab.file";
|
||||
String REST_KERBEROS_PRINCIPAL = "hbase.rest.kerberos.principal";
|
||||
String REST_AUTHENTICATION_TYPE = "hbase.rest.authentication.type";
|
||||
String REST_AUTHENTICATION_PRINCIPAL = "hbase.rest.authentication.kerberos.principal";
|
||||
|
||||
static final String REST_SSL_ENABLED = "hbase.rest.ssl.enabled";
|
||||
static final String REST_SSL_KEYSTORE_STORE = "hbase.rest.ssl.keystore.store";
|
||||
static final String REST_SSL_KEYSTORE_PASSWORD = "hbase.rest.ssl.keystore.password";
|
||||
static final String REST_SSL_KEYSTORE_KEYPASSWORD =
|
||||
"hbase.rest.ssl.keystore.keypassword";
|
||||
String REST_SSL_ENABLED = "hbase.rest.ssl.enabled";
|
||||
String REST_SSL_KEYSTORE_STORE = "hbase.rest.ssl.keystore.store";
|
||||
String REST_SSL_KEYSTORE_PASSWORD = "hbase.rest.ssl.keystore.password";
|
||||
String REST_SSL_KEYSTORE_KEYPASSWORD = "hbase.rest.ssl.keystore.keypassword";
|
||||
|
||||
static final String REST_DNS_NAMESERVER = "hbase.rest.dns.nameserver";
|
||||
static final String REST_DNS_INTERFACE = "hbase.rest.dns.interface";
|
||||
String REST_DNS_NAMESERVER = "hbase.rest.dns.nameserver";
|
||||
String REST_DNS_INTERFACE = "hbase.rest.dns.interface";
|
||||
|
||||
public static final String FILTER_CLASSES = "hbase.rest.filter.classes";
|
||||
public static final String SCAN_START_ROW = "startrow";
|
||||
public static final String SCAN_END_ROW = "endrow";
|
||||
public static final String SCAN_COLUMN = "column";
|
||||
public static final String SCAN_START_TIME = "starttime";
|
||||
public static final String SCAN_END_TIME = "endtime";
|
||||
public static final String SCAN_MAX_VERSIONS = "maxversions";
|
||||
public static final String SCAN_BATCH_SIZE = "batchsize";
|
||||
public static final String SCAN_LIMIT = "limit";
|
||||
public static final String SCAN_FETCH_SIZE = "hbase.rest.scan.fetchsize";
|
||||
String FILTER_CLASSES = "hbase.rest.filter.classes";
|
||||
String SCAN_START_ROW = "startrow";
|
||||
String SCAN_END_ROW = "endrow";
|
||||
String SCAN_COLUMN = "column";
|
||||
String SCAN_START_TIME = "starttime";
|
||||
String SCAN_END_TIME = "endtime";
|
||||
String SCAN_MAX_VERSIONS = "maxversions";
|
||||
String SCAN_BATCH_SIZE = "batchsize";
|
||||
String SCAN_LIMIT = "limit";
|
||||
String SCAN_FETCH_SIZE = "hbase.rest.scan.fetchsize";
|
||||
|
||||
String ROW_KEYS_PARAM_NAME = "row";
|
||||
/** If this query parameter is present when processing row or scanner resources,
|
||||
it disables server side block caching */
|
||||
String NOCACHE_PARAM_NAME = "nocache";
|
||||
}
|
||||
|
|
|
@ -37,9 +37,8 @@ import org.apache.hadoop.hbase.rest.model.CellSetModel;
|
|||
import org.apache.hadoop.hbase.rest.model.RowModel;
|
||||
|
||||
@InterfaceAudience.Private
|
||||
public class MultiRowResource extends ResourceBase {
|
||||
public class MultiRowResource extends ResourceBase implements Constants {
|
||||
private static final Log LOG = LogFactory.getLog(MultiRowResource.class);
|
||||
public static final String ROW_KEYS_PARAM_NAME = "row";
|
||||
|
||||
TableResource tableResource;
|
||||
Integer versions = null;
|
||||
|
@ -75,9 +74,9 @@ public class MultiRowResource extends ResourceBase {
|
|||
if (this.versions != null) {
|
||||
rowSpec.setMaxVersions(this.versions);
|
||||
}
|
||||
|
||||
ResultGenerator generator =
|
||||
ResultGenerator.fromRowSpec(this.tableResource.getName(), rowSpec, null);
|
||||
ResultGenerator.fromRowSpec(this.tableResource.getName(), rowSpec, null,
|
||||
!params.containsKey(NOCACHE_PARAM_NAME));
|
||||
Cell value = null;
|
||||
RowModel rowModel = new RowModel(rk);
|
||||
if (generator.hasNext()) {
|
||||
|
|
|
@ -31,11 +31,12 @@ import org.apache.hadoop.hbase.rest.model.ScannerModel;
|
|||
public abstract class ResultGenerator implements Iterator<Cell> {
|
||||
|
||||
public static ResultGenerator fromRowSpec(final String table,
|
||||
final RowSpec rowspec, final Filter filter) throws IOException {
|
||||
final RowSpec rowspec, final Filter filter, final boolean cacheBlocks)
|
||||
throws IOException {
|
||||
if (rowspec.isSingleRow()) {
|
||||
return new RowResultGenerator(table, rowspec, filter);
|
||||
return new RowResultGenerator(table, rowspec, filter, cacheBlocks);
|
||||
} else {
|
||||
return new ScannerResultGenerator(table, rowspec, filter);
|
||||
return new ScannerResultGenerator(table, rowspec, filter, cacheBlocks);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ import javax.ws.rs.PUT;
|
|||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.ResponseBuilder;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
@ -88,9 +89,11 @@ public class RowResource extends ResourceBase {
|
|||
LOG.debug("GET " + uriInfo.getAbsolutePath());
|
||||
}
|
||||
servlet.getMetrics().incrementRequests(1);
|
||||
MultivaluedMap<String, String> params = uriInfo.getQueryParameters();
|
||||
try {
|
||||
ResultGenerator generator =
|
||||
ResultGenerator.fromRowSpec(tableResource.getName(), rowspec, null);
|
||||
ResultGenerator.fromRowSpec(tableResource.getName(), rowspec, null,
|
||||
!params.containsKey(NOCACHE_PARAM_NAME));
|
||||
if (!generator.hasNext()) {
|
||||
servlet.getMetrics().incrementFailedGetRequests(1);
|
||||
return Response.status(Response.Status.NOT_FOUND)
|
||||
|
@ -138,9 +141,11 @@ public class RowResource extends ResourceBase {
|
|||
return Response.status(Response.Status.BAD_REQUEST).type(MIMETYPE_TEXT)
|
||||
.entity("Bad request: Either 0 or more than 1 columns specified." + CRLF).build();
|
||||
}
|
||||
MultivaluedMap<String, String> params = uriInfo.getQueryParameters();
|
||||
try {
|
||||
ResultGenerator generator =
|
||||
ResultGenerator.fromRowSpec(tableResource.getName(), rowspec, null);
|
||||
ResultGenerator.fromRowSpec(tableResource.getName(), rowspec, null,
|
||||
!params.containsKey(NOCACHE_PARAM_NAME));
|
||||
if (!generator.hasNext()) {
|
||||
servlet.getMetrics().incrementFailedGetRequests(1);
|
||||
return Response.status(Response.Status.NOT_FOUND)
|
||||
|
|
|
@ -43,7 +43,8 @@ public class RowResultGenerator extends ResultGenerator {
|
|||
private Cell cache;
|
||||
|
||||
public RowResultGenerator(final String tableName, final RowSpec rowspec,
|
||||
final Filter filter) throws IllegalArgumentException, IOException {
|
||||
final Filter filter, final boolean cacheBlocks)
|
||||
throws IllegalArgumentException, IOException {
|
||||
HTableInterface table = RESTServlet.getInstance().getTable(tableName);
|
||||
try {
|
||||
Get get = new Get(rowspec.getRow());
|
||||
|
@ -64,6 +65,7 @@ public class RowResultGenerator extends ResultGenerator {
|
|||
if (filter != null) {
|
||||
get.setFilter(filter);
|
||||
}
|
||||
get.setCacheBlocks(cacheBlocks);
|
||||
Result result = table.get(get);
|
||||
if (result != null && !result.isEmpty()) {
|
||||
valuesI = result.listCells().iterator();
|
||||
|
|
|
@ -31,6 +31,7 @@ import javax.ws.rs.PUT;
|
|||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriBuilder;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
@ -90,11 +91,14 @@ public class ScannerResource extends ResourceBase {
|
|||
spec = new RowSpec(model.getStartRow(), endRow, model.getColumns(), model.getStartTime(),
|
||||
model.getEndTime(), model.getMaxVersions());
|
||||
}
|
||||
MultivaluedMap<String, String> params = uriInfo.getQueryParameters();
|
||||
|
||||
try {
|
||||
Filter filter = ScannerResultGenerator.buildFilterFromModel(model);
|
||||
String tableName = tableResource.getName();
|
||||
ScannerResultGenerator gen =
|
||||
new ScannerResultGenerator(tableName, spec, filter, model.getCaching());
|
||||
new ScannerResultGenerator(tableName, spec, filter, model.getCaching(),
|
||||
model.getCacheBlocks());
|
||||
String id = gen.getID();
|
||||
ScannerInstanceResource instance =
|
||||
new ScannerInstanceResource(tableName, id, gen, model.getBatch());
|
||||
|
|
|
@ -59,12 +59,14 @@ public class ScannerResultGenerator extends ResultGenerator {
|
|||
private Result cached;
|
||||
|
||||
public ScannerResultGenerator(final String tableName, final RowSpec rowspec,
|
||||
final Filter filter) throws IllegalArgumentException, IOException {
|
||||
this(tableName, rowspec, filter, -1);
|
||||
final Filter filter, final boolean cacheBlocks)
|
||||
throws IllegalArgumentException, IOException {
|
||||
this(tableName, rowspec, filter, -1, cacheBlocks);
|
||||
}
|
||||
|
||||
public ScannerResultGenerator(final String tableName, final RowSpec rowspec,
|
||||
final Filter filter, final int caching) throws IllegalArgumentException, IOException {
|
||||
final Filter filter, final int caching, final boolean cacheBlocks)
|
||||
throws IllegalArgumentException, IOException {
|
||||
HTableInterface table = RESTServlet.getInstance().getTable(tableName);
|
||||
try {
|
||||
Scan scan;
|
||||
|
@ -94,6 +96,7 @@ public class ScannerResultGenerator extends ResultGenerator {
|
|||
if (caching > 0 ) {
|
||||
scan.setCaching(caching);
|
||||
}
|
||||
scan.setCacheBlocks(cacheBlocks);
|
||||
if (rowspec.hasLabels()) {
|
||||
scan.setAuthorizations(new Authorizations(rowspec.getLabels()));
|
||||
}
|
||||
|
|
|
@ -116,6 +116,7 @@ public class ScannerModel implements ProtobufMessageHandler, Serializable {
|
|||
private int maxVersions = Integer.MAX_VALUE;
|
||||
private int caching = -1;
|
||||
private List<String> labels = new ArrayList<String>();
|
||||
private boolean cacheBlocks = true;
|
||||
|
||||
@XmlRootElement
|
||||
static class FilterModel {
|
||||
|
@ -666,6 +667,14 @@ public class ScannerModel implements ProtobufMessageHandler, Serializable {
|
|||
return caching;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if HFile blocks should be cached on the servers for this scan, false otherwise
|
||||
*/
|
||||
@XmlAttribute
|
||||
public boolean getCacheBlocks() {
|
||||
return cacheBlocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lower bound on timestamps of items of interest
|
||||
*/
|
||||
|
@ -733,6 +742,13 @@ public class ScannerModel implements ProtobufMessageHandler, Serializable {
|
|||
this.caching = caching;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value true if HFile blocks should be cached on the servers for this scan, false otherwise
|
||||
*/
|
||||
public void setCacheBlocks(boolean value) {
|
||||
this.cacheBlocks = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param maxVersions maximum number of versions to return
|
||||
*/
|
||||
|
@ -791,6 +807,7 @@ public class ScannerModel implements ProtobufMessageHandler, Serializable {
|
|||
for (String label : labels)
|
||||
builder.addLabels(label);
|
||||
}
|
||||
builder.setCacheBlocks(cacheBlocks);
|
||||
return builder.build().toByteArray();
|
||||
}
|
||||
|
||||
|
@ -826,12 +843,15 @@ public class ScannerModel implements ProtobufMessageHandler, Serializable {
|
|||
if (builder.hasFilter()) {
|
||||
filter = builder.getFilter();
|
||||
}
|
||||
if(builder.getLabelsList() != null) {
|
||||
if (builder.getLabelsList() != null) {
|
||||
List<String> labels = builder.getLabelsList();
|
||||
for(String label : labels) {
|
||||
addLabel(label);
|
||||
}
|
||||
}
|
||||
if (builder.hasCacheBlocks()) {
|
||||
this.cacheBlocks = builder.getCacheBlocks();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -103,10 +103,18 @@ public final class ScannerMessage {
|
|||
// optional int32 caching = 9;
|
||||
/**
|
||||
* <code>optional int32 caching = 9;</code>
|
||||
*
|
||||
* <pre>
|
||||
* specifies REST scanner caching
|
||||
* </pre>
|
||||
*/
|
||||
boolean hasCaching();
|
||||
/**
|
||||
* <code>optional int32 caching = 9;</code>
|
||||
*
|
||||
* <pre>
|
||||
* specifies REST scanner caching
|
||||
* </pre>
|
||||
*/
|
||||
int getCaching();
|
||||
|
||||
|
@ -129,6 +137,24 @@ public final class ScannerMessage {
|
|||
*/
|
||||
com.google.protobuf.ByteString
|
||||
getLabelsBytes(int index);
|
||||
|
||||
// optional bool cacheBlocks = 11;
|
||||
/**
|
||||
* <code>optional bool cacheBlocks = 11;</code>
|
||||
*
|
||||
* <pre>
|
||||
* server side block caching hint
|
||||
* </pre>
|
||||
*/
|
||||
boolean hasCacheBlocks();
|
||||
/**
|
||||
* <code>optional bool cacheBlocks = 11;</code>
|
||||
*
|
||||
* <pre>
|
||||
* server side block caching hint
|
||||
* </pre>
|
||||
*/
|
||||
boolean getCacheBlocks();
|
||||
}
|
||||
/**
|
||||
* Protobuf type {@code org.apache.hadoop.hbase.rest.protobuf.generated.Scanner}
|
||||
|
@ -237,6 +263,11 @@ public final class ScannerMessage {
|
|||
labels_.add(input.readBytes());
|
||||
break;
|
||||
}
|
||||
case 88: {
|
||||
bitField0_ |= 0x00000100;
|
||||
cacheBlocks_ = input.readBool();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
|
@ -450,12 +481,20 @@ public final class ScannerMessage {
|
|||
private int caching_;
|
||||
/**
|
||||
* <code>optional int32 caching = 9;</code>
|
||||
*
|
||||
* <pre>
|
||||
* specifies REST scanner caching
|
||||
* </pre>
|
||||
*/
|
||||
public boolean hasCaching() {
|
||||
return ((bitField0_ & 0x00000080) == 0x00000080);
|
||||
}
|
||||
/**
|
||||
* <code>optional int32 caching = 9;</code>
|
||||
*
|
||||
* <pre>
|
||||
* specifies REST scanner caching
|
||||
* </pre>
|
||||
*/
|
||||
public int getCaching() {
|
||||
return caching_;
|
||||
|
@ -491,6 +530,30 @@ public final class ScannerMessage {
|
|||
return labels_.getByteString(index);
|
||||
}
|
||||
|
||||
// optional bool cacheBlocks = 11;
|
||||
public static final int CACHEBLOCKS_FIELD_NUMBER = 11;
|
||||
private boolean cacheBlocks_;
|
||||
/**
|
||||
* <code>optional bool cacheBlocks = 11;</code>
|
||||
*
|
||||
* <pre>
|
||||
* server side block caching hint
|
||||
* </pre>
|
||||
*/
|
||||
public boolean hasCacheBlocks() {
|
||||
return ((bitField0_ & 0x00000100) == 0x00000100);
|
||||
}
|
||||
/**
|
||||
* <code>optional bool cacheBlocks = 11;</code>
|
||||
*
|
||||
* <pre>
|
||||
* server side block caching hint
|
||||
* </pre>
|
||||
*/
|
||||
public boolean getCacheBlocks() {
|
||||
return cacheBlocks_;
|
||||
}
|
||||
|
||||
private void initFields() {
|
||||
startRow_ = com.google.protobuf.ByteString.EMPTY;
|
||||
endRow_ = com.google.protobuf.ByteString.EMPTY;
|
||||
|
@ -502,6 +565,7 @@ public final class ScannerMessage {
|
|||
filter_ = "";
|
||||
caching_ = 0;
|
||||
labels_ = com.google.protobuf.LazyStringArrayList.EMPTY;
|
||||
cacheBlocks_ = false;
|
||||
}
|
||||
private byte memoizedIsInitialized = -1;
|
||||
public final boolean isInitialized() {
|
||||
|
@ -545,6 +609,9 @@ public final class ScannerMessage {
|
|||
for (int i = 0; i < labels_.size(); i++) {
|
||||
output.writeBytes(10, labels_.getByteString(i));
|
||||
}
|
||||
if (((bitField0_ & 0x00000100) == 0x00000100)) {
|
||||
output.writeBool(11, cacheBlocks_);
|
||||
}
|
||||
getUnknownFields().writeTo(output);
|
||||
}
|
||||
|
||||
|
@ -604,6 +671,10 @@ public final class ScannerMessage {
|
|||
size += dataSize;
|
||||
size += 1 * getLabelsList().size();
|
||||
}
|
||||
if (((bitField0_ & 0x00000100) == 0x00000100)) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeBoolSize(11, cacheBlocks_);
|
||||
}
|
||||
size += getUnknownFields().getSerializedSize();
|
||||
memoizedSerializedSize = size;
|
||||
return size;
|
||||
|
@ -740,6 +811,8 @@ public final class ScannerMessage {
|
|||
bitField0_ = (bitField0_ & ~0x00000100);
|
||||
labels_ = com.google.protobuf.LazyStringArrayList.EMPTY;
|
||||
bitField0_ = (bitField0_ & ~0x00000200);
|
||||
cacheBlocks_ = false;
|
||||
bitField0_ = (bitField0_ & ~0x00000400);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -811,6 +884,10 @@ public final class ScannerMessage {
|
|||
bitField0_ = (bitField0_ & ~0x00000200);
|
||||
}
|
||||
result.labels_ = labels_;
|
||||
if (((from_bitField0_ & 0x00000400) == 0x00000400)) {
|
||||
to_bitField0_ |= 0x00000100;
|
||||
}
|
||||
result.cacheBlocks_ = cacheBlocks_;
|
||||
result.bitField0_ = to_bitField0_;
|
||||
onBuilt();
|
||||
return result;
|
||||
|
@ -873,6 +950,9 @@ public final class ScannerMessage {
|
|||
}
|
||||
onChanged();
|
||||
}
|
||||
if (other.hasCacheBlocks()) {
|
||||
setCacheBlocks(other.getCacheBlocks());
|
||||
}
|
||||
this.mergeUnknownFields(other.getUnknownFields());
|
||||
return this;
|
||||
}
|
||||
|
@ -1254,18 +1334,30 @@ public final class ScannerMessage {
|
|||
private int caching_ ;
|
||||
/**
|
||||
* <code>optional int32 caching = 9;</code>
|
||||
*
|
||||
* <pre>
|
||||
* specifies REST scanner caching
|
||||
* </pre>
|
||||
*/
|
||||
public boolean hasCaching() {
|
||||
return ((bitField0_ & 0x00000100) == 0x00000100);
|
||||
}
|
||||
/**
|
||||
* <code>optional int32 caching = 9;</code>
|
||||
*
|
||||
* <pre>
|
||||
* specifies REST scanner caching
|
||||
* </pre>
|
||||
*/
|
||||
public int getCaching() {
|
||||
return caching_;
|
||||
}
|
||||
/**
|
||||
* <code>optional int32 caching = 9;</code>
|
||||
*
|
||||
* <pre>
|
||||
* specifies REST scanner caching
|
||||
* </pre>
|
||||
*/
|
||||
public Builder setCaching(int value) {
|
||||
bitField0_ |= 0x00000100;
|
||||
|
@ -1275,6 +1367,10 @@ public final class ScannerMessage {
|
|||
}
|
||||
/**
|
||||
* <code>optional int32 caching = 9;</code>
|
||||
*
|
||||
* <pre>
|
||||
* specifies REST scanner caching
|
||||
* </pre>
|
||||
*/
|
||||
public Builder clearCaching() {
|
||||
bitField0_ = (bitField0_ & ~0x00000100);
|
||||
|
@ -1376,6 +1472,55 @@ public final class ScannerMessage {
|
|||
return this;
|
||||
}
|
||||
|
||||
// optional bool cacheBlocks = 11;
|
||||
private boolean cacheBlocks_ ;
|
||||
/**
|
||||
* <code>optional bool cacheBlocks = 11;</code>
|
||||
*
|
||||
* <pre>
|
||||
* server side block caching hint
|
||||
* </pre>
|
||||
*/
|
||||
public boolean hasCacheBlocks() {
|
||||
return ((bitField0_ & 0x00000400) == 0x00000400);
|
||||
}
|
||||
/**
|
||||
* <code>optional bool cacheBlocks = 11;</code>
|
||||
*
|
||||
* <pre>
|
||||
* server side block caching hint
|
||||
* </pre>
|
||||
*/
|
||||
public boolean getCacheBlocks() {
|
||||
return cacheBlocks_;
|
||||
}
|
||||
/**
|
||||
* <code>optional bool cacheBlocks = 11;</code>
|
||||
*
|
||||
* <pre>
|
||||
* server side block caching hint
|
||||
* </pre>
|
||||
*/
|
||||
public Builder setCacheBlocks(boolean value) {
|
||||
bitField0_ |= 0x00000400;
|
||||
cacheBlocks_ = value;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <code>optional bool cacheBlocks = 11;</code>
|
||||
*
|
||||
* <pre>
|
||||
* server side block caching hint
|
||||
* </pre>
|
||||
*/
|
||||
public Builder clearCacheBlocks() {
|
||||
bitField0_ = (bitField0_ & ~0x00000400);
|
||||
cacheBlocks_ = false;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:org.apache.hadoop.hbase.rest.protobuf.generated.Scanner)
|
||||
}
|
||||
|
||||
|
@ -1402,12 +1547,12 @@ public final class ScannerMessage {
|
|||
static {
|
||||
java.lang.String[] descriptorData = {
|
||||
"\n\024ScannerMessage.proto\022/org.apache.hadoo" +
|
||||
"p.hbase.rest.protobuf.generated\"\265\001\n\007Scan" +
|
||||
"p.hbase.rest.protobuf.generated\"\312\001\n\007Scan" +
|
||||
"ner\022\020\n\010startRow\030\001 \001(\014\022\016\n\006endRow\030\002 \001(\014\022\017\n" +
|
||||
"\007columns\030\003 \003(\014\022\r\n\005batch\030\004 \001(\005\022\021\n\tstartTi" +
|
||||
"me\030\005 \001(\003\022\017\n\007endTime\030\006 \001(\003\022\023\n\013maxVersions" +
|
||||
"\030\007 \001(\005\022\016\n\006filter\030\010 \001(\t\022\017\n\007caching\030\t \001(\005\022" +
|
||||
"\016\n\006labels\030\n \003(\t"
|
||||
"\016\n\006labels\030\n \003(\t\022\023\n\013cacheBlocks\030\013 \001(\010"
|
||||
};
|
||||
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
|
||||
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
|
||||
|
@ -1419,7 +1564,7 @@ public final class ScannerMessage {
|
|||
internal_static_org_apache_hadoop_hbase_rest_protobuf_generated_Scanner_fieldAccessorTable = new
|
||||
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
|
||||
internal_static_org_apache_hadoop_hbase_rest_protobuf_generated_Scanner_descriptor,
|
||||
new java.lang.String[] { "StartRow", "EndRow", "Columns", "Batch", "StartTime", "EndTime", "MaxVersions", "Filter", "Caching", "Labels", });
|
||||
new java.lang.String[] { "StartRow", "EndRow", "Columns", "Batch", "StartTime", "EndTime", "MaxVersions", "Filter", "Caching", "Labels", "CacheBlocks", });
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -111,13 +111,18 @@
|
|||
<complexType name="Scanner">
|
||||
<sequence>
|
||||
<element name="column" type="base64Binary" minOccurs="0" maxOccurs="unbounded"></element>
|
||||
<element name="filter" type="string" minOccurs="0" maxOccurs="1"></element>
|
||||
</sequence>
|
||||
<attribute name="startRow" type="base64Binary"></attribute>
|
||||
<attribute name="endRow" type="base64Binary"></attribute>
|
||||
<attribute name="batch" type="int"></attribute>
|
||||
<attribute name="startTime" type="int"></attribute>
|
||||
<attribute name="endTime" type="int"></attribute>
|
||||
<attribute name="filter" type="string"></attribute>
|
||||
<attribute name="caching" type="int"></attribute>
|
||||
<sequence>
|
||||
<element name="labels" type="string" minOccurs="0" maxOccurs="unbounded"></element>
|
||||
</sequence>
|
||||
<attribute name="cacheBlocks" type="boolean"></attribute>
|
||||
</complexType>
|
||||
|
||||
<element name="StorageClusterVersion" type="tns:StorageClusterVersion" />
|
||||
|
|
|
@ -26,6 +26,7 @@ message Scanner {
|
|||
optional int64 endTime = 6;
|
||||
optional int32 maxVersions = 7;
|
||||
optional string filter = 8;
|
||||
optional int32 caching = 9;
|
||||
optional int32 caching = 9; // specifies REST scanner caching
|
||||
repeated string labels = 10;
|
||||
optional bool cacheBlocks = 11; // server side block caching hint
|
||||
}
|
||||
|
|
|
@ -20,22 +20,14 @@
|
|||
|
||||
package org.apache.hadoop.hbase.rest.model;
|
||||
|
||||
import com.sun.jersey.api.json.JSONJAXBContext;
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.hadoop.hbase.SmallTests;
|
||||
import org.apache.hadoop.hbase.rest.ProtobufMessageHandler;
|
||||
import org.apache.hadoop.hbase.rest.provider.JAXBContextResolver;
|
||||
import org.apache.hadoop.hbase.util.Base64;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.codehaus.jackson.JsonGenerationException;
|
||||
import org.codehaus.jackson.JsonParseException;
|
||||
import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider;
|
||||
import org.codehaus.jackson.map.AnnotationIntrospector;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.codehaus.jackson.map.SerializationConfig;
|
||||
import org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector;
|
||||
import org.codehaus.jackson.node.ObjectNode;
|
||||
import org.codehaus.jackson.xc.JaxbAnnotationIntrospector;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
@ -44,7 +36,6 @@ import javax.xml.bind.JAXBException;
|
|||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
@Category(SmallTests.class)
|
||||
public abstract class TestModelBase<T> extends TestCase {
|
||||
|
|
|
@ -35,23 +35,26 @@ public class TestScannerModel extends TestModelBase<ScannerModel> {
|
|||
private static final long END_TIME = 1245393318192L;
|
||||
private static final int CACHING = 1000;
|
||||
private static final int BATCH = 100;
|
||||
private static final boolean CACHE_BLOCKS = false;
|
||||
|
||||
public TestScannerModel() throws Exception {
|
||||
super(ScannerModel.class);
|
||||
AS_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
|
||||
+ "<Scanner batch=\"100\" caching=\"1000\" endRow=\"enp5eng=\" endTime=\"1245393318192\" "
|
||||
+ "maxVersions=\"2147483647\" startRow=\"YWJyYWNhZGFicmE=\" startTime=\"1245219839331\">"
|
||||
+ "<Scanner batch=\"100\" cacheBlocks=\"false\" caching=\"1000\" endRow=\"enp5eng=\" "
|
||||
+ "endTime=\"1245393318192\" maxVersions=\"2147483647\" startRow=\"YWJyYWNhZGFicmE=\" "
|
||||
+ "startTime=\"1245219839331\">"
|
||||
+ "<column>Y29sdW1uMQ==</column><column>Y29sdW1uMjpmb28=</column>"
|
||||
+ "<label>private</label><label>public</label></Scanner>";
|
||||
+ "<label>private</label><label>public</label>"
|
||||
+ "</Scanner>";
|
||||
|
||||
AS_JSON = "{\"batch\":100,\"caching\":1000,\"endRow\":\"enp5eng=\",\"endTime\":1245393318192,"
|
||||
+ "\"maxVersions\":2147483647,\"startRow\":\"YWJyYWNhZGFicmE=\",\"startTime\":1245219839331,"
|
||||
+ "\"column\":[\"Y29sdW1uMQ==\",\"Y29sdW1uMjpmb28=\"],"
|
||||
+"\"labels\":[\"private\",\"public\"]}";
|
||||
AS_JSON = "{\"batch\":100,\"caching\":1000,\"cacheBlocks\":false,\"endRow\":\"enp5eng=\","
|
||||
+ "\"endTime\":1245393318192,\"maxVersions\":2147483647,\"startRow\":\"YWJyYWNhZGFicmE=\","
|
||||
+ "\"startTime\":1245219839331,\"column\":[\"Y29sdW1uMQ==\",\"Y29sdW1uMjpmb28=\"],"
|
||||
+"\"labels\":[\"private\",\"public\"]"
|
||||
+"}";
|
||||
|
||||
// TODO
|
||||
AS_PB = "CgthYnJhY2FkYWJyYRIFenp5engaB2NvbHVtbjEaC2NvbHVtbjI6Zm9vIGQo47qL554kMLDi57mf"
|
||||
+ "JDj/////B0joBw==";
|
||||
+ "JDj/////B0joB1IHcHJpdmF0ZVIGcHVibGljWAA=";
|
||||
}
|
||||
|
||||
protected ScannerModel buildTestModel() {
|
||||
|
@ -66,6 +69,7 @@ public class TestScannerModel extends TestModelBase<ScannerModel> {
|
|||
model.setCaching(CACHING);
|
||||
model.addLabel(PRIVATE);
|
||||
model.addLabel(PUBLIC);
|
||||
model.setCacheBlocks(CACHE_BLOCKS);
|
||||
return model;
|
||||
}
|
||||
|
||||
|
@ -86,6 +90,7 @@ public class TestScannerModel extends TestModelBase<ScannerModel> {
|
|||
assertEquals(model.getEndTime(), END_TIME);
|
||||
assertEquals(model.getBatch(), BATCH);
|
||||
assertEquals(model.getCaching(), CACHING);
|
||||
assertEquals(model.getCacheBlocks(), CACHE_BLOCKS);
|
||||
boolean foundLabel1 = false;
|
||||
boolean foundLabel2 = false;
|
||||
if (model.getLabels() != null && model.getLabels().size() > 0) {
|
||||
|
|
Loading…
Reference in New Issue