You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2018/12/31 12:46:11 UTC
[35/47] hbase git commit: HBASE-21650 Add DDL operation and some
other miscellaneous to thrift2
http://git-wip-us.apache.org/repos/asf/hbase/blob/7820ba1d/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TTableName.java
----------------------------------------------------------------------
diff --git a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TTableName.java b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TTableName.java
new file mode 100644
index 0000000..f2c0743
--- /dev/null
+++ b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TTableName.java
@@ -0,0 +1,512 @@
+/**
+ * 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 org.apache.thrift.scheme.IScheme;
+import org.apache.thrift.scheme.SchemeFactory;
+import org.apache.thrift.scheme.StandardScheme;
+
+import org.apache.thrift.scheme.TupleScheme;
+import org.apache.thrift.protocol.TTupleProtocol;
+import org.apache.thrift.protocol.TProtocolException;
+import org.apache.thrift.EncodingUtils;
+import org.apache.thrift.TException;
+import org.apache.thrift.async.AsyncMethodCallback;
+import org.apache.thrift.server.AbstractNonblockingServer.*;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.EnumMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.EnumSet;
+import java.util.Collections;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import javax.annotation.Generated;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-27")
+public class TTableName implements org.apache.thrift.TBase<TTableName, TTableName._Fields>, java.io.Serializable, Cloneable, Comparable<TTableName> {
+ private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TTableName");
+
+ private static final org.apache.thrift.protocol.TField NS_FIELD_DESC = new org.apache.thrift.protocol.TField("ns", org.apache.thrift.protocol.TType.STRING, (short)1);
+ private static final org.apache.thrift.protocol.TField QUALIFIER_FIELD_DESC = new org.apache.thrift.protocol.TField("qualifier", org.apache.thrift.protocol.TType.STRING, (short)2);
+
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new TTableNameStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new TTableNameTupleSchemeFactory());
+ }
+
+ public ByteBuffer ns; // required
+ public ByteBuffer qualifier; // required
+
+ /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+ public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+ NS((short)1, "ns"),
+ QUALIFIER((short)2, "qualifier");
+
+ private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+ static {
+ for (_Fields field : EnumSet.allOf(_Fields.class)) {
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not found.
+ */
+ public static _Fields findByThriftId(int fieldId) {
+ switch(fieldId) {
+ case 1: // NS
+ return NS;
+ case 2: // QUALIFIER
+ return QUALIFIER;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ public static _Fields findByName(String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final String _fieldName;
+
+ _Fields(short thriftId, String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+ 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);
+ tmpMap.put(_Fields.NS, new org.apache.thrift.meta_data.FieldMetaData("ns", org.apache.thrift.TFieldRequirementType.REQUIRED,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
+ tmpMap.put(_Fields.QUALIFIER, new org.apache.thrift.meta_data.FieldMetaData("qualifier", org.apache.thrift.TFieldRequirementType.REQUIRED,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
+ metaDataMap = Collections.unmodifiableMap(tmpMap);
+ org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TTableName.class, metaDataMap);
+ }
+
+ public TTableName() {
+ }
+
+ public TTableName(
+ ByteBuffer ns,
+ ByteBuffer qualifier)
+ {
+ this();
+ this.ns = org.apache.thrift.TBaseHelper.copyBinary(ns);
+ this.qualifier = org.apache.thrift.TBaseHelper.copyBinary(qualifier);
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public TTableName(TTableName other) {
+ if (other.isSetNs()) {
+ this.ns = org.apache.thrift.TBaseHelper.copyBinary(other.ns);
+ }
+ if (other.isSetQualifier()) {
+ this.qualifier = org.apache.thrift.TBaseHelper.copyBinary(other.qualifier);
+ }
+ }
+
+ public TTableName deepCopy() {
+ return new TTableName(this);
+ }
+
+ @Override
+ public void clear() {
+ this.ns = null;
+ this.qualifier = null;
+ }
+
+ public byte[] getNs() {
+ setNs(org.apache.thrift.TBaseHelper.rightSize(ns));
+ return ns == null ? null : ns.array();
+ }
+
+ public ByteBuffer bufferForNs() {
+ return org.apache.thrift.TBaseHelper.copyBinary(ns);
+ }
+
+ public TTableName setNs(byte[] ns) {
+ this.ns = ns == null ? (ByteBuffer)null : ByteBuffer.wrap(Arrays.copyOf(ns, ns.length));
+ return this;
+ }
+
+ public TTableName setNs(ByteBuffer ns) {
+ this.ns = org.apache.thrift.TBaseHelper.copyBinary(ns);
+ return this;
+ }
+
+ public void unsetNs() {
+ this.ns = null;
+ }
+
+ /** Returns true if field ns is set (has been assigned a value) and false otherwise */
+ public boolean isSetNs() {
+ return this.ns != null;
+ }
+
+ public void setNsIsSet(boolean value) {
+ if (!value) {
+ this.ns = null;
+ }
+ }
+
+ public byte[] getQualifier() {
+ setQualifier(org.apache.thrift.TBaseHelper.rightSize(qualifier));
+ return qualifier == null ? null : qualifier.array();
+ }
+
+ public ByteBuffer bufferForQualifier() {
+ return org.apache.thrift.TBaseHelper.copyBinary(qualifier);
+ }
+
+ public TTableName setQualifier(byte[] qualifier) {
+ this.qualifier = qualifier == null ? (ByteBuffer)null : ByteBuffer.wrap(Arrays.copyOf(qualifier, qualifier.length));
+ return this;
+ }
+
+ public TTableName setQualifier(ByteBuffer qualifier) {
+ this.qualifier = org.apache.thrift.TBaseHelper.copyBinary(qualifier);
+ return this;
+ }
+
+ public void unsetQualifier() {
+ this.qualifier = null;
+ }
+
+ /** Returns true if field qualifier is set (has been assigned a value) and false otherwise */
+ public boolean isSetQualifier() {
+ return this.qualifier != null;
+ }
+
+ public void setQualifierIsSet(boolean value) {
+ if (!value) {
+ this.qualifier = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case NS:
+ if (value == null) {
+ unsetNs();
+ } else {
+ setNs((ByteBuffer)value);
+ }
+ break;
+
+ case QUALIFIER:
+ if (value == null) {
+ unsetQualifier();
+ } else {
+ setQualifier((ByteBuffer)value);
+ }
+ break;
+
+ }
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case NS:
+ return getNs();
+
+ case QUALIFIER:
+ return getQualifier();
+
+ }
+ throw new IllegalStateException();
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ if (field == null) {
+ throw new IllegalArgumentException();
+ }
+
+ switch (field) {
+ case NS:
+ return isSetNs();
+ case QUALIFIER:
+ return isSetQualifier();
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof TTableName)
+ return this.equals((TTableName)that);
+ return false;
+ }
+
+ public boolean equals(TTableName that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_ns = true && this.isSetNs();
+ boolean that_present_ns = true && that.isSetNs();
+ if (this_present_ns || that_present_ns) {
+ if (!(this_present_ns && that_present_ns))
+ return false;
+ if (!this.ns.equals(that.ns))
+ return false;
+ }
+
+ boolean this_present_qualifier = true && this.isSetQualifier();
+ boolean that_present_qualifier = true && that.isSetQualifier();
+ if (this_present_qualifier || that_present_qualifier) {
+ if (!(this_present_qualifier && that_present_qualifier))
+ return false;
+ if (!this.qualifier.equals(that.qualifier))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ List<Object> list = new ArrayList<Object>();
+
+ boolean present_ns = true && (isSetNs());
+ list.add(present_ns);
+ if (present_ns)
+ list.add(ns);
+
+ boolean present_qualifier = true && (isSetQualifier());
+ list.add(present_qualifier);
+ if (present_qualifier)
+ list.add(qualifier);
+
+ return list.hashCode();
+ }
+
+ @Override
+ public int compareTo(TTableName other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+
+ lastComparison = Boolean.valueOf(isSetNs()).compareTo(other.isSetNs());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetNs()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ns, other.ns);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ lastComparison = Boolean.valueOf(isSetQualifier()).compareTo(other.isSetQualifier());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetQualifier()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.qualifier, other.qualifier);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ return 0;
+ }
+
+ public _Fields fieldForId(int fieldId) {
+ return _Fields.findByThriftId(fieldId);
+ }
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+ schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+ schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("TTableName(");
+ boolean first = true;
+
+ sb.append("ns:");
+ if (this.ns == null) {
+ sb.append("null");
+ } else {
+ org.apache.thrift.TBaseHelper.toString(this.ns, sb);
+ }
+ first = false;
+ if (!first) sb.append(", ");
+ sb.append("qualifier:");
+ if (this.qualifier == null) {
+ sb.append("null");
+ } else {
+ org.apache.thrift.TBaseHelper.toString(this.qualifier, sb);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws org.apache.thrift.TException {
+ // check for required fields
+ if (ns == null) {
+ throw new org.apache.thrift.protocol.TProtocolException("Required field 'ns' was not present! Struct: " + toString());
+ }
+ if (qualifier == null) {
+ throw new org.apache.thrift.protocol.TProtocolException("Required field 'qualifier' was not present! Struct: " + toString());
+ }
+ // check for sub-struct validity
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+ try {
+ write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
+ try {
+ 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);
+ }
+ }
+
+ private static class TTableNameStandardSchemeFactory implements SchemeFactory {
+ public TTableNameStandardScheme getScheme() {
+ return new TTableNameStandardScheme();
+ }
+ }
+
+ private static class TTableNameStandardScheme extends StandardScheme<TTableName> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, TTableName struct) throws org.apache.thrift.TException {
+ org.apache.thrift.protocol.TField schemeField;
+ iprot.readStructBegin();
+ while (true)
+ {
+ schemeField = iprot.readFieldBegin();
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ break;
+ }
+ switch (schemeField.id) {
+ case 1: // NS
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+ struct.ns = iprot.readBinary();
+ struct.setNsIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ case 2: // QUALIFIER
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+ struct.qualifier = iprot.readBinary();
+ struct.setQualifierIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
+ default:
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked in the validate method
+ struct.validate();
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot, TTableName struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (struct.ns != null) {
+ oprot.writeFieldBegin(NS_FIELD_DESC);
+ oprot.writeBinary(struct.ns);
+ oprot.writeFieldEnd();
+ }
+ if (struct.qualifier != null) {
+ oprot.writeFieldBegin(QUALIFIER_FIELD_DESC);
+ oprot.writeBinary(struct.qualifier);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class TTableNameTupleSchemeFactory implements SchemeFactory {
+ public TTableNameTupleScheme getScheme() {
+ return new TTableNameTupleScheme();
+ }
+ }
+
+ private static class TTableNameTupleScheme extends TupleScheme<TTableName> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, TTableName struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ oprot.writeBinary(struct.ns);
+ oprot.writeBinary(struct.qualifier);
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, TTableName struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ struct.ns = iprot.readBinary();
+ struct.setNsIsSet(true);
+ struct.qualifier = iprot.readBinary();
+ struct.setQualifierIsSet(true);
+ }
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/hbase/blob/7820ba1d/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TTimeRange.java
----------------------------------------------------------------------
diff --git a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TTimeRange.java b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TTimeRange.java
index 74c7255..1e1898c 100644
--- a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TTimeRange.java
+++ b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TTimeRange.java
@@ -34,7 +34,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
-@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-05-25")
+@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2018-12-27")
public class TTimeRange implements org.apache.thrift.TBase<TTimeRange, TTimeRange._Fields>, java.io.Serializable, Cloneable, Comparable<TTimeRange> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TTimeRange");
http://git-wip-us.apache.org/repos/asf/hbase/blob/7820ba1d/hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift
----------------------------------------------------------------------
diff --git a/hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift b/hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift
index 79196f4..6383329 100644
--- a/hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift
+++ b/hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift
@@ -48,7 +48,8 @@ struct TColumnValue {
2: required binary qualifier,
3: required binary value,
4: optional i64 timestamp,
- 5: optional binary tags
+ 5: optional binary tags,
+ 6: optional byte type
}
/**
@@ -67,6 +68,7 @@ struct TResult {
1: optional binary row,
2: required list<TColumnValue> columnValues,
3: optional bool stale = false
+ 4: optional bool partial = false
}
/**
@@ -90,6 +92,7 @@ enum TDeleteType {
*/
enum TDurability {
+ USE_DEFAULT = 0,
SKIP_WAL = 1,
ASYNC_WAL = 2,
SYNC_WAL = 3,
@@ -139,6 +142,11 @@ struct TGet {
8: optional TAuthorization authorizations
9: optional TConsistency consistency
10: optional i32 targetReplicaId
+ 11: optional bool cacheBlocks
+ 12: optional i32 storeLimit
+ 13: optional i32 storeOffset
+ 14: optional bool existence_only
+
}
/**
@@ -211,6 +219,7 @@ struct TIncrement {
4: optional map<binary, binary> attributes,
5: optional TDurability durability
6: optional TCellVisibility cellVisibility
+ 7: optional bool returnResults
}
/*
@@ -222,6 +231,7 @@ struct TAppend {
3: optional map<binary, binary> attributes,
4: optional TDurability durability
5: optional TCellVisibility cellVisibility
+ 6: optional bool returnResults
}
enum TReadType {
@@ -258,8 +268,8 @@ struct TScan {
* Atomic mutation for the specified row. It can be either Put or Delete.
*/
union TMutation {
- 1: TPut put,
- 2: TDelete deleteSingle,
+ 1: TPut put
+ 2: TDelete deleteSingle
}
/**
@@ -305,6 +315,112 @@ enum TCompareOp {
NO_OP = 6
}
+enum TBloomFilterType {
+/**
+ * Bloomfilters disabled
+ */
+ NONE = 0,
+ /**
+ * Bloom enabled with Table row as Key
+ */
+ ROW = 1,
+ /**
+ * Bloom enabled with Table row & column (family+qualifier) as Key
+ */
+ ROWCOL = 2,
+ /**
+ * Bloom enabled with Table row prefix as Key, specify the length of the prefix
+ */
+ ROWPREFIX_FIXED_LENGTH = 3,
+ /**
+ * Bloom enabled with Table row prefix as Key, specify the delimiter of the prefix
+ */
+ ROWPREFIX_DELIMITED = 4
+}
+
+enum TCompressionAlgorithm {
+ LZO = 0,
+ GZ = 1,
+ NONE = 2,
+ SNAPPY = 3,
+ LZ4 = 4,
+ BZIP2 = 5,
+ ZSTD = 6
+}
+
+enum TDataBlockEncoding {
+/** Disable data block encoding. */
+ NONE = 0,
+ // id 1 is reserved for the BITSET algorithm to be added later
+ PREFIX = 2,
+ DIFF = 3,
+ FAST_DIFF = 4,
+ // id 5 is reserved for the COPY_KEY algorithm for benchmarking
+ // COPY_KEY(5, "org.apache.hadoop.hbase.io.encoding.CopyKeyDataBlockEncoder"),
+ // PREFIX_TREE(6, "org.apache.hadoop.hbase.codec.prefixtree.PrefixTreeCodec"),
+ ROW_INDEX_V1 = 7
+}
+
+enum TKeepDeletedCells {
+ /** Deleted Cells are not retained. */
+ FALSE = 0,
+ /**
+ * Deleted Cells are retained until they are removed by other means
+ * such TTL or VERSIONS.
+ * If no TTL is specified or no new versions of delete cells are
+ * written, they are retained forever.
+ */
+ TRUE = 1,
+ /**
+ * Deleted Cells are retained until the delete marker expires due to TTL.
+ * This is useful when TTL is combined with MIN_VERSIONS and one
+ * wants to keep a minimum number of versions around but at the same
+ * time remove deleted cells after the TTL.
+ */
+ TTL = 2
+}
+
+struct TTableName {
+ 1: required binary ns
+ 2: required binary qualifier
+}
+
+struct TColumnFamilyDescriptor {
+ 1: required binary name
+ 2: optional map<binary, binary> attributes
+ 3: optional map<string, string> configuration
+ 4: optional i32 blockSize
+ 5: optional TBloomFilterType bloomnFilterType
+ 6: optional TCompressionAlgorithm compressionType
+ 7: optional i16 dfsReplication
+ 8: optional TDataBlockEncoding dataBlockEncoding
+ 9: optional TKeepDeletedCells keepDeletedCells
+ 10: optional i32 maxVersions
+ 11: optional i32 minVersions
+ 12: optional i32 scope
+ 13: optional i32 timeToLive
+ 14: optional bool blockCacheEnabled
+ 15: optional bool cacheBloomsOnWrite
+ 16: optional bool cacheDataOnWrite
+ 17: optional bool cacheIndexesOnWrite
+ 18: optional bool compressTags
+ 19: optional bool evictBlocksOnClose
+ 20: optional bool inMemory
+
+}
+
+struct TTableDescriptor {
+ 1: required TTableName tableName
+ 2: optional list<TColumnFamilyDescriptor> columns
+ 3: optional map<binary, binary> attributes
+ 4: optional TDurability durability
+}
+
+struct TNamespaceDescriptor {
+1: required string name
+2: optional map<string, string> configuration
+}
+
//
// Exceptions
@@ -644,4 +760,111 @@ service THBaseService {
/** row mutations to execute if the value matches */
7: required TRowMutations rowMutations
) throws (1: TIOError io)
+
+ TTableDescriptor getTableDescriptor(
+ 1: required TTableName table
+ ) throws (1: TIOError io)
+
+ list<TTableDescriptor> getTableDescriptors(
+ 1: required list<TTableName> tables
+ ) throws (1: TIOError io)
+
+ bool tableExists(
+ 1: TTableName tableName
+ ) throws (1: TIOError io)
+
+ list<TTableDescriptor> getTableDescriptorsByPattern(
+ 1: required string regex
+ 2: required bool includeSysTables
+ ) throws (1: TIOError io)
+
+ list<TTableDescriptor> getTableDescriptorsByNamespace(
+ 1: required string name
+ ) throws (1: TIOError io)
+
+ list<TTableName> getTableNamesByPattern(
+ 1: required string regex
+ 2: required bool includeSysTables
+ ) throws (1: TIOError io)
+
+ list<TTableName> getTableNamesByNamespace(
+ 1: required string name
+ ) throws (1: TIOError io)
+
+ void createTable(
+ 1: required TTableDescriptor desc
+ 2: required list<binary> splitKeys
+ ) throws (1: TIOError io)
+
+ void deleteTable(
+ 1: required TTableName tableName
+ ) throws (1: TIOError io)
+
+ void truncateTable(
+ 1: required TTableName tableName
+ 2: required bool preserveSplits
+ ) throws (1: TIOError io)
+
+ void enableTable(
+ 1: required TTableName tableName
+ ) throws (1: TIOError io)
+
+ void disableTable(
+ 1: required TTableName tableName
+ ) throws (1: TIOError io)
+
+ bool isTableEnabled(
+ 1: required TTableName tableName
+ ) throws (1: TIOError io)
+
+ bool isTableDisabled(
+ 1: required TTableName tableName
+ ) throws (1: TIOError io)
+
+ bool isTableAvailable(
+ 1: required TTableName tableName
+ ) throws (1: TIOError io)
+
+ bool isTableAvailableWithSplit(
+ 1: required TTableName tableName
+ 2: required list<binary> splitKeys
+ ) throws (1: TIOError io)
+
+ void addColumnFamily(
+ 1: required TTableName tableName
+ 2: required TColumnFamilyDescriptor column
+ ) throws (1: TIOError io)
+
+ void deleteColumnFamily(
+ 1: required TTableName tableName
+ 2: required binary column
+ ) throws (1: TIOError io)
+
+ void modifyColumnFamily(
+ 1: required TTableName tableName
+ 2: required TColumnFamilyDescriptor column
+ ) throws (1: TIOError io)
+
+ void modifyTable(
+ 1: required TTableDescriptor desc
+ ) throws (1: TIOError io)
+
+ void createNamespace(
+ 1: required TNamespaceDescriptor namespaceDesc
+ ) throws (1: TIOError io)
+
+ void modifyNamespace(
+ 1: required TNamespaceDescriptor namespaceDesc
+ ) throws (1: TIOError io)
+
+ void deleteNamespace(
+ 1: required string name
+ ) throws (1: TIOError io)
+
+ TNamespaceDescriptor getNamespaceDescriptor(
+ 1: required string name
+ ) throws (1: TIOError io)
+
+ list<TNamespaceDescriptor> listNamespaceDescriptors(
+ ) throws (1: TIOError io)
}
http://git-wip-us.apache.org/repos/asf/hbase/blob/7820ba1d/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java
----------------------------------------------------------------------
diff --git a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java
index 1626121..0734f85 100644
--- a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java
+++ b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandler.java
@@ -60,6 +60,7 @@ import org.apache.hadoop.hbase.client.Increment;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.client.TableDescriptor;
import org.apache.hadoop.hbase.coprocessor.ObserverContext;
import org.apache.hadoop.hbase.coprocessor.RegionCoprocessor;
import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
@@ -73,10 +74,12 @@ import org.apache.hadoop.hbase.thrift.ErrorThrowingGetObserver;
import org.apache.hadoop.hbase.thrift.ThriftMetrics;
import org.apache.hadoop.hbase.thrift2.generated.TAppend;
import org.apache.hadoop.hbase.thrift2.generated.TColumn;
+import org.apache.hadoop.hbase.thrift2.generated.TColumnFamilyDescriptor;
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.TDataBlockEncoding;
import org.apache.hadoop.hbase.thrift2.generated.TDelete;
import org.apache.hadoop.hbase.thrift2.generated.TDeleteType;
import org.apache.hadoop.hbase.thrift2.generated.TDurability;
@@ -86,11 +89,14 @@ import org.apache.hadoop.hbase.thrift2.generated.TIOError;
import org.apache.hadoop.hbase.thrift2.generated.TIllegalArgument;
import org.apache.hadoop.hbase.thrift2.generated.TIncrement;
import org.apache.hadoop.hbase.thrift2.generated.TMutation;
+import org.apache.hadoop.hbase.thrift2.generated.TNamespaceDescriptor;
import org.apache.hadoop.hbase.thrift2.generated.TPut;
import org.apache.hadoop.hbase.thrift2.generated.TReadType;
import org.apache.hadoop.hbase.thrift2.generated.TResult;
import org.apache.hadoop.hbase.thrift2.generated.TRowMutations;
import org.apache.hadoop.hbase.thrift2.generated.TScan;
+import org.apache.hadoop.hbase.thrift2.generated.TTableDescriptor;
+import org.apache.hadoop.hbase.thrift2.generated.TTableName;
import org.apache.hadoop.hbase.thrift2.generated.TTimeRange;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.thrift.TException;
@@ -1592,6 +1598,96 @@ public class TestThriftHBaseServiceHandler {
assertTrue(tResult.isSetStale());
}
+ @Test
+ public void testDDLOpertions() throws Exception {
+ String namespace = "testDDLOpertionsNamespace";
+ String table = "testDDLOpertionsTable";
+ TTableName tTableName = new TTableName();
+ tTableName.setNs(Bytes.toBytes(namespace));
+ tTableName.setQualifier(Bytes.toBytes(table));
+ ThriftHBaseServiceHandler handler = createHandler();
+ //create name space
+ TNamespaceDescriptor namespaceDescriptor = new TNamespaceDescriptor();
+ namespaceDescriptor.setName(namespace);
+ namespaceDescriptor.putToConfiguration("key1", "value1");
+ namespaceDescriptor.putToConfiguration("key2", "value2");
+ handler.createNamespace(namespaceDescriptor);
+ //list namespace
+ List<TNamespaceDescriptor> namespaceDescriptors = handler.listNamespaceDescriptors();
+ // should have 3 namespace, default hbase and testDDLOpertionsNamespace
+ assertTrue(namespaceDescriptors.size() == 3);
+ //modify namesapce
+ namespaceDescriptor.putToConfiguration("kye3", "value3");
+ handler.modifyNamespace(namespaceDescriptor);
+ //get namespace
+ TNamespaceDescriptor namespaceDescriptorReturned = handler.getNamespaceDescriptor(namespace);
+ assertTrue(namespaceDescriptorReturned.getConfiguration().size() == 3);
+ //create table
+ TTableDescriptor tableDescriptor = new TTableDescriptor();
+ tableDescriptor.setTableName(tTableName);
+ TColumnFamilyDescriptor columnFamilyDescriptor1 = new TColumnFamilyDescriptor();
+ columnFamilyDescriptor1.setName(familyAname);
+ columnFamilyDescriptor1.setDataBlockEncoding(TDataBlockEncoding.DIFF);
+ tableDescriptor.addToColumns(columnFamilyDescriptor1);
+ List<ByteBuffer> splitKeys = new ArrayList<>();
+ splitKeys.add(ByteBuffer.wrap(Bytes.toBytes(5)));
+ handler.createTable(tableDescriptor, splitKeys);
+ //modify table
+ tableDescriptor.setDurability(TDurability.ASYNC_WAL);
+ handler.modifyTable(tableDescriptor);
+ //modify column family
+ columnFamilyDescriptor1.setInMemory(true);
+ handler.modifyColumnFamily(tTableName, columnFamilyDescriptor1);
+ //add column family
+ TColumnFamilyDescriptor columnFamilyDescriptor2 = new TColumnFamilyDescriptor();
+ columnFamilyDescriptor2.setName(familyBname);
+ columnFamilyDescriptor2.setDataBlockEncoding(TDataBlockEncoding.PREFIX);
+ handler.addColumnFamily(tTableName, columnFamilyDescriptor2);
+ //get table descriptor
+ TTableDescriptor tableDescriptorReturned = handler.getTableDescriptor(tTableName);
+ assertTrue(tableDescriptorReturned.getColumns().size() == 2);
+ assertTrue(tableDescriptorReturned.getDurability() == TDurability.ASYNC_WAL);
+ TColumnFamilyDescriptor columnFamilyDescriptor1Returned = tableDescriptorReturned.getColumns()
+ .stream().filter(desc -> Bytes.equals(desc.getName(), familyAname)).findFirst().get();
+ assertTrue(columnFamilyDescriptor1Returned.isInMemory() == true);
+ //delete column family
+ handler.deleteColumnFamily(tTableName, ByteBuffer.wrap(familyBname));
+ tableDescriptorReturned = handler.getTableDescriptor(tTableName);
+ assertTrue(tableDescriptorReturned.getColumns().size() == 1);
+ //disable table
+ handler.disableTable(tTableName);
+ assertTrue(handler.isTableDisabled(tTableName));
+ //enable table
+ handler.enableTable(tTableName);
+ assertTrue(handler.isTableEnabled(tTableName));
+ assertTrue(handler.isTableAvailable(tTableName));
+ //truncate table
+ handler.disableTable(tTableName);
+ handler.truncateTable(tTableName, true);
+ assertTrue(handler.isTableAvailable(tTableName));
+ //delete table
+ handler.disableTable(tTableName);
+ handler.deleteTable(tTableName);
+ assertFalse(handler.tableExists(tTableName));
+ //delete namespace
+ handler.deleteNamespace(namespace);
+ namespaceDescriptors = handler.listNamespaceDescriptors();
+ // should have 2 namespace, default and hbase
+ assertTrue(namespaceDescriptors.size() == 2);
+ }
+
+ @Test
+ public void testGetTableDescriptor() throws Exception {
+ ThriftHBaseServiceHandler handler = createHandler();
+ TTableDescriptor tableDescriptor = handler
+ .getTableDescriptor(ThriftUtilities.tableNameFromHBase(TableName.valueOf(tableAname)));
+ TableDescriptor table = ThriftUtilities.tableDescriptorFromThrift(tableDescriptor);
+ assertTrue(table.getTableName().equals(TableName.valueOf(tableAname)));
+ assertTrue(table.getColumnFamilies().length == 2);
+ assertTrue(table.getColumnFamily(familyAname).getMaxVersions() == 3);
+ assertTrue(table.getColumnFamily(familyBname).getMaxVersions() == 2);
+ }
+
public static class DelayingRegionObserver implements RegionCoprocessor, RegionObserver {
private static final Logger LOG = LoggerFactory.getLogger(DelayingRegionObserver.class);
// sleep time in msec