You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ra...@apache.org on 2013/12/02 13:44:03 UTC
svn commit: r1546988 [1/3] - in /hbase/trunk:
hbase-server/src/main/java/org/apache/hadoop/hbase/rest/
hbase-server/src/main/java/org/apache/hadoop/hbase/rest/model/
hbase-server/src/main/java/org/apache/hadoop/hbase/rest/protobuf/generated/
hbase-serv...
Author: ramkrishna
Date: Mon Dec 2 12:44:03 2013
New Revision: 1546988
URL: http://svn.apache.org/r1546988
Log:
HBASE-9884 - Add Thrift and REST support for Visibility Labels (Ram)
Added:
hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithLabels.java
hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TAuthorization.java
hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TCellVisibility.java
hbase/trunk/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift2/TestThriftHBaseServiceHandlerWithLabels.java
Modified:
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/ScannerResource.java
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/ScannerResultGenerator.java
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/model/ScannerModel.java
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/protobuf/generated/ScannerMessage.java
hbase/trunk/hbase-server/src/main/resources/org/apache/hadoop/hbase/rest/protobuf/ScannerMessage.proto
hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/model/TestScannerModel.java
hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java
hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TAppend.java
hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TColumnValue.java
hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TGet.java
hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TIncrement.java
hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TPut.java
hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TScan.java
hbase/trunk/hbase-thrift/src/main/resources/org/apache/hadoop/hbase/thrift2/hbase.thrift
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java?rev=1546988&r1=1546987&r2=1546988&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java Mon Dec 2 12:44:03 2013
@@ -21,7 +21,9 @@ package org.apache.hadoop.hbase.rest;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import java.util.TreeSet;
import org.apache.hadoop.classification.InterfaceAudience;
@@ -43,6 +45,7 @@ public class RowSpec {
private byte[] endRow = null;
private TreeSet<byte[]> columns =
new TreeSet<byte[]>(Bytes.BYTES_COMPARATOR);
+ private List<String> labels = new ArrayList<String>();
private long startTime = DEFAULT_START_TIMESTAMP;
private long endTime = DEFAULT_END_TIMESTAMP;
private int maxVersions = 1;
@@ -277,6 +280,13 @@ public class RowSpec {
}
public RowSpec(byte[] startRow, byte[] endRow, Collection<byte[]> columns,
+ long startTime, long endTime, int maxVersions, Collection<String> labels) {
+ this(startRow, endRow, columns, startTime, endTime, maxVersions);
+ if(labels != null) {
+ this.labels.addAll(labels);
+ }
+ }
+ public RowSpec(byte[] startRow, byte[] endRow, Collection<byte[]> columns,
long startTime, long endTime, int maxVersions) {
this.row = startRow;
this.endRow = endRow;
@@ -311,6 +321,10 @@ public class RowSpec {
public boolean hasColumns() {
return !columns.isEmpty();
}
+
+ public boolean hasLabels() {
+ return !labels.isEmpty();
+ }
public byte[] getRow() {
return row;
@@ -335,6 +349,10 @@ public class RowSpec {
public byte[][] getColumns() {
return columns.toArray(new byte[columns.size()][]);
}
+
+ public List<String> getLabels() {
+ return labels;
+ }
public boolean hasTimestamp() {
return (startTime == 0) && (endTime != Long.MAX_VALUE);
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/ScannerResource.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/ScannerResource.java?rev=1546988&r1=1546987&r2=1546988&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/ScannerResource.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/ScannerResource.java Mon Dec 2 12:44:03 2013
@@ -82,9 +82,14 @@ public class ScannerResource extends Res
.build();
}
byte[] endRow = model.hasEndRow() ? model.getEndRow() : null;
- RowSpec spec = new RowSpec(model.getStartRow(), endRow,
- model.getColumns(), model.getStartTime(), model.getEndTime(),
- model.getMaxVersions());
+ RowSpec spec = null;
+ if (model.getLabels() != null) {
+ spec = new RowSpec(model.getStartRow(), endRow, model.getColumns(), model.getStartTime(),
+ model.getEndTime(), model.getMaxVersions(), model.getLabels());
+ } else {
+ spec = new RowSpec(model.getStartRow(), endRow, model.getColumns(), model.getStartTime(),
+ model.getEndTime(), model.getMaxVersions());
+ }
try {
Filter filter = ScannerResultGenerator.buildFilterFromModel(model);
String tableName = tableResource.getName();
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/ScannerResultGenerator.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/ScannerResultGenerator.java?rev=1546988&r1=1546987&r2=1546988&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/ScannerResultGenerator.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/ScannerResultGenerator.java Mon Dec 2 12:44:03 2013
@@ -34,6 +34,7 @@ import org.apache.hadoop.hbase.client.Re
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.filter.Filter;
import org.apache.hadoop.hbase.rest.model.ScannerModel;
+import org.apache.hadoop.hbase.security.visibility.Authorizations;
import org.apache.hadoop.util.StringUtils;
@InterfaceAudience.Private
@@ -95,6 +96,9 @@ public class ScannerResultGenerator exte
if (caching > 0 ) {
scan.setCaching(caching);
}
+ if(rowspec.hasLabels()) {
+ scan.setAuthorizations(new Authorizations(rowspec.getLabels()));
+ }
scanner = table.getScanner(scan);
cached = null;
id = Long.toString(System.currentTimeMillis()) +
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/model/ScannerModel.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/model/ScannerModel.java?rev=1546988&r1=1546987&r2=1546988&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/model/ScannerModel.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/model/ScannerModel.java Mon Dec 2 12:44:03 2013
@@ -35,10 +35,41 @@ import javax.xml.bind.annotation.XmlRoot
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.client.Scan;
-import org.apache.hadoop.hbase.filter.*;
+import org.apache.hadoop.hbase.filter.BinaryComparator;
+import org.apache.hadoop.hbase.filter.BinaryPrefixComparator;
+import org.apache.hadoop.hbase.filter.BitComparator;
+import org.apache.hadoop.hbase.filter.ByteArrayComparable;
+import org.apache.hadoop.hbase.filter.ColumnCountGetFilter;
+import org.apache.hadoop.hbase.filter.ColumnPaginationFilter;
+import org.apache.hadoop.hbase.filter.ColumnPrefixFilter;
+import org.apache.hadoop.hbase.filter.ColumnRangeFilter;
+import org.apache.hadoop.hbase.filter.CompareFilter;
import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
+import org.apache.hadoop.hbase.filter.DependentColumnFilter;
+import org.apache.hadoop.hbase.filter.FamilyFilter;
+import org.apache.hadoop.hbase.filter.Filter;
+import org.apache.hadoop.hbase.filter.FilterList;
+import org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter;
+import org.apache.hadoop.hbase.filter.InclusiveStopFilter;
+import org.apache.hadoop.hbase.filter.KeyOnlyFilter;
+import org.apache.hadoop.hbase.filter.MultipleColumnPrefixFilter;
+import org.apache.hadoop.hbase.filter.NullComparator;
+import org.apache.hadoop.hbase.filter.PageFilter;
+import org.apache.hadoop.hbase.filter.PrefixFilter;
+import org.apache.hadoop.hbase.filter.QualifierFilter;
+import org.apache.hadoop.hbase.filter.RandomRowFilter;
+import org.apache.hadoop.hbase.filter.RegexStringComparator;
+import org.apache.hadoop.hbase.filter.RowFilter;
+import org.apache.hadoop.hbase.filter.SingleColumnValueExcludeFilter;
+import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;
+import org.apache.hadoop.hbase.filter.SkipFilter;
+import org.apache.hadoop.hbase.filter.SubstringComparator;
+import org.apache.hadoop.hbase.filter.TimestampsFilter;
+import org.apache.hadoop.hbase.filter.ValueFilter;
+import org.apache.hadoop.hbase.filter.WhileMatchFilter;
import org.apache.hadoop.hbase.rest.ProtobufMessageHandler;
import org.apache.hadoop.hbase.rest.protobuf.generated.ScannerMessage.Scanner;
+import org.apache.hadoop.hbase.security.visibility.Authorizations;
import org.apache.hadoop.hbase.util.Base64;
import org.apache.hadoop.hbase.util.Bytes;
@@ -83,7 +114,8 @@ public class ScannerModel implements Pro
private String filter = null;
private int maxVersions = Integer.MAX_VALUE;
private int caching = -1;
-
+ private List<String> labels = new ArrayList<String>();
+
@XmlRootElement
static class FilterModel {
@@ -488,6 +520,14 @@ public class ScannerModel implements Pro
if (filter != null) {
model.setFilter(stringifyFilter(filter));
}
+ // Add the visbility labels if found in the attributes
+ Authorizations authorizations = scan.getAuthorizations();
+ if (authorizations != null) {
+ List<String> labels = authorizations.getLabels();
+ for (String label : labels) {
+ model.addLabel(label);
+ }
+ }
return model;
}
@@ -554,7 +594,13 @@ public class ScannerModel implements Pro
public void addColumn(byte[] column) {
columns.add(column);
}
-
+
+ /**
+ * Add a visibility label to the scan
+ */
+ public void addLabel(String label) {
+ labels.add(label);
+ }
/**
* @return true if a start row was specified
*/
@@ -592,6 +638,11 @@ public class ScannerModel implements Pro
public List<byte[]> getColumns() {
return columns;
}
+
+ @XmlElement(name="label")
+ public List<String> getLabels() {
+ return labels;
+ }
/**
* @return the number of cells to return in batch
@@ -730,6 +781,10 @@ public class ScannerModel implements Pro
if (filter != null) {
builder.setFilter(filter);
}
+ if (labels != null && labels.size() > 0) {
+ for (String label : labels)
+ builder.addLabels(label);
+ }
return builder.build().toByteArray();
}
@@ -765,6 +820,12 @@ public class ScannerModel implements Pro
if (builder.hasFilter()) {
filter = builder.getFilter();
}
+ if(builder.getLabelsList() != null) {
+ List<String> labels = builder.getLabelsList();
+ for(String label : labels) {
+ addLabel(label);
+ }
+ }
return this;
}
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/protobuf/generated/ScannerMessage.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/protobuf/generated/ScannerMessage.java?rev=1546988&r1=1546987&r2=1546988&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/protobuf/generated/ScannerMessage.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/protobuf/generated/ScannerMessage.java Mon Dec 2 12:44:03 2013
@@ -109,6 +109,26 @@ public final class ScannerMessage {
* <code>optional int32 caching = 9;</code>
*/
int getCaching();
+
+ // repeated string labels = 10;
+ /**
+ * <code>repeated string labels = 10;</code>
+ */
+ java.util.List<java.lang.String>
+ getLabelsList();
+ /**
+ * <code>repeated string labels = 10;</code>
+ */
+ int getLabelsCount();
+ /**
+ * <code>repeated string labels = 10;</code>
+ */
+ java.lang.String getLabels(int index);
+ /**
+ * <code>repeated string labels = 10;</code>
+ */
+ com.google.protobuf.ByteString
+ getLabelsBytes(int index);
}
/**
* Protobuf type {@code org.apache.hadoop.hbase.rest.protobuf.generated.Scanner}
@@ -209,6 +229,14 @@ public final class ScannerMessage {
caching_ = input.readInt32();
break;
}
+ case 82: {
+ if (!((mutable_bitField0_ & 0x00000200) == 0x00000200)) {
+ labels_ = new com.google.protobuf.LazyStringArrayList();
+ mutable_bitField0_ |= 0x00000200;
+ }
+ labels_.add(input.readBytes());
+ break;
+ }
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
@@ -220,6 +248,9 @@ public final class ScannerMessage {
if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) {
columns_ = java.util.Collections.unmodifiableList(columns_);
}
+ if (((mutable_bitField0_ & 0x00000200) == 0x00000200)) {
+ labels_ = new com.google.protobuf.UnmodifiableLazyStringList(labels_);
+ }
this.unknownFields = unknownFields.build();
makeExtensionsImmutable();
}
@@ -430,6 +461,36 @@ public final class ScannerMessage {
return caching_;
}
+ // repeated string labels = 10;
+ public static final int LABELS_FIELD_NUMBER = 10;
+ private com.google.protobuf.LazyStringList labels_;
+ /**
+ * <code>repeated string labels = 10;</code>
+ */
+ public java.util.List<java.lang.String>
+ getLabelsList() {
+ return labels_;
+ }
+ /**
+ * <code>repeated string labels = 10;</code>
+ */
+ public int getLabelsCount() {
+ return labels_.size();
+ }
+ /**
+ * <code>repeated string labels = 10;</code>
+ */
+ public java.lang.String getLabels(int index) {
+ return labels_.get(index);
+ }
+ /**
+ * <code>repeated string labels = 10;</code>
+ */
+ public com.google.protobuf.ByteString
+ getLabelsBytes(int index) {
+ return labels_.getByteString(index);
+ }
+
private void initFields() {
startRow_ = com.google.protobuf.ByteString.EMPTY;
endRow_ = com.google.protobuf.ByteString.EMPTY;
@@ -440,6 +501,7 @@ public final class ScannerMessage {
maxVersions_ = 0;
filter_ = "";
caching_ = 0;
+ labels_ = com.google.protobuf.LazyStringArrayList.EMPTY;
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
@@ -480,6 +542,9 @@ public final class ScannerMessage {
if (((bitField0_ & 0x00000080) == 0x00000080)) {
output.writeInt32(9, caching_);
}
+ for (int i = 0; i < labels_.size(); i++) {
+ output.writeBytes(10, labels_.getByteString(i));
+ }
getUnknownFields().writeTo(output);
}
@@ -530,6 +595,15 @@ public final class ScannerMessage {
size += com.google.protobuf.CodedOutputStream
.computeInt32Size(9, caching_);
}
+ {
+ int dataSize = 0;
+ for (int i = 0; i < labels_.size(); i++) {
+ dataSize += com.google.protobuf.CodedOutputStream
+ .computeBytesSizeNoTag(labels_.getByteString(i));
+ }
+ size += dataSize;
+ size += 1 * getLabelsList().size();
+ }
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
return size;
@@ -664,6 +738,8 @@ public final class ScannerMessage {
bitField0_ = (bitField0_ & ~0x00000080);
caching_ = 0;
bitField0_ = (bitField0_ & ~0x00000100);
+ labels_ = com.google.protobuf.LazyStringArrayList.EMPTY;
+ bitField0_ = (bitField0_ & ~0x00000200);
return this;
}
@@ -729,6 +805,12 @@ public final class ScannerMessage {
to_bitField0_ |= 0x00000080;
}
result.caching_ = caching_;
+ if (((bitField0_ & 0x00000200) == 0x00000200)) {
+ labels_ = new com.google.protobuf.UnmodifiableLazyStringList(
+ labels_);
+ bitField0_ = (bitField0_ & ~0x00000200);
+ }
+ result.labels_ = labels_;
result.bitField0_ = to_bitField0_;
onBuilt();
return result;
@@ -781,6 +863,16 @@ public final class ScannerMessage {
if (other.hasCaching()) {
setCaching(other.getCaching());
}
+ if (!other.labels_.isEmpty()) {
+ if (labels_.isEmpty()) {
+ labels_ = other.labels_;
+ bitField0_ = (bitField0_ & ~0x00000200);
+ } else {
+ ensureLabelsIsMutable();
+ labels_.addAll(other.labels_);
+ }
+ onChanged();
+ }
this.mergeUnknownFields(other.getUnknownFields());
return this;
}
@@ -1191,6 +1283,99 @@ public final class ScannerMessage {
return this;
}
+ // repeated string labels = 10;
+ private com.google.protobuf.LazyStringList labels_ = com.google.protobuf.LazyStringArrayList.EMPTY;
+ private void ensureLabelsIsMutable() {
+ if (!((bitField0_ & 0x00000200) == 0x00000200)) {
+ labels_ = new com.google.protobuf.LazyStringArrayList(labels_);
+ bitField0_ |= 0x00000200;
+ }
+ }
+ /**
+ * <code>repeated string labels = 10;</code>
+ */
+ public java.util.List<java.lang.String>
+ getLabelsList() {
+ return java.util.Collections.unmodifiableList(labels_);
+ }
+ /**
+ * <code>repeated string labels = 10;</code>
+ */
+ public int getLabelsCount() {
+ return labels_.size();
+ }
+ /**
+ * <code>repeated string labels = 10;</code>
+ */
+ public java.lang.String getLabels(int index) {
+ return labels_.get(index);
+ }
+ /**
+ * <code>repeated string labels = 10;</code>
+ */
+ public com.google.protobuf.ByteString
+ getLabelsBytes(int index) {
+ return labels_.getByteString(index);
+ }
+ /**
+ * <code>repeated string labels = 10;</code>
+ */
+ public Builder setLabels(
+ int index, java.lang.String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureLabelsIsMutable();
+ labels_.set(index, value);
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>repeated string labels = 10;</code>
+ */
+ public Builder addLabels(
+ java.lang.String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureLabelsIsMutable();
+ labels_.add(value);
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>repeated string labels = 10;</code>
+ */
+ public Builder addAllLabels(
+ java.lang.Iterable<java.lang.String> values) {
+ ensureLabelsIsMutable();
+ super.addAll(values, labels_);
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>repeated string labels = 10;</code>
+ */
+ public Builder clearLabels() {
+ labels_ = com.google.protobuf.LazyStringArrayList.EMPTY;
+ bitField0_ = (bitField0_ & ~0x00000200);
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>repeated string labels = 10;</code>
+ */
+ public Builder addLabelsBytes(
+ com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ ensureLabelsIsMutable();
+ labels_.add(value);
+ onChanged();
+ return this;
+ }
+
// @@protoc_insertion_point(builder_scope:org.apache.hadoop.hbase.rest.protobuf.generated.Scanner)
}
@@ -1217,11 +1402,12 @@ public final class ScannerMessage {
static {
java.lang.String[] descriptorData = {
"\n\024ScannerMessage.proto\022/org.apache.hadoo" +
- "p.hbase.rest.protobuf.generated\"\245\001\n\007Scan" +
+ "p.hbase.rest.protobuf.generated\"\265\001\n\007Scan" +
"ner\022\020\n\010startRow\030\001 \001(\014\022\016\n\006endRow\030\002 \001(\014\022\017\n" +
"\007columns\030\003 \003(\014\022\r\n\005batch\030\004 \001(\005\022\021\n\tstartTi" +
"me\030\005 \001(\003\022\017\n\007endTime\030\006 \001(\003\022\023\n\013maxVersions" +
- "\030\007 \001(\005\022\016\n\006filter\030\010 \001(\t\022\017\n\007caching\030\t \001(\005"
+ "\030\007 \001(\005\022\016\n\006filter\030\010 \001(\t\022\017\n\007caching\030\t \001(\005\022" +
+ "\016\n\006labels\030\n \003(\t"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@@ -1233,7 +1419,7 @@ public final class ScannerMessage {
internal_static_org_apache_hadoop_hbase_rest_protobuf_generated_Scanner_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_org_apache_hadoop_hbase_rest_protobuf_generated_Scanner_descriptor,
- new java.lang.String[] { "StartRow", "EndRow", "Columns", "Batch", "StartTime", "EndTime", "MaxVersions", "Filter", "Caching", });
+ new java.lang.String[] { "StartRow", "EndRow", "Columns", "Batch", "StartTime", "EndTime", "MaxVersions", "Filter", "Caching", "Labels", });
return null;
}
};
Modified: hbase/trunk/hbase-server/src/main/resources/org/apache/hadoop/hbase/rest/protobuf/ScannerMessage.proto
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/resources/org/apache/hadoop/hbase/rest/protobuf/ScannerMessage.proto?rev=1546988&r1=1546987&r2=1546988&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/resources/org/apache/hadoop/hbase/rest/protobuf/ScannerMessage.proto (original)
+++ hbase/trunk/hbase-server/src/main/resources/org/apache/hadoop/hbase/rest/protobuf/ScannerMessage.proto Mon Dec 2 12:44:03 2013
@@ -27,4 +27,5 @@ message Scanner {
optional int32 maxVersions = 7;
optional string filter = 8;
optional int32 caching = 9;
+ repeated string labels = 10;
}
Added: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithLabels.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithLabels.java?rev=1546988&view=auto
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithLabels.java (added)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithLabels.java Mon Dec 2 12:44:03 2013
@@ -0,0 +1,237 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */package org.apache.hadoop.hbase.rest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.security.PrivilegedExceptionAction;
+import java.util.Iterator;
+import java.util.Random;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.MediumTests;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Durability;
+import org.apache.hadoop.hbase.client.HBaseAdmin;
+import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabelsResponse;
+import org.apache.hadoop.hbase.rest.client.Client;
+import org.apache.hadoop.hbase.rest.client.Cluster;
+import org.apache.hadoop.hbase.rest.client.Response;
+import org.apache.hadoop.hbase.rest.model.CellModel;
+import org.apache.hadoop.hbase.rest.model.CellSetModel;
+import org.apache.hadoop.hbase.rest.model.RowModel;
+import org.apache.hadoop.hbase.rest.model.ScannerModel;
+import org.apache.hadoop.hbase.security.User;
+import org.apache.hadoop.hbase.security.visibility.CellVisibility;
+import org.apache.hadoop.hbase.security.visibility.ScanLabelGenerator;
+import org.apache.hadoop.hbase.security.visibility.SimpleScanLabelGenerator;
+import org.apache.hadoop.hbase.security.visibility.VisibilityClient;
+import org.apache.hadoop.hbase.security.visibility.VisibilityConstants;
+import org.apache.hadoop.hbase.security.visibility.VisibilityController;
+import org.apache.hadoop.hbase.security.visibility.VisibilityUtils;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(MediumTests.class)
+public class TestScannersWithLabels {
+ private static final String TABLE = "TestScannersWithLabels";
+ private static final String CFA = "a";
+ private static final String CFB = "b";
+ private static final String COLUMN_1 = CFA + ":1";
+ private static final String COLUMN_2 = CFB + ":2";
+ private final static String TOPSECRET = "topsecret";
+ private final static String PUBLIC = "public";
+ private final static String PRIVATE = "private";
+ private final static String CONFIDENTIAL = "confidential";
+ private final static String SECRET = "secret";
+ private static User SUPERUSER;
+
+ private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
+ private static final HBaseRESTTestingUtility REST_TEST_UTIL = new HBaseRESTTestingUtility();
+ private static Client client;
+ private static JAXBContext context;
+ private static Marshaller marshaller;
+ private static Unmarshaller unmarshaller;
+ private static Configuration conf;
+
+ private static int insertData(String tableName, String column, double prob) throws IOException {
+ Random rng = new Random();
+ int count = 0;
+ HTable table = new HTable(TEST_UTIL.getConfiguration(), tableName);
+ byte[] k = new byte[3];
+ byte[][] famAndQf = KeyValue.parseColumn(Bytes.toBytes(column));
+
+ for (int i = 0; i < 9; i++) {
+ Put put = new Put(Bytes.toBytes("row" + i));
+ put.setDurability(Durability.SKIP_WAL);
+ put.add(famAndQf[0], famAndQf[1], k);
+ put.setCellVisibility(new CellVisibility("(" + SECRET + "|" + CONFIDENTIAL + ")" + "&" + "!"
+ + TOPSECRET));
+ table.put(put);
+ count++;
+ }
+ table.flushCommits();
+ return count;
+ }
+
+ private static int countCellSet(CellSetModel model) {
+ int count = 0;
+ Iterator<RowModel> rows = model.getRows().iterator();
+ while (rows.hasNext()) {
+ RowModel row = rows.next();
+ Iterator<CellModel> cells = row.getCells().iterator();
+ while (cells.hasNext()) {
+ cells.next();
+ count++;
+ }
+ }
+ return count;
+ }
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ SUPERUSER = User.createUserForTesting(conf, "admin",
+ new String[] { "supergroup" });
+ conf = TEST_UTIL.getConfiguration();
+ conf.setClass(VisibilityUtils.VISIBILITY_LABEL_GENERATOR_CLASS,
+ SimpleScanLabelGenerator.class, ScanLabelGenerator.class);
+ conf.set("hbase.superuser", SUPERUSER.getShortName());
+ conf.set("hbase.coprocessor.master.classes", VisibilityController.class.getName());
+ conf.set("hbase.coprocessor.region.classes", VisibilityController.class.getName());
+ TEST_UTIL.startMiniCluster(1);
+ // Wait for the labels table to become available
+ TEST_UTIL.waitTableEnabled(VisibilityConstants.LABELS_TABLE_NAME.getName(), 50000);
+ createLabels();
+ setAuths();
+ REST_TEST_UTIL.startServletContainer(conf);
+ client = new Client(new Cluster().add("localhost", REST_TEST_UTIL.getServletPort()));
+ context = JAXBContext.newInstance(CellModel.class, CellSetModel.class, RowModel.class,
+ ScannerModel.class);
+ marshaller = context.createMarshaller();
+ unmarshaller = context.createUnmarshaller();
+ HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
+ if (admin.tableExists(TABLE)) {
+ return;
+ }
+ HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(TABLE));
+ htd.addFamily(new HColumnDescriptor(CFA));
+ htd.addFamily(new HColumnDescriptor(CFB));
+ admin.createTable(htd);
+ insertData(TABLE, COLUMN_1, 1.0);
+ insertData(TABLE, COLUMN_2, 0.5);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ REST_TEST_UTIL.shutdownServletContainer();
+ TEST_UTIL.shutdownMiniCluster();
+ }
+
+ private static void createLabels() throws IOException, InterruptedException {
+ PrivilegedExceptionAction<VisibilityLabelsResponse> action = new PrivilegedExceptionAction<VisibilityLabelsResponse>() {
+ public VisibilityLabelsResponse run() throws Exception {
+ String[] labels = { SECRET, CONFIDENTIAL, PRIVATE, PUBLIC, TOPSECRET };
+ try {
+ VisibilityClient.addLabels(conf, labels);
+ } catch (Throwable t) {
+ throw new IOException(t);
+ }
+ return null;
+ }
+ };
+ SUPERUSER.runAs(action);
+ }
+ private static void setAuths() throws Exception {
+ String[] labels = { SECRET, CONFIDENTIAL, PRIVATE, PUBLIC, TOPSECRET };
+ try {
+ VisibilityClient.setAuths(conf, labels, User.getCurrent().getShortName());
+ } catch (Throwable t) {
+ throw new IOException(t);
+ }
+ }
+ @Test
+ public void testSimpleScannerXMLWithLabelsThatReceivesNoData() throws IOException, JAXBException {
+ final int BATCH_SIZE = 5;
+ // new scanner
+ ScannerModel model = new ScannerModel();
+ model.setBatch(BATCH_SIZE);
+ model.addColumn(Bytes.toBytes(COLUMN_1));
+ model.addLabel(PUBLIC);
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(model, writer);
+ byte[] body = Bytes.toBytes(writer.toString());
+ // recall previous put operation with read-only off
+ conf.set("hbase.rest.readonly", "false");
+ Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body);
+ assertEquals(response.getCode(), 201);
+ String scannerURI = response.getLocation();
+ assertNotNull(scannerURI);
+
+ // get a cell set
+ response = client.get(scannerURI, Constants.MIMETYPE_XML);
+ // Respond with 204 as there are no cells to be retrieved
+ assertEquals(response.getCode(), 204);
+ assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
+ }
+
+ @Test
+ public void testSimpleScannerXMLWithLabelsThatReceivesData() throws IOException, JAXBException {
+ // new scanner
+ ScannerModel model = new ScannerModel();
+ model.setBatch(5);
+ model.addColumn(Bytes.toBytes(COLUMN_1));
+ model.addLabel(SECRET);
+ StringWriter writer = new StringWriter();
+ marshaller.marshal(model, writer);
+ byte[] body = Bytes.toBytes(writer.toString());
+
+ // recall previous put operation with read-only off
+ conf.set("hbase.rest.readonly", "false");
+ Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body);
+ assertEquals(response.getCode(), 201);
+ String scannerURI = response.getLocation();
+ assertNotNull(scannerURI);
+
+ // get a cell set
+ response = client.get(scannerURI, Constants.MIMETYPE_XML);
+ // Respond with 204 as there are no cells to be retrieved
+ assertEquals(response.getCode(), 200);
+ assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
+ CellSetModel cellSet = (CellSetModel) unmarshaller.unmarshal(new ByteArrayInputStream(response
+ .getBody()));
+ assertEquals(countCellSet(cellSet), 5);
+ }
+
+}
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/model/TestScannerModel.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/model/TestScannerModel.java?rev=1546988&r1=1546987&r2=1546988&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/model/TestScannerModel.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/model/TestScannerModel.java Mon Dec 2 12:44:03 2013
@@ -19,22 +19,14 @@
package org.apache.hadoop.hbase.rest.model;
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-
import org.apache.hadoop.hbase.SmallTests;
-import org.apache.hadoop.hbase.util.Base64;
import org.apache.hadoop.hbase.util.Bytes;
-
-import junit.framework.TestCase;
import org.junit.experimental.categories.Category;
@Category(SmallTests.class)
public class TestScannerModel extends TestModelBase<ScannerModel> {
+ private static final String PRIVATE = "private";
+ private static final String PUBLIC = "public";
private static final byte[] START_ROW = Bytes.toBytes("abracadabra");
private static final byte[] END_ROW = Bytes.toBytes("zzyzx");
private static final byte[] COLUMN1 = Bytes.toBytes("column1");
@@ -46,20 +38,20 @@ public class TestScannerModel extends Te
public TestScannerModel() throws Exception {
super(ScannerModel.class);
- AS_XML =
- "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" +
- "<Scanner batch=\"100\" caching=\"1000\" endRow=\"enp5eng=\" endTime=\"1245393318192\" " +
- "maxVersions=\"2147483647\" startRow=\"YWJyYWNhZGFicmE=\" startTime=\"1245219839331\">" +
- "<column>Y29sdW1uMQ==</column><column>Y29sdW1uMjpmb28=</column></Scanner>";
-
- AS_JSON =
- "{\"batch\":100,\"caching\":1000,\"endRow\":\"enp5eng=\",\"endTime\":1245393318192,"+
- "\"maxVersions\":2147483647,\"startRow\":\"YWJyYWNhZGFicmE=\",\"startTime\":1245219839331,"+
- "\"column\":[\"Y29sdW1uMQ==\",\"Y29sdW1uMjpmb28=\"]}";
-
- AS_PB =
- "CgthYnJhY2FkYWJyYRIFenp5engaB2NvbHVtbjEaC2NvbHVtbjI6Zm9vIGQo47qL554kMLDi57mf" +
- "JDj/////B0joBw==";
+ AS_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
+ + "<Scanner batch=\"100\" caching=\"1000\" endRow=\"enp5eng=\" endTime=\"1245393318192\" "
+ + "maxVersions=\"2147483647\" startRow=\"YWJyYWNhZGFicmE=\" startTime=\"1245219839331\">"
+ + "<column>Y29sdW1uMQ==</column><column>Y29sdW1uMjpmb28=</column>"
+ + "<label>private</label><label>public</label></Scanner>";
+
+ AS_JSON = "{\"batch\":100,\"caching\":1000,\"endRow\":\"enp5eng=\",\"endTime\":1245393318192,"
+ + "\"maxVersions\":2147483647,\"startRow\":\"YWJyYWNhZGFicmE=\",\"startTime\":1245219839331,"
+ + "\"column\":[\"Y29sdW1uMQ==\",\"Y29sdW1uMjpmb28=\"],"
+ +"\"labels\":[\"private\",\"public\"]}";
+
+ // TODO
+ AS_PB = "CgthYnJhY2FkYWJyYRIFenp5engaB2NvbHVtbjEaC2NvbHVtbjI6Zm9vIGQo47qL554kMLDi57mf"
+ + "JDj/////B0joBw==";
}
protected ScannerModel buildTestModel() {
@@ -72,6 +64,8 @@ public class TestScannerModel extends Te
model.setEndTime(END_TIME);
model.setBatch(BATCH);
model.setCaching(CACHING);
+ model.addLabel(PRIVATE);
+ model.addLabel(PUBLIC);
return model;
}
@@ -79,7 +73,7 @@ public class TestScannerModel extends Te
assertTrue(Bytes.equals(model.getStartRow(), START_ROW));
assertTrue(Bytes.equals(model.getEndRow(), END_ROW));
boolean foundCol1 = false, foundCol2 = false;
- for (byte[] column: model.getColumns()) {
+ for (byte[] column : model.getColumns()) {
if (Bytes.equals(column, COLUMN1)) {
foundCol1 = true;
} else if (Bytes.equals(column, COLUMN2)) {
@@ -92,7 +86,19 @@ public class TestScannerModel extends Te
assertEquals(model.getEndTime(), END_TIME);
assertEquals(model.getBatch(), BATCH);
assertEquals(model.getCaching(), CACHING);
+ boolean foundLabel1 = false;
+ boolean foundLabel2 = false;
+ if (model.getLabels() != null && model.getLabels().size() > 0) {
+ for (String label : model.getLabels()) {
+ if (label.equals(PRIVATE)) {
+ foundLabel1 = true;
+ } else if (label.equals(PUBLIC)) {
+ foundLabel2 = true;
+ }
+ }
+ assertTrue(foundLabel1);
+ assertTrue(foundLabel2);
+ }
}
}
-
Modified: hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java?rev=1546988&r1=1546987&r2=1546988&view=diff
==============================================================================
--- hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java (original)
+++ hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java Mon Dec 2 12:44:03 2013
@@ -43,6 +43,8 @@ import org.apache.hadoop.hbase.client.Re
import org.apache.hadoop.hbase.client.RowMutations;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.filter.ParseFilter;
+import org.apache.hadoop.hbase.security.visibility.Authorizations;
+import org.apache.hadoop.hbase.security.visibility.CellVisibility;
import org.apache.hadoop.hbase.thrift2.generated.TAppend;
import org.apache.hadoop.hbase.thrift2.generated.TColumn;
import org.apache.hadoop.hbase.thrift2.generated.TColumnIncrement;
@@ -101,6 +103,10 @@ public class ThriftUtilities {
addAttributes(out,in.getAttributes());
}
+ if (in.isSetAuthorizations()) {
+ out.setAuthorizations(new Authorizations(in.getAuthorizations().getLabels()));
+ }
+
if (!in.isSetColumns()) {
return out;
}
@@ -155,6 +161,9 @@ public class ThriftUtilities {
col.setQualifier(CellUtil.cloneQualifier(kv));
col.setTimestamp(kv.getTimestamp());
col.setValue(CellUtil.cloneValue(kv));
+ if (kv.getTagsLength() > 0) {
+ col.setTags(CellUtil.getTagArray(kv));
+ }
columnValues.add(col);
}
out.setColumnValues(columnValues);
@@ -212,6 +221,10 @@ public class ThriftUtilities {
if (in.isSetAttributes()) {
addAttributes(out,in.getAttributes());
}
+
+ if (in.getCellVisibility() != null) {
+ out.setCellVisibility(new CellVisibility(in.getCellVisibility().getExpression()));
+ }
return out;
}
@@ -403,6 +416,10 @@ public class ThriftUtilities {
if (in.isSetAttributes()) {
addAttributes(out,in.getAttributes());
}
+
+ if (in.isSetAuthorizations()) {
+ out.setAuthorizations(new Authorizations(in.getAuthorizations().getLabels()));
+ }
return out;
}
@@ -420,6 +437,10 @@ public class ThriftUtilities {
if (in.isSetDurability()) {
out.setDurability(durabilityFromThrift(in.getDurability()));
}
+
+ if(in.getCellVisibility() != null) {
+ out.setCellVisibility(new CellVisibility(in.getCellVisibility().getExpression()));
+ }
return out;
}
@@ -437,6 +458,10 @@ public class ThriftUtilities {
if (append.isSetDurability()) {
out.setDurability(durabilityFromThrift(append.getDurability()));
}
+
+ if(append.getCellVisibility() != null) {
+ out.setCellVisibility(new CellVisibility(append.getCellVisibility().getExpression()));
+ }
return out;
}
Modified: hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TAppend.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TAppend.java?rev=1546988&r1=1546987&r2=1546988&view=diff
==============================================================================
--- hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TAppend.java (original)
+++ hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TAppend.java Mon Dec 2 12:44:03 2013
@@ -37,6 +37,7 @@ public class TAppend implements org.apac
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 ATTRIBUTES_FIELD_DESC = new org.apache.thrift.protocol.TField("attributes", org.apache.thrift.protocol.TType.MAP, (short)3);
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)4);
+ private static final org.apache.thrift.protocol.TField CELL_VISIBILITY_FIELD_DESC = new org.apache.thrift.protocol.TField("cellVisibility", org.apache.thrift.protocol.TType.STRUCT, (short)5);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
@@ -52,6 +53,7 @@ public class TAppend implements org.apac
* @see TDurability
*/
public TDurability durability; // optional
+ public TCellVisibility cellVisibility; // 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 {
@@ -62,7 +64,8 @@ public class TAppend implements org.apac
*
* @see TDurability
*/
- DURABILITY((short)4, "durability");
+ DURABILITY((short)4, "durability"),
+ CELL_VISIBILITY((short)5, "cellVisibility");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
@@ -85,6 +88,8 @@ public class TAppend implements org.apac
return ATTRIBUTES;
case 4: // DURABILITY
return DURABILITY;
+ case 5: // CELL_VISIBILITY
+ return CELL_VISIBILITY;
default:
return null;
}
@@ -125,7 +130,7 @@ public class TAppend implements org.apac
}
// isset id assignments
- private _Fields optionals[] = {_Fields.ATTRIBUTES,_Fields.DURABILITY};
+ private _Fields optionals[] = {_Fields.ATTRIBUTES,_Fields.DURABILITY,_Fields.CELL_VISIBILITY};
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);
@@ -140,6 +145,8 @@ public class TAppend implements org.apac
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)));
+ tmpMap.put(_Fields.CELL_VISIBILITY, new org.apache.thrift.meta_data.FieldMetaData("cellVisibility", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TCellVisibility.class)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TAppend.class, metaDataMap);
}
@@ -191,6 +198,9 @@ public class TAppend implements org.apac
if (other.isSetDurability()) {
this.durability = other.durability;
}
+ if (other.isSetCellVisibility()) {
+ this.cellVisibility = new TCellVisibility(other.cellVisibility);
+ }
}
public TAppend deepCopy() {
@@ -203,6 +213,7 @@ public class TAppend implements org.apac
this.columns = null;
this.attributes = null;
this.durability = null;
+ this.cellVisibility = null;
}
public byte[] getRow() {
@@ -345,6 +356,30 @@ public class TAppend implements org.apac
}
}
+ public TCellVisibility getCellVisibility() {
+ return this.cellVisibility;
+ }
+
+ public TAppend setCellVisibility(TCellVisibility cellVisibility) {
+ this.cellVisibility = cellVisibility;
+ return this;
+ }
+
+ public void unsetCellVisibility() {
+ this.cellVisibility = null;
+ }
+
+ /** Returns true if field cellVisibility is set (has been assigned a value) and false otherwise */
+ public boolean isSetCellVisibility() {
+ return this.cellVisibility != null;
+ }
+
+ public void setCellVisibilityIsSet(boolean value) {
+ if (!value) {
+ this.cellVisibility = null;
+ }
+ }
+
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case ROW:
@@ -379,6 +414,14 @@ public class TAppend implements org.apac
}
break;
+ case CELL_VISIBILITY:
+ if (value == null) {
+ unsetCellVisibility();
+ } else {
+ setCellVisibility((TCellVisibility)value);
+ }
+ break;
+
}
}
@@ -396,6 +439,9 @@ public class TAppend implements org.apac
case DURABILITY:
return getDurability();
+ case CELL_VISIBILITY:
+ return getCellVisibility();
+
}
throw new IllegalStateException();
}
@@ -415,6 +461,8 @@ public class TAppend implements org.apac
return isSetAttributes();
case DURABILITY:
return isSetDurability();
+ case CELL_VISIBILITY:
+ return isSetCellVisibility();
}
throw new IllegalStateException();
}
@@ -468,6 +516,15 @@ public class TAppend implements org.apac
return false;
}
+ boolean this_present_cellVisibility = true && this.isSetCellVisibility();
+ boolean that_present_cellVisibility = true && that.isSetCellVisibility();
+ if (this_present_cellVisibility || that_present_cellVisibility) {
+ if (!(this_present_cellVisibility && that_present_cellVisibility))
+ return false;
+ if (!this.cellVisibility.equals(that.cellVisibility))
+ return false;
+ }
+
return true;
}
@@ -524,6 +581,16 @@ public class TAppend implements org.apac
return lastComparison;
}
}
+ lastComparison = Boolean.valueOf(isSetCellVisibility()).compareTo(typedOther.isSetCellVisibility());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetCellVisibility()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.cellVisibility, typedOther.cellVisibility);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
return 0;
}
@@ -579,6 +646,16 @@ public class TAppend implements org.apac
}
first = false;
}
+ if (isSetCellVisibility()) {
+ if (!first) sb.append(", ");
+ sb.append("cellVisibility:");
+ if (this.cellVisibility == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.cellVisibility);
+ }
+ first = false;
+ }
sb.append(")");
return sb.toString();
}
@@ -592,6 +669,9 @@ public class TAppend implements org.apac
throw new org.apache.thrift.protocol.TProtocolException("Required field 'columns' was not present! Struct: " + toString());
}
// check for sub-struct validity
+ if (cellVisibility != null) {
+ cellVisibility.validate();
+ }
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
@@ -639,14 +719,14 @@ public class TAppend implements org.apac
case 2: // COLUMNS
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
{
- org.apache.thrift.protocol.TList _list80 = iprot.readListBegin();
- struct.columns = new ArrayList<TColumnValue>(_list80.size);
- for (int _i81 = 0; _i81 < _list80.size; ++_i81)
+ org.apache.thrift.protocol.TList _list88 = iprot.readListBegin();
+ struct.columns = new ArrayList<TColumnValue>(_list88.size);
+ for (int _i89 = 0; _i89 < _list88.size; ++_i89)
{
- TColumnValue _elem82; // required
- _elem82 = new TColumnValue();
- _elem82.read(iprot);
- struct.columns.add(_elem82);
+ TColumnValue _elem90; // required
+ _elem90 = new TColumnValue();
+ _elem90.read(iprot);
+ struct.columns.add(_elem90);
}
iprot.readListEnd();
}
@@ -658,15 +738,15 @@ public class TAppend implements org.apac
case 3: // ATTRIBUTES
if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
{
- org.apache.thrift.protocol.TMap _map83 = iprot.readMapBegin();
- struct.attributes = new HashMap<ByteBuffer,ByteBuffer>(2*_map83.size);
- for (int _i84 = 0; _i84 < _map83.size; ++_i84)
+ org.apache.thrift.protocol.TMap _map91 = iprot.readMapBegin();
+ struct.attributes = new HashMap<ByteBuffer,ByteBuffer>(2*_map91.size);
+ for (int _i92 = 0; _i92 < _map91.size; ++_i92)
{
- ByteBuffer _key85; // required
- ByteBuffer _val86; // required
- _key85 = iprot.readBinary();
- _val86 = iprot.readBinary();
- struct.attributes.put(_key85, _val86);
+ ByteBuffer _key93; // required
+ ByteBuffer _val94; // required
+ _key93 = iprot.readBinary();
+ _val94 = iprot.readBinary();
+ struct.attributes.put(_key93, _val94);
}
iprot.readMapEnd();
}
@@ -683,6 +763,15 @@ public class TAppend implements org.apac
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
+ case 5: // CELL_VISIBILITY
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+ struct.cellVisibility = new TCellVisibility();
+ struct.cellVisibility.read(iprot);
+ struct.setCellVisibilityIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+ }
+ break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
@@ -707,9 +796,9 @@ public class TAppend implements org.apac
oprot.writeFieldBegin(COLUMNS_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.columns.size()));
- for (TColumnValue _iter87 : struct.columns)
+ for (TColumnValue _iter95 : struct.columns)
{
- _iter87.write(oprot);
+ _iter95.write(oprot);
}
oprot.writeListEnd();
}
@@ -720,10 +809,10 @@ public class TAppend implements org.apac
oprot.writeFieldBegin(ATTRIBUTES_FIELD_DESC);
{
oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.attributes.size()));
- for (Map.Entry<ByteBuffer, ByteBuffer> _iter88 : struct.attributes.entrySet())
+ for (Map.Entry<ByteBuffer, ByteBuffer> _iter96 : struct.attributes.entrySet())
{
- oprot.writeBinary(_iter88.getKey());
- oprot.writeBinary(_iter88.getValue());
+ oprot.writeBinary(_iter96.getKey());
+ oprot.writeBinary(_iter96.getValue());
}
oprot.writeMapEnd();
}
@@ -737,6 +826,13 @@ public class TAppend implements org.apac
oprot.writeFieldEnd();
}
}
+ if (struct.cellVisibility != null) {
+ if (struct.isSetCellVisibility()) {
+ oprot.writeFieldBegin(CELL_VISIBILITY_FIELD_DESC);
+ struct.cellVisibility.write(oprot);
+ oprot.writeFieldEnd();
+ }
+ }
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@@ -757,9 +853,9 @@ public class TAppend implements org.apac
oprot.writeBinary(struct.row);
{
oprot.writeI32(struct.columns.size());
- for (TColumnValue _iter89 : struct.columns)
+ for (TColumnValue _iter97 : struct.columns)
{
- _iter89.write(oprot);
+ _iter97.write(oprot);
}
}
BitSet optionals = new BitSet();
@@ -769,20 +865,26 @@ public class TAppend implements org.apac
if (struct.isSetDurability()) {
optionals.set(1);
}
- oprot.writeBitSet(optionals, 2);
+ if (struct.isSetCellVisibility()) {
+ optionals.set(2);
+ }
+ oprot.writeBitSet(optionals, 3);
if (struct.isSetAttributes()) {
{
oprot.writeI32(struct.attributes.size());
- for (Map.Entry<ByteBuffer, ByteBuffer> _iter90 : struct.attributes.entrySet())
+ for (Map.Entry<ByteBuffer, ByteBuffer> _iter98 : struct.attributes.entrySet())
{
- oprot.writeBinary(_iter90.getKey());
- oprot.writeBinary(_iter90.getValue());
+ oprot.writeBinary(_iter98.getKey());
+ oprot.writeBinary(_iter98.getValue());
}
}
}
if (struct.isSetDurability()) {
oprot.writeI32(struct.durability.getValue());
}
+ if (struct.isSetCellVisibility()) {
+ struct.cellVisibility.write(oprot);
+ }
}
@Override
@@ -791,29 +893,29 @@ public class TAppend implements org.apac
struct.row = iprot.readBinary();
struct.setRowIsSet(true);
{
- org.apache.thrift.protocol.TList _list91 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
- struct.columns = new ArrayList<TColumnValue>(_list91.size);
- for (int _i92 = 0; _i92 < _list91.size; ++_i92)
+ org.apache.thrift.protocol.TList _list99 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
+ struct.columns = new ArrayList<TColumnValue>(_list99.size);
+ for (int _i100 = 0; _i100 < _list99.size; ++_i100)
{
- TColumnValue _elem93; // required
- _elem93 = new TColumnValue();
- _elem93.read(iprot);
- struct.columns.add(_elem93);
+ TColumnValue _elem101; // required
+ _elem101 = new TColumnValue();
+ _elem101.read(iprot);
+ struct.columns.add(_elem101);
}
}
struct.setColumnsIsSet(true);
- BitSet incoming = iprot.readBitSet(2);
+ BitSet incoming = iprot.readBitSet(3);
if (incoming.get(0)) {
{
- org.apache.thrift.protocol.TMap _map94 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
- struct.attributes = new HashMap<ByteBuffer,ByteBuffer>(2*_map94.size);
- for (int _i95 = 0; _i95 < _map94.size; ++_i95)
+ org.apache.thrift.protocol.TMap _map102 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
+ struct.attributes = new HashMap<ByteBuffer,ByteBuffer>(2*_map102.size);
+ for (int _i103 = 0; _i103 < _map102.size; ++_i103)
{
- ByteBuffer _key96; // required
- ByteBuffer _val97; // required
- _key96 = iprot.readBinary();
- _val97 = iprot.readBinary();
- struct.attributes.put(_key96, _val97);
+ ByteBuffer _key104; // required
+ ByteBuffer _val105; // required
+ _key104 = iprot.readBinary();
+ _val105 = iprot.readBinary();
+ struct.attributes.put(_key104, _val105);
}
}
struct.setAttributesIsSet(true);
@@ -822,6 +924,11 @@ public class TAppend implements org.apac
struct.durability = TDurability.findByValue(iprot.readI32());
struct.setDurabilityIsSet(true);
}
+ if (incoming.get(2)) {
+ struct.cellVisibility = new TCellVisibility();
+ struct.cellVisibility.read(iprot);
+ struct.setCellVisibilityIsSet(true);
+ }
}
}
Added: hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TAuthorization.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TAuthorization.java?rev=1546988&view=auto
==============================================================================
--- hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TAuthorization.java (added)
+++ hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TAuthorization.java Mon Dec 2 12:44:03 2013
@@ -0,0 +1,436 @@
+/**
+ * Autogenerated by Thrift Compiler (0.9.0)
+ *
+ * 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 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 org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TAuthorization implements org.apache.thrift.TBase<TAuthorization, TAuthorization._Fields>, java.io.Serializable, Cloneable {
+ private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TAuthorization");
+
+ private static final org.apache.thrift.protocol.TField LABELS_FIELD_DESC = new org.apache.thrift.protocol.TField("labels", org.apache.thrift.protocol.TType.LIST, (short)1);
+
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new TAuthorizationStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new TAuthorizationTupleSchemeFactory());
+ }
+
+ public List<String> labels; // 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 {
+ LABELS((short)1, "labels");
+
+ 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: // LABELS
+ return LABELS;
+ 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
+ private _Fields optionals[] = {_Fields.LABELS};
+ 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.LABELS, new org.apache.thrift.meta_data.FieldMetaData("labels", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
+ metaDataMap = Collections.unmodifiableMap(tmpMap);
+ org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TAuthorization.class, metaDataMap);
+ }
+
+ public TAuthorization() {
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public TAuthorization(TAuthorization other) {
+ if (other.isSetLabels()) {
+ List<String> __this__labels = new ArrayList<String>();
+ for (String other_element : other.labels) {
+ __this__labels.add(other_element);
+ }
+ this.labels = __this__labels;
+ }
+ }
+
+ public TAuthorization deepCopy() {
+ return new TAuthorization(this);
+ }
+
+ @Override
+ public void clear() {
+ this.labels = null;
+ }
+
+ public int getLabelsSize() {
+ return (this.labels == null) ? 0 : this.labels.size();
+ }
+
+ public java.util.Iterator<String> getLabelsIterator() {
+ return (this.labels == null) ? null : this.labels.iterator();
+ }
+
+ public void addToLabels(String elem) {
+ if (this.labels == null) {
+ this.labels = new ArrayList<String>();
+ }
+ this.labels.add(elem);
+ }
+
+ public List<String> getLabels() {
+ return this.labels;
+ }
+
+ public TAuthorization setLabels(List<String> labels) {
+ this.labels = labels;
+ return this;
+ }
+
+ public void unsetLabels() {
+ this.labels = null;
+ }
+
+ /** Returns true if field labels is set (has been assigned a value) and false otherwise */
+ public boolean isSetLabels() {
+ return this.labels != null;
+ }
+
+ public void setLabelsIsSet(boolean value) {
+ if (!value) {
+ this.labels = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case LABELS:
+ if (value == null) {
+ unsetLabels();
+ } else {
+ setLabels((List<String>)value);
+ }
+ break;
+
+ }
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case LABELS:
+ return getLabels();
+
+ }
+ 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 LABELS:
+ return isSetLabels();
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof TAuthorization)
+ return this.equals((TAuthorization)that);
+ return false;
+ }
+
+ public boolean equals(TAuthorization that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_labels = true && this.isSetLabels();
+ boolean that_present_labels = true && that.isSetLabels();
+ if (this_present_labels || that_present_labels) {
+ if (!(this_present_labels && that_present_labels))
+ return false;
+ if (!this.labels.equals(that.labels))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(TAuthorization other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ TAuthorization typedOther = (TAuthorization)other;
+
+ lastComparison = Boolean.valueOf(isSetLabels()).compareTo(typedOther.isSetLabels());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetLabels()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.labels, typedOther.labels);
+ 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("TAuthorization(");
+ boolean first = true;
+
+ if (isSetLabels()) {
+ sb.append("labels:");
+ if (this.labels == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.labels);
+ }
+ first = false;
+ }
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws org.apache.thrift.TException {
+ // check for required fields
+ // 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 TAuthorizationStandardSchemeFactory implements SchemeFactory {
+ public TAuthorizationStandardScheme getScheme() {
+ return new TAuthorizationStandardScheme();
+ }
+ }
+
+ private static class TAuthorizationStandardScheme extends StandardScheme<TAuthorization> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, TAuthorization 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: // LABELS
+ if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
+ {
+ org.apache.thrift.protocol.TList _list8 = iprot.readListBegin();
+ struct.labels = new ArrayList<String>(_list8.size);
+ for (int _i9 = 0; _i9 < _list8.size; ++_i9)
+ {
+ String _elem10; // required
+ _elem10 = iprot.readString();
+ struct.labels.add(_elem10);
+ }
+ iprot.readListEnd();
+ }
+ struct.setLabelsIsSet(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, TAuthorization struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (struct.labels != null) {
+ if (struct.isSetLabels()) {
+ oprot.writeFieldBegin(LABELS_FIELD_DESC);
+ {
+ oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.labels.size()));
+ for (String _iter11 : struct.labels)
+ {
+ oprot.writeString(_iter11);
+ }
+ oprot.writeListEnd();
+ }
+ oprot.writeFieldEnd();
+ }
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class TAuthorizationTupleSchemeFactory implements SchemeFactory {
+ public TAuthorizationTupleScheme getScheme() {
+ return new TAuthorizationTupleScheme();
+ }
+ }
+
+ private static class TAuthorizationTupleScheme extends TupleScheme<TAuthorization> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, TAuthorization struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ BitSet optionals = new BitSet();
+ if (struct.isSetLabels()) {
+ optionals.set(0);
+ }
+ oprot.writeBitSet(optionals, 1);
+ if (struct.isSetLabels()) {
+ {
+ oprot.writeI32(struct.labels.size());
+ for (String _iter12 : struct.labels)
+ {
+ oprot.writeString(_iter12);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, TAuthorization struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ BitSet incoming = iprot.readBitSet(1);
+ if (incoming.get(0)) {
+ {
+ org.apache.thrift.protocol.TList _list13 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
+ struct.labels = new ArrayList<String>(_list13.size);
+ for (int _i14 = 0; _i14 < _list13.size; ++_i14)
+ {
+ String _elem15; // required
+ _elem15 = iprot.readString();
+ struct.labels.add(_elem15);
+ }
+ }
+ struct.setLabelsIsSet(true);
+ }
+ }
+ }
+
+}
+
Added: hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TCellVisibility.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TCellVisibility.java?rev=1546988&view=auto
==============================================================================
--- hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TCellVisibility.java (added)
+++ hbase/trunk/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/generated/TCellVisibility.java Mon Dec 2 12:44:03 2013
@@ -0,0 +1,384 @@
+/**
+ * Autogenerated by Thrift Compiler (0.9.0)
+ *
+ * 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 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 org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TCellVisibility implements org.apache.thrift.TBase<TCellVisibility, TCellVisibility._Fields>, java.io.Serializable, Cloneable {
+ private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TCellVisibility");
+
+ private static final org.apache.thrift.protocol.TField EXPRESSION_FIELD_DESC = new org.apache.thrift.protocol.TField("expression", org.apache.thrift.protocol.TType.STRING, (short)1);
+
+ private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
+ static {
+ schemes.put(StandardScheme.class, new TCellVisibilityStandardSchemeFactory());
+ schemes.put(TupleScheme.class, new TCellVisibilityTupleSchemeFactory());
+ }
+
+ public String expression; // 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 {
+ EXPRESSION((short)1, "expression");
+
+ 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: // EXPRESSION
+ return EXPRESSION;
+ 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
+ private _Fields optionals[] = {_Fields.EXPRESSION};
+ 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.EXPRESSION, new org.apache.thrift.meta_data.FieldMetaData("expression", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+ metaDataMap = Collections.unmodifiableMap(tmpMap);
+ org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TCellVisibility.class, metaDataMap);
+ }
+
+ public TCellVisibility() {
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public TCellVisibility(TCellVisibility other) {
+ if (other.isSetExpression()) {
+ this.expression = other.expression;
+ }
+ }
+
+ public TCellVisibility deepCopy() {
+ return new TCellVisibility(this);
+ }
+
+ @Override
+ public void clear() {
+ this.expression = null;
+ }
+
+ public String getExpression() {
+ return this.expression;
+ }
+
+ public TCellVisibility setExpression(String expression) {
+ this.expression = expression;
+ return this;
+ }
+
+ public void unsetExpression() {
+ this.expression = null;
+ }
+
+ /** Returns true if field expression is set (has been assigned a value) and false otherwise */
+ public boolean isSetExpression() {
+ return this.expression != null;
+ }
+
+ public void setExpressionIsSet(boolean value) {
+ if (!value) {
+ this.expression = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field, Object value) {
+ switch (field) {
+ case EXPRESSION:
+ if (value == null) {
+ unsetExpression();
+ } else {
+ setExpression((String)value);
+ }
+ break;
+
+ }
+ }
+
+ public Object getFieldValue(_Fields field) {
+ switch (field) {
+ case EXPRESSION:
+ return getExpression();
+
+ }
+ 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 EXPRESSION:
+ return isSetExpression();
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(Object that) {
+ if (that == null)
+ return false;
+ if (that instanceof TCellVisibility)
+ return this.equals((TCellVisibility)that);
+ return false;
+ }
+
+ public boolean equals(TCellVisibility that) {
+ if (that == null)
+ return false;
+
+ boolean this_present_expression = true && this.isSetExpression();
+ boolean that_present_expression = true && that.isSetExpression();
+ if (this_present_expression || that_present_expression) {
+ if (!(this_present_expression && that_present_expression))
+ return false;
+ if (!this.expression.equals(that.expression))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ public int compareTo(TCellVisibility other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+ TCellVisibility typedOther = (TCellVisibility)other;
+
+ lastComparison = Boolean.valueOf(isSetExpression()).compareTo(typedOther.isSetExpression());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetExpression()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.expression, typedOther.expression);
+ 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("TCellVisibility(");
+ boolean first = true;
+
+ if (isSetExpression()) {
+ sb.append("expression:");
+ if (this.expression == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.expression);
+ }
+ first = false;
+ }
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public void validate() throws org.apache.thrift.TException {
+ // check for required fields
+ // 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 TCellVisibilityStandardSchemeFactory implements SchemeFactory {
+ public TCellVisibilityStandardScheme getScheme() {
+ return new TCellVisibilityStandardScheme();
+ }
+ }
+
+ private static class TCellVisibilityStandardScheme extends StandardScheme<TCellVisibility> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot, TCellVisibility 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: // EXPRESSION
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+ struct.expression = iprot.readString();
+ struct.setExpressionIsSet(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, TCellVisibility struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (struct.expression != null) {
+ if (struct.isSetExpression()) {
+ oprot.writeFieldBegin(EXPRESSION_FIELD_DESC);
+ oprot.writeString(struct.expression);
+ oprot.writeFieldEnd();
+ }
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class TCellVisibilityTupleSchemeFactory implements SchemeFactory {
+ public TCellVisibilityTupleScheme getScheme() {
+ return new TCellVisibilityTupleScheme();
+ }
+ }
+
+ private static class TCellVisibilityTupleScheme extends TupleScheme<TCellVisibility> {
+
+ @Override
+ public void write(org.apache.thrift.protocol.TProtocol prot, TCellVisibility struct) throws org.apache.thrift.TException {
+ TTupleProtocol oprot = (TTupleProtocol) prot;
+ BitSet optionals = new BitSet();
+ if (struct.isSetExpression()) {
+ optionals.set(0);
+ }
+ oprot.writeBitSet(optionals, 1);
+ if (struct.isSetExpression()) {
+ oprot.writeString(struct.expression);
+ }
+ }
+
+ @Override
+ public void read(org.apache.thrift.protocol.TProtocol prot, TCellVisibility struct) throws org.apache.thrift.TException {
+ TTupleProtocol iprot = (TTupleProtocol) prot;
+ BitSet incoming = iprot.readBitSet(1);
+ if (incoming.get(0)) {
+ struct.expression = iprot.readString();
+ struct.setExpressionIsSet(true);
+ }
+ }
+ }
+
+}
+