HBASE-20845 Support set the consistency for Gets and Scans in thrift2

Signed-off-by: Andrew Purtell <apurtell@apache.org>
This commit is contained in:
Guangxu Cheng 2018-07-05 10:49:01 +08:00 committed by Andrew Purtell
parent 4329330cf1
commit b9413839ab
8 changed files with 1082 additions and 332 deletions

View File

@ -37,6 +37,7 @@ import org.apache.hadoop.hbase.HRegionLocation;
import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.client.Append;
import org.apache.hadoop.hbase.client.Consistency;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Durability;
import org.apache.hadoop.hbase.client.Get;
@ -55,6 +56,7 @@ import org.apache.hadoop.hbase.thrift2.generated.TColumn;
import org.apache.hadoop.hbase.thrift2.generated.TColumnIncrement;
import org.apache.hadoop.hbase.thrift2.generated.TColumnValue;
import org.apache.hadoop.hbase.thrift2.generated.TCompareOp;
import org.apache.hadoop.hbase.thrift2.generated.TConsistency;
import org.apache.hadoop.hbase.thrift2.generated.TDelete;
import org.apache.hadoop.hbase.thrift2.generated.TDurability;
import org.apache.hadoop.hbase.thrift2.generated.TGet;
@ -119,6 +121,14 @@ public final class ThriftUtilities {
out.setAuthorizations(new Authorizations(in.getAuthorizations().getLabels()));
}
if (in.isSetConsistency()) {
out.setConsistency(consistencyFromThrift(in.getConsistency()));
}
if (in.isSetTargetReplicaId()) {
out.setReplicaId(in.getTargetReplicaId());
}
if (!in.isSetColumns()) {
return out;
}
@ -179,6 +189,8 @@ public final class ThriftUtilities {
columnValues.add(col);
}
out.setColumnValues(columnValues);
out.setStale(in.isStale());
return out;
}
@ -491,6 +503,14 @@ public final class ThriftUtilities {
out.setLimit(in.getLimit());
}
if (in.isSetConsistency()) {
out.setConsistency(consistencyFromThrift(in.getConsistency()));
}
if (in.isSetTargetReplicaId()) {
out.setReplicaId(in.getTargetReplicaId());
}
return out;
}
@ -615,4 +635,12 @@ public final class ThriftUtilities {
default: return null;
}
}
private static Consistency consistencyFromThrift(TConsistency tConsistency) {
switch (tConsistency.getValue()) {
case 1: return Consistency.STRONG;
case 2: return Consistency.TIMELINE;
default: return Consistency.STRONG;
}
}
}

View File

@ -0,0 +1,50 @@
/**
* Autogenerated by Thrift Compiler (0.9.3)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package org.apache.hadoop.hbase.thrift2.generated;
import java.util.Map;
import java.util.HashMap;
import org.apache.thrift.TEnum;
/**
* Specify Consistency:
* - STRONG means reads only from primary region
* - TIMELINE means reads might return values from secondary region replicas
*/
public enum TConsistency implements org.apache.thrift.TEnum {
STRONG(1),
TIMELINE(2);
private final int value;
private TConsistency(int value) {
this.value = value;
}
/**
* Get the integer value of this enum value, as defined in the Thrift IDL.
*/
public int getValue() {
return value;
}
/**
* Find a the enum type by its integer value, as defined in the Thrift IDL.
* @return null if the value is not found.
*/
public static TConsistency findByValue(int value) {
switch (value) {
case 1:
return STRONG;
case 2:
return TIMELINE;
default:
return null;
}
}
}

View File

@ -47,7 +47,7 @@ import org.slf4j.LoggerFactory;
* If you specify a time range and a timestamp the range is ignored.
* Timestamps on TColumns are ignored.
*/
@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-05-25")
@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-07-03")
public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.io.Serializable, Cloneable, Comparable<TGet> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TGet");
@ -59,6 +59,8 @@ public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.i
private static final org.apache.thrift.protocol.TField FILTER_STRING_FIELD_DESC = new org.apache.thrift.protocol.TField("filterString", org.apache.thrift.protocol.TType.STRING, (short)6);
private static final org.apache.thrift.protocol.TField ATTRIBUTES_FIELD_DESC = new org.apache.thrift.protocol.TField("attributes", org.apache.thrift.protocol.TType.MAP, (short)7);
private static final org.apache.thrift.protocol.TField AUTHORIZATIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("authorizations", org.apache.thrift.protocol.TType.STRUCT, (short)8);
private static final org.apache.thrift.protocol.TField CONSISTENCY_FIELD_DESC = new org.apache.thrift.protocol.TField("consistency", org.apache.thrift.protocol.TType.I32, (short)9);
private static final org.apache.thrift.protocol.TField TARGET_REPLICA_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("targetReplicaId", org.apache.thrift.protocol.TType.I32, (short)10);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
@ -74,6 +76,12 @@ public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.i
public ByteBuffer filterString; // optional
public Map<ByteBuffer,ByteBuffer> attributes; // optional
public TAuthorization authorizations; // optional
/**
*
* @see TConsistency
*/
public TConsistency consistency; // optional
public int targetReplicaId; // optional
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
@ -84,7 +92,13 @@ public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.i
MAX_VERSIONS((short)5, "maxVersions"),
FILTER_STRING((short)6, "filterString"),
ATTRIBUTES((short)7, "attributes"),
AUTHORIZATIONS((short)8, "authorizations");
AUTHORIZATIONS((short)8, "authorizations"),
/**
*
* @see TConsistency
*/
CONSISTENCY((short)9, "consistency"),
TARGET_REPLICA_ID((short)10, "targetReplicaId");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
@ -115,6 +129,10 @@ public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.i
return ATTRIBUTES;
case 8: // AUTHORIZATIONS
return AUTHORIZATIONS;
case 9: // CONSISTENCY
return CONSISTENCY;
case 10: // TARGET_REPLICA_ID
return TARGET_REPLICA_ID;
default:
return null;
}
@ -157,8 +175,9 @@ public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.i
// isset id assignments
private static final int __TIMESTAMP_ISSET_ID = 0;
private static final int __MAXVERSIONS_ISSET_ID = 1;
private static final int __TARGETREPLICAID_ISSET_ID = 2;
private byte __isset_bitfield = 0;
private static final _Fields optionals[] = {_Fields.COLUMNS,_Fields.TIMESTAMP,_Fields.TIME_RANGE,_Fields.MAX_VERSIONS,_Fields.FILTER_STRING,_Fields.ATTRIBUTES,_Fields.AUTHORIZATIONS};
private static final _Fields optionals[] = {_Fields.COLUMNS,_Fields.TIMESTAMP,_Fields.TIME_RANGE,_Fields.MAX_VERSIONS,_Fields.FILTER_STRING,_Fields.ATTRIBUTES,_Fields.AUTHORIZATIONS,_Fields.CONSISTENCY,_Fields.TARGET_REPLICA_ID};
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
@ -181,6 +200,10 @@ public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.i
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true))));
tmpMap.put(_Fields.AUTHORIZATIONS, new org.apache.thrift.meta_data.FieldMetaData("authorizations", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TAuthorization.class)));
tmpMap.put(_Fields.CONSISTENCY, new org.apache.thrift.meta_data.FieldMetaData("consistency", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TConsistency.class)));
tmpMap.put(_Fields.TARGET_REPLICA_ID, new org.apache.thrift.meta_data.FieldMetaData("targetReplicaId", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TGet.class, metaDataMap);
}
@ -225,6 +248,10 @@ public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.i
if (other.isSetAuthorizations()) {
this.authorizations = new TAuthorization(other.authorizations);
}
if (other.isSetConsistency()) {
this.consistency = other.consistency;
}
this.targetReplicaId = other.targetReplicaId;
}
public TGet deepCopy() {
@ -243,6 +270,9 @@ public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.i
this.filterString = null;
this.attributes = null;
this.authorizations = null;
this.consistency = null;
setTargetReplicaIdIsSet(false);
this.targetReplicaId = 0;
}
public byte[] getRow() {
@ -481,6 +511,61 @@ public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.i
}
}
/**
*
* @see TConsistency
*/
public TConsistency getConsistency() {
return this.consistency;
}
/**
*
* @see TConsistency
*/
public TGet setConsistency(TConsistency consistency) {
this.consistency = consistency;
return this;
}
public void unsetConsistency() {
this.consistency = null;
}
/** Returns true if field consistency is set (has been assigned a value) and false otherwise */
public boolean isSetConsistency() {
return this.consistency != null;
}
public void setConsistencyIsSet(boolean value) {
if (!value) {
this.consistency = null;
}
}
public int getTargetReplicaId() {
return this.targetReplicaId;
}
public TGet setTargetReplicaId(int targetReplicaId) {
this.targetReplicaId = targetReplicaId;
setTargetReplicaIdIsSet(true);
return this;
}
public void unsetTargetReplicaId() {
__isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __TARGETREPLICAID_ISSET_ID);
}
/** Returns true if field targetReplicaId is set (has been assigned a value) and false otherwise */
public boolean isSetTargetReplicaId() {
return EncodingUtils.testBit(__isset_bitfield, __TARGETREPLICAID_ISSET_ID);
}
public void setTargetReplicaIdIsSet(boolean value) {
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __TARGETREPLICAID_ISSET_ID, value);
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case ROW:
@ -547,6 +632,22 @@ public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.i
}
break;
case CONSISTENCY:
if (value == null) {
unsetConsistency();
} else {
setConsistency((TConsistency)value);
}
break;
case TARGET_REPLICA_ID:
if (value == null) {
unsetTargetReplicaId();
} else {
setTargetReplicaId((Integer)value);
}
break;
}
}
@ -576,6 +677,12 @@ public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.i
case AUTHORIZATIONS:
return getAuthorizations();
case CONSISTENCY:
return getConsistency();
case TARGET_REPLICA_ID:
return getTargetReplicaId();
}
throw new IllegalStateException();
}
@ -603,6 +710,10 @@ public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.i
return isSetAttributes();
case AUTHORIZATIONS:
return isSetAuthorizations();
case CONSISTENCY:
return isSetConsistency();
case TARGET_REPLICA_ID:
return isSetTargetReplicaId();
}
throw new IllegalStateException();
}
@ -692,6 +803,24 @@ public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.i
return false;
}
boolean this_present_consistency = true && this.isSetConsistency();
boolean that_present_consistency = true && that.isSetConsistency();
if (this_present_consistency || that_present_consistency) {
if (!(this_present_consistency && that_present_consistency))
return false;
if (!this.consistency.equals(that.consistency))
return false;
}
boolean this_present_targetReplicaId = true && this.isSetTargetReplicaId();
boolean that_present_targetReplicaId = true && that.isSetTargetReplicaId();
if (this_present_targetReplicaId || that_present_targetReplicaId) {
if (!(this_present_targetReplicaId && that_present_targetReplicaId))
return false;
if (this.targetReplicaId != that.targetReplicaId)
return false;
}
return true;
}
@ -739,6 +868,16 @@ public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.i
if (present_authorizations)
list.add(authorizations);
boolean present_consistency = true && (isSetConsistency());
list.add(present_consistency);
if (present_consistency)
list.add(consistency.getValue());
boolean present_targetReplicaId = true && (isSetTargetReplicaId());
list.add(present_targetReplicaId);
if (present_targetReplicaId)
list.add(targetReplicaId);
return list.hashCode();
}
@ -830,6 +969,26 @@ public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.i
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetConsistency()).compareTo(other.isSetConsistency());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetConsistency()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.consistency, other.consistency);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetTargetReplicaId()).compareTo(other.isSetTargetReplicaId());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetTargetReplicaId()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.targetReplicaId, other.targetReplicaId);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
@ -919,6 +1078,22 @@ public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.i
}
first = false;
}
if (isSetConsistency()) {
if (!first) sb.append(", ");
sb.append("consistency:");
if (this.consistency == null) {
sb.append("null");
} else {
sb.append(this.consistency);
}
first = false;
}
if (isSetTargetReplicaId()) {
if (!first) sb.append(", ");
sb.append("targetReplicaId:");
sb.append(this.targetReplicaId);
first = false;
}
sb.append(")");
return sb.toString();
}
@ -1062,6 +1237,22 @@ public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.i
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 9: // CONSISTENCY
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.consistency = org.apache.hadoop.hbase.thrift2.generated.TConsistency.findByValue(iprot.readI32());
struct.setConsistencyIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 10: // TARGET_REPLICA_ID
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.targetReplicaId = iprot.readI32();
struct.setTargetReplicaIdIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
@ -1142,6 +1333,18 @@ public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.i
oprot.writeFieldEnd();
}
}
if (struct.consistency != null) {
if (struct.isSetConsistency()) {
oprot.writeFieldBegin(CONSISTENCY_FIELD_DESC);
oprot.writeI32(struct.consistency.getValue());
oprot.writeFieldEnd();
}
}
if (struct.isSetTargetReplicaId()) {
oprot.writeFieldBegin(TARGET_REPLICA_ID_FIELD_DESC);
oprot.writeI32(struct.targetReplicaId);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@ -1182,7 +1385,13 @@ public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.i
if (struct.isSetAuthorizations()) {
optionals.set(6);
}
oprot.writeBitSet(optionals, 7);
if (struct.isSetConsistency()) {
optionals.set(7);
}
if (struct.isSetTargetReplicaId()) {
optionals.set(8);
}
oprot.writeBitSet(optionals, 9);
if (struct.isSetColumns()) {
{
oprot.writeI32(struct.columns.size());
@ -1217,6 +1426,12 @@ public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.i
if (struct.isSetAuthorizations()) {
struct.authorizations.write(oprot);
}
if (struct.isSetConsistency()) {
oprot.writeI32(struct.consistency.getValue());
}
if (struct.isSetTargetReplicaId()) {
oprot.writeI32(struct.targetReplicaId);
}
}
@Override
@ -1224,7 +1439,7 @@ public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.i
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.row = iprot.readBinary();
struct.setRowIsSet(true);
BitSet incoming = iprot.readBitSet(7);
BitSet incoming = iprot.readBitSet(9);
if (incoming.get(0)) {
{
org.apache.thrift.protocol.TList _list27 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
@ -1276,6 +1491,14 @@ public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.i
struct.authorizations.read(iprot);
struct.setAuthorizationsIsSet(true);
}
if (incoming.get(7)) {
struct.consistency = org.apache.hadoop.hbase.thrift2.generated.TConsistency.findByValue(iprot.readI32());
struct.setConsistencyIsSet(true);
}
if (incoming.get(8)) {
struct.targetReplicaId = iprot.readI32();
struct.setTargetReplicaIdIsSet(true);
}
}
}

View File

@ -37,12 +37,13 @@ import org.slf4j.LoggerFactory;
/**
* if no Result is found, row and columnValues will not be set.
*/
@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-05-25")
@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-07-04")
public class TResult implements org.apache.thrift.TBase<TResult, TResult._Fields>, java.io.Serializable, Cloneable, Comparable<TResult> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TResult");
private static final org.apache.thrift.protocol.TField ROW_FIELD_DESC = new org.apache.thrift.protocol.TField("row", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField COLUMN_VALUES_FIELD_DESC = new org.apache.thrift.protocol.TField("columnValues", org.apache.thrift.protocol.TType.LIST, (short)2);
private static final org.apache.thrift.protocol.TField STALE_FIELD_DESC = new org.apache.thrift.protocol.TField("stale", org.apache.thrift.protocol.TType.BOOL, (short)3);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
@ -52,11 +53,13 @@ public class TResult implements org.apache.thrift.TBase<TResult, TResult._Fields
public ByteBuffer row; // optional
public List<TColumnValue> columnValues; // required
public boolean stale; // optional
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
ROW((short)1, "row"),
COLUMN_VALUES((short)2, "columnValues");
COLUMN_VALUES((short)2, "columnValues"),
STALE((short)3, "stale");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
@ -75,6 +78,8 @@ public class TResult implements org.apache.thrift.TBase<TResult, TResult._Fields
return ROW;
case 2: // COLUMN_VALUES
return COLUMN_VALUES;
case 3: // STALE
return STALE;
default:
return null;
}
@ -115,7 +120,9 @@ public class TResult implements org.apache.thrift.TBase<TResult, TResult._Fields
}
// isset id assignments
private static final _Fields optionals[] = {_Fields.ROW};
private static final int __STALE_ISSET_ID = 0;
private byte __isset_bitfield = 0;
private static final _Fields optionals[] = {_Fields.ROW,_Fields.STALE};
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
@ -124,11 +131,15 @@ public class TResult implements org.apache.thrift.TBase<TResult, TResult._Fields
tmpMap.put(_Fields.COLUMN_VALUES, new org.apache.thrift.meta_data.FieldMetaData("columnValues", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TColumnValue.class))));
tmpMap.put(_Fields.STALE, new org.apache.thrift.meta_data.FieldMetaData("stale", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TResult.class, metaDataMap);
}
public TResult() {
this.stale = false;
}
public TResult(
@ -142,6 +153,7 @@ public class TResult implements org.apache.thrift.TBase<TResult, TResult._Fields
* Performs a deep copy on <i>other</i>.
*/
public TResult(TResult other) {
__isset_bitfield = other.__isset_bitfield;
if (other.isSetRow()) {
this.row = org.apache.thrift.TBaseHelper.copyBinary(other.row);
}
@ -152,6 +164,7 @@ public class TResult implements org.apache.thrift.TBase<TResult, TResult._Fields
}
this.columnValues = __this__columnValues;
}
this.stale = other.stale;
}
public TResult deepCopy() {
@ -162,6 +175,8 @@ public class TResult implements org.apache.thrift.TBase<TResult, TResult._Fields
public void clear() {
this.row = null;
this.columnValues = null;
this.stale = false;
}
public byte[] getRow() {
@ -237,6 +252,29 @@ public class TResult implements org.apache.thrift.TBase<TResult, TResult._Fields
}
}
public boolean isStale() {
return this.stale;
}
public TResult setStale(boolean stale) {
this.stale = stale;
setStaleIsSet(true);
return this;
}
public void unsetStale() {
__isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __STALE_ISSET_ID);
}
/** Returns true if field stale is set (has been assigned a value) and false otherwise */
public boolean isSetStale() {
return EncodingUtils.testBit(__isset_bitfield, __STALE_ISSET_ID);
}
public void setStaleIsSet(boolean value) {
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __STALE_ISSET_ID, value);
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case ROW:
@ -255,6 +293,14 @@ public class TResult implements org.apache.thrift.TBase<TResult, TResult._Fields
}
break;
case STALE:
if (value == null) {
unsetStale();
} else {
setStale((Boolean)value);
}
break;
}
}
@ -266,6 +312,9 @@ public class TResult implements org.apache.thrift.TBase<TResult, TResult._Fields
case COLUMN_VALUES:
return getColumnValues();
case STALE:
return isStale();
}
throw new IllegalStateException();
}
@ -281,6 +330,8 @@ public class TResult implements org.apache.thrift.TBase<TResult, TResult._Fields
return isSetRow();
case COLUMN_VALUES:
return isSetColumnValues();
case STALE:
return isSetStale();
}
throw new IllegalStateException();
}
@ -316,6 +367,15 @@ public class TResult implements org.apache.thrift.TBase<TResult, TResult._Fields
return false;
}
boolean this_present_stale = true && this.isSetStale();
boolean that_present_stale = true && that.isSetStale();
if (this_present_stale || that_present_stale) {
if (!(this_present_stale && that_present_stale))
return false;
if (this.stale != that.stale)
return false;
}
return true;
}
@ -333,6 +393,11 @@ public class TResult implements org.apache.thrift.TBase<TResult, TResult._Fields
if (present_columnValues)
list.add(columnValues);
boolean present_stale = true && (isSetStale());
list.add(present_stale);
if (present_stale)
list.add(stale);
return list.hashCode();
}
@ -364,6 +429,16 @@ public class TResult implements org.apache.thrift.TBase<TResult, TResult._Fields
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetStale()).compareTo(other.isSetStale());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetStale()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.stale, other.stale);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
@ -401,6 +476,12 @@ public class TResult implements org.apache.thrift.TBase<TResult, TResult._Fields
sb.append(this.columnValues);
}
first = false;
if (isSetStale()) {
if (!first) sb.append(", ");
sb.append("stale:");
sb.append(this.stale);
first = false;
}
sb.append(")");
return sb.toString();
}
@ -423,6 +504,8 @@ public class TResult implements org.apache.thrift.TBase<TResult, TResult._Fields
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bitfield = 0;
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
@ -474,6 +557,14 @@ public class TResult implements org.apache.thrift.TBase<TResult, TResult._Fields
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 3: // STALE
if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
struct.stale = iprot.readBool();
struct.setStaleIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
@ -508,6 +599,11 @@ public class TResult implements org.apache.thrift.TBase<TResult, TResult._Fields
}
oprot.writeFieldEnd();
}
if (struct.isSetStale()) {
oprot.writeFieldBegin(STALE_FIELD_DESC);
oprot.writeBool(struct.stale);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@ -536,10 +632,16 @@ public class TResult implements org.apache.thrift.TBase<TResult, TResult._Fields
if (struct.isSetRow()) {
optionals.set(0);
}
oprot.writeBitSet(optionals, 1);
if (struct.isSetStale()) {
optionals.set(1);
}
oprot.writeBitSet(optionals, 2);
if (struct.isSetRow()) {
oprot.writeBinary(struct.row);
}
if (struct.isSetStale()) {
oprot.writeBool(struct.stale);
}
}
@Override
@ -557,11 +659,15 @@ public class TResult implements org.apache.thrift.TBase<TResult, TResult._Fields
}
}
struct.setColumnValuesIsSet(true);
BitSet incoming = iprot.readBitSet(1);
BitSet incoming = iprot.readBitSet(2);
if (incoming.get(0)) {
struct.row = iprot.readBinary();
struct.setRowIsSet(true);
}
if (incoming.get(1)) {
struct.stale = iprot.readBool();
struct.setStaleIsSet(true);
}
}
}

View File

@ -38,7 +38,7 @@ import org.slf4j.LoggerFactory;
* Any timestamps in the columns are ignored but the colFamTimeRangeMap included, use timeRange to select by timestamp.
* Max versions defaults to 1.
*/
@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2017-03-27")
@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-07-03")
public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, java.io.Serializable, Cloneable, Comparable<TScan> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TScan");
@ -57,6 +57,8 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
private static final org.apache.thrift.protocol.TField COL_FAM_TIME_RANGE_MAP_FIELD_DESC = new org.apache.thrift.protocol.TField("colFamTimeRangeMap", org.apache.thrift.protocol.TType.MAP, (short)13);
private static final org.apache.thrift.protocol.TField READ_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("readType", org.apache.thrift.protocol.TType.I32, (short)14);
private static final org.apache.thrift.protocol.TField LIMIT_FIELD_DESC = new org.apache.thrift.protocol.TField("limit", org.apache.thrift.protocol.TType.I32, (short)15);
private static final org.apache.thrift.protocol.TField CONSISTENCY_FIELD_DESC = new org.apache.thrift.protocol.TField("consistency", org.apache.thrift.protocol.TType.I32, (short)16);
private static final org.apache.thrift.protocol.TField TARGET_REPLICA_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("targetReplicaId", org.apache.thrift.protocol.TType.I32, (short)17);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
@ -83,6 +85,12 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
*/
public TReadType readType; // optional
public int limit; // optional
/**
*
* @see TConsistency
*/
public TConsistency consistency; // optional
public int targetReplicaId; // optional
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
@ -104,7 +112,13 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
* @see TReadType
*/
READ_TYPE((short)14, "readType"),
LIMIT((short)15, "limit");
LIMIT((short)15, "limit"),
/**
*
* @see TConsistency
*/
CONSISTENCY((short)16, "consistency"),
TARGET_REPLICA_ID((short)17, "targetReplicaId");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
@ -149,6 +163,10 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
return READ_TYPE;
case 15: // LIMIT
return LIMIT;
case 16: // CONSISTENCY
return CONSISTENCY;
case 17: // TARGET_REPLICA_ID
return TARGET_REPLICA_ID;
default:
return null;
}
@ -195,8 +213,9 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
private static final int __REVERSED_ISSET_ID = 3;
private static final int __CACHEBLOCKS_ISSET_ID = 4;
private static final int __LIMIT_ISSET_ID = 5;
private static final int __TARGETREPLICAID_ISSET_ID = 6;
private byte __isset_bitfield = 0;
private static final _Fields optionals[] = {_Fields.START_ROW,_Fields.STOP_ROW,_Fields.COLUMNS,_Fields.CACHING,_Fields.MAX_VERSIONS,_Fields.TIME_RANGE,_Fields.FILTER_STRING,_Fields.BATCH_SIZE,_Fields.ATTRIBUTES,_Fields.AUTHORIZATIONS,_Fields.REVERSED,_Fields.CACHE_BLOCKS,_Fields.COL_FAM_TIME_RANGE_MAP,_Fields.READ_TYPE,_Fields.LIMIT};
private static final _Fields optionals[] = {_Fields.START_ROW,_Fields.STOP_ROW,_Fields.COLUMNS,_Fields.CACHING,_Fields.MAX_VERSIONS,_Fields.TIME_RANGE,_Fields.FILTER_STRING,_Fields.BATCH_SIZE,_Fields.ATTRIBUTES,_Fields.AUTHORIZATIONS,_Fields.REVERSED,_Fields.CACHE_BLOCKS,_Fields.COL_FAM_TIME_RANGE_MAP,_Fields.READ_TYPE,_Fields.LIMIT,_Fields.CONSISTENCY,_Fields.TARGET_REPLICA_ID};
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
@ -235,6 +254,10 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TReadType.class)));
tmpMap.put(_Fields.LIMIT, new org.apache.thrift.meta_data.FieldMetaData("limit", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
tmpMap.put(_Fields.CONSISTENCY, new org.apache.thrift.meta_data.FieldMetaData("consistency", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TConsistency.class)));
tmpMap.put(_Fields.TARGET_REPLICA_ID, new org.apache.thrift.meta_data.FieldMetaData("targetReplicaId", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TScan.class, metaDataMap);
}
@ -299,6 +322,10 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
this.readType = other.readType;
}
this.limit = other.limit;
if (other.isSetConsistency()) {
this.consistency = other.consistency;
}
this.targetReplicaId = other.targetReplicaId;
}
public TScan deepCopy() {
@ -328,6 +355,9 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
this.readType = null;
setLimitIsSet(false);
this.limit = 0;
this.consistency = null;
setTargetReplicaIdIsSet(false);
this.targetReplicaId = 0;
}
public byte[] getStartRow() {
@ -759,6 +789,61 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __LIMIT_ISSET_ID, value);
}
/**
*
* @see TConsistency
*/
public TConsistency getConsistency() {
return this.consistency;
}
/**
*
* @see TConsistency
*/
public TScan setConsistency(TConsistency consistency) {
this.consistency = consistency;
return this;
}
public void unsetConsistency() {
this.consistency = null;
}
/** Returns true if field consistency is set (has been assigned a value) and false otherwise */
public boolean isSetConsistency() {
return this.consistency != null;
}
public void setConsistencyIsSet(boolean value) {
if (!value) {
this.consistency = null;
}
}
public int getTargetReplicaId() {
return this.targetReplicaId;
}
public TScan setTargetReplicaId(int targetReplicaId) {
this.targetReplicaId = targetReplicaId;
setTargetReplicaIdIsSet(true);
return this;
}
public void unsetTargetReplicaId() {
__isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __TARGETREPLICAID_ISSET_ID);
}
/** Returns true if field targetReplicaId is set (has been assigned a value) and false otherwise */
public boolean isSetTargetReplicaId() {
return EncodingUtils.testBit(__isset_bitfield, __TARGETREPLICAID_ISSET_ID);
}
public void setTargetReplicaIdIsSet(boolean value) {
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __TARGETREPLICAID_ISSET_ID, value);
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case START_ROW:
@ -881,6 +966,22 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
}
break;
case CONSISTENCY:
if (value == null) {
unsetConsistency();
} else {
setConsistency((TConsistency)value);
}
break;
case TARGET_REPLICA_ID:
if (value == null) {
unsetTargetReplicaId();
} else {
setTargetReplicaId((Integer)value);
}
break;
}
}
@ -931,6 +1032,12 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
case LIMIT:
return getLimit();
case CONSISTENCY:
return getConsistency();
case TARGET_REPLICA_ID:
return getTargetReplicaId();
}
throw new IllegalStateException();
}
@ -972,6 +1079,10 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
return isSetReadType();
case LIMIT:
return isSetLimit();
case CONSISTENCY:
return isSetConsistency();
case TARGET_REPLICA_ID:
return isSetTargetReplicaId();
}
throw new IllegalStateException();
}
@ -1124,6 +1235,24 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
return false;
}
boolean this_present_consistency = true && this.isSetConsistency();
boolean that_present_consistency = true && that.isSetConsistency();
if (this_present_consistency || that_present_consistency) {
if (!(this_present_consistency && that_present_consistency))
return false;
if (!this.consistency.equals(that.consistency))
return false;
}
boolean this_present_targetReplicaId = true && this.isSetTargetReplicaId();
boolean that_present_targetReplicaId = true && that.isSetTargetReplicaId();
if (this_present_targetReplicaId || that_present_targetReplicaId) {
if (!(this_present_targetReplicaId && that_present_targetReplicaId))
return false;
if (this.targetReplicaId != that.targetReplicaId)
return false;
}
return true;
}
@ -1206,6 +1335,16 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
if (present_limit)
list.add(limit);
boolean present_consistency = true && (isSetConsistency());
list.add(present_consistency);
if (present_consistency)
list.add(consistency.getValue());
boolean present_targetReplicaId = true && (isSetTargetReplicaId());
list.add(present_targetReplicaId);
if (present_targetReplicaId)
list.add(targetReplicaId);
return list.hashCode();
}
@ -1367,6 +1506,26 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetConsistency()).compareTo(other.isSetConsistency());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetConsistency()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.consistency, other.consistency);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetTargetReplicaId()).compareTo(other.isSetTargetReplicaId());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetTargetReplicaId()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.targetReplicaId, other.targetReplicaId);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
@ -1512,6 +1671,22 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
sb.append(this.limit);
first = false;
}
if (isSetConsistency()) {
if (!first) sb.append(", ");
sb.append("consistency:");
if (this.consistency == null) {
sb.append("null");
} else {
sb.append(this.consistency);
}
first = false;
}
if (isSetTargetReplicaId()) {
if (!first) sb.append(", ");
sb.append("targetReplicaId:");
sb.append(this.targetReplicaId);
first = false;
}
sb.append(")");
return sb.toString();
}
@ -1721,6 +1896,22 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 16: // CONSISTENCY
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.consistency = org.apache.hadoop.hbase.thrift2.generated.TConsistency.findByValue(iprot.readI32());
struct.setConsistencyIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 17: // TARGET_REPLICA_ID
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.targetReplicaId = iprot.readI32();
struct.setTargetReplicaIdIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
@ -1852,6 +2043,18 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
oprot.writeI32(struct.limit);
oprot.writeFieldEnd();
}
if (struct.consistency != null) {
if (struct.isSetConsistency()) {
oprot.writeFieldBegin(CONSISTENCY_FIELD_DESC);
oprot.writeI32(struct.consistency.getValue());
oprot.writeFieldEnd();
}
}
if (struct.isSetTargetReplicaId()) {
oprot.writeFieldBegin(TARGET_REPLICA_ID_FIELD_DESC);
oprot.writeI32(struct.targetReplicaId);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@ -1915,7 +2118,13 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
if (struct.isSetLimit()) {
optionals.set(14);
}
oprot.writeBitSet(optionals, 15);
if (struct.isSetConsistency()) {
optionals.set(15);
}
if (struct.isSetTargetReplicaId()) {
optionals.set(16);
}
oprot.writeBitSet(optionals, 17);
if (struct.isSetStartRow()) {
oprot.writeBinary(struct.startRow);
}
@ -1981,12 +2190,18 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
if (struct.isSetLimit()) {
oprot.writeI32(struct.limit);
}
if (struct.isSetConsistency()) {
oprot.writeI32(struct.consistency.getValue());
}
if (struct.isSetTargetReplicaId()) {
oprot.writeI32(struct.targetReplicaId);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TScan struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
BitSet incoming = iprot.readBitSet(15);
BitSet incoming = iprot.readBitSet(17);
if (incoming.get(0)) {
struct.startRow = iprot.readBinary();
struct.setStartRowIsSet(true);
@ -2082,6 +2297,14 @@ public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, jav
struct.limit = iprot.readI32();
struct.setLimitIsSet(true);
}
if (incoming.get(15)) {
struct.consistency = org.apache.hadoop.hbase.thrift2.generated.TConsistency.findByValue(iprot.readI32());
struct.setConsistencyIsSet(true);
}
if (incoming.get(16)) {
struct.targetReplicaId = iprot.readI32();
struct.setTargetReplicaIdIsSet(true);
}
}
}

View File

@ -65,7 +65,8 @@ struct TColumnIncrement {
*/
struct TResult {
1: optional binary row,
2: required list<TColumnValue> columnValues
2: required list<TColumnValue> columnValues,
3: optional bool stale = false
}
/**
@ -101,6 +102,17 @@ struct TAuthorization {
struct TCellVisibility {
1: optional string expression
}
/**
* Specify Consistency:
* - STRONG means reads only from primary region
* - TIMELINE means reads might return values from secondary region replicas
*/
enum TConsistency {
STRONG = 1,
TIMELINE = 2
}
/**
* Used to perform Get operations on a single row.
*
@ -125,6 +137,8 @@ struct TGet {
6: optional binary filterString,
7: optional map<binary, binary> attributes
8: optional TAuthorization authorizations
9: optional TConsistency consistency
10: optional i32 targetReplicaId
}
/**
@ -236,6 +250,8 @@ struct TScan {
13: optional map<binary,TTimeRange> colFamTimeRangeMap
14: optional TReadType readType
15: optional i32 limit
16: optional TConsistency consistency
17: optional i32 targetReplicaId
}
/**

View File

@ -52,6 +52,7 @@ import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Consistency;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Durability;
import org.apache.hadoop.hbase.client.Get;
@ -75,6 +76,7 @@ import org.apache.hadoop.hbase.thrift2.generated.TColumn;
import org.apache.hadoop.hbase.thrift2.generated.TColumnIncrement;
import org.apache.hadoop.hbase.thrift2.generated.TColumnValue;
import org.apache.hadoop.hbase.thrift2.generated.TCompareOp;
import org.apache.hadoop.hbase.thrift2.generated.TConsistency;
import org.apache.hadoop.hbase.thrift2.generated.TDelete;
import org.apache.hadoop.hbase.thrift2.generated.TDeleteType;
import org.apache.hadoop.hbase.thrift2.generated.TDurability;
@ -1559,6 +1561,37 @@ public class TestThriftHBaseServiceHandler {
assertTColumnValueEqual(columnValueB, result.getColumnValues().get(1));
}
@Test
public void testConsistency() throws Exception {
byte[] rowName = Bytes.toBytes("testConsistency");
TGet tGet = new TGet(wrap(rowName));
tGet.setConsistency(TConsistency.STRONG);
Get get = getFromThrift(tGet);
assertEquals(Consistency.STRONG, get.getConsistency());
tGet.setConsistency(TConsistency.TIMELINE);
tGet.setTargetReplicaId(1);
get = getFromThrift(tGet);
assertEquals(Consistency.TIMELINE, get.getConsistency());
assertEquals(1, get.getReplicaId());
TScan tScan = new TScan();
tScan.setConsistency(TConsistency.STRONG);
Scan scan = scanFromThrift(tScan);
assertEquals(Consistency.STRONG, scan.getConsistency());
tScan.setConsistency(TConsistency.TIMELINE);
tScan.setTargetReplicaId(1);
scan = scanFromThrift(tScan);
assertEquals(Consistency.TIMELINE, scan.getConsistency());
assertEquals(1, scan.getReplicaId());
TResult tResult = new TResult();
assertFalse(tResult.isSetStale());
tResult.setStale(true);
assertTrue(tResult.isSetStale());
}
public static class DelayingRegionObserver implements RegionCoprocessor, RegionObserver {
private static final Logger LOG = LoggerFactory.getLogger(DelayingRegionObserver.class);
// sleep time in msec