HBASE-26037 Implement namespace and table level access control for thrift & thrift2 (#3437)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
Signed-off-by: stack <stack@apache.org>
This commit is contained in:
YutSean 2021-08-17 02:10:42 +08:00 committed by GitHub
parent ad7e2cefc8
commit 1c71cb20d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
65 changed files with 6113 additions and 130 deletions

View File

@ -67,6 +67,8 @@ import org.apache.hadoop.hbase.filter.ParseFilter;
import org.apache.hadoop.hbase.filter.PrefixFilter;
import org.apache.hadoop.hbase.filter.WhileMatchFilter;
import org.apache.hadoop.hbase.security.UserProvider;
import org.apache.hadoop.hbase.security.access.AccessControlClient;
import org.apache.hadoop.hbase.security.access.Permission;
import org.apache.hadoop.hbase.thrift.generated.AlreadyExists;
import org.apache.hadoop.hbase.thrift.generated.BatchMutation;
import org.apache.hadoop.hbase.thrift.generated.ColumnDescriptor;
@ -74,9 +76,11 @@ import org.apache.hadoop.hbase.thrift.generated.Hbase;
import org.apache.hadoop.hbase.thrift.generated.IOError;
import org.apache.hadoop.hbase.thrift.generated.IllegalArgument;
import org.apache.hadoop.hbase.thrift.generated.Mutation;
import org.apache.hadoop.hbase.thrift.generated.TAccessControlEntity;
import org.apache.hadoop.hbase.thrift.generated.TAppend;
import org.apache.hadoop.hbase.thrift.generated.TCell;
import org.apache.hadoop.hbase.thrift.generated.TIncrement;
import org.apache.hadoop.hbase.thrift.generated.TPermissionScope;
import org.apache.hadoop.hbase.thrift.generated.TRegionInfo;
import org.apache.hadoop.hbase.thrift.generated.TRowResult;
import org.apache.hadoop.hbase.thrift.generated.TScan;
@ -1290,6 +1294,50 @@ public class ThriftHBaseServiceHandler extends HBaseServiceHandler implements Hb
return connectionCache.getClusterId();
}
@Override
public boolean grant(TAccessControlEntity info) throws IOError, TException {
Permission.Action[] actions = ThriftUtilities.permissionActionsFromString(info.actions);
try {
if (info.scope == TPermissionScope.NAMESPACE) {
AccessControlClient.grant(connectionCache.getAdmin().getConnection(),
info.getNsName(), info.getUsername(), actions);
} else if (info.scope == TPermissionScope.TABLE) {
TableName tableName = TableName.valueOf(info.getTableName());
AccessControlClient.grant(connectionCache.getAdmin().getConnection(),
tableName, info.getUsername(), null, null, actions);
}
} catch (Throwable t) {
if (t instanceof IOException) {
throw getIOError(t);
} else {
throw getIOError(new DoNotRetryIOException(t.getMessage()));
}
}
return true;
}
@Override
public boolean revoke(TAccessControlEntity info) throws IOError, TException {
Permission.Action[] actions = ThriftUtilities.permissionActionsFromString(info.actions);
try {
if (info.scope == TPermissionScope.NAMESPACE) {
AccessControlClient.revoke(connectionCache.getAdmin().getConnection(),
info.getNsName(), info.getUsername(), actions);
} else if (info.scope == TPermissionScope.TABLE) {
TableName tableName = TableName.valueOf(info.getTableName());
AccessControlClient.revoke(connectionCache.getAdmin().getConnection(),
tableName, info.getUsername(), null, null, actions);
}
} catch (Throwable t) {
if (t instanceof IOException) {
throw getIOError(t);
} else {
throw getIOError(new DoNotRetryIOException(t.getMessage()));
}
}
return true;
}
private static IOError getIOError(Throwable throwable) {
IOError error = new IOErrorWithCause(throwable);
error.setCanRetry(!(throwable instanceof DoNotRetryIOException));

View File

@ -22,8 +22,10 @@ import static org.apache.hadoop.hbase.util.Bytes.getBytes;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.TreeMap;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
@ -35,6 +37,7 @@ import org.apache.hadoop.hbase.client.Increment;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.io.compress.Compression;
import org.apache.hadoop.hbase.regionserver.BloomType;
import org.apache.hadoop.hbase.security.access.Permission;
import org.apache.hadoop.hbase.thrift.generated.ColumnDescriptor;
import org.apache.hadoop.hbase.thrift.generated.IllegalArgument;
import org.apache.hadoop.hbase.thrift.generated.TAppend;
@ -237,4 +240,19 @@ public final class ThriftUtilities {
}
return append;
}
public static Permission.Action[] permissionActionsFromString(String permission_actions) {
Set<Permission.Action> actions = new HashSet<>();
for (char c : permission_actions.toCharArray()) {
switch (c) {
case 'R': actions.add(Permission.Action.READ); break;
case 'W': actions.add(Permission.Action.WRITE); break;
case 'C': actions.add(Permission.Action.CREATE); break;
case 'X': actions.add(Permission.Action.EXEC); break;
case 'A': actions.add(Permission.Action.ADMIN); break;
default: break;
}
}
return actions.toArray(new Permission.Action[0]);
}
}

View File

@ -11,7 +11,7 @@ package org.apache.hadoop.hbase.thrift.generated;
* An AlreadyExists exceptions signals that a table with the specified
* name already exists
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class AlreadyExists extends org.apache.thrift.TException implements org.apache.thrift.TBase<AlreadyExists, AlreadyExists._Fields>, java.io.Serializable, Cloneable, Comparable<AlreadyExists> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("AlreadyExists");

View File

@ -10,7 +10,7 @@ package org.apache.hadoop.hbase.thrift.generated;
/**
* A BatchMutation object is used to apply a number of Mutations to a single row.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class BatchMutation implements org.apache.thrift.TBase<BatchMutation, BatchMutation._Fields>, java.io.Serializable, Cloneable, Comparable<BatchMutation> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("BatchMutation");

View File

@ -12,7 +12,7 @@ package org.apache.hadoop.hbase.thrift.generated;
* such as the number of versions, compression settings, etc. It is
* used as input when creating a table or adding a column.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class ColumnDescriptor implements org.apache.thrift.TBase<ColumnDescriptor, ColumnDescriptor._Fields>, java.io.Serializable, Cloneable, Comparable<ColumnDescriptor> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ColumnDescriptor");

View File

@ -12,7 +12,7 @@ package org.apache.hadoop.hbase.thrift.generated;
* to the Hbase master or an Hbase region server. Also used to return
* more general Hbase error conditions.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class IOError extends org.apache.thrift.TException implements org.apache.thrift.TBase<IOError, IOError._Fields>, java.io.Serializable, Cloneable, Comparable<IOError> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("IOError");
@ -94,10 +94,10 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.CAN_RETRY, new org.apache.thrift.meta_data.FieldMetaData("canRetry", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.CAN_RETRY, new org.apache.thrift.meta_data.FieldMetaData("canRetry", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(IOError.class, metaDataMap);
}
@ -187,21 +187,21 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) {
switch (field) {
case MESSAGE:
if (value == null) {
unsetMessage();
} else {
setMessage((java.lang.String)value);
}
break;
case MESSAGE:
if (value == null) {
unsetMessage();
} else {
setMessage((java.lang.String)value);
}
break;
case CAN_RETRY:
if (value == null) {
unsetCanRetry();
} else {
setCanRetry((java.lang.Boolean)value);
}
break;
case CAN_RETRY:
if (value == null) {
unsetCanRetry();
} else {
setCanRetry((java.lang.Boolean)value);
}
break;
}
}
@ -209,11 +209,11 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
@org.apache.thrift.annotation.Nullable
public java.lang.Object getFieldValue(_Fields field) {
switch (field) {
case MESSAGE:
return getMessage();
case MESSAGE:
return getMessage();
case CAN_RETRY:
return isCanRetry();
case CAN_RETRY:
return isCanRetry();
}
throw new java.lang.IllegalStateException();
@ -226,10 +226,10 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
}
switch (field) {
case MESSAGE:
return isSetMessage();
case CAN_RETRY:
return isSetCanRetry();
case MESSAGE:
return isSetMessage();
case CAN_RETRY:
return isSetCanRetry();
}
throw new java.lang.IllegalStateException();
}
@ -382,7 +382,7 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
@ -390,7 +390,7 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.message = iprot.readString();
struct.setMessageIsSet(true);
} else {
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
@ -398,7 +398,7 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
struct.canRetry = iprot.readBool();
struct.setCanRetryIsSet(true);
} else {
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;

View File

@ -11,7 +11,7 @@ package org.apache.hadoop.hbase.thrift.generated;
* An IllegalArgument exception indicates an illegal or invalid
* argument was passed into a procedure.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class IllegalArgument extends org.apache.thrift.TException implements org.apache.thrift.TBase<IllegalArgument, IllegalArgument._Fields>, java.io.Serializable, Cloneable, Comparable<IllegalArgument> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("IllegalArgument");

View File

@ -10,7 +10,7 @@ package org.apache.hadoop.hbase.thrift.generated;
/**
* A Mutation object is used to either update or delete a column-value.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class Mutation implements org.apache.thrift.TBase<Mutation, Mutation._Fields>, java.io.Serializable, Cloneable, Comparable<Mutation> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Mutation");

View File

@ -0,0 +1,820 @@
/**
* Autogenerated by Thrift Compiler (0.14.1)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package org.apache.hadoop.hbase.thrift.generated;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
/**
* TAccessControlEntity for permission control
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TAccessControlEntity implements org.apache.thrift.TBase<TAccessControlEntity, TAccessControlEntity._Fields>, java.io.Serializable, Cloneable, Comparable<TAccessControlEntity> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TAccessControlEntity");
private static final org.apache.thrift.protocol.TField USERNAME_FIELD_DESC = new org.apache.thrift.protocol.TField("username", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField SCOPE_FIELD_DESC = new org.apache.thrift.protocol.TField("scope", org.apache.thrift.protocol.TType.I32, (short)2);
private static final org.apache.thrift.protocol.TField ACTIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("actions", org.apache.thrift.protocol.TType.STRING, (short)4);
private static final org.apache.thrift.protocol.TField TABLE_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("tableName", org.apache.thrift.protocol.TType.STRING, (short)5);
private static final org.apache.thrift.protocol.TField NS_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("nsName", org.apache.thrift.protocol.TType.STRING, (short)6);
private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new TAccessControlEntityStandardSchemeFactory();
private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new TAccessControlEntityTupleSchemeFactory();
public @org.apache.thrift.annotation.Nullable java.lang.String username; // required
/**
*
* @see TPermissionScope
*/
public @org.apache.thrift.annotation.Nullable TPermissionScope scope; // required
public @org.apache.thrift.annotation.Nullable java.lang.String actions; // required
public @org.apache.thrift.annotation.Nullable java.nio.ByteBuffer tableName; // optional
public @org.apache.thrift.annotation.Nullable java.lang.String nsName; // 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 {
USERNAME((short)1, "username"),
/**
*
* @see TPermissionScope
*/
SCOPE((short)2, "scope"),
ACTIONS((short)4, "actions"),
TABLE_NAME((short)5, "tableName"),
NS_NAME((short)6, "nsName");
private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
static {
for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
@org.apache.thrift.annotation.Nullable
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // USERNAME
return USERNAME;
case 2: // SCOPE
return SCOPE;
case 4: // ACTIONS
return ACTIONS;
case 5: // TABLE_NAME
return TABLE_NAME;
case 6: // NS_NAME
return NS_NAME;
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 java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
@org.apache.thrift.annotation.Nullable
public static _Fields findByName(java.lang.String name) {
return byName.get(name);
}
private final short _thriftId;
private final java.lang.String _fieldName;
_Fields(short thriftId, java.lang.String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public java.lang.String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final _Fields optionals[] = {_Fields.TABLE_NAME,_Fields.NS_NAME};
public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.USERNAME, new org.apache.thrift.meta_data.FieldMetaData("username", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.SCOPE, new org.apache.thrift.meta_data.FieldMetaData("scope", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TPermissionScope.class)));
tmpMap.put(_Fields.ACTIONS, new org.apache.thrift.meta_data.FieldMetaData("actions", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.TABLE_NAME, new org.apache.thrift.meta_data.FieldMetaData("tableName", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , "Bytes")));
tmpMap.put(_Fields.NS_NAME, new org.apache.thrift.meta_data.FieldMetaData("nsName", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TAccessControlEntity.class, metaDataMap);
}
public TAccessControlEntity() {
}
public TAccessControlEntity(
java.lang.String username,
TPermissionScope scope,
java.lang.String actions)
{
this();
this.username = username;
this.scope = scope;
this.actions = actions;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TAccessControlEntity(TAccessControlEntity other) {
if (other.isSetUsername()) {
this.username = other.username;
}
if (other.isSetScope()) {
this.scope = other.scope;
}
if (other.isSetActions()) {
this.actions = other.actions;
}
if (other.isSetTableName()) {
this.tableName = org.apache.thrift.TBaseHelper.copyBinary(other.tableName);
}
if (other.isSetNsName()) {
this.nsName = other.nsName;
}
}
public TAccessControlEntity deepCopy() {
return new TAccessControlEntity(this);
}
@Override
public void clear() {
this.username = null;
this.scope = null;
this.actions = null;
this.tableName = null;
this.nsName = null;
}
@org.apache.thrift.annotation.Nullable
public java.lang.String getUsername() {
return this.username;
}
public TAccessControlEntity setUsername(@org.apache.thrift.annotation.Nullable java.lang.String username) {
this.username = username;
return this;
}
public void unsetUsername() {
this.username = null;
}
/** Returns true if field username is set (has been assigned a value) and false otherwise */
public boolean isSetUsername() {
return this.username != null;
}
public void setUsernameIsSet(boolean value) {
if (!value) {
this.username = null;
}
}
/**
*
* @see TPermissionScope
*/
@org.apache.thrift.annotation.Nullable
public TPermissionScope getScope() {
return this.scope;
}
/**
*
* @see TPermissionScope
*/
public TAccessControlEntity setScope(@org.apache.thrift.annotation.Nullable TPermissionScope scope) {
this.scope = scope;
return this;
}
public void unsetScope() {
this.scope = null;
}
/** Returns true if field scope is set (has been assigned a value) and false otherwise */
public boolean isSetScope() {
return this.scope != null;
}
public void setScopeIsSet(boolean value) {
if (!value) {
this.scope = null;
}
}
@org.apache.thrift.annotation.Nullable
public java.lang.String getActions() {
return this.actions;
}
public TAccessControlEntity setActions(@org.apache.thrift.annotation.Nullable java.lang.String actions) {
this.actions = actions;
return this;
}
public void unsetActions() {
this.actions = null;
}
/** Returns true if field actions is set (has been assigned a value) and false otherwise */
public boolean isSetActions() {
return this.actions != null;
}
public void setActionsIsSet(boolean value) {
if (!value) {
this.actions = null;
}
}
public byte[] getTableName() {
setTableName(org.apache.thrift.TBaseHelper.rightSize(tableName));
return tableName == null ? null : tableName.array();
}
public java.nio.ByteBuffer bufferForTableName() {
return org.apache.thrift.TBaseHelper.copyBinary(tableName);
}
public TAccessControlEntity setTableName(byte[] tableName) {
this.tableName = tableName == null ? (java.nio.ByteBuffer)null : java.nio.ByteBuffer.wrap(tableName.clone());
return this;
}
public TAccessControlEntity setTableName(@org.apache.thrift.annotation.Nullable java.nio.ByteBuffer tableName) {
this.tableName = org.apache.thrift.TBaseHelper.copyBinary(tableName);
return this;
}
public void unsetTableName() {
this.tableName = null;
}
/** Returns true if field tableName is set (has been assigned a value) and false otherwise */
public boolean isSetTableName() {
return this.tableName != null;
}
public void setTableNameIsSet(boolean value) {
if (!value) {
this.tableName = null;
}
}
@org.apache.thrift.annotation.Nullable
public java.lang.String getNsName() {
return this.nsName;
}
public TAccessControlEntity setNsName(@org.apache.thrift.annotation.Nullable java.lang.String nsName) {
this.nsName = nsName;
return this;
}
public void unsetNsName() {
this.nsName = null;
}
/** Returns true if field nsName is set (has been assigned a value) and false otherwise */
public boolean isSetNsName() {
return this.nsName != null;
}
public void setNsNameIsSet(boolean value) {
if (!value) {
this.nsName = null;
}
}
public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) {
switch (field) {
case USERNAME:
if (value == null) {
unsetUsername();
} else {
setUsername((java.lang.String)value);
}
break;
case SCOPE:
if (value == null) {
unsetScope();
} else {
setScope((TPermissionScope)value);
}
break;
case ACTIONS:
if (value == null) {
unsetActions();
} else {
setActions((java.lang.String)value);
}
break;
case TABLE_NAME:
if (value == null) {
unsetTableName();
} else {
if (value instanceof byte[]) {
setTableName((byte[])value);
} else {
setTableName((java.nio.ByteBuffer)value);
}
}
break;
case NS_NAME:
if (value == null) {
unsetNsName();
} else {
setNsName((java.lang.String)value);
}
break;
}
}
@org.apache.thrift.annotation.Nullable
public java.lang.Object getFieldValue(_Fields field) {
switch (field) {
case USERNAME:
return getUsername();
case SCOPE:
return getScope();
case ACTIONS:
return getActions();
case TABLE_NAME:
return getTableName();
case NS_NAME:
return getNsName();
}
throw new java.lang.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 java.lang.IllegalArgumentException();
}
switch (field) {
case USERNAME:
return isSetUsername();
case SCOPE:
return isSetScope();
case ACTIONS:
return isSetActions();
case TABLE_NAME:
return isSetTableName();
case NS_NAME:
return isSetNsName();
}
throw new java.lang.IllegalStateException();
}
@Override
public boolean equals(java.lang.Object that) {
if (that instanceof TAccessControlEntity)
return this.equals((TAccessControlEntity)that);
return false;
}
public boolean equals(TAccessControlEntity that) {
if (that == null)
return false;
if (this == that)
return true;
boolean this_present_username = true && this.isSetUsername();
boolean that_present_username = true && that.isSetUsername();
if (this_present_username || that_present_username) {
if (!(this_present_username && that_present_username))
return false;
if (!this.username.equals(that.username))
return false;
}
boolean this_present_scope = true && this.isSetScope();
boolean that_present_scope = true && that.isSetScope();
if (this_present_scope || that_present_scope) {
if (!(this_present_scope && that_present_scope))
return false;
if (!this.scope.equals(that.scope))
return false;
}
boolean this_present_actions = true && this.isSetActions();
boolean that_present_actions = true && that.isSetActions();
if (this_present_actions || that_present_actions) {
if (!(this_present_actions && that_present_actions))
return false;
if (!this.actions.equals(that.actions))
return false;
}
boolean this_present_tableName = true && this.isSetTableName();
boolean that_present_tableName = true && that.isSetTableName();
if (this_present_tableName || that_present_tableName) {
if (!(this_present_tableName && that_present_tableName))
return false;
if (!this.tableName.equals(that.tableName))
return false;
}
boolean this_present_nsName = true && this.isSetNsName();
boolean that_present_nsName = true && that.isSetNsName();
if (this_present_nsName || that_present_nsName) {
if (!(this_present_nsName && that_present_nsName))
return false;
if (!this.nsName.equals(that.nsName))
return false;
}
return true;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = hashCode * 8191 + ((isSetUsername()) ? 131071 : 524287);
if (isSetUsername())
hashCode = hashCode * 8191 + username.hashCode();
hashCode = hashCode * 8191 + ((isSetScope()) ? 131071 : 524287);
if (isSetScope())
hashCode = hashCode * 8191 + scope.getValue();
hashCode = hashCode * 8191 + ((isSetActions()) ? 131071 : 524287);
if (isSetActions())
hashCode = hashCode * 8191 + actions.hashCode();
hashCode = hashCode * 8191 + ((isSetTableName()) ? 131071 : 524287);
if (isSetTableName())
hashCode = hashCode * 8191 + tableName.hashCode();
hashCode = hashCode * 8191 + ((isSetNsName()) ? 131071 : 524287);
if (isSetNsName())
hashCode = hashCode * 8191 + nsName.hashCode();
return hashCode;
}
@Override
public int compareTo(TAccessControlEntity other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = java.lang.Boolean.compare(isSetUsername(), other.isSetUsername());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetUsername()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.username, other.username);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = java.lang.Boolean.compare(isSetScope(), other.isSetScope());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetScope()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.scope, other.scope);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = java.lang.Boolean.compare(isSetActions(), other.isSetActions());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetActions()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.actions, other.actions);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = java.lang.Boolean.compare(isSetTableName(), other.isSetTableName());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetTableName()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tableName, other.tableName);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = java.lang.Boolean.compare(isSetNsName(), other.isSetNsName());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetNsName()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.nsName, other.nsName);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
@org.apache.thrift.annotation.Nullable
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
scheme(iprot).read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
scheme(oprot).write(oprot, this);
}
@Override
public java.lang.String toString() {
java.lang.StringBuilder sb = new java.lang.StringBuilder("TAccessControlEntity(");
boolean first = true;
sb.append("username:");
if (this.username == null) {
sb.append("null");
} else {
sb.append(this.username);
}
first = false;
if (!first) sb.append(", ");
sb.append("scope:");
if (this.scope == null) {
sb.append("null");
} else {
sb.append(this.scope);
}
first = false;
if (!first) sb.append(", ");
sb.append("actions:");
if (this.actions == null) {
sb.append("null");
} else {
sb.append(this.actions);
}
first = false;
if (isSetTableName()) {
if (!first) sb.append(", ");
sb.append("tableName:");
if (this.tableName == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.tableName, sb);
}
first = false;
}
if (isSetNsName()) {
if (!first) sb.append(", ");
sb.append("nsName:");
if (this.nsName == null) {
sb.append("null");
} else {
sb.append(this.nsName);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (username == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'username' was not present! Struct: " + toString());
}
if (scope == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'scope' was not present! Struct: " + toString());
}
if (actions == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'actions' 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, java.lang.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 TAccessControlEntityStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public TAccessControlEntityStandardScheme getScheme() {
return new TAccessControlEntityStandardScheme();
}
}
private static class TAccessControlEntityStandardScheme extends org.apache.thrift.scheme.StandardScheme<TAccessControlEntity> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TAccessControlEntity 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: // USERNAME
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.username = iprot.readString();
struct.setUsernameIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // SCOPE
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.scope = org.apache.hadoop.hbase.thrift.generated.TPermissionScope.findByValue(iprot.readI32());
struct.setScopeIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 4: // ACTIONS
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.actions = iprot.readString();
struct.setActionsIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 5: // TABLE_NAME
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.tableName = iprot.readBinary();
struct.setTableNameIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 6: // NS_NAME
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.nsName = iprot.readString();
struct.setNsNameIsSet(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, TAccessControlEntity struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.username != null) {
oprot.writeFieldBegin(USERNAME_FIELD_DESC);
oprot.writeString(struct.username);
oprot.writeFieldEnd();
}
if (struct.scope != null) {
oprot.writeFieldBegin(SCOPE_FIELD_DESC);
oprot.writeI32(struct.scope.getValue());
oprot.writeFieldEnd();
}
if (struct.actions != null) {
oprot.writeFieldBegin(ACTIONS_FIELD_DESC);
oprot.writeString(struct.actions);
oprot.writeFieldEnd();
}
if (struct.tableName != null) {
if (struct.isSetTableName()) {
oprot.writeFieldBegin(TABLE_NAME_FIELD_DESC);
oprot.writeBinary(struct.tableName);
oprot.writeFieldEnd();
}
}
if (struct.nsName != null) {
if (struct.isSetNsName()) {
oprot.writeFieldBegin(NS_NAME_FIELD_DESC);
oprot.writeString(struct.nsName);
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TAccessControlEntityTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public TAccessControlEntityTupleScheme getScheme() {
return new TAccessControlEntityTupleScheme();
}
}
private static class TAccessControlEntityTupleScheme extends org.apache.thrift.scheme.TupleScheme<TAccessControlEntity> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TAccessControlEntity struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
oprot.writeString(struct.username);
oprot.writeI32(struct.scope.getValue());
oprot.writeString(struct.actions);
java.util.BitSet optionals = new java.util.BitSet();
if (struct.isSetTableName()) {
optionals.set(0);
}
if (struct.isSetNsName()) {
optionals.set(1);
}
oprot.writeBitSet(optionals, 2);
if (struct.isSetTableName()) {
oprot.writeBinary(struct.tableName);
}
if (struct.isSetNsName()) {
oprot.writeString(struct.nsName);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TAccessControlEntity struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
struct.username = iprot.readString();
struct.setUsernameIsSet(true);
struct.scope = org.apache.hadoop.hbase.thrift.generated.TPermissionScope.findByValue(iprot.readI32());
struct.setScopeIsSet(true);
struct.actions = iprot.readString();
struct.setActionsIsSet(true);
java.util.BitSet incoming = iprot.readBitSet(2);
if (incoming.get(0)) {
struct.tableName = iprot.readBinary();
struct.setTableNameIsSet(true);
}
if (incoming.get(1)) {
struct.nsName = iprot.readString();
struct.setNsNameIsSet(true);
}
}
}
private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
}
}

View File

@ -10,7 +10,7 @@ package org.apache.hadoop.hbase.thrift.generated;
/**
* An Append object is used to specify the parameters for performing the append operation.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TAppend implements org.apache.thrift.TBase<TAppend, TAppend._Fields>, java.io.Serializable, Cloneable, Comparable<TAppend> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TAppend");

View File

@ -13,7 +13,7 @@ package org.apache.hadoop.hbase.thrift.generated;
* the timestamp of a cell to a first-class value, making it easy to take
* note of temporal data. Cell is used all the way from HStore up to HTable.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TCell implements org.apache.thrift.TBase<TCell, TCell._Fields>, java.io.Serializable, Cloneable, Comparable<TCell> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TCell");

View File

@ -10,7 +10,7 @@ package org.apache.hadoop.hbase.thrift.generated;
/**
* Holds column name and the cell.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TColumn implements org.apache.thrift.TBase<TColumn, TColumn._Fields>, java.io.Serializable, Cloneable, Comparable<TColumn> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TColumn");

View File

@ -11,7 +11,7 @@ package org.apache.hadoop.hbase.thrift.generated;
* For increments that are not incrementColumnValue
* equivalents.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncrement._Fields>, java.io.Serializable, Cloneable, Comparable<TIncrement> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TIncrement");

View File

@ -0,0 +1,43 @@
/**
* Autogenerated by Thrift Compiler (0.14.1)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package org.apache.hadoop.hbase.thrift.generated;
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public enum TPermissionScope implements org.apache.thrift.TEnum {
TABLE(0),
NAMESPACE(1);
private final int value;
private TPermissionScope(int value) {
this.value = value;
}
/**
* Get the integer value of this enum value, as defined in the Thrift IDL.
*/
public int getValue() {
return value;
}
/**
* Find a the enum type by its integer value, as defined in the Thrift IDL.
* @return null if the value is not found.
*/
@org.apache.thrift.annotation.Nullable
public static TPermissionScope findByValue(int value) {
switch (value) {
case 0:
return TABLE;
case 1:
return NAMESPACE;
default:
return null;
}
}
}

View File

@ -10,7 +10,7 @@ package org.apache.hadoop.hbase.thrift.generated;
/**
* A TRegionInfo contains information about an HTable region.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TRegionInfo implements org.apache.thrift.TBase<TRegionInfo, TRegionInfo._Fields>, java.io.Serializable, Cloneable, Comparable<TRegionInfo> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TRegionInfo");

View File

@ -10,7 +10,7 @@ package org.apache.hadoop.hbase.thrift.generated;
/**
* Holds row name and then a map of columns to cells.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TRowResult implements org.apache.thrift.TBase<TRowResult, TRowResult._Fields>, java.io.Serializable, Cloneable, Comparable<TRowResult> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TRowResult");

View File

@ -10,7 +10,7 @@ package org.apache.hadoop.hbase.thrift.generated;
/**
* A Scan object is used to specify scanner parameters when opening a scanner.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, java.io.Serializable, Cloneable, Comparable<TScan> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TScan");

View File

@ -10,7 +10,7 @@ package org.apache.hadoop.hbase.thrift.generated;
/**
* Specify type of thrift server: thrift and thrift2
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public enum TThriftServerType implements org.apache.thrift.TEnum {
ONE(1),
TWO(2);

View File

@ -70,7 +70,10 @@ import org.apache.hadoop.hbase.client.OnlineLogRecord;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.client.TableDescriptor;
import org.apache.hadoop.hbase.security.UserProvider;
import org.apache.hadoop.hbase.security.access.AccessControlClient;
import org.apache.hadoop.hbase.security.access.Permission;
import org.apache.hadoop.hbase.thrift.HBaseServiceHandler;
import org.apache.hadoop.hbase.thrift2.generated.TAccessControlEntity;
import org.apache.hadoop.hbase.thrift2.generated.TAppend;
import org.apache.hadoop.hbase.thrift2.generated.TColumnFamilyDescriptor;
import org.apache.hadoop.hbase.thrift2.generated.TCompareOperator;
@ -84,6 +87,7 @@ import org.apache.hadoop.hbase.thrift2.generated.TIncrement;
import org.apache.hadoop.hbase.thrift2.generated.TLogQueryFilter;
import org.apache.hadoop.hbase.thrift2.generated.TNamespaceDescriptor;
import org.apache.hadoop.hbase.thrift2.generated.TOnlineLogRecord;
import org.apache.hadoop.hbase.thrift2.generated.TPermissionScope;
import org.apache.hadoop.hbase.thrift2.generated.TPut;
import org.apache.hadoop.hbase.thrift2.generated.TResult;
import org.apache.hadoop.hbase.thrift2.generated.TRowMutations;
@ -856,6 +860,50 @@ public class ThriftHBaseServiceHandler extends HBaseServiceHandler implements TH
}
}
@Override
public boolean grant(TAccessControlEntity info) throws TIOError, TException {
Permission.Action[] actions = ThriftUtilities.permissionActionsFromString(info.actions);
try {
if (info.scope == TPermissionScope.NAMESPACE) {
AccessControlClient.grant(connectionCache.getAdmin().getConnection(),
info.getNsName(), info.getUsername(), actions);
} else if (info.scope == TPermissionScope.TABLE) {
TableName tableName = TableName.valueOf(info.getTableName());
AccessControlClient.grant(connectionCache.getAdmin().getConnection(),
tableName, info.getUsername(), null, null, actions);
}
} catch (Throwable t) {
if (t instanceof IOException) {
throw getTIOError((IOException) t);
} else {
throw getTIOError(new DoNotRetryIOException(t.getMessage()));
}
}
return true;
}
@Override
public boolean revoke(TAccessControlEntity info) throws TIOError, TException {
Permission.Action[] actions = ThriftUtilities.permissionActionsFromString(info.actions);
try {
if (info.scope == TPermissionScope.NAMESPACE) {
AccessControlClient.revoke(connectionCache.getAdmin().getConnection(),
info.getNsName(), info.getUsername(), actions);
} else if (info.scope == TPermissionScope.TABLE) {
TableName tableName = TableName.valueOf(info.getTableName());
AccessControlClient.revoke(connectionCache.getAdmin().getConnection(),
tableName, info.getUsername(), null, null, actions);
}
} catch (Throwable t) {
if (t instanceof IOException) {
throw getTIOError((IOException) t);
} else {
throw getTIOError(new DoNotRetryIOException(t.getMessage()));
}
}
return true;
}
@Override
public List<TNamespaceDescriptor> listNamespaceDescriptors() throws TIOError, TException {
try {

View File

@ -24,6 +24,7 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.NavigableSet;
@ -70,6 +71,7 @@ import org.apache.hadoop.hbase.io.TimeRange;
import org.apache.hadoop.hbase.io.compress.Compression;
import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding;
import org.apache.hadoop.hbase.regionserver.BloomType;
import org.apache.hadoop.hbase.security.access.Permission;
import org.apache.hadoop.hbase.security.visibility.Authorizations;
import org.apache.hadoop.hbase.security.visibility.CellVisibility;
import org.apache.hadoop.hbase.thrift2.generated.TAppend;
@ -1645,4 +1647,19 @@ public final class ThriftUtilities {
.collect(Collectors.toList());
}
public static Permission.Action[] permissionActionsFromString(String permission_actions) {
Set<Permission.Action> actions = new HashSet<>();
for (char c : permission_actions.toCharArray()) {
switch (c) {
case 'R': actions.add(Permission.Action.READ); break;
case 'W': actions.add(Permission.Action.WRITE); break;
case 'C': actions.add(Permission.Action.CREATE); break;
case 'X': actions.add(Permission.Action.EXEC); break;
case 'A': actions.add(Permission.Action.ADMIN); break;
default: break;
}
}
return actions.toArray(new Permission.Action[0]);
}
}

View File

@ -0,0 +1,807 @@
/**
* Autogenerated by Thrift Compiler (0.14.1)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package org.apache.hadoop.hbase.thrift2.generated;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
/**
* TAccessControlEntity for permission control
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TAccessControlEntity implements org.apache.thrift.TBase<TAccessControlEntity, TAccessControlEntity._Fields>, java.io.Serializable, Cloneable, Comparable<TAccessControlEntity> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TAccessControlEntity");
private static final org.apache.thrift.protocol.TField USERNAME_FIELD_DESC = new org.apache.thrift.protocol.TField("username", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField SCOPE_FIELD_DESC = new org.apache.thrift.protocol.TField("scope", org.apache.thrift.protocol.TType.I32, (short)2);
private static final org.apache.thrift.protocol.TField ACTIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("actions", org.apache.thrift.protocol.TType.STRING, (short)4);
private static final org.apache.thrift.protocol.TField TABLE_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("tableName", org.apache.thrift.protocol.TType.STRING, (short)5);
private static final org.apache.thrift.protocol.TField NS_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("nsName", org.apache.thrift.protocol.TType.STRING, (short)6);
private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new TAccessControlEntityStandardSchemeFactory();
private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new TAccessControlEntityTupleSchemeFactory();
public @org.apache.thrift.annotation.Nullable java.lang.String username; // required
/**
*
* @see TPermissionScope
*/
public @org.apache.thrift.annotation.Nullable TPermissionScope scope; // required
public @org.apache.thrift.annotation.Nullable java.lang.String actions; // required
public @org.apache.thrift.annotation.Nullable java.lang.String tableName; // optional
public @org.apache.thrift.annotation.Nullable java.lang.String nsName; // 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 {
USERNAME((short)1, "username"),
/**
*
* @see TPermissionScope
*/
SCOPE((short)2, "scope"),
ACTIONS((short)4, "actions"),
TABLE_NAME((short)5, "tableName"),
NS_NAME((short)6, "nsName");
private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
static {
for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
@org.apache.thrift.annotation.Nullable
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // USERNAME
return USERNAME;
case 2: // SCOPE
return SCOPE;
case 4: // ACTIONS
return ACTIONS;
case 5: // TABLE_NAME
return TABLE_NAME;
case 6: // NS_NAME
return NS_NAME;
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 java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
@org.apache.thrift.annotation.Nullable
public static _Fields findByName(java.lang.String name) {
return byName.get(name);
}
private final short _thriftId;
private final java.lang.String _fieldName;
_Fields(short thriftId, java.lang.String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public java.lang.String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final _Fields optionals[] = {_Fields.TABLE_NAME,_Fields.NS_NAME};
public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.USERNAME, new org.apache.thrift.meta_data.FieldMetaData("username", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.SCOPE, new org.apache.thrift.meta_data.FieldMetaData("scope", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TPermissionScope.class)));
tmpMap.put(_Fields.ACTIONS, new org.apache.thrift.meta_data.FieldMetaData("actions", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.TABLE_NAME, new org.apache.thrift.meta_data.FieldMetaData("tableName", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.NS_NAME, new org.apache.thrift.meta_data.FieldMetaData("nsName", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TAccessControlEntity.class, metaDataMap);
}
public TAccessControlEntity() {
}
public TAccessControlEntity(
java.lang.String username,
TPermissionScope scope,
java.lang.String actions)
{
this();
this.username = username;
this.scope = scope;
this.actions = actions;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TAccessControlEntity(TAccessControlEntity other) {
if (other.isSetUsername()) {
this.username = other.username;
}
if (other.isSetScope()) {
this.scope = other.scope;
}
if (other.isSetActions()) {
this.actions = other.actions;
}
if (other.isSetTableName()) {
this.tableName = other.tableName;
}
if (other.isSetNsName()) {
this.nsName = other.nsName;
}
}
public TAccessControlEntity deepCopy() {
return new TAccessControlEntity(this);
}
@Override
public void clear() {
this.username = null;
this.scope = null;
this.actions = null;
this.tableName = null;
this.nsName = null;
}
@org.apache.thrift.annotation.Nullable
public java.lang.String getUsername() {
return this.username;
}
public TAccessControlEntity setUsername(@org.apache.thrift.annotation.Nullable java.lang.String username) {
this.username = username;
return this;
}
public void unsetUsername() {
this.username = null;
}
/** Returns true if field username is set (has been assigned a value) and false otherwise */
public boolean isSetUsername() {
return this.username != null;
}
public void setUsernameIsSet(boolean value) {
if (!value) {
this.username = null;
}
}
/**
*
* @see TPermissionScope
*/
@org.apache.thrift.annotation.Nullable
public TPermissionScope getScope() {
return this.scope;
}
/**
*
* @see TPermissionScope
*/
public TAccessControlEntity setScope(@org.apache.thrift.annotation.Nullable TPermissionScope scope) {
this.scope = scope;
return this;
}
public void unsetScope() {
this.scope = null;
}
/** Returns true if field scope is set (has been assigned a value) and false otherwise */
public boolean isSetScope() {
return this.scope != null;
}
public void setScopeIsSet(boolean value) {
if (!value) {
this.scope = null;
}
}
@org.apache.thrift.annotation.Nullable
public java.lang.String getActions() {
return this.actions;
}
public TAccessControlEntity setActions(@org.apache.thrift.annotation.Nullable java.lang.String actions) {
this.actions = actions;
return this;
}
public void unsetActions() {
this.actions = null;
}
/** Returns true if field actions is set (has been assigned a value) and false otherwise */
public boolean isSetActions() {
return this.actions != null;
}
public void setActionsIsSet(boolean value) {
if (!value) {
this.actions = null;
}
}
@org.apache.thrift.annotation.Nullable
public java.lang.String getTableName() {
return this.tableName;
}
public TAccessControlEntity setTableName(@org.apache.thrift.annotation.Nullable java.lang.String tableName) {
this.tableName = tableName;
return this;
}
public void unsetTableName() {
this.tableName = null;
}
/** Returns true if field tableName is set (has been assigned a value) and false otherwise */
public boolean isSetTableName() {
return this.tableName != null;
}
public void setTableNameIsSet(boolean value) {
if (!value) {
this.tableName = null;
}
}
@org.apache.thrift.annotation.Nullable
public java.lang.String getNsName() {
return this.nsName;
}
public TAccessControlEntity setNsName(@org.apache.thrift.annotation.Nullable java.lang.String nsName) {
this.nsName = nsName;
return this;
}
public void unsetNsName() {
this.nsName = null;
}
/** Returns true if field nsName is set (has been assigned a value) and false otherwise */
public boolean isSetNsName() {
return this.nsName != null;
}
public void setNsNameIsSet(boolean value) {
if (!value) {
this.nsName = null;
}
}
public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) {
switch (field) {
case USERNAME:
if (value == null) {
unsetUsername();
} else {
setUsername((java.lang.String)value);
}
break;
case SCOPE:
if (value == null) {
unsetScope();
} else {
setScope((TPermissionScope)value);
}
break;
case ACTIONS:
if (value == null) {
unsetActions();
} else {
setActions((java.lang.String)value);
}
break;
case TABLE_NAME:
if (value == null) {
unsetTableName();
} else {
setTableName((java.lang.String)value);
}
break;
case NS_NAME:
if (value == null) {
unsetNsName();
} else {
setNsName((java.lang.String)value);
}
break;
}
}
@org.apache.thrift.annotation.Nullable
public java.lang.Object getFieldValue(_Fields field) {
switch (field) {
case USERNAME:
return getUsername();
case SCOPE:
return getScope();
case ACTIONS:
return getActions();
case TABLE_NAME:
return getTableName();
case NS_NAME:
return getNsName();
}
throw new java.lang.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 java.lang.IllegalArgumentException();
}
switch (field) {
case USERNAME:
return isSetUsername();
case SCOPE:
return isSetScope();
case ACTIONS:
return isSetActions();
case TABLE_NAME:
return isSetTableName();
case NS_NAME:
return isSetNsName();
}
throw new java.lang.IllegalStateException();
}
@Override
public boolean equals(java.lang.Object that) {
if (that instanceof TAccessControlEntity)
return this.equals((TAccessControlEntity)that);
return false;
}
public boolean equals(TAccessControlEntity that) {
if (that == null)
return false;
if (this == that)
return true;
boolean this_present_username = true && this.isSetUsername();
boolean that_present_username = true && that.isSetUsername();
if (this_present_username || that_present_username) {
if (!(this_present_username && that_present_username))
return false;
if (!this.username.equals(that.username))
return false;
}
boolean this_present_scope = true && this.isSetScope();
boolean that_present_scope = true && that.isSetScope();
if (this_present_scope || that_present_scope) {
if (!(this_present_scope && that_present_scope))
return false;
if (!this.scope.equals(that.scope))
return false;
}
boolean this_present_actions = true && this.isSetActions();
boolean that_present_actions = true && that.isSetActions();
if (this_present_actions || that_present_actions) {
if (!(this_present_actions && that_present_actions))
return false;
if (!this.actions.equals(that.actions))
return false;
}
boolean this_present_tableName = true && this.isSetTableName();
boolean that_present_tableName = true && that.isSetTableName();
if (this_present_tableName || that_present_tableName) {
if (!(this_present_tableName && that_present_tableName))
return false;
if (!this.tableName.equals(that.tableName))
return false;
}
boolean this_present_nsName = true && this.isSetNsName();
boolean that_present_nsName = true && that.isSetNsName();
if (this_present_nsName || that_present_nsName) {
if (!(this_present_nsName && that_present_nsName))
return false;
if (!this.nsName.equals(that.nsName))
return false;
}
return true;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = hashCode * 8191 + ((isSetUsername()) ? 131071 : 524287);
if (isSetUsername())
hashCode = hashCode * 8191 + username.hashCode();
hashCode = hashCode * 8191 + ((isSetScope()) ? 131071 : 524287);
if (isSetScope())
hashCode = hashCode * 8191 + scope.getValue();
hashCode = hashCode * 8191 + ((isSetActions()) ? 131071 : 524287);
if (isSetActions())
hashCode = hashCode * 8191 + actions.hashCode();
hashCode = hashCode * 8191 + ((isSetTableName()) ? 131071 : 524287);
if (isSetTableName())
hashCode = hashCode * 8191 + tableName.hashCode();
hashCode = hashCode * 8191 + ((isSetNsName()) ? 131071 : 524287);
if (isSetNsName())
hashCode = hashCode * 8191 + nsName.hashCode();
return hashCode;
}
@Override
public int compareTo(TAccessControlEntity other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = java.lang.Boolean.compare(isSetUsername(), other.isSetUsername());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetUsername()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.username, other.username);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = java.lang.Boolean.compare(isSetScope(), other.isSetScope());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetScope()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.scope, other.scope);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = java.lang.Boolean.compare(isSetActions(), other.isSetActions());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetActions()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.actions, other.actions);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = java.lang.Boolean.compare(isSetTableName(), other.isSetTableName());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetTableName()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tableName, other.tableName);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = java.lang.Boolean.compare(isSetNsName(), other.isSetNsName());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetNsName()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.nsName, other.nsName);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
@org.apache.thrift.annotation.Nullable
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
scheme(iprot).read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
scheme(oprot).write(oprot, this);
}
@Override
public java.lang.String toString() {
java.lang.StringBuilder sb = new java.lang.StringBuilder("TAccessControlEntity(");
boolean first = true;
sb.append("username:");
if (this.username == null) {
sb.append("null");
} else {
sb.append(this.username);
}
first = false;
if (!first) sb.append(", ");
sb.append("scope:");
if (this.scope == null) {
sb.append("null");
} else {
sb.append(this.scope);
}
first = false;
if (!first) sb.append(", ");
sb.append("actions:");
if (this.actions == null) {
sb.append("null");
} else {
sb.append(this.actions);
}
first = false;
if (isSetTableName()) {
if (!first) sb.append(", ");
sb.append("tableName:");
if (this.tableName == null) {
sb.append("null");
} else {
sb.append(this.tableName);
}
first = false;
}
if (isSetNsName()) {
if (!first) sb.append(", ");
sb.append("nsName:");
if (this.nsName == null) {
sb.append("null");
} else {
sb.append(this.nsName);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (username == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'username' was not present! Struct: " + toString());
}
if (scope == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'scope' was not present! Struct: " + toString());
}
if (actions == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'actions' 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, java.lang.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 TAccessControlEntityStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public TAccessControlEntityStandardScheme getScheme() {
return new TAccessControlEntityStandardScheme();
}
}
private static class TAccessControlEntityStandardScheme extends org.apache.thrift.scheme.StandardScheme<TAccessControlEntity> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TAccessControlEntity 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: // USERNAME
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.username = iprot.readString();
struct.setUsernameIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // SCOPE
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.scope = org.apache.hadoop.hbase.thrift2.generated.TPermissionScope.findByValue(iprot.readI32());
struct.setScopeIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 4: // ACTIONS
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.actions = iprot.readString();
struct.setActionsIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 5: // TABLE_NAME
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.tableName = iprot.readString();
struct.setTableNameIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 6: // NS_NAME
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.nsName = iprot.readString();
struct.setNsNameIsSet(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, TAccessControlEntity struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.username != null) {
oprot.writeFieldBegin(USERNAME_FIELD_DESC);
oprot.writeString(struct.username);
oprot.writeFieldEnd();
}
if (struct.scope != null) {
oprot.writeFieldBegin(SCOPE_FIELD_DESC);
oprot.writeI32(struct.scope.getValue());
oprot.writeFieldEnd();
}
if (struct.actions != null) {
oprot.writeFieldBegin(ACTIONS_FIELD_DESC);
oprot.writeString(struct.actions);
oprot.writeFieldEnd();
}
if (struct.tableName != null) {
if (struct.isSetTableName()) {
oprot.writeFieldBegin(TABLE_NAME_FIELD_DESC);
oprot.writeString(struct.tableName);
oprot.writeFieldEnd();
}
}
if (struct.nsName != null) {
if (struct.isSetNsName()) {
oprot.writeFieldBegin(NS_NAME_FIELD_DESC);
oprot.writeString(struct.nsName);
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TAccessControlEntityTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
public TAccessControlEntityTupleScheme getScheme() {
return new TAccessControlEntityTupleScheme();
}
}
private static class TAccessControlEntityTupleScheme extends org.apache.thrift.scheme.TupleScheme<TAccessControlEntity> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TAccessControlEntity struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
oprot.writeString(struct.username);
oprot.writeI32(struct.scope.getValue());
oprot.writeString(struct.actions);
java.util.BitSet optionals = new java.util.BitSet();
if (struct.isSetTableName()) {
optionals.set(0);
}
if (struct.isSetNsName()) {
optionals.set(1);
}
oprot.writeBitSet(optionals, 2);
if (struct.isSetTableName()) {
oprot.writeString(struct.tableName);
}
if (struct.isSetNsName()) {
oprot.writeString(struct.nsName);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TAccessControlEntity struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
struct.username = iprot.readString();
struct.setUsernameIsSet(true);
struct.scope = org.apache.hadoop.hbase.thrift2.generated.TPermissionScope.findByValue(iprot.readI32());
struct.setScopeIsSet(true);
struct.actions = iprot.readString();
struct.setActionsIsSet(true);
java.util.BitSet incoming = iprot.readBitSet(2);
if (incoming.get(0)) {
struct.tableName = iprot.readString();
struct.setTableNameIsSet(true);
}
if (incoming.get(1)) {
struct.nsName = iprot.readString();
struct.setNsNameIsSet(true);
}
}
}
private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
}
}

View File

@ -7,7 +7,7 @@
package org.apache.hadoop.hbase.thrift2.generated;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TAppend implements org.apache.thrift.TBase<TAppend, TAppend._Fields>, java.io.Serializable, Cloneable, Comparable<TAppend> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TAppend");

View File

@ -7,7 +7,7 @@
package org.apache.hadoop.hbase.thrift2.generated;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TAuthorization implements org.apache.thrift.TBase<TAuthorization, TAuthorization._Fields>, java.io.Serializable, Cloneable, Comparable<TAuthorization> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TAuthorization");

View File

@ -11,7 +11,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
* Thrift wrapper around
* org.apache.hadoop.hbase.regionserver.BloomType
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public enum TBloomFilterType implements org.apache.thrift.TEnum {
/**
* Bloomfilters disabled

View File

@ -7,7 +7,7 @@
package org.apache.hadoop.hbase.thrift2.generated;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TCellVisibility implements org.apache.thrift.TBase<TCellVisibility, TCellVisibility._Fields>, java.io.Serializable, Cloneable, Comparable<TCellVisibility> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TCellVisibility");

View File

@ -12,7 +12,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
* in a HBase table by column family and optionally
* a column qualifier and timestamp
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TColumn implements org.apache.thrift.TBase<TColumn, TColumn._Fields>, java.io.Serializable, Cloneable, Comparable<TColumn> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TColumn");

View File

@ -11,7 +11,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
* Thrift wrapper around
* org.apache.hadoop.hbase.client.ColumnFamilyDescriptor
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TColumnFamilyDescriptor implements org.apache.thrift.TBase<TColumnFamilyDescriptor, TColumnFamilyDescriptor._Fields>, java.io.Serializable, Cloneable, Comparable<TColumnFamilyDescriptor> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TColumnFamilyDescriptor");

View File

@ -10,7 +10,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
/**
* Represents a single cell and the amount to increment it by
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TColumnIncrement implements org.apache.thrift.TBase<TColumnIncrement, TColumnIncrement._Fields>, java.io.Serializable, Cloneable, Comparable<TColumnIncrement> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TColumnIncrement");

View File

@ -10,7 +10,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
/**
* Represents a single cell and its value.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TColumnValue implements org.apache.thrift.TBase<TColumnValue, TColumnValue._Fields>, java.io.Serializable, Cloneable, Comparable<TColumnValue> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TColumnValue");

View File

@ -11,7 +11,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
* Thrift wrapper around
* org.apache.hadoop.hbase.CompareOperator.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public enum TCompareOperator implements org.apache.thrift.TEnum {
LESS(0),
LESS_OR_EQUAL(1),

View File

@ -11,7 +11,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
* Thrift wrapper around
* org.apache.hadoop.hbase.io.compress.Algorithm
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public enum TCompressionAlgorithm implements org.apache.thrift.TEnum {
LZO(0),
GZ(1),

View File

@ -12,7 +12,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
* - STRONG means reads only from primary region
* - TIMELINE means reads might return values from secondary region replicas
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public enum TConsistency implements org.apache.thrift.TEnum {
STRONG(1),
TIMELINE(2);

View File

@ -11,7 +11,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
* Thrift wrapper around
* org.apache.hadoop.hbase.io.encoding.DataBlockEncoding
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public enum TDataBlockEncoding implements org.apache.thrift.TEnum {
/**
* Disable data block encoding.

View File

@ -33,7 +33,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
* by changing the durability. If you don't provide durability, it defaults to
* column family's default setting for durability.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields>, java.io.Serializable, Cloneable, Comparable<TDelete> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TDelete");

View File

@ -12,7 +12,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
* - DELETE_COLUMN means exactly one version will be removed,
* - DELETE_COLUMNS means previous versions will also be removed.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public enum TDeleteType implements org.apache.thrift.TEnum {
DELETE_COLUMN(0),
DELETE_COLUMNS(1),

View File

@ -14,7 +14,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
* - SYNC_WAL means write the Mutation to the WAL synchronously,
* - FSYNC_WAL means Write the Mutation to the WAL synchronously and force the entries to disk.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public enum TDurability implements org.apache.thrift.TEnum {
USE_DEFAULT(0),
SKIP_WAL(1),

View File

@ -7,7 +7,7 @@
package org.apache.hadoop.hbase.thrift2.generated;
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public enum TFilterByOperator implements org.apache.thrift.TEnum {
AND(0),
OR(1);

View File

@ -20,7 +20,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
* If you specify a time range and a timestamp the range is ignored.
* Timestamps on TColumns are ignored.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TGet implements org.apache.thrift.TBase<TGet, TGet._Fields>, java.io.Serializable, Cloneable, Comparable<TGet> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TGet");

View File

@ -7,7 +7,7 @@
package org.apache.hadoop.hbase.thrift2.generated;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class THRegionInfo implements org.apache.thrift.TBase<THRegionInfo, THRegionInfo._Fields>, java.io.Serializable, Cloneable, Comparable<THRegionInfo> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("THRegionInfo");

View File

@ -7,7 +7,7 @@
package org.apache.hadoop.hbase.thrift2.generated;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class THRegionLocation implements org.apache.thrift.TBase<THRegionLocation, THRegionLocation._Fields>, java.io.Serializable, Cloneable, Comparable<THRegionLocation> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("THRegionLocation");

View File

@ -12,12 +12,12 @@ package org.apache.hadoop.hbase.thrift2.generated;
* to the HBase master or a HBase region server. Also used to return
* more general HBase error conditions.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TIOError extends org.apache.thrift.TException implements org.apache.thrift.TBase<TIOError, TIOError._Fields>, java.io.Serializable, Cloneable, Comparable<TIOError> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TIOError");
private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("message", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField CAN_RETRY_FIELD_DESC = new org.apache.thrift.protocol.TField("canRetry", org.apache.thrift.protocol.TType.BOOL, (short) 2);
private static final org.apache.thrift.protocol.TField CAN_RETRY_FIELD_DESC = new org.apache.thrift.protocol.TField("canRetry", org.apache.thrift.protocol.TType.BOOL, (short)2);
private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new TIOErrorStandardSchemeFactory();
private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new TIOErrorTupleSchemeFactory();
@ -27,7 +27,8 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
MESSAGE((short) 1, "message"), CAN_RETRY((short) 2, "canRetry");
MESSAGE((short)1, "message"),
CAN_RETRY((short)2, "canRetry");
private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
@ -90,13 +91,13 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
// isset id assignments
private static final int __CANRETRY_ISSET_ID = 0;
private byte __isset_bitfield = 0;
private static final _Fields optionals[] = { _Fields.MESSAGE, _Fields.CAN_RETRY };
private static final _Fields optionals[] = {_Fields.MESSAGE,_Fields.CAN_RETRY};
public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.OPTIONAL,
tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.CAN_RETRY, new org.apache.thrift.meta_data.FieldMetaData("canRetry", org.apache.thrift.TFieldRequirementType.OPTIONAL,
tmpMap.put(_Fields.CAN_RETRY, new org.apache.thrift.meta_data.FieldMetaData("canRetry", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TIOError.class, metaDataMap);
@ -177,21 +178,21 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) {
switch (field) {
case MESSAGE:
if (value == null) {
unsetMessage();
} else {
setMessage((java.lang.String) value);
}
break;
case MESSAGE:
if (value == null) {
unsetMessage();
} else {
setMessage((java.lang.String)value);
}
break;
case CAN_RETRY:
if (value == null) {
unsetCanRetry();
} else {
setCanRetry((java.lang.Boolean) value);
}
break;
case CAN_RETRY:
if (value == null) {
unsetCanRetry();
} else {
setCanRetry((java.lang.Boolean)value);
}
break;
}
}
@ -199,11 +200,11 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
@org.apache.thrift.annotation.Nullable
public java.lang.Object getFieldValue(_Fields field) {
switch (field) {
case MESSAGE:
return getMessage();
case MESSAGE:
return getMessage();
case CAN_RETRY:
return isCanRetry();
case CAN_RETRY:
return isCanRetry();
}
throw new java.lang.IllegalStateException();
@ -216,36 +217,43 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
}
switch (field) {
case MESSAGE:
return isSetMessage();
case CAN_RETRY:
return isSetCanRetry();
case MESSAGE:
return isSetMessage();
case CAN_RETRY:
return isSetCanRetry();
}
throw new java.lang.IllegalStateException();
}
@Override
public boolean equals(java.lang.Object that) {
if (that instanceof TIOError) return this.equals((TIOError) that);
if (that instanceof TIOError)
return this.equals((TIOError)that);
return false;
}
public boolean equals(TIOError that) {
if (that == null) return false;
if (this == that) return true;
if (that == null)
return false;
if (this == that)
return true;
boolean this_present_message = true && this.isSetMessage();
boolean that_present_message = true && that.isSetMessage();
if (this_present_message || that_present_message) {
if (!(this_present_message && that_present_message)) return false;
if (!this.message.equals(that.message)) return false;
if (!(this_present_message && that_present_message))
return false;
if (!this.message.equals(that.message))
return false;
}
boolean this_present_canRetry = true && this.isSetCanRetry();
boolean that_present_canRetry = true && that.isSetCanRetry();
if (this_present_canRetry || that_present_canRetry) {
if (!(this_present_canRetry && that_present_canRetry)) return false;
if (this.canRetry != that.canRetry) return false;
if (!(this_present_canRetry && that_present_canRetry))
return false;
if (this.canRetry != that.canRetry)
return false;
}
return true;
@ -256,10 +264,12 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
int hashCode = 1;
hashCode = hashCode * 8191 + ((isSetMessage()) ? 131071 : 524287);
if (isSetMessage()) hashCode = hashCode * 8191 + message.hashCode();
if (isSetMessage())
hashCode = hashCode * 8191 + message.hashCode();
hashCode = hashCode * 8191 + ((isSetCanRetry()) ? 131071 : 524287);
if (isSetCanRetry()) hashCode = hashCode * 8191 + ((canRetry) ? 131071 : 524287);
if (isSetCanRetry())
hashCode = hashCode * 8191 + ((canRetry) ? 131071 : 524287);
return hashCode;
}
@ -366,9 +376,10 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
public void read(org.apache.thrift.protocol.TProtocol iprot, TIOError struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true) {
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
@ -376,7 +387,7 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.message = iprot.readString();
struct.setMessageIsSet(true);
} else {
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
@ -384,7 +395,7 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
struct.canRetry = iprot.readBool();
struct.setCanRetryIsSet(true);
} else {
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
@ -430,8 +441,7 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
private static class TIOErrorTupleScheme extends org.apache.thrift.scheme.TupleScheme<TIOError> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TIOError struct)
throws org.apache.thrift.TException {
public void write(org.apache.thrift.protocol.TProtocol prot, TIOError struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet optionals = new java.util.BitSet();
if (struct.isSetMessage()) {
@ -450,8 +460,7 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TIOError struct)
throws org.apache.thrift.TException {
public void read(org.apache.thrift.protocol.TProtocol prot, TIOError struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet incoming = iprot.readBitSet(2);
if (incoming.get(0)) {
@ -466,8 +475,7 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
}
private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ?
STANDARD_SCHEME_FACTORY :
TUPLE_SCHEME_FACTORY).getScheme();
return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
}
}

View File

@ -11,7 +11,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
* A TIllegalArgument exception indicates an illegal or invalid
* argument was passed into a procedure.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TIllegalArgument extends org.apache.thrift.TException implements org.apache.thrift.TBase<TIllegalArgument, TIllegalArgument._Fields>, java.io.Serializable, Cloneable, Comparable<TIllegalArgument> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TIllegalArgument");

View File

@ -14,7 +14,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
* by changing the durability. If you don't provide durability, it defaults to
* column family's default setting for durability.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncrement._Fields>, java.io.Serializable, Cloneable, Comparable<TIncrement> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TIncrement");

View File

@ -11,7 +11,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
* Thrift wrapper around
* org.apache.hadoop.hbase.KeepDeletedCells
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public enum TKeepDeletedCells implements org.apache.thrift.TEnum {
/**
* Deleted Cells are not retained.

View File

@ -11,7 +11,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
* Thrift wrapper around
* org.apache.hadoop.hbase.client.LogQueryFilter
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TLogQueryFilter implements org.apache.thrift.TBase<TLogQueryFilter, TLogQueryFilter._Fields>, java.io.Serializable, Cloneable, Comparable<TLogQueryFilter> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TLogQueryFilter");

View File

@ -7,7 +7,7 @@
package org.apache.hadoop.hbase.thrift2.generated;
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public enum TLogType implements org.apache.thrift.TEnum {
SLOW_LOG(1),
LARGE_LOG(2);

View File

@ -10,7 +10,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
/**
* Atomic mutation for the specified row. It can be either Put or Delete.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TMutation extends org.apache.thrift.TUnion<TMutation, TMutation._Fields> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TMutation");
private static final org.apache.thrift.protocol.TField PUT_FIELD_DESC = new org.apache.thrift.protocol.TField("put", org.apache.thrift.protocol.TType.STRUCT, (short)1);

View File

@ -11,7 +11,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
* Thrift wrapper around
* org.apache.hadoop.hbase.NamespaceDescriptor
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TNamespaceDescriptor implements org.apache.thrift.TBase<TNamespaceDescriptor, TNamespaceDescriptor._Fields>, java.io.Serializable, Cloneable, Comparable<TNamespaceDescriptor> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TNamespaceDescriptor");

View File

@ -11,7 +11,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
* Thrift wrapper around
* org.apache.hadoop.hbase.client.OnlineLogRecordrd
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TOnlineLogRecord implements org.apache.thrift.TBase<TOnlineLogRecord, TOnlineLogRecord._Fields>, java.io.Serializable, Cloneable, Comparable<TOnlineLogRecord> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TOnlineLogRecord");

View File

@ -0,0 +1,43 @@
/**
* Autogenerated by Thrift Compiler (0.14.1)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package org.apache.hadoop.hbase.thrift2.generated;
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public enum TPermissionScope implements org.apache.thrift.TEnum {
TABLE(0),
NAMESPACE(1);
private final int value;
private TPermissionScope(int value) {
this.value = value;
}
/**
* Get the integer value of this enum value, as defined in the Thrift IDL.
*/
public int getValue() {
return value;
}
/**
* Find a the enum type by its integer value, as defined in the Thrift IDL.
* @return null if the value is not found.
*/
@org.apache.thrift.annotation.Nullable
public static TPermissionScope findByValue(int value) {
switch (value) {
case 0:
return TABLE;
case 1:
return NAMESPACE;
default:
return null;
}
}
}

View File

@ -19,7 +19,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
* by changing the durability. If you don't provide durability, it defaults to
* column family's default setting for durability.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.io.Serializable, Cloneable, Comparable<TPut> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TPut");

View File

@ -7,7 +7,7 @@
package org.apache.hadoop.hbase.thrift2.generated;
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public enum TReadType implements org.apache.thrift.TEnum {
DEFAULT(1),
STREAM(2),

View File

@ -10,7 +10,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
/**
* if no Result is found, row and columnValues will not be set.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TResult implements org.apache.thrift.TBase<TResult, TResult._Fields>, java.io.Serializable, Cloneable, Comparable<TResult> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TResult");

View File

@ -10,7 +10,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
/**
* A TRowMutations object is used to apply a number of Mutations to a single row.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TRowMutations implements org.apache.thrift.TBase<TRowMutations, TRowMutations._Fields>, java.io.Serializable, Cloneable, Comparable<TRowMutations> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TRowMutations");

View File

@ -11,7 +11,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
* Any timestamps in the columns are ignored but the colFamTimeRangeMap included, use timeRange to select by timestamp.
* Max versions defaults to 1.
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TScan implements org.apache.thrift.TBase<TScan, TScan._Fields>, java.io.Serializable, Cloneable, Comparable<TScan> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TScan");

View File

@ -7,7 +7,7 @@
package org.apache.hadoop.hbase.thrift2.generated;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TServerName implements org.apache.thrift.TBase<TServerName, TServerName._Fields>, java.io.Serializable, Cloneable, Comparable<TServerName> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TServerName");

View File

@ -11,7 +11,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
* Thrift wrapper around
* org.apache.hadoop.hbase.client.TableDescriptor
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public class TTableDescriptor implements org.apache.thrift.TBase<TTableDescriptor, TTableDescriptor._Fields>, java.io.Serializable, Cloneable, Comparable<TTableDescriptor> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TTableDescriptor");

View File

@ -11,7 +11,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
* Thrift wrapper around
* org.apache.hadoop.hbase.TableName
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
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");

View File

@ -10,7 +10,7 @@ package org.apache.hadoop.hbase.thrift2.generated;
/**
* Specify type of thrift server: thrift and thrift2
*/
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
public enum TThriftServerType implements org.apache.thrift.TEnum {
ONE(1),
TWO(2);

View File

@ -7,7 +7,7 @@
package org.apache.hadoop.hbase.thrift2.generated;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-03-11")
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-19")
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");

View File

@ -201,6 +201,22 @@ enum TThriftServerType {
TWO = 2
}
enum TPermissionScope {
TABLE = 0,
NAMESPACE = 1
}
/**
* TAccessControlEntity for permission control
*/
struct TAccessControlEntity {
1: required string username
2: required TPermissionScope scope
4: required string actions
5: optional Bytes tableName
6: optional string nsName
}
//
// Service
//
@ -978,4 +994,18 @@ service Hbase {
* Returns the cluster ID for this cluster.
*/
string getClusterId()
/**
* Grant permissions in namespace or table level.
*/
bool grant(
1: required TAccessControlEntity info
) throws (1: IOError io)
/**
* Revoke permissions in namespace or table level.
*/
bool revoke(
1: required TAccessControlEntity info
) throws (1: IOError io)
}

View File

@ -530,6 +530,22 @@ enum TThriftServerType {
TWO = 2
}
enum TPermissionScope {
TABLE = 0,
NAMESPACE = 1
}
/**
* TAccessControlEntity for permission control
*/
struct TAccessControlEntity {
1: required string username
2: required TPermissionScope scope
4: required string actions
5: optional string tableName
6: optional string nsName
}
service THBaseService {
/**
@ -1132,4 +1148,17 @@ service THBaseService {
1: set<TServerName> serverNames
) throws (1: TIOError io)
/**
* Grant permissions in table or namespace level.
*/
bool grant(
1: required TAccessControlEntity info
) throws (1: TIOError io)
/**
* Revoke permissions in table or namespace level.
*/
bool revoke(
1: required TAccessControlEntity info
) throws (1: TIOError io)
}

View File

@ -76,6 +76,9 @@ import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
import org.apache.hadoop.hbase.coprocessor.RegionObserver;
import org.apache.hadoop.hbase.filter.ParseFilter;
import org.apache.hadoop.hbase.security.UserProvider;
import org.apache.hadoop.hbase.security.access.AccessControlClient;
import org.apache.hadoop.hbase.security.access.Permission;
import org.apache.hadoop.hbase.security.access.UserPermission;
import org.apache.hadoop.hbase.test.MetricsAssertHelper;
import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
@ -84,6 +87,7 @@ import org.apache.hadoop.hbase.thrift.HBaseThriftTestingUtility;
import org.apache.hadoop.hbase.thrift.HbaseHandlerMetricsProxy;
import org.apache.hadoop.hbase.thrift.ThriftMetrics;
import org.apache.hadoop.hbase.thrift.ThriftMetrics.ThriftServerType;
import org.apache.hadoop.hbase.thrift2.generated.TAccessControlEntity;
import org.apache.hadoop.hbase.thrift2.generated.TAppend;
import org.apache.hadoop.hbase.thrift2.generated.TColumn;
import org.apache.hadoop.hbase.thrift2.generated.TColumnFamilyDescriptor;
@ -105,6 +109,7 @@ import org.apache.hadoop.hbase.thrift2.generated.TLogQueryFilter;
import org.apache.hadoop.hbase.thrift2.generated.TMutation;
import org.apache.hadoop.hbase.thrift2.generated.TNamespaceDescriptor;
import org.apache.hadoop.hbase.thrift2.generated.TOnlineLogRecord;
import org.apache.hadoop.hbase.thrift2.generated.TPermissionScope;
import org.apache.hadoop.hbase.thrift2.generated.TPut;
import org.apache.hadoop.hbase.thrift2.generated.TReadType;
import org.apache.hadoop.hbase.thrift2.generated.TResult;
@ -201,6 +206,20 @@ public class TestThriftHBaseServiceHandler {
public static void beforeClass() throws Exception {
UTIL.getConfiguration().set("hbase.client.retries.number", "3");
UTIL.getConfiguration().setBoolean("hbase.regionserver.slowlog.buffer.enabled", true);
UTIL.getConfiguration().set("hbase.client.retries.number", "3");
UTIL.getConfiguration().setBoolean("hbase.security.authorization", true);
UTIL.getConfiguration().set("hbase.coprocessor.master.classes",
"org.apache.hadoop.hbase.security.access.AccessController");
UTIL.getConfiguration().set("hbase.coprocessor.region.classes",
"org.apache.hadoop.hbase.security.access.AccessController");
UTIL.getConfiguration().set("hbase.coprocessor.regionserver.classes",
"org.apache.hadoop.hbase.security.access.AccessController");
// as we opened access control, we need to start as a superuser. Otherwise, we will not have
// sufficient permission to do operations.
UTIL.getConfiguration().set("hbase.superuser", System.getProperty("user.name"));
UTIL.startMiniCluster();
TableDescriptor tableDescriptor = TableDescriptorBuilder
.newBuilder(TableName.valueOf(tableAname)).setColumnFamilies(Arrays.asList(families)).build();
@ -1774,6 +1793,71 @@ public class TestThriftHBaseServiceHandler {
assertEquals(tLogRecords.size(), 0);
}
@Test
public void testPerformTablePermissions() throws Throwable {
// initialize fake objects.
String fakeUser = "user";
TAccessControlEntity tce = new TAccessControlEntity();
tce.setActions("R");
tce.setTableName(Bytes.toString(tableAname));
tce.setScope(TPermissionScope.TABLE);
tce.setUsername(fakeUser);
ThriftHBaseServiceHandler handler = createHandler();
handler.grant(tce);
List<UserPermission> permissionList = AccessControlClient.getUserPermissions(UTIL.getConnection(),
Bytes.toString(tableAname), fakeUser);
// we only grant one R permission
assertEquals(permissionList.size(), 1);
Permission.Action[] actions = permissionList.get(0).getPermission().getActions();
assertEquals(actions.length, 1);
assertEquals(actions[0], Permission.Action.READ);
// than revoke the permission
handler.revoke(tce);
permissionList = AccessControlClient.getUserPermissions(UTIL.getConnection(),
Bytes.toString(tableAname), fakeUser);
// it should return an empty list
assertEquals(0, permissionList.size());
}
@Test
public void testPerformNamespacePermissions() throws Throwable {
// initialize fake objects. We test the permission grant and revoke on default NS.
String fakeUser = "user";
String defaultNameSpace = "default";
TAccessControlEntity tce = new TAccessControlEntity();
tce.setActions("R");
tce.setNsName(defaultNameSpace);
tce.setScope(TPermissionScope.NAMESPACE);
tce.setUsername(fakeUser);
ThriftHBaseServiceHandler handler = createHandler();
handler.grant(tce);
List<UserPermission> permissionList = AccessControlClient.getUserPermissions(UTIL.getConnection(),
"@" + defaultNameSpace, fakeUser);
// we only grant one R permission
assertEquals(permissionList.size(), 1);
Permission.Action[] actions = permissionList.get(0).getPermission().getActions();
assertEquals(actions.length, 1);
assertEquals(actions[0], Permission.Action.READ);
// revoke the permission
handler.revoke(tce);
permissionList = AccessControlClient.getUserPermissions(UTIL.getConnection(),
"@" + defaultNameSpace, fakeUser);
// it should return an empty list
assertEquals(0, permissionList.size());
}
public static class DelayingRegionObserver implements RegionCoprocessor, RegionObserver {
private static final Logger LOG = LoggerFactory.getLogger(DelayingRegionObserver.class);
// sleep time in msec