diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java index a75ce4bd4f1..cbaa13f16a7 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java @@ -167,7 +167,9 @@ public class ThriftUtilities { out = new Put(in.getRow()); } - out.setDurability(in.isWriteToWal() ? Durability.SYNC_WAL : Durability.SKIP_WAL); + if (in.isSetDurability()) { + out.setDurability(durabilityFromThrift(in.getDurability())); + } for (TColumnValue columnValue : in.getColumnValues()) { if (columnValue.isSetTimestamp()) { @@ -250,7 +252,10 @@ public class ThriftUtilities { addAttributes(out,in.getAttributes()); } - out.setDurability(in.isWriteToWal() ? Durability.SYNC_WAL : Durability.SKIP_WAL); + if (in.isSetDurability()) { + out.setDurability(durabilityFromThrift(in.getDurability())); + } + return out; } @@ -383,7 +388,10 @@ public class ThriftUtilities { addAttributes(out,in.getAttributes()); } - out.setDurability(in.isWriteToWal() ? Durability.SYNC_WAL : Durability.SKIP_WAL); + if (in.isSetDurability()) { + out.setDurability(durabilityFromThrift(in.getDurability())); + } + return out; } @@ -401,4 +409,14 @@ public class ThriftUtilities { op.setAttribute(name, value); } } + + private static Durability durabilityFromThrift(TDurability tDurability) { + switch (tDurability.getValue()) { + case 1: return Durability.SKIP_WAL; + case 2: return Durability.ASYNC_WAL; + case 3: return Durability.SYNC_WAL; + case 4: return Durability.FSYNC_WAL; + default: return null; + } + } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TDelete.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TDelete.java index 9647c866de8..16ef3f992f0 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TDelete.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TDelete.java @@ -52,6 +52,9 @@ import org.slf4j.LoggerFactory; * as if you had added a TColumn for every column family and this timestamp * (i.e. all versions older than or equal in all column families will be deleted) * + * You can specify how this Delete should be written to the write-ahead Log (WAL) + * by changing the durability. If you don't provide durability, it defaults to + * column family's default setting for durability. */ public class TDelete implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TDelete"); @@ -60,8 +63,8 @@ public class TDelete implements org.apache.thrift.TBase, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { @@ -77,8 +80,12 @@ public class TDelete implements org.apache.thrift.TBase attributes; // optional + /** + * + * @see TDurability + */ + public TDurability durability; // 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 { @@ -90,8 +97,12 @@ public class TDelete implements org.apache.thrift.TBase byName = new HashMap(); @@ -114,10 +125,10 @@ public class TDelete implements org.apache.thrift.TBase metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); @@ -174,12 +184,12 @@ public class TDelete implements org.apache.thrift.TBase __this__attributes = new HashMap(); for (Map.Entry other_element : other.attributes.entrySet()) { @@ -236,6 +243,9 @@ public class TDelete implements org.apache.thrift.TBase(_list44.size); for (int _i45 = 0; _i45 < _list44.size; ++_i45) { - TColumn _elem46; // required + TColumn _elem46; // optional _elem46 = new TColumn(); _elem46.read(iprot); struct.columns.add(_elem46); @@ -844,14 +866,6 @@ public class TDelete implements org.apache.thrift.TBase(_list55.size); for (int _i56 = 0; _i56 < _list55.size; ++_i56) { - TColumn _elem57; // required + TColumn _elem57; // optional _elem57 = new TColumn(); _elem57.read(iprot); struct.columns.add(_elem57); @@ -1032,10 +1056,6 @@ public class TDelete implements org.apache.thrift.TBase(2*_map58.size); @@ -1050,6 +1070,10 @@ public class TDelete implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TIncrement"); 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 COLUMNS_FIELD_DESC = new org.apache.thrift.protocol.TField("columns", org.apache.thrift.protocol.TType.LIST, (short)2); - private static final org.apache.thrift.protocol.TField WRITE_TO_WAL_FIELD_DESC = new org.apache.thrift.protocol.TField("writeToWal", org.apache.thrift.protocol.TType.BOOL, (short)3); 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)4); + private static final org.apache.thrift.protocol.TField DURABILITY_FIELD_DESC = new org.apache.thrift.protocol.TField("durability", org.apache.thrift.protocol.TType.I32, (short)5); private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { @@ -52,15 +53,23 @@ public class TIncrement implements org.apache.thrift.TBase columns; // required - public boolean writeToWal; // optional public Map attributes; // optional + /** + * + * @see TDurability + */ + public TDurability durability; // 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"), COLUMNS((short)2, "columns"), - WRITE_TO_WAL((short)3, "writeToWal"), - ATTRIBUTES((short)4, "attributes"); + ATTRIBUTES((short)4, "attributes"), + /** + * + * @see TDurability + */ + DURABILITY((short)5, "durability"); private static final Map byName = new HashMap(); @@ -79,10 +88,10 @@ public class TIncrement implements org.apache.thrift.TBase metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); @@ -134,19 +141,17 @@ public class TIncrement implements org.apache.thrift.TBaseother. */ public TIncrement(TIncrement other) { - __isset_bitfield = other.__isset_bitfield; if (other.isSetRow()) { this.row = org.apache.thrift.TBaseHelper.copyBinary(other.row); ; @@ -174,7 +178,6 @@ public class TIncrement implements org.apache.thrift.TBase __this__attributes = new HashMap(); for (Map.Entry other_element : other.attributes.entrySet()) { @@ -192,6 +195,9 @@ public class TIncrement implements org.apache.thrift.TBase(_list62.size); for (int _i63 = 0; _i63 < _list62.size; ++_i63) { - TColumnIncrement _elem64; // required + TColumnIncrement _elem64; // optional _elem64 = new TColumnIncrement(); _elem64.read(iprot); struct.columns.add(_elem64); @@ -646,14 +662,6 @@ public class TIncrement implements org.apache.thrift.TBase(_list73.size); for (int _i74 = 0; _i74 < _list73.size; ++_i74) { - TColumnIncrement _elem75; // required + TColumnIncrement _elem75; // optional _elem75 = new TColumnIncrement(); _elem75.read(iprot); struct.columns.add(_elem75); @@ -793,10 +811,6 @@ public class TIncrement implements org.apache.thrift.TBase(2*_map76.size); @@ -811,6 +825,10 @@ public class TIncrement implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TPut"); @@ -47,8 +48,8 @@ public class TPut implements org.apache.thrift.TBase, java.i 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 TIMESTAMP_FIELD_DESC = new org.apache.thrift.protocol.TField("timestamp", org.apache.thrift.protocol.TType.I64, (short)3); - private static final org.apache.thrift.protocol.TField WRITE_TO_WAL_FIELD_DESC = new org.apache.thrift.protocol.TField("writeToWal", org.apache.thrift.protocol.TType.BOOL, (short)4); 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)5); + private static final org.apache.thrift.protocol.TField DURABILITY_FIELD_DESC = new org.apache.thrift.protocol.TField("durability", org.apache.thrift.protocol.TType.I32, (short)6); private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { @@ -59,16 +60,24 @@ public class TPut implements org.apache.thrift.TBase, java.i public ByteBuffer row; // required public List columnValues; // required public long timestamp; // optional - public boolean writeToWal; // optional public Map attributes; // optional + /** + * + * @see TDurability + */ + public TDurability durability; // 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"), TIMESTAMP((short)3, "timestamp"), - WRITE_TO_WAL((short)4, "writeToWal"), - ATTRIBUTES((short)5, "attributes"); + ATTRIBUTES((short)5, "attributes"), + /** + * + * @see TDurability + */ + DURABILITY((short)6, "durability"); private static final Map byName = new HashMap(); @@ -89,10 +98,10 @@ public class TPut implements org.apache.thrift.TBase, java.i return COLUMN_VALUES; case 3: // TIMESTAMP return TIMESTAMP; - case 4: // WRITE_TO_WAL - return WRITE_TO_WAL; case 5: // ATTRIBUTES return ATTRIBUTES; + case 6: // DURABILITY + return DURABILITY; default: return null; } @@ -134,9 +143,8 @@ public class TPut implements org.apache.thrift.TBase, java.i // isset id assignments private static final int __TIMESTAMP_ISSET_ID = 0; - private static final int __WRITETOWAL_ISSET_ID = 1; private byte __isset_bitfield = 0; - private _Fields optionals[] = {_Fields.TIMESTAMP,_Fields.WRITE_TO_WAL,_Fields.ATTRIBUTES}; + private _Fields optionals[] = {_Fields.TIMESTAMP,_Fields.ATTRIBUTES,_Fields.DURABILITY}; 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); @@ -147,19 +155,17 @@ public class TPut implements org.apache.thrift.TBase, java.i new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TColumnValue.class)))); tmpMap.put(_Fields.TIMESTAMP, new org.apache.thrift.meta_data.FieldMetaData("timestamp", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); - tmpMap.put(_Fields.WRITE_TO_WAL, new org.apache.thrift.meta_data.FieldMetaData("writeToWal", org.apache.thrift.TFieldRequirementType.OPTIONAL, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); tmpMap.put(_Fields.ATTRIBUTES, new org.apache.thrift.meta_data.FieldMetaData("attributes", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true), new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)))); + tmpMap.put(_Fields.DURABILITY, new org.apache.thrift.meta_data.FieldMetaData("durability", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TDurability.class))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TPut.class, metaDataMap); } public TPut() { - this.writeToWal = true; - } public TPut( @@ -188,7 +194,6 @@ public class TPut implements org.apache.thrift.TBase, java.i this.columnValues = __this__columnValues; } this.timestamp = other.timestamp; - this.writeToWal = other.writeToWal; if (other.isSetAttributes()) { Map __this__attributes = new HashMap(); for (Map.Entry other_element : other.attributes.entrySet()) { @@ -206,6 +211,9 @@ public class TPut implements org.apache.thrift.TBase, java.i } this.attributes = __this__attributes; } + if (other.isSetDurability()) { + this.durability = other.durability; + } } public TPut deepCopy() { @@ -218,9 +226,8 @@ public class TPut implements org.apache.thrift.TBase, java.i this.columnValues = null; setTimestampIsSet(false); this.timestamp = 0; - this.writeToWal = true; - this.attributes = null; + this.durability = null; } public byte[] getRow() { @@ -319,29 +326,6 @@ public class TPut implements org.apache.thrift.TBase, java.i __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __TIMESTAMP_ISSET_ID, value); } - public boolean isWriteToWal() { - return this.writeToWal; - } - - public TPut setWriteToWal(boolean writeToWal) { - this.writeToWal = writeToWal; - setWriteToWalIsSet(true); - return this; - } - - public void unsetWriteToWal() { - __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __WRITETOWAL_ISSET_ID); - } - - /** Returns true if field writeToWal is set (has been assigned a value) and false otherwise */ - public boolean isSetWriteToWal() { - return EncodingUtils.testBit(__isset_bitfield, __WRITETOWAL_ISSET_ID); - } - - public void setWriteToWalIsSet(boolean value) { - __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __WRITETOWAL_ISSET_ID, value); - } - public int getAttributesSize() { return (this.attributes == null) ? 0 : this.attributes.size(); } @@ -377,6 +361,38 @@ public class TPut implements org.apache.thrift.TBase, java.i } } + /** + * + * @see TDurability + */ + public TDurability getDurability() { + return this.durability; + } + + /** + * + * @see TDurability + */ + public TPut setDurability(TDurability durability) { + this.durability = durability; + return this; + } + + public void unsetDurability() { + this.durability = null; + } + + /** Returns true if field durability is set (has been assigned a value) and false otherwise */ + public boolean isSetDurability() { + return this.durability != null; + } + + public void setDurabilityIsSet(boolean value) { + if (!value) { + this.durability = null; + } + } + public void setFieldValue(_Fields field, Object value) { switch (field) { case ROW: @@ -403,14 +419,6 @@ public class TPut implements org.apache.thrift.TBase, java.i } break; - case WRITE_TO_WAL: - if (value == null) { - unsetWriteToWal(); - } else { - setWriteToWal((Boolean)value); - } - break; - case ATTRIBUTES: if (value == null) { unsetAttributes(); @@ -419,6 +427,14 @@ public class TPut implements org.apache.thrift.TBase, java.i } break; + case DURABILITY: + if (value == null) { + unsetDurability(); + } else { + setDurability((TDurability)value); + } + break; + } } @@ -433,12 +449,12 @@ public class TPut implements org.apache.thrift.TBase, java.i case TIMESTAMP: return Long.valueOf(getTimestamp()); - case WRITE_TO_WAL: - return Boolean.valueOf(isWriteToWal()); - case ATTRIBUTES: return getAttributes(); + case DURABILITY: + return getDurability(); + } throw new IllegalStateException(); } @@ -456,10 +472,10 @@ public class TPut implements org.apache.thrift.TBase, java.i return isSetColumnValues(); case TIMESTAMP: return isSetTimestamp(); - case WRITE_TO_WAL: - return isSetWriteToWal(); case ATTRIBUTES: return isSetAttributes(); + case DURABILITY: + return isSetDurability(); } throw new IllegalStateException(); } @@ -504,15 +520,6 @@ public class TPut implements org.apache.thrift.TBase, java.i return false; } - boolean this_present_writeToWal = true && this.isSetWriteToWal(); - boolean that_present_writeToWal = true && that.isSetWriteToWal(); - if (this_present_writeToWal || that_present_writeToWal) { - if (!(this_present_writeToWal && that_present_writeToWal)) - return false; - if (this.writeToWal != that.writeToWal) - return false; - } - boolean this_present_attributes = true && this.isSetAttributes(); boolean that_present_attributes = true && that.isSetAttributes(); if (this_present_attributes || that_present_attributes) { @@ -522,6 +529,15 @@ public class TPut implements org.apache.thrift.TBase, java.i return false; } + boolean this_present_durability = true && this.isSetDurability(); + boolean that_present_durability = true && that.isSetDurability(); + if (this_present_durability || that_present_durability) { + if (!(this_present_durability && that_present_durability)) + return false; + if (!this.durability.equals(that.durability)) + return false; + } + return true; } @@ -568,16 +584,6 @@ public class TPut implements org.apache.thrift.TBase, java.i return lastComparison; } } - lastComparison = Boolean.valueOf(isSetWriteToWal()).compareTo(typedOther.isSetWriteToWal()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetWriteToWal()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.writeToWal, typedOther.writeToWal); - if (lastComparison != 0) { - return lastComparison; - } - } lastComparison = Boolean.valueOf(isSetAttributes()).compareTo(typedOther.isSetAttributes()); if (lastComparison != 0) { return lastComparison; @@ -588,6 +594,16 @@ public class TPut implements org.apache.thrift.TBase, java.i return lastComparison; } } + lastComparison = Boolean.valueOf(isSetDurability()).compareTo(typedOther.isSetDurability()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetDurability()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.durability, typedOther.durability); + if (lastComparison != 0) { + return lastComparison; + } + } return 0; } @@ -629,12 +645,6 @@ public class TPut implements org.apache.thrift.TBase, java.i sb.append(this.timestamp); first = false; } - if (isSetWriteToWal()) { - if (!first) sb.append(", "); - sb.append("writeToWal:"); - sb.append(this.writeToWal); - first = false; - } if (isSetAttributes()) { if (!first) sb.append(", "); sb.append("attributes:"); @@ -645,6 +655,16 @@ public class TPut implements org.apache.thrift.TBase, java.i } first = false; } + if (isSetDurability()) { + if (!first) sb.append(", "); + sb.append("durability:"); + if (this.durability == null) { + sb.append("null"); + } else { + sb.append(this.durability); + } + first = false; + } sb.append(")"); return sb.toString(); } @@ -711,7 +731,7 @@ public class TPut implements org.apache.thrift.TBase, java.i struct.columnValues = new ArrayList(_list26.size); for (int _i27 = 0; _i27 < _list26.size; ++_i27) { - TColumnValue _elem28; // required + TColumnValue _elem28; // optional _elem28 = new TColumnValue(); _elem28.read(iprot); struct.columnValues.add(_elem28); @@ -731,14 +751,6 @@ public class TPut implements org.apache.thrift.TBase, java.i org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case 4: // WRITE_TO_WAL - if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { - struct.writeToWal = iprot.readBool(); - struct.setWriteToWalIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; case 5: // ATTRIBUTES if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { { @@ -759,6 +771,14 @@ public class TPut implements org.apache.thrift.TBase, java.i org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; + case 6: // DURABILITY + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.durability = TDurability.findByValue(iprot.readI32()); + struct.setDurabilityIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -796,11 +816,6 @@ public class TPut implements org.apache.thrift.TBase, java.i oprot.writeI64(struct.timestamp); oprot.writeFieldEnd(); } - if (struct.isSetWriteToWal()) { - oprot.writeFieldBegin(WRITE_TO_WAL_FIELD_DESC); - oprot.writeBool(struct.writeToWal); - oprot.writeFieldEnd(); - } if (struct.attributes != null) { if (struct.isSetAttributes()) { oprot.writeFieldBegin(ATTRIBUTES_FIELD_DESC); @@ -816,6 +831,13 @@ public class TPut implements org.apache.thrift.TBase, java.i oprot.writeFieldEnd(); } } + if (struct.durability != null) { + if (struct.isSetDurability()) { + oprot.writeFieldBegin(DURABILITY_FIELD_DESC); + oprot.writeI32(struct.durability.getValue()); + oprot.writeFieldEnd(); + } + } oprot.writeFieldStop(); oprot.writeStructEnd(); } @@ -845,19 +867,16 @@ public class TPut implements org.apache.thrift.TBase, java.i if (struct.isSetTimestamp()) { optionals.set(0); } - if (struct.isSetWriteToWal()) { + if (struct.isSetAttributes()) { optionals.set(1); } - if (struct.isSetAttributes()) { + if (struct.isSetDurability()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetTimestamp()) { oprot.writeI64(struct.timestamp); } - if (struct.isSetWriteToWal()) { - oprot.writeBool(struct.writeToWal); - } if (struct.isSetAttributes()) { { oprot.writeI32(struct.attributes.size()); @@ -868,6 +887,9 @@ public class TPut implements org.apache.thrift.TBase, java.i } } } + if (struct.isSetDurability()) { + oprot.writeI32(struct.durability.getValue()); + } } @Override @@ -880,7 +902,7 @@ public class TPut implements org.apache.thrift.TBase, java.i struct.columnValues = new ArrayList(_list37.size); for (int _i38 = 0; _i38 < _list37.size; ++_i38) { - TColumnValue _elem39; // required + TColumnValue _elem39; // optional _elem39 = new TColumnValue(); _elem39.read(iprot); struct.columnValues.add(_elem39); @@ -893,10 +915,6 @@ public class TPut implements org.apache.thrift.TBase, java.i struct.setTimestampIsSet(true); } if (incoming.get(1)) { - struct.writeToWal = iprot.readBool(); - struct.setWriteToWalIsSet(true); - } - if (incoming.get(2)) { { org.apache.thrift.protocol.TMap _map40 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32()); struct.attributes = new HashMap(2*_map40.size); @@ -911,6 +929,10 @@ public class TPut implements org.apache.thrift.TBase, java.i } struct.setAttributesIsSet(true); } + if (incoming.get(2)) { + struct.durability = TDurability.findByValue(iprot.readI32()); + struct.setDurabilityIsSet(true); + } } } diff --git a/hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift b/hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift index d5018526563..4590ec9edc5 100644 --- a/hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift +++ b/hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift @@ -77,6 +77,21 @@ enum TDeleteType { DELETE_COLUMNS = 1 } +/** + * Specify Durability: + * - SKIP_WAL means do not write the Mutation to the WAL. + * - ASYNC_WAL means write the Mutation to the WAL asynchronously, + * - SYNC_WAL means write the Mutation to the WAL synchronously, + * - FSYNC_WAL means Write the Mutation to the WAL synchronously and force the entries to disk. + */ + +enum TDurability { + SKIP_WAL = 1, + ASYNC_WAL = 2, + SYNC_WAL = 3, + FSYNC_WAL = 4 +} + /** * Used to perform Get operations on a single row. * @@ -110,15 +125,16 @@ struct TGet { * don't have one. If you don't provide a default timestamp * the current time is inserted. * - * You can also specify if this Put should be written - * to the write-ahead Log (WAL) or not. It defaults to true. + * You can specify how this Put should be written to the write-ahead Log (WAL) + * by changing the durability. If you don't provide durability, it defaults to + * column family's default setting for durability. */ struct TPut { 1: required binary row, 2: required list columnValues 3: optional i64 timestamp, - 4: optional bool writeToWal = 1, - 5: optional map attributes + 5: optional map attributes, + 6: optional TDurability durability } /** @@ -143,27 +159,32 @@ struct TPut { * as if you had added a TColumn for every column family and this timestamp * (i.e. all versions older than or equal in all column families will be deleted) * + * You can specify how this Delete should be written to the write-ahead Log (WAL) + * by changing the durability. If you don't provide durability, it defaults to + * column family's default setting for durability. */ struct TDelete { 1: required binary row, 2: optional list columns, 3: optional i64 timestamp, 4: optional TDeleteType deleteType = 1, - 5: optional bool writeToWal = 1, - 6: optional map attributes + 6: optional map attributes, + 7: optional TDurability durability + } /** * Used to perform Increment operations for a single row. * - * You can specify if this Increment should be written - * to the write-ahead Log (WAL) or not. It defaults to true. + * You can specify how this Increment should be written to the write-ahead Log (WAL) + * by changing the durability. If you don't provide durability, it defaults to + * column family's default setting for durability. */ struct TIncrement { 1: required binary row, 2: required list columns, - 3: optional bool writeToWal = 1, - 4: optional map attributes + 4: optional map attributes, + 5: optional TDurability durability } /** diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java index dfdbe9c1d99..36be0842ce3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java @@ -32,6 +32,7 @@ import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.client.Increment; import org.apache.hadoop.hbase.client.Delete; +import org.apache.hadoop.hbase.client.Durability; import org.apache.hadoop.hbase.filter.ParseFilter; import org.apache.hadoop.hbase.test.MetricsAssertHelper; import org.apache.hadoop.hbase.thrift.ThriftMetrics; @@ -50,6 +51,7 @@ import org.apache.hadoop.hbase.thrift2.generated.TResult; import org.apache.hadoop.hbase.thrift2.generated.TScan; import org.apache.hadoop.hbase.thrift2.generated.TMutation; import org.apache.hadoop.hbase.thrift2.generated.TRowMutations; +import org.apache.hadoop.hbase.thrift2.generated.TDurability; import org.apache.hadoop.hbase.util.Bytes; import org.apache.thrift.TException; import org.junit.AfterClass; @@ -864,5 +866,74 @@ public class TestThriftHBaseServiceHandler { expectedColumnValues.add(columnValueB); assertTColumnValuesEqual(expectedColumnValues, returnedColumnValues); } + + /** + * Create TPut, TDelete , TIncrement objects, set durability then call ThriftUtility + * functions to get Put , Delete and Increment respectively. Use getDurability to make sure + * the returned objects have the appropriate durability setting. + * + * @throws Exception + */ + @Test + public void testDurability() throws Exception { + byte[] rowName = "testDurability".getBytes(); + List columnValues = new ArrayList(); + columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(valueAname))); + + List incrementColumns = new ArrayList(); + incrementColumns.add(new TColumnIncrement(wrap(familyAname), wrap(qualifierAname))); + + TDelete tDelete = new TDelete(wrap(rowName)); + tDelete.setDurability(TDurability.SKIP_WAL); + Delete delete = deleteFromThrift(tDelete); + assertEquals(delete.getDurability(), Durability.SKIP_WAL); + + tDelete.setDurability(TDurability.ASYNC_WAL); + delete = deleteFromThrift(tDelete); + assertEquals(delete.getDurability(), Durability.ASYNC_WAL); + + tDelete.setDurability(TDurability.SYNC_WAL); + delete = deleteFromThrift(tDelete); + assertEquals(delete.getDurability(), Durability.SYNC_WAL); + + tDelete.setDurability(TDurability.FSYNC_WAL); + delete = deleteFromThrift(tDelete); + assertEquals(delete.getDurability(), Durability.FSYNC_WAL); + + TPut tPut = new TPut(wrap(rowName), columnValues); + tPut.setDurability(TDurability.SKIP_WAL); + Put put = putFromThrift(tPut); + assertEquals(put.getDurability(), Durability.SKIP_WAL); + + tPut.setDurability(TDurability.ASYNC_WAL); + put = putFromThrift(tPut); + assertEquals(put.getDurability(), Durability.ASYNC_WAL); + + tPut.setDurability(TDurability.SYNC_WAL); + put = putFromThrift(tPut); + assertEquals(put.getDurability(), Durability.SYNC_WAL); + + tPut.setDurability(TDurability.FSYNC_WAL); + put = putFromThrift(tPut); + assertEquals(put.getDurability(), Durability.FSYNC_WAL); + + TIncrement tIncrement = new TIncrement(wrap(rowName), incrementColumns); + + tIncrement.setDurability(TDurability.SKIP_WAL); + Increment increment = incrementFromThrift(tIncrement); + assertEquals(increment.getDurability(), Durability.SKIP_WAL); + + tIncrement.setDurability(TDurability.ASYNC_WAL); + increment = incrementFromThrift(tIncrement); + assertEquals(increment.getDurability(), Durability.ASYNC_WAL); + + tIncrement.setDurability(TDurability.SYNC_WAL); + increment = incrementFromThrift(tIncrement); + assertEquals(increment.getDurability(), Durability.SYNC_WAL); + + tIncrement.setDurability(TDurability.FSYNC_WAL); + increment = incrementFromThrift(tIncrement); + assertEquals(increment.getDurability(), Durability.FSYNC_WAL); + } }