HBASE-12564 consolidate the getTableDescriptors() semantic

This commit is contained in:
Matteo Bertozzi 2014-12-09 12:06:00 +00:00
parent b4371252fe
commit 8a2c84156a
20 changed files with 1040 additions and 394 deletions

View File

@ -114,6 +114,30 @@ public interface Admin extends Abortable, Closeable {
*/ */
HTableDescriptor[] listTables(String regex) throws IOException; HTableDescriptor[] listTables(String regex) throws IOException;
/**
* List all the tables matching the given pattern.
*
* @param pattern The compiled regular expression to match against
* @param includeSysTables False to match only against userspace tables
* @return - returns an array of HTableDescriptors
* @throws IOException if a remote or network exception occurs
* @see #listTables()
*/
HTableDescriptor[] listTables(Pattern pattern, boolean includeSysTables)
throws IOException;
/**
* List all the tables matching the given pattern.
*
* @param regex The regular expression to match against
* @param includeSysTables False to match only against userspace tables
* @return - returns an array of HTableDescriptors
* @throws IOException if a remote or network exception occurs
* @see #listTables(java.util.regex.Pattern, boolean)
*/
HTableDescriptor[] listTables(String regex, boolean includeSysTables)
throws IOException;
/** /**
* List all of the names of userspace tables. * List all of the names of userspace tables.
* *
@ -122,6 +146,42 @@ public interface Admin extends Abortable, Closeable {
*/ */
TableName[] listTableNames() throws IOException; TableName[] listTableNames() throws IOException;
/**
* List all of the names of userspace tables.
* @param pattern The regular expression to match against
* @return TableName[] table names
* @throws IOException if a remote or network exception occurs
*/
TableName[] listTableNames(Pattern pattern) throws IOException;
/**
* List all of the names of userspace tables.
* @param regex The regular expression to match against
* @return TableName[] table names
* @throws IOException if a remote or network exception occurs
*/
TableName[] listTableNames(String regex) throws IOException;
/**
* List all of the names of userspace tables.
* @param pattern The regular expression to match against
* @param includeSysTables False to match only against userspace tables
* @return TableName[] table names
* @throws IOException if a remote or network exception occurs
*/
TableName[] listTableNames(final Pattern pattern, final boolean includeSysTables)
throws IOException;
/**
* List all of the names of userspace tables.
* @param regex The regular expression to match against
* @param includeSysTables False to match only against userspace tables
* @return TableName[] table names
* @throws IOException if a remote or network exception occurs
*/
TableName[] listTableNames(final String regex, final boolean includeSysTables)
throws IOException;
/** /**
* Method for getting the tableDescriptor * Method for getting the tableDescriptor
* *

View File

@ -176,11 +176,6 @@ abstract class ConnectionAdapter implements ClusterConnection {
return wrappedConnection.listTables(); return wrappedConnection.listTables();
} }
@Override
public HTableDescriptor[] listTables(String regex) throws IOException {
return wrappedConnection.listTables(regex);
}
@Override @Override
public String[] getTableNames() throws IOException { public String[] getTableNames() throws IOException {
return wrappedConnection.getTableNames(); return wrappedConnection.getTableNames();

View File

@ -2383,20 +2383,6 @@ class ConnectionManager {
* @deprecated Use {@link Admin#listTableNames()} instead * @deprecated Use {@link Admin#listTableNames()} instead
*/ */
@Deprecated @Deprecated
@Override
public HTableDescriptor[] listTables(String regex) throws IOException {
MasterKeepAliveConnection master = getKeepAliveMasterService();
try {
GetTableDescriptorsRequest req =
RequestConverter.buildGetTableDescriptorsRequest(regex);
return ProtobufUtil.getHTableDescriptorArray(master.getTableDescriptors(null, req));
} catch (ServiceException se) {
throw ProtobufUtil.getRemoteException(se);
} finally {
master.close();
}
}
@Override @Override
public String[] getTableNames() throws IOException { public String[] getTableNames() throws IOException {
TableName[] tableNames = listTableNames(); TableName[] tableNames = listTableNames();

View File

@ -296,52 +296,38 @@ public class HBaseAdmin implements Admin {
return tableExists(TableName.valueOf(tableName)); return tableExists(TableName.valueOf(tableName));
} }
/**
* List all the userspace tables. In other words, scan the hbase:meta table.
*
* If we wanted this to be really fast, we could implement a special
* catalog table that just contains table names and their descriptors.
* Right now, it only exists as part of the hbase:meta table's region info.
*
* @return - returns an array of HTableDescriptors
* @throws IOException if a remote or network exception occurs
*/
@Override @Override
public HTableDescriptor[] listTables() throws IOException { public HTableDescriptor[] listTables() throws IOException {
return executeCallable(new MasterCallable<HTableDescriptor[]>(getConnection()) { return listTables((Pattern)null, false);
}
@Override
public HTableDescriptor[] listTables(Pattern pattern) throws IOException {
return listTables(pattern, false);
}
@Override
public HTableDescriptor[] listTables(String regex) throws IOException {
return listTables(Pattern.compile(regex), false);
}
@Override
public HTableDescriptor[] listTables(final Pattern pattern, final boolean includeSysTables)
throws IOException {
return executeCallable(new MasterCallable<HTableDescriptor[]>(getConnection()) {
@Override @Override
public HTableDescriptor[] call(int callTimeout) throws ServiceException { public HTableDescriptor[] call(int callTimeout) throws ServiceException {
GetTableDescriptorsRequest req = GetTableDescriptorsRequest req =
RequestConverter.buildGetTableDescriptorsRequest((List<TableName>)null); RequestConverter.buildGetTableDescriptorsRequest(pattern, includeSysTables);
return ProtobufUtil.getHTableDescriptorArray(master.getTableDescriptors(null, req)); return ProtobufUtil.getHTableDescriptorArray(master.getTableDescriptors(null, req));
} }
}); });
} }
/**
* List all the userspace tables matching the given pattern.
*
* @param pattern The compiled regular expression to match against
* @return - returns an array of HTableDescriptors
* @throws IOException if a remote or network exception occurs
* @see #listTables()
*/
@Override @Override
public HTableDescriptor[] listTables(Pattern pattern) throws IOException { public HTableDescriptor[] listTables(String regex, boolean includeSysTables)
return this.connection.listTables(pattern.toString()); throws IOException {
} return listTables(Pattern.compile(regex), includeSysTables);
/**
* List all the userspace tables matching the given regular expression.
*
* @param regex The regular expression to match against
* @return - returns an array of HTableDescriptors
* @throws IOException if a remote or network exception occurs
* @see #listTables(java.util.regex.Pattern)
*/
@Override
public HTableDescriptor[] listTables(String regex) throws IOException {
return listTables(Pattern.compile(regex));
} }
/** /**
@ -365,17 +351,16 @@ public class HBaseAdmin implements Admin {
* @param pattern The regular expression to match against * @param pattern The regular expression to match against
* @return String[] table names * @return String[] table names
* @throws IOException if a remote or network exception occurs * @throws IOException if a remote or network exception occurs
* @deprecated Use {@link Admin#listTables(Pattern)} instead. * @deprecated Use {@link Admin#listTableNames(Pattern)} instead.
*/ */
@Deprecated @Deprecated
public String[] getTableNames(Pattern pattern) throws IOException { public String[] getTableNames(Pattern pattern) throws IOException {
List<String> matched = new ArrayList<String>(); TableName[] tableNames = listTableNames(pattern);
for (String name: getTableNames()) { String result[] = new String[tableNames.length];
if (pattern.matcher(name).matches()) { for (int i = 0; i < tableNames.length; i++) {
matched.add(name); result[i] = tableNames[i].getNameAsString();
}
} }
return matched.toArray(new String[matched.size()]); return result;
} }
/** /**
@ -383,30 +368,48 @@ public class HBaseAdmin implements Admin {
* @param regex The regular expression to match against * @param regex The regular expression to match against
* @return String[] table names * @return String[] table names
* @throws IOException if a remote or network exception occurs * @throws IOException if a remote or network exception occurs
* @deprecated Use {@link Admin#listTables(Pattern)} instead. * @deprecated Use {@link Admin#listTableNames(Pattern)} instead.
*/ */
@Deprecated @Deprecated
public String[] getTableNames(String regex) throws IOException { public String[] getTableNames(String regex) throws IOException {
return getTableNames(Pattern.compile(regex)); return getTableNames(Pattern.compile(regex));
} }
/**
* List all of the names of userspace tables.
* @return TableName[] table names
* @throws IOException if a remote or network exception occurs
*/
@Override @Override
public TableName[] listTableNames() throws IOException { public TableName[] listTableNames() throws IOException {
return listTableNames((Pattern)null, false);
}
@Override
public TableName[] listTableNames(Pattern pattern) throws IOException {
return listTableNames(pattern, false);
}
@Override
public TableName[] listTableNames(String regex) throws IOException {
return listTableNames(Pattern.compile(regex), false);
}
@Override
public TableName[] listTableNames(final Pattern pattern, final boolean includeSysTables)
throws IOException {
return executeCallable(new MasterCallable<TableName[]>(getConnection()) { return executeCallable(new MasterCallable<TableName[]>(getConnection()) {
@Override @Override
public TableName[] call(int callTimeout) throws ServiceException { public TableName[] call(int callTimeout) throws ServiceException {
return ProtobufUtil.getTableNameArray(master.getTableNames(null, GetTableNamesRequest req =
GetTableNamesRequest.newBuilder().build()) RequestConverter.buildGetTableNamesRequest(pattern, includeSysTables);
.getTableNamesList()); return ProtobufUtil.getTableNameArray(master.getTableNames(null, req)
.getTableNamesList());
} }
}); });
} }
@Override
public TableName[] listTableNames(final String regex, final boolean includeSysTables)
throws IOException {
return listTableNames(Pattern.compile(regex), includeSysTables);
}
/** /**
* Method for getting the tableDescriptor * Method for getting the tableDescriptor
* @param tableName as a byte [] * @param tableName as a byte []

View File

@ -258,13 +258,6 @@ public interface HConnection extends Connection {
@Deprecated @Deprecated
HTableDescriptor[] listTables() throws IOException; HTableDescriptor[] listTables() throws IOException;
/**
* List all the userspace tables matching the pattern.
* @return - returns an array of HTableDescriptors
* @throws IOException if a remote or network exception occurs
*/
HTableDescriptor[] listTables(String pattern) throws IOException;
// This is a bit ugly - We call this getTableNames in 0.94 and the // This is a bit ugly - We call this getTableNames in 0.94 and the
// successor function, returning TableName, listTableNames in later versions // successor function, returning TableName, listTableNames in later versions
// because Java polymorphism doesn't consider return value types // because Java polymorphism doesn't consider return value types

View File

@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.protobuf;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.regex.Pattern;
import org.apache.hadoop.hbase.CellScannable; import org.apache.hadoop.hbase.CellScannable;
import org.apache.hadoop.hbase.DoNotRetryIOException; import org.apache.hadoop.hbase.DoNotRetryIOException;
@ -88,6 +89,7 @@ import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.EnableTableReques
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetClusterStatusRequest; import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetClusterStatusRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetSchemaAlterStatusRequest; import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetSchemaAlterStatusRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsRequest; import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableNamesRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableStateRequest; import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableStateRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsCatalogJanitorEnabledRequest; import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsCatalogJanitorEnabledRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsMasterRunningRequest; import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsMasterRunningRequest;
@ -1229,11 +1231,30 @@ public final class RequestConverter {
/** /**
* Creates a protocol buffer GetTableDescriptorsRequest * Creates a protocol buffer GetTableDescriptorsRequest
* *
* @param pattern The compiled regular expression to match against
* @param includeSysTables False to match only against userspace tables
* @return a GetTableDescriptorsRequest * @return a GetTableDescriptorsRequest
*/ */
public static GetTableDescriptorsRequest buildGetTableDescriptorsRequest(final String pattern) { public static GetTableDescriptorsRequest buildGetTableDescriptorsRequest(final Pattern pattern,
boolean includeSysTables) {
GetTableDescriptorsRequest.Builder builder = GetTableDescriptorsRequest.newBuilder(); GetTableDescriptorsRequest.Builder builder = GetTableDescriptorsRequest.newBuilder();
builder.setRegex(pattern); if (pattern != null) builder.setRegex(pattern.toString());
builder.setIncludeSysTables(includeSysTables);
return builder.build();
}
/**
* Creates a protocol buffer GetTableNamesRequest
*
* @param pattern The compiled regular expression to match against
* @param includeSysTables False to match only against userspace tables
* @return a GetTableNamesRequest
*/
public static GetTableNamesRequest buildGetTableNamesRequest(final Pattern pattern,
boolean includeSysTables) {
GetTableNamesRequest.Builder builder = GetTableNamesRequest.newBuilder();
if (pattern != null) builder.setRegex(pattern.toString());
builder.setIncludeSysTables(includeSysTables);
return builder.build(); return builder.build();
} }

View File

@ -178,7 +178,7 @@ public class AccessControlClient {
String namespace = tableRegex.substring(1); String namespace = tableRegex.substring(1);
permList = ProtobufUtil.getUserPermissions(protocol, Bytes.toBytes(namespace)); permList = ProtobufUtil.getUserPermissions(protocol, Bytes.toBytes(namespace));
} else { } else {
htds = admin.listTables(Pattern.compile(tableRegex)); htds = admin.listTables(Pattern.compile(tableRegex), true);
for (HTableDescriptor hd : htds) { for (HTableDescriptor hd : htds) {
permList.addAll(ProtobufUtil.getUserPermissions(protocol, hd.getTableName())); permList.addAll(ProtobufUtil.getUserPermissions(protocol, hd.getTableName()));
} }

View File

@ -34196,6 +34196,16 @@ public final class MasterProtos {
*/ */
com.google.protobuf.ByteString com.google.protobuf.ByteString
getRegexBytes(); getRegexBytes();
// optional bool include_sys_tables = 3 [default = false];
/**
* <code>optional bool include_sys_tables = 3 [default = false];</code>
*/
boolean hasIncludeSysTables();
/**
* <code>optional bool include_sys_tables = 3 [default = false];</code>
*/
boolean getIncludeSysTables();
} }
/** /**
* Protobuf type {@code GetTableDescriptorsRequest} * Protobuf type {@code GetTableDescriptorsRequest}
@ -34261,6 +34271,11 @@ public final class MasterProtos {
regex_ = input.readBytes(); regex_ = input.readBytes();
break; break;
} }
case 24: {
bitField0_ |= 0x00000002;
includeSysTables_ = input.readBool();
break;
}
} }
} }
} catch (com.google.protobuf.InvalidProtocolBufferException e) { } catch (com.google.protobuf.InvalidProtocolBufferException e) {
@ -34383,9 +34398,26 @@ public final class MasterProtos {
} }
} }
// optional bool include_sys_tables = 3 [default = false];
public static final int INCLUDE_SYS_TABLES_FIELD_NUMBER = 3;
private boolean includeSysTables_;
/**
* <code>optional bool include_sys_tables = 3 [default = false];</code>
*/
public boolean hasIncludeSysTables() {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
/**
* <code>optional bool include_sys_tables = 3 [default = false];</code>
*/
public boolean getIncludeSysTables() {
return includeSysTables_;
}
private void initFields() { private void initFields() {
tableNames_ = java.util.Collections.emptyList(); tableNames_ = java.util.Collections.emptyList();
regex_ = ""; regex_ = "";
includeSysTables_ = false;
} }
private byte memoizedIsInitialized = -1; private byte memoizedIsInitialized = -1;
public final boolean isInitialized() { public final boolean isInitialized() {
@ -34411,6 +34443,9 @@ public final class MasterProtos {
if (((bitField0_ & 0x00000001) == 0x00000001)) { if (((bitField0_ & 0x00000001) == 0x00000001)) {
output.writeBytes(2, getRegexBytes()); output.writeBytes(2, getRegexBytes());
} }
if (((bitField0_ & 0x00000002) == 0x00000002)) {
output.writeBool(3, includeSysTables_);
}
getUnknownFields().writeTo(output); getUnknownFields().writeTo(output);
} }
@ -34428,6 +34463,10 @@ public final class MasterProtos {
size += com.google.protobuf.CodedOutputStream size += com.google.protobuf.CodedOutputStream
.computeBytesSize(2, getRegexBytes()); .computeBytesSize(2, getRegexBytes());
} }
if (((bitField0_ & 0x00000002) == 0x00000002)) {
size += com.google.protobuf.CodedOutputStream
.computeBoolSize(3, includeSysTables_);
}
size += getUnknownFields().getSerializedSize(); size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size; memoizedSerializedSize = size;
return size; return size;
@ -34458,6 +34497,11 @@ public final class MasterProtos {
result = result && getRegex() result = result && getRegex()
.equals(other.getRegex()); .equals(other.getRegex());
} }
result = result && (hasIncludeSysTables() == other.hasIncludeSysTables());
if (hasIncludeSysTables()) {
result = result && (getIncludeSysTables()
== other.getIncludeSysTables());
}
result = result && result = result &&
getUnknownFields().equals(other.getUnknownFields()); getUnknownFields().equals(other.getUnknownFields());
return result; return result;
@ -34479,6 +34523,10 @@ public final class MasterProtos {
hash = (37 * hash) + REGEX_FIELD_NUMBER; hash = (37 * hash) + REGEX_FIELD_NUMBER;
hash = (53 * hash) + getRegex().hashCode(); hash = (53 * hash) + getRegex().hashCode();
} }
if (hasIncludeSysTables()) {
hash = (37 * hash) + INCLUDE_SYS_TABLES_FIELD_NUMBER;
hash = (53 * hash) + hashBoolean(getIncludeSysTables());
}
hash = (29 * hash) + getUnknownFields().hashCode(); hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash; memoizedHashCode = hash;
return hash; return hash;
@ -34597,6 +34645,8 @@ public final class MasterProtos {
} }
regex_ = ""; regex_ = "";
bitField0_ = (bitField0_ & ~0x00000002); bitField0_ = (bitField0_ & ~0x00000002);
includeSysTables_ = false;
bitField0_ = (bitField0_ & ~0x00000004);
return this; return this;
} }
@ -34638,6 +34688,10 @@ public final class MasterProtos {
to_bitField0_ |= 0x00000001; to_bitField0_ |= 0x00000001;
} }
result.regex_ = regex_; result.regex_ = regex_;
if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
to_bitField0_ |= 0x00000002;
}
result.includeSysTables_ = includeSysTables_;
result.bitField0_ = to_bitField0_; result.bitField0_ = to_bitField0_;
onBuilt(); onBuilt();
return result; return result;
@ -34685,6 +34739,9 @@ public final class MasterProtos {
regex_ = other.regex_; regex_ = other.regex_;
onChanged(); onChanged();
} }
if (other.hasIncludeSysTables()) {
setIncludeSysTables(other.getIncludeSysTables());
}
this.mergeUnknownFields(other.getUnknownFields()); this.mergeUnknownFields(other.getUnknownFields());
return this; return this;
} }
@ -35032,6 +35089,39 @@ public final class MasterProtos {
return this; return this;
} }
// optional bool include_sys_tables = 3 [default = false];
private boolean includeSysTables_ ;
/**
* <code>optional bool include_sys_tables = 3 [default = false];</code>
*/
public boolean hasIncludeSysTables() {
return ((bitField0_ & 0x00000004) == 0x00000004);
}
/**
* <code>optional bool include_sys_tables = 3 [default = false];</code>
*/
public boolean getIncludeSysTables() {
return includeSysTables_;
}
/**
* <code>optional bool include_sys_tables = 3 [default = false];</code>
*/
public Builder setIncludeSysTables(boolean value) {
bitField0_ |= 0x00000004;
includeSysTables_ = value;
onChanged();
return this;
}
/**
* <code>optional bool include_sys_tables = 3 [default = false];</code>
*/
public Builder clearIncludeSysTables() {
bitField0_ = (bitField0_ & ~0x00000004);
includeSysTables_ = false;
onChanged();
return this;
}
// @@protoc_insertion_point(builder_scope:GetTableDescriptorsRequest) // @@protoc_insertion_point(builder_scope:GetTableDescriptorsRequest)
} }
@ -35766,6 +35856,31 @@ public final class MasterProtos {
public interface GetTableNamesRequestOrBuilder public interface GetTableNamesRequestOrBuilder
extends com.google.protobuf.MessageOrBuilder { extends com.google.protobuf.MessageOrBuilder {
// optional string regex = 1;
/**
* <code>optional string regex = 1;</code>
*/
boolean hasRegex();
/**
* <code>optional string regex = 1;</code>
*/
java.lang.String getRegex();
/**
* <code>optional string regex = 1;</code>
*/
com.google.protobuf.ByteString
getRegexBytes();
// optional bool include_sys_tables = 2 [default = false];
/**
* <code>optional bool include_sys_tables = 2 [default = false];</code>
*/
boolean hasIncludeSysTables();
/**
* <code>optional bool include_sys_tables = 2 [default = false];</code>
*/
boolean getIncludeSysTables();
} }
/** /**
* Protobuf type {@code GetTableNamesRequest} * Protobuf type {@code GetTableNamesRequest}
@ -35800,6 +35915,7 @@ public final class MasterProtos {
com.google.protobuf.ExtensionRegistryLite extensionRegistry) com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException { throws com.google.protobuf.InvalidProtocolBufferException {
initFields(); initFields();
int mutable_bitField0_ = 0;
com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.Builder unknownFields =
com.google.protobuf.UnknownFieldSet.newBuilder(); com.google.protobuf.UnknownFieldSet.newBuilder();
try { try {
@ -35817,6 +35933,16 @@ public final class MasterProtos {
} }
break; break;
} }
case 10: {
bitField0_ |= 0x00000001;
regex_ = input.readBytes();
break;
}
case 16: {
bitField0_ |= 0x00000002;
includeSysTables_ = input.readBool();
break;
}
} }
} }
} catch (com.google.protobuf.InvalidProtocolBufferException e) { } catch (com.google.protobuf.InvalidProtocolBufferException e) {
@ -35856,7 +35982,69 @@ public final class MasterProtos {
return PARSER; return PARSER;
} }
private int bitField0_;
// optional string regex = 1;
public static final int REGEX_FIELD_NUMBER = 1;
private java.lang.Object regex_;
/**
* <code>optional string regex = 1;</code>
*/
public boolean hasRegex() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
* <code>optional string regex = 1;</code>
*/
public java.lang.String getRegex() {
java.lang.Object ref = regex_;
if (ref instanceof java.lang.String) {
return (java.lang.String) ref;
} else {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
if (bs.isValidUtf8()) {
regex_ = s;
}
return s;
}
}
/**
* <code>optional string regex = 1;</code>
*/
public com.google.protobuf.ByteString
getRegexBytes() {
java.lang.Object ref = regex_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
regex_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
// optional bool include_sys_tables = 2 [default = false];
public static final int INCLUDE_SYS_TABLES_FIELD_NUMBER = 2;
private boolean includeSysTables_;
/**
* <code>optional bool include_sys_tables = 2 [default = false];</code>
*/
public boolean hasIncludeSysTables() {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
/**
* <code>optional bool include_sys_tables = 2 [default = false];</code>
*/
public boolean getIncludeSysTables() {
return includeSysTables_;
}
private void initFields() { private void initFields() {
regex_ = "";
includeSysTables_ = false;
} }
private byte memoizedIsInitialized = -1; private byte memoizedIsInitialized = -1;
public final boolean isInitialized() { public final boolean isInitialized() {
@ -35870,6 +36058,12 @@ public final class MasterProtos {
public void writeTo(com.google.protobuf.CodedOutputStream output) public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException { throws java.io.IOException {
getSerializedSize(); getSerializedSize();
if (((bitField0_ & 0x00000001) == 0x00000001)) {
output.writeBytes(1, getRegexBytes());
}
if (((bitField0_ & 0x00000002) == 0x00000002)) {
output.writeBool(2, includeSysTables_);
}
getUnknownFields().writeTo(output); getUnknownFields().writeTo(output);
} }
@ -35879,6 +36073,14 @@ public final class MasterProtos {
if (size != -1) return size; if (size != -1) return size;
size = 0; size = 0;
if (((bitField0_ & 0x00000001) == 0x00000001)) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(1, getRegexBytes());
}
if (((bitField0_ & 0x00000002) == 0x00000002)) {
size += com.google.protobuf.CodedOutputStream
.computeBoolSize(2, includeSysTables_);
}
size += getUnknownFields().getSerializedSize(); size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size; memoizedSerializedSize = size;
return size; return size;
@ -35902,6 +36104,16 @@ public final class MasterProtos {
org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableNamesRequest other = (org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableNamesRequest) obj; org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableNamesRequest other = (org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableNamesRequest) obj;
boolean result = true; boolean result = true;
result = result && (hasRegex() == other.hasRegex());
if (hasRegex()) {
result = result && getRegex()
.equals(other.getRegex());
}
result = result && (hasIncludeSysTables() == other.hasIncludeSysTables());
if (hasIncludeSysTables()) {
result = result && (getIncludeSysTables()
== other.getIncludeSysTables());
}
result = result && result = result &&
getUnknownFields().equals(other.getUnknownFields()); getUnknownFields().equals(other.getUnknownFields());
return result; return result;
@ -35915,6 +36127,14 @@ public final class MasterProtos {
} }
int hash = 41; int hash = 41;
hash = (19 * hash) + getDescriptorForType().hashCode(); hash = (19 * hash) + getDescriptorForType().hashCode();
if (hasRegex()) {
hash = (37 * hash) + REGEX_FIELD_NUMBER;
hash = (53 * hash) + getRegex().hashCode();
}
if (hasIncludeSysTables()) {
hash = (37 * hash) + INCLUDE_SYS_TABLES_FIELD_NUMBER;
hash = (53 * hash) + hashBoolean(getIncludeSysTables());
}
hash = (29 * hash) + getUnknownFields().hashCode(); hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash; memoizedHashCode = hash;
return hash; return hash;
@ -36024,6 +36244,10 @@ public final class MasterProtos {
public Builder clear() { public Builder clear() {
super.clear(); super.clear();
regex_ = "";
bitField0_ = (bitField0_ & ~0x00000001);
includeSysTables_ = false;
bitField0_ = (bitField0_ & ~0x00000002);
return this; return this;
} }
@ -36050,6 +36274,17 @@ public final class MasterProtos {
public org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableNamesRequest buildPartial() { public org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableNamesRequest buildPartial() {
org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableNamesRequest result = new org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableNamesRequest(this); org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableNamesRequest result = new org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableNamesRequest(this);
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
to_bitField0_ |= 0x00000001;
}
result.regex_ = regex_;
if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
to_bitField0_ |= 0x00000002;
}
result.includeSysTables_ = includeSysTables_;
result.bitField0_ = to_bitField0_;
onBuilt(); onBuilt();
return result; return result;
} }
@ -36065,6 +36300,14 @@ public final class MasterProtos {
public Builder mergeFrom(org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableNamesRequest other) { public Builder mergeFrom(org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableNamesRequest other) {
if (other == org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableNamesRequest.getDefaultInstance()) return this; if (other == org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableNamesRequest.getDefaultInstance()) return this;
if (other.hasRegex()) {
bitField0_ |= 0x00000001;
regex_ = other.regex_;
onChanged();
}
if (other.hasIncludeSysTables()) {
setIncludeSysTables(other.getIncludeSysTables());
}
this.mergeUnknownFields(other.getUnknownFields()); this.mergeUnknownFields(other.getUnknownFields());
return this; return this;
} }
@ -36090,6 +36333,114 @@ public final class MasterProtos {
} }
return this; return this;
} }
private int bitField0_;
// optional string regex = 1;
private java.lang.Object regex_ = "";
/**
* <code>optional string regex = 1;</code>
*/
public boolean hasRegex() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
* <code>optional string regex = 1;</code>
*/
public java.lang.String getRegex() {
java.lang.Object ref = regex_;
if (!(ref instanceof java.lang.String)) {
java.lang.String s = ((com.google.protobuf.ByteString) ref)
.toStringUtf8();
regex_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
* <code>optional string regex = 1;</code>
*/
public com.google.protobuf.ByteString
getRegexBytes() {
java.lang.Object ref = regex_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
regex_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <code>optional string regex = 1;</code>
*/
public Builder setRegex(
java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
bitField0_ |= 0x00000001;
regex_ = value;
onChanged();
return this;
}
/**
* <code>optional string regex = 1;</code>
*/
public Builder clearRegex() {
bitField0_ = (bitField0_ & ~0x00000001);
regex_ = getDefaultInstance().getRegex();
onChanged();
return this;
}
/**
* <code>optional string regex = 1;</code>
*/
public Builder setRegexBytes(
com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
bitField0_ |= 0x00000001;
regex_ = value;
onChanged();
return this;
}
// optional bool include_sys_tables = 2 [default = false];
private boolean includeSysTables_ ;
/**
* <code>optional bool include_sys_tables = 2 [default = false];</code>
*/
public boolean hasIncludeSysTables() {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
/**
* <code>optional bool include_sys_tables = 2 [default = false];</code>
*/
public boolean getIncludeSysTables() {
return includeSysTables_;
}
/**
* <code>optional bool include_sys_tables = 2 [default = false];</code>
*/
public Builder setIncludeSysTables(boolean value) {
bitField0_ |= 0x00000002;
includeSysTables_ = value;
onChanged();
return this;
}
/**
* <code>optional bool include_sys_tables = 2 [default = false];</code>
*/
public Builder clearIncludeSysTables() {
bitField0_ = (bitField0_ & ~0x00000002);
includeSysTables_ = false;
onChanged();
return this;
}
// @@protoc_insertion_point(builder_scope:GetTableNamesRequest) // @@protoc_insertion_point(builder_scope:GetTableNamesRequest)
} }
@ -47998,113 +48349,115 @@ public final class MasterProtos {
"equest\022\036\n\ntable_name\030\001 \002(\0132\n.TableName\"T", "equest\022\036\n\ntable_name\030\001 \002(\0132\n.TableName\"T",
"\n\034GetSchemaAlterStatusResponse\022\035\n\025yet_to" + "\n\034GetSchemaAlterStatusResponse\022\035\n\025yet_to" +
"_update_regions\030\001 \001(\r\022\025\n\rtotal_regions\030\002" + "_update_regions\030\001 \001(\r\022\025\n\rtotal_regions\030\002" +
" \001(\r\"L\n\032GetTableDescriptorsRequest\022\037\n\013ta" + " \001(\r\"o\n\032GetTableDescriptorsRequest\022\037\n\013ta" +
"ble_names\030\001 \003(\0132\n.TableName\022\r\n\005regex\030\002 \001" + "ble_names\030\001 \003(\0132\n.TableName\022\r\n\005regex\030\002 \001" +
"(\t\"A\n\033GetTableDescriptorsResponse\022\"\n\014tab" + "(\t\022!\n\022include_sys_tables\030\003 \001(\010:\005false\"A\n" +
"le_schema\030\001 \003(\0132\014.TableSchema\"\026\n\024GetTabl" + "\033GetTableDescriptorsResponse\022\"\n\014table_sc" +
"eNamesRequest\"8\n\025GetTableNamesResponse\022\037" + "hema\030\001 \003(\0132\014.TableSchema\"H\n\024GetTableName" +
"\n\013table_names\030\001 \003(\0132\n.TableName\"6\n\024GetTa" + "sRequest\022\r\n\005regex\030\001 \001(\t\022!\n\022include_sys_t" +
"bleStateRequest\022\036\n\ntable_name\030\001 \002(\0132\n.Ta" + "ables\030\002 \001(\010:\005false\"8\n\025GetTableNamesRespo" +
"bleName\"9\n\025GetTableStateResponse\022 \n\013tabl", "nse\022\037\n\013table_names\030\001 \003(\0132\n.TableName\"6\n\024",
"e_state\030\001 \002(\0132\013.TableState\"\031\n\027GetCluster" + "GetTableStateRequest\022\036\n\ntable_name\030\001 \002(\013" +
"StatusRequest\"B\n\030GetClusterStatusRespons" + "2\n.TableName\"9\n\025GetTableStateResponse\022 \n" +
"e\022&\n\016cluster_status\030\001 \002(\0132\016.ClusterStatu" + "\013table_state\030\001 \002(\0132\013.TableState\"\031\n\027GetCl" +
"s\"\030\n\026IsMasterRunningRequest\"4\n\027IsMasterR" + "usterStatusRequest\"B\n\030GetClusterStatusRe" +
"unningResponse\022\031\n\021is_master_running\030\001 \002(" + "sponse\022&\n\016cluster_status\030\001 \002(\0132\016.Cluster" +
"\010\"@\n\024ExecProcedureRequest\022(\n\tprocedure\030\001" + "Status\"\030\n\026IsMasterRunningRequest\"4\n\027IsMa" +
" \002(\0132\025.ProcedureDescription\"F\n\025ExecProce" + "sterRunningResponse\022\031\n\021is_master_running" +
"dureResponse\022\030\n\020expected_timeout\030\001 \001(\003\022\023" + "\030\001 \002(\010\"@\n\024ExecProcedureRequest\022(\n\tproced" +
"\n\013return_data\030\002 \001(\014\"B\n\026IsProcedureDoneRe" + "ure\030\001 \002(\0132\025.ProcedureDescription\"F\n\025Exec" +
"quest\022(\n\tprocedure\030\001 \001(\0132\025.ProcedureDesc", "ProcedureResponse\022\030\n\020expected_timeout\030\001 ",
"ription\"W\n\027IsProcedureDoneResponse\022\023\n\004do" + "\001(\003\022\023\n\013return_data\030\002 \001(\014\"B\n\026IsProcedureD" +
"ne\030\001 \001(\010:\005false\022\'\n\010snapshot\030\002 \001(\0132\025.Proc" + "oneRequest\022(\n\tprocedure\030\001 \001(\0132\025.Procedur" +
"edureDescription\"\273\001\n\017SetQuotaRequest\022\021\n\t" + "eDescription\"W\n\027IsProcedureDoneResponse\022" +
"user_name\030\001 \001(\t\022\022\n\nuser_group\030\002 \001(\t\022\021\n\tn" + "\023\n\004done\030\001 \001(\010:\005false\022\'\n\010snapshot\030\002 \001(\0132\025" +
"amespace\030\003 \001(\t\022\036\n\ntable_name\030\004 \001(\0132\n.Tab" + ".ProcedureDescription\"\273\001\n\017SetQuotaReques" +
"leName\022\022\n\nremove_all\030\005 \001(\010\022\026\n\016bypass_glo" + "t\022\021\n\tuser_name\030\001 \001(\t\022\022\n\nuser_group\030\002 \001(\t" +
"bals\030\006 \001(\010\022\"\n\010throttle\030\007 \001(\0132\020.ThrottleR" + "\022\021\n\tnamespace\030\003 \001(\t\022\036\n\ntable_name\030\004 \001(\0132" +
"equest\"\022\n\020SetQuotaResponse2\346\030\n\rMasterSer" + "\n.TableName\022\022\n\nremove_all\030\005 \001(\010\022\026\n\016bypas" +
"vice\022S\n\024GetSchemaAlterStatus\022\034.GetSchema" + "s_globals\030\006 \001(\010\022\"\n\010throttle\030\007 \001(\0132\020.Thro" +
"AlterStatusRequest\032\035.GetSchemaAlterStatu", "ttleRequest\"\022\n\020SetQuotaResponse2\346\030\n\rMast",
"sResponse\022P\n\023GetTableDescriptors\022\033.GetTa" + "erService\022S\n\024GetSchemaAlterStatus\022\034.GetS" +
"bleDescriptorsRequest\032\034.GetTableDescript" + "chemaAlterStatusRequest\032\035.GetSchemaAlter" +
"orsResponse\022>\n\rGetTableNames\022\025.GetTableN" + "StatusResponse\022P\n\023GetTableDescriptors\022\033." +
"amesRequest\032\026.GetTableNamesResponse\022G\n\020G" + "GetTableDescriptorsRequest\032\034.GetTableDes" +
"etClusterStatus\022\030.GetClusterStatusReques" + "criptorsResponse\022>\n\rGetTableNames\022\025.GetT" +
"t\032\031.GetClusterStatusResponse\022D\n\017IsMaster" + "ableNamesRequest\032\026.GetTableNamesResponse" +
"Running\022\027.IsMasterRunningRequest\032\030.IsMas" + "\022G\n\020GetClusterStatus\022\030.GetClusterStatusR" +
"terRunningResponse\0222\n\tAddColumn\022\021.AddCol" + "equest\032\031.GetClusterStatusResponse\022D\n\017IsM" +
"umnRequest\032\022.AddColumnResponse\022;\n\014Delete" + "asterRunning\022\027.IsMasterRunningRequest\032\030." +
"Column\022\024.DeleteColumnRequest\032\025.DeleteCol", "IsMasterRunningResponse\0222\n\tAddColumn\022\021.A",
"umnResponse\022;\n\014ModifyColumn\022\024.ModifyColu" + "ddColumnRequest\032\022.AddColumnResponse\022;\n\014D" +
"mnRequest\032\025.ModifyColumnResponse\0225\n\nMove" + "eleteColumn\022\024.DeleteColumnRequest\032\025.Dele" +
"Region\022\022.MoveRegionRequest\032\023.MoveRegionR" + "teColumnResponse\022;\n\014ModifyColumn\022\024.Modif" +
"esponse\022Y\n\026DispatchMergingRegions\022\036.Disp" + "yColumnRequest\032\025.ModifyColumnResponse\0225\n" +
"atchMergingRegionsRequest\032\037.DispatchMerg" + "\nMoveRegion\022\022.MoveRegionRequest\032\023.MoveRe" +
"ingRegionsResponse\022;\n\014AssignRegion\022\024.Ass" + "gionResponse\022Y\n\026DispatchMergingRegions\022\036" +
"ignRegionRequest\032\025.AssignRegionResponse\022" + ".DispatchMergingRegionsRequest\032\037.Dispatc" +
"A\n\016UnassignRegion\022\026.UnassignRegionReques" + "hMergingRegionsResponse\022;\n\014AssignRegion\022" +
"t\032\027.UnassignRegionResponse\022>\n\rOfflineReg" + "\024.AssignRegionRequest\032\025.AssignRegionResp" +
"ion\022\025.OfflineRegionRequest\032\026.OfflineRegi", "onse\022A\n\016UnassignRegion\022\026.UnassignRegionR",
"onResponse\0228\n\013DeleteTable\022\023.DeleteTableR" + "equest\032\027.UnassignRegionResponse\022>\n\rOffli" +
"equest\032\024.DeleteTableResponse\022>\n\rtruncate" + "neRegion\022\025.OfflineRegionRequest\032\026.Offlin" +
"Table\022\025.TruncateTableRequest\032\026.TruncateT" + "eRegionResponse\0228\n\013DeleteTable\022\023.DeleteT" +
"ableResponse\0228\n\013EnableTable\022\023.EnableTabl" + "ableRequest\032\024.DeleteTableResponse\022>\n\rtru" +
"eRequest\032\024.EnableTableResponse\022;\n\014Disabl" + "ncateTable\022\025.TruncateTableRequest\032\026.Trun" +
"eTable\022\024.DisableTableRequest\032\025.DisableTa" + "cateTableResponse\0228\n\013EnableTable\022\023.Enabl" +
"bleResponse\0228\n\013ModifyTable\022\023.ModifyTable" + "eTableRequest\032\024.EnableTableResponse\022;\n\014D" +
"Request\032\024.ModifyTableResponse\0228\n\013CreateT" + "isableTable\022\024.DisableTableRequest\032\025.Disa" +
"able\022\023.CreateTableRequest\032\024.CreateTableR" + "bleTableResponse\0228\n\013ModifyTable\022\023.Modify" +
"esponse\022/\n\010Shutdown\022\020.ShutdownRequest\032\021.", "TableRequest\032\024.ModifyTableResponse\0228\n\013Cr",
"ShutdownResponse\0225\n\nStopMaster\022\022.StopMas" + "eateTable\022\023.CreateTableRequest\032\024.CreateT" +
"terRequest\032\023.StopMasterResponse\022,\n\007Balan" + "ableResponse\022/\n\010Shutdown\022\020.ShutdownReque" +
"ce\022\017.BalanceRequest\032\020.BalanceResponse\022M\n" + "st\032\021.ShutdownResponse\0225\n\nStopMaster\022\022.St" +
"\022SetBalancerRunning\022\032.SetBalancerRunning" + "opMasterRequest\032\023.StopMasterResponse\022,\n\007" +
"Request\032\033.SetBalancerRunningResponse\022A\n\016" + "Balance\022\017.BalanceRequest\032\020.BalanceRespon" +
"RunCatalogScan\022\026.RunCatalogScanRequest\032\027" + "se\022M\n\022SetBalancerRunning\022\032.SetBalancerRu" +
".RunCatalogScanResponse\022S\n\024EnableCatalog" + "nningRequest\032\033.SetBalancerRunningRespons" +
"Janitor\022\034.EnableCatalogJanitorRequest\032\035." + "e\022A\n\016RunCatalogScan\022\026.RunCatalogScanRequ" +
"EnableCatalogJanitorResponse\022\\\n\027IsCatalo" + "est\032\027.RunCatalogScanResponse\022S\n\024EnableCa" +
"gJanitorEnabled\022\037.IsCatalogJanitorEnable", "talogJanitor\022\034.EnableCatalogJanitorReque",
"dRequest\032 .IsCatalogJanitorEnabledRespon" + "st\032\035.EnableCatalogJanitorResponse\022\\\n\027IsC" +
"se\022L\n\021ExecMasterService\022\032.CoprocessorSer" + "atalogJanitorEnabled\022\037.IsCatalogJanitorE" +
"viceRequest\032\033.CoprocessorServiceResponse" + "nabledRequest\032 .IsCatalogJanitorEnabledR" +
"\022/\n\010Snapshot\022\020.SnapshotRequest\032\021.Snapsho" + "esponse\022L\n\021ExecMasterService\022\032.Coprocess" +
"tResponse\022V\n\025GetCompletedSnapshots\022\035.Get" + "orServiceRequest\032\033.CoprocessorServiceRes" +
"CompletedSnapshotsRequest\032\036.GetCompleted" + "ponse\022/\n\010Snapshot\022\020.SnapshotRequest\032\021.Sn" +
"SnapshotsResponse\022A\n\016DeleteSnapshot\022\026.De" + "apshotResponse\022V\n\025GetCompletedSnapshots\022" +
"leteSnapshotRequest\032\027.DeleteSnapshotResp" + "\035.GetCompletedSnapshotsRequest\032\036.GetComp" +
"onse\022A\n\016IsSnapshotDone\022\026.IsSnapshotDoneR" + "letedSnapshotsResponse\022A\n\016DeleteSnapshot" +
"equest\032\027.IsSnapshotDoneResponse\022D\n\017Resto", "\022\026.DeleteSnapshotRequest\032\027.DeleteSnapsho",
"reSnapshot\022\027.RestoreSnapshotRequest\032\030.Re" + "tResponse\022A\n\016IsSnapshotDone\022\026.IsSnapshot" +
"storeSnapshotResponse\022V\n\025IsRestoreSnapsh" + "DoneRequest\032\027.IsSnapshotDoneResponse\022D\n\017" +
"otDone\022\035.IsRestoreSnapshotDoneRequest\032\036." + "RestoreSnapshot\022\027.RestoreSnapshotRequest" +
"IsRestoreSnapshotDoneResponse\022>\n\rExecPro" + "\032\030.RestoreSnapshotResponse\022V\n\025IsRestoreS" +
"cedure\022\025.ExecProcedureRequest\032\026.ExecProc" + "napshotDone\022\035.IsRestoreSnapshotDoneReque" +
"edureResponse\022E\n\024ExecProcedureWithRet\022\025." + "st\032\036.IsRestoreSnapshotDoneResponse\022>\n\rEx" +
"ExecProcedureRequest\032\026.ExecProcedureResp" + "ecProcedure\022\025.ExecProcedureRequest\032\026.Exe" +
"onse\022D\n\017IsProcedureDone\022\027.IsProcedureDon" + "cProcedureResponse\022E\n\024ExecProcedureWithR" +
"eRequest\032\030.IsProcedureDoneResponse\022D\n\017Mo" + "et\022\025.ExecProcedureRequest\032\026.ExecProcedur" +
"difyNamespace\022\027.ModifyNamespaceRequest\032\030", "eResponse\022D\n\017IsProcedureDone\022\027.IsProcedu",
".ModifyNamespaceResponse\022D\n\017CreateNamesp" + "reDoneRequest\032\030.IsProcedureDoneResponse\022" +
"ace\022\027.CreateNamespaceRequest\032\030.CreateNam" + "D\n\017ModifyNamespace\022\027.ModifyNamespaceRequ" +
"espaceResponse\022D\n\017DeleteNamespace\022\027.Dele" + "est\032\030.ModifyNamespaceResponse\022D\n\017CreateN" +
"teNamespaceRequest\032\030.DeleteNamespaceResp" + "amespace\022\027.CreateNamespaceRequest\032\030.Crea" +
"onse\022Y\n\026GetNamespaceDescriptor\022\036.GetName" + "teNamespaceResponse\022D\n\017DeleteNamespace\022\027" +
"spaceDescriptorRequest\032\037.GetNamespaceDes" + ".DeleteNamespaceRequest\032\030.DeleteNamespac" +
"criptorResponse\022_\n\030ListNamespaceDescript" + "eResponse\022Y\n\026GetNamespaceDescriptor\022\036.Ge" +
"ors\022 .ListNamespaceDescriptorsRequest\032!." + "tNamespaceDescriptorRequest\032\037.GetNamespa" +
"ListNamespaceDescriptorsResponse\022t\n\037List" + "ceDescriptorResponse\022_\n\030ListNamespaceDes" +
"TableDescriptorsByNamespace\022\'.ListTableD", "criptors\022 .ListNamespaceDescriptorsReque",
"escriptorsByNamespaceRequest\032(.ListTable" + "st\032!.ListNamespaceDescriptorsResponse\022t\n" +
"DescriptorsByNamespaceResponse\022b\n\031ListTa" + "\037ListTableDescriptorsByNamespace\022\'.ListT" +
"bleNamesByNamespace\022!.ListTableNamesByNa" + "ableDescriptorsByNamespaceRequest\032(.List" +
"mespaceRequest\032\".ListTableNamesByNamespa" + "TableDescriptorsByNamespaceResponse\022b\n\031L" +
"ceResponse\022>\n\rGetTableState\022\025.GetTableSt" + "istTableNamesByNamespace\022!.ListTableName" +
"ateRequest\032\026.GetTableStateResponse\022/\n\010Se" + "sByNamespaceRequest\032\".ListTableNamesByNa" +
"tQuota\022\020.SetQuotaRequest\032\021.SetQuotaRespo" + "mespaceResponse\022>\n\rGetTableState\022\025.GetTa" +
"nseBB\n*org.apache.hadoop.hbase.protobuf." + "bleStateRequest\032\026.GetTableStateResponse\022" +
"generatedB\014MasterProtosH\001\210\001\001\240\001\001" "/\n\010SetQuota\022\020.SetQuotaRequest\032\021.SetQuota" +
"ResponseBB\n*org.apache.hadoop.hbase.prot",
"obuf.generatedB\014MasterProtosH\001\210\001\001\240\001\001"
}; };
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@ -48536,7 +48889,7 @@ public final class MasterProtos {
internal_static_GetTableDescriptorsRequest_fieldAccessorTable = new internal_static_GetTableDescriptorsRequest_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable( com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_GetTableDescriptorsRequest_descriptor, internal_static_GetTableDescriptorsRequest_descriptor,
new java.lang.String[] { "TableNames", "Regex", }); new java.lang.String[] { "TableNames", "Regex", "IncludeSysTables", });
internal_static_GetTableDescriptorsResponse_descriptor = internal_static_GetTableDescriptorsResponse_descriptor =
getDescriptor().getMessageTypes().get(71); getDescriptor().getMessageTypes().get(71);
internal_static_GetTableDescriptorsResponse_fieldAccessorTable = new internal_static_GetTableDescriptorsResponse_fieldAccessorTable = new
@ -48548,7 +48901,7 @@ public final class MasterProtos {
internal_static_GetTableNamesRequest_fieldAccessorTable = new internal_static_GetTableNamesRequest_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable( com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_GetTableNamesRequest_descriptor, internal_static_GetTableNamesRequest_descriptor,
new java.lang.String[] { }); new java.lang.String[] { "Regex", "IncludeSysTables", });
internal_static_GetTableNamesResponse_descriptor = internal_static_GetTableNamesResponse_descriptor =
getDescriptor().getMessageTypes().get(73); getDescriptor().getMessageTypes().get(73);
internal_static_GetTableNamesResponse_fieldAccessorTable = new internal_static_GetTableNamesResponse_fieldAccessorTable = new

View File

@ -315,6 +315,7 @@ message GetSchemaAlterStatusResponse {
message GetTableDescriptorsRequest { message GetTableDescriptorsRequest {
repeated TableName table_names = 1; repeated TableName table_names = 1;
optional string regex = 2; optional string regex = 2;
optional bool include_sys_tables = 3 [default=false];
} }
message GetTableDescriptorsResponse { message GetTableDescriptorsResponse {
@ -322,6 +323,8 @@ message GetTableDescriptorsResponse {
} }
message GetTableNamesRequest { message GetTableNamesRequest {
optional string regex = 1;
optional bool include_sys_tables = 2 [default=false];
} }
message GetTableNamesResponse { message GetTableNamesResponse {

View File

@ -418,23 +418,23 @@ public abstract class BaseMasterAndRegionObserver extends BaseRegionObserver
@Override @Override
public void preGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx, public void preGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<TableName> tableNamesList, List<HTableDescriptor> descriptors) List<TableName> tableNamesList, List<HTableDescriptor> descriptors,
throws IOException { String regex) throws IOException {
}
@Override
public void preGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<TableName> tableNamesList, List<HTableDescriptor> descriptors, String regex)
throws IOException {
} }
@Override @Override
public void postGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx, public void postGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<HTableDescriptor> descriptors) throws IOException { List<TableName> tableNamesList, List<HTableDescriptor> descriptors,
String regex) throws IOException {
} }
@Override @Override
public void postGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx, public void preGetTableNames(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<HTableDescriptor> descriptors, String regex) throws IOException {
}
@Override
public void postGetTableNames(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<HTableDescriptor> descriptors, String regex) throws IOException { List<HTableDescriptor> descriptors, String regex) throws IOException {
} }

View File

@ -409,11 +409,6 @@ public class BaseMasterObserver implements MasterObserver {
final SnapshotDescription snapshot) throws IOException { final SnapshotDescription snapshot) throws IOException {
} }
@Override
public void preGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<TableName> tableNamesList, List<HTableDescriptor> descriptors) throws IOException {
}
@Override @Override
public void preGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx, public void preGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<TableName> tableNamesList, List<HTableDescriptor> descriptors, String regex) List<TableName> tableNamesList, List<HTableDescriptor> descriptors, String regex)
@ -422,11 +417,17 @@ public class BaseMasterObserver implements MasterObserver {
@Override @Override
public void postGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx, public void postGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<HTableDescriptor> descriptors) throws IOException { List<TableName> tableNamesList, List<HTableDescriptor> descriptors,
String regex) throws IOException {
} }
@Override @Override
public void postGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx, public void preGetTableNames(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<HTableDescriptor> descriptors, String regex) throws IOException {
}
@Override
public void postGetTableNames(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<HTableDescriptor> descriptors, String regex) throws IOException { List<HTableDescriptor> descriptors, String regex) throws IOException {
} }

View File

@ -688,18 +688,6 @@ public interface MasterObserver extends Coprocessor {
void postDeleteSnapshot(final ObserverContext<MasterCoprocessorEnvironment> ctx, void postDeleteSnapshot(final ObserverContext<MasterCoprocessorEnvironment> ctx,
final SnapshotDescription snapshot) throws IOException; final SnapshotDescription snapshot) throws IOException;
/**
* Called before a getTableDescriptors request has been processed.
* @param ctx the environment to interact with the framework and master
* @param tableNamesList the list of table names, or null if querying for all
* @param descriptors an empty list, can be filled with what to return if bypassing
* @throws IOException
* @deprecated Use preGetTableDescriptors with regex instead.
*/
@Deprecated
void preGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<TableName> tableNamesList, List<HTableDescriptor> descriptors) throws IOException;
/** /**
* Called before a getTableDescriptors request has been processed. * Called before a getTableDescriptors request has been processed.
* @param ctx the environment to interact with the framework and master * @param ctx the environment to interact with the framework and master
@ -715,24 +703,37 @@ public interface MasterObserver extends Coprocessor {
/** /**
* Called after a getTableDescriptors request has been processed. * Called after a getTableDescriptors request has been processed.
* @param ctx the environment to interact with the framework and master * @param ctx the environment to interact with the framework and master
* @param descriptors the list of descriptors about to be returned * @param tableNamesList the list of table names, or null if querying for all
* @throws IOException
* @deprecated Use postGetTableDescriptors with regex instead.
*/
@Deprecated
void postGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<HTableDescriptor> descriptors) throws IOException;
/**
* Called after a getTableDescriptors request has been processed.
* @param ctx the environment to interact with the framework and master
* @param descriptors the list of descriptors about to be returned * @param descriptors the list of descriptors about to be returned
* @param regex regular expression used for filtering the table names * @param regex regular expression used for filtering the table names
* @throws IOException * @throws IOException
*/ */
void postGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx, void postGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<TableName> tableNamesList, List<HTableDescriptor> descriptors,
String regex) throws IOException;
/**
* Called before a getTableNames request has been processed.
* @param ctx the environment to interact with the framework and master
* @param descriptors an empty list, can be filled with what to return if bypassing
* @param regex regular expression used for filtering the table names
* @throws IOException
*/
void preGetTableNames(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<HTableDescriptor> descriptors, String regex) throws IOException; List<HTableDescriptor> descriptors, String regex) throws IOException;
/**
* Called after a getTableNames request has been processed.
* @param ctx the environment to interact with the framework and master
* @param descriptors the list of descriptors about to be returned
* @param regex regular expression used for filtering the table names
* @throws IOException
*/
void postGetTableNames(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<HTableDescriptor> descriptors, String regex) throws IOException;
/** /**
* Called before a new namespace is created by * Called before a new namespace is created by
* {@link org.apache.hadoop.hbase.master.HMaster}. * {@link org.apache.hadoop.hbase.master.HMaster}.

View File

@ -27,13 +27,16 @@ import java.net.InetSocketAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Pattern;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
@ -1997,4 +2000,116 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
} }
return tableNames; return tableNames;
} }
/**
* Returns the list of table descriptors that match the specified request
*
* @param regex The regular expression to match against, or null if querying for all
* @param tableNameList the list of table names, or null if querying for all
* @param includeSysTables False to match only against userspace tables
* @return the list of table descriptors
*/
public List<HTableDescriptor> listTableDescriptors(final String regex,
final List<TableName> tableNameList, final boolean includeSysTables)
throws IOException {
final List<HTableDescriptor> descriptors = new ArrayList<HTableDescriptor>();
boolean bypass = false;
if (cpHost != null) {
bypass = cpHost.preGetTableDescriptors(tableNameList, descriptors, regex);
}
if (!bypass) {
if (tableNameList == null || tableNameList.size() == 0) {
// request for all TableDescriptors
Collection<HTableDescriptor> htds = tableDescriptors.getAll().values();
for (HTableDescriptor desc: htds) {
if (includeSysTables || !desc.getTableName().isSystemTable()) {
descriptors.add(desc);
}
}
} else {
for (TableName s: tableNameList) {
HTableDescriptor desc = tableDescriptors.get(s);
if (desc != null) {
descriptors.add(desc);
}
}
}
// Retains only those matched by regular expression.
if (regex != null) {
filterTablesByRegex(descriptors, Pattern.compile(regex));
}
if (cpHost != null) {
cpHost.postGetTableDescriptors(tableNameList, descriptors, regex);
}
}
return descriptors;
}
/**
* Returns the list of table names that match the specified request
* @param regex The regular expression to match against, or null if querying for all
* @param includeSysTables False to match only against userspace tables
* @return the list of table names
*/
public List<TableName> listTableNames(final String regex, final boolean includeSysTables)
throws IOException {
final List<HTableDescriptor> descriptors = new ArrayList<HTableDescriptor>();
boolean bypass = false;
if (cpHost != null) {
bypass = cpHost.preGetTableNames(descriptors, regex);
}
if (!bypass) {
// get all descriptors
Collection<HTableDescriptor> htds = tableDescriptors.getAll().values();
for (HTableDescriptor htd: htds) {
if (includeSysTables || !htd.getTableName().isSystemTable()) {
descriptors.add(htd);
}
}
// Retains only those matched by regular expression.
if (regex != null) {
filterTablesByRegex(descriptors, Pattern.compile(regex));
}
if (cpHost != null) {
cpHost.postGetTableNames(descriptors, regex);
}
}
List<TableName> result = new ArrayList(descriptors.size());
for (HTableDescriptor htd: descriptors) {
result.add(htd.getTableName());
}
return result;
}
/**
* Removes the table descriptors that don't match the pattern.
* @param descriptors list of table descriptors to filter
* @param pattern the regex to use
*/
private static void filterTablesByRegex(final Collection<HTableDescriptor> descriptors,
final Pattern pattern) {
final String defaultNS = NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR;
Iterator<HTableDescriptor> itr = descriptors.iterator();
while (itr.hasNext()) {
HTableDescriptor htd = itr.next();
String tableName = htd.getTableName().getNameAsString();
boolean matched = pattern.matcher(tableName).matches();
if (!matched && htd.getTableName().getNamespaceAsString().equals(defaultNS)) {
matched = pattern.matcher(defaultNS + TableName.NAMESPACE_DELIM + tableName).matches();
}
if (!matched) {
itr.remove();
}
}
}
} }

View File

@ -811,17 +811,6 @@ public class MasterCoprocessorHost
}); });
} }
public boolean preGetTableDescriptors(final List<TableName> tableNamesList,
final List<HTableDescriptor> descriptors) throws IOException {
return execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() {
@Override
public void call(MasterObserver oserver, ObserverContext<MasterCoprocessorEnvironment> ctx)
throws IOException {
oserver.preGetTableDescriptors(ctx, tableNamesList, descriptors);
}
});
}
public boolean preGetTableDescriptors(final List<TableName> tableNamesList, public boolean preGetTableDescriptors(final List<TableName> tableNamesList,
final List<HTableDescriptor> descriptors, final String regex) throws IOException { final List<HTableDescriptor> descriptors, final String regex) throws IOException {
return execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() { return execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() {
@ -833,24 +822,35 @@ public class MasterCoprocessorHost
}); });
} }
public void postGetTableDescriptors(final List<HTableDescriptor> descriptors) public void postGetTableDescriptors(final List<TableName> tableNamesList,
throws IOException { final List<HTableDescriptor> descriptors, final String regex) throws IOException {
execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() { execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() {
@Override @Override
public void call(MasterObserver oserver, ObserverContext<MasterCoprocessorEnvironment> ctx) public void call(MasterObserver oserver, ObserverContext<MasterCoprocessorEnvironment> ctx)
throws IOException { throws IOException {
oserver.postGetTableDescriptors(ctx, descriptors); oserver.postGetTableDescriptors(ctx, tableNamesList, descriptors, regex);
} }
}); });
} }
public void postGetTableDescriptors(final List<HTableDescriptor> descriptors, final String regex) public boolean preGetTableNames(final List<HTableDescriptor> descriptors,
throws IOException { final String regex) throws IOException {
return execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() {
@Override
public void call(MasterObserver oserver, ObserverContext<MasterCoprocessorEnvironment> ctx)
throws IOException {
oserver.preGetTableNames(ctx, descriptors, regex);
}
});
}
public void postGetTableNames(final List<HTableDescriptor> descriptors,
final String regex) throws IOException {
execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() { execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() {
@Override @Override
public void call(MasterObserver oserver, ObserverContext<MasterCoprocessorEnvironment> ctx) public void call(MasterObserver oserver, ObserverContext<MasterCoprocessorEnvironment> ctx)
throws IOException { throws IOException {
oserver.postGetTableDescriptors(ctx, descriptors, regex); oserver.postGetTableNames(ctx, descriptors, regex);
} }
}); });
} }

View File

@ -21,11 +21,8 @@ package org.apache.hadoop.hbase.master;
import java.io.IOException; import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Pattern;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -788,90 +785,30 @@ public class MasterRpcServices extends RSRpcServices
GetTableDescriptorsRequest req) throws ServiceException { GetTableDescriptorsRequest req) throws ServiceException {
try { try {
master.checkInitialized(); master.checkInitialized();
} catch (IOException e) {
throw new ServiceException(e);
}
List<HTableDescriptor> descriptors = new ArrayList<HTableDescriptor>(); final String regex = req.hasRegex() ? req.getRegex() : null;
List<TableName> tableNameList = new ArrayList<TableName>(); List<TableName> tableNameList = null;
for(HBaseProtos.TableName tableNamePB: req.getTableNamesList()) { if (req.getTableNamesCount() > 0) {
tableNameList.add(ProtobufUtil.toTableName(tableNamePB)); tableNameList = new ArrayList<TableName>(req.getTableNamesCount());
} for (HBaseProtos.TableName tableNamePB: req.getTableNamesList()) {
boolean bypass = false; tableNameList.add(ProtobufUtil.toTableName(tableNamePB));
String regex = req.hasRegex() ? req.getRegex() : null;
if (master.cpHost != null) {
try {
bypass = master.cpHost.preGetTableDescriptors(tableNameList, descriptors);
// method required for AccessController.
bypass |= master.cpHost.preGetTableDescriptors(tableNameList, descriptors, regex);
} catch (IOException ioe) {
throw new ServiceException(ioe);
}
}
if (!bypass) {
if (req.getTableNamesCount() == 0) {
// request for all TableDescriptors
Map<String, HTableDescriptor> descriptorMap = null;
try {
descriptorMap = master.getTableDescriptors().getAll();
} catch (IOException e) {
LOG.warn("Failed getting all descriptors", e);
}
if (descriptorMap != null) {
for(HTableDescriptor desc: descriptorMap.values()) {
if(!desc.getTableName().isSystemTable()) {
descriptors.add(desc);
}
}
}
} else {
for (TableName s: tableNameList) {
try {
HTableDescriptor desc = master.getTableDescriptors().get(s);
if (desc != null) {
descriptors.add(desc);
}
} catch (IOException e) {
LOG.warn("Failed getting descriptor for " + s, e);
}
} }
} }
// Retains only those matched by regular expression. List<HTableDescriptor> descriptors = master.listTableDescriptors(regex, tableNameList,
if(regex != null) { req.getIncludeSysTables());
Pattern pat = Pattern.compile(regex);
for (Iterator<HTableDescriptor> itr = descriptors.iterator(); itr.hasNext(); ) {
HTableDescriptor htd = itr.next();
String tableName = htd.getTableName().getNameAsString();
String defaultNameSpace = NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR;
boolean matched = pat.matcher(tableName).matches();
if(!matched && htd.getTableName().getNamespaceAsString().equals(defaultNameSpace)) {
matched = pat.matcher(defaultNameSpace + TableName.NAMESPACE_DELIM + tableName)
.matches();
}
if (!matched)
itr.remove();
}
}
if (master.cpHost != null) { GetTableDescriptorsResponse.Builder builder = GetTableDescriptorsResponse.newBuilder();
try { if (descriptors != null && descriptors.size() > 0) {
master.cpHost.postGetTableDescriptors(descriptors); // Add the table descriptors to the response
// method required for AccessController. for (HTableDescriptor htd: descriptors) {
master.cpHost.postGetTableDescriptors(descriptors, regex); builder.addTableSchema(htd.convert());
} catch (IOException ioe) {
throw new ServiceException(ioe);
} }
} }
return builder.build();
} catch (IOException ioe) {
throw new ServiceException(ioe);
} }
GetTableDescriptorsResponse.Builder builder = GetTableDescriptorsResponse.newBuilder();
for (HTableDescriptor htd: descriptors) {
builder.addTableSchema(htd.convert());
}
return builder.build();
} }
/** /**
@ -886,13 +823,16 @@ public class MasterRpcServices extends RSRpcServices
GetTableNamesRequest req) throws ServiceException { GetTableNamesRequest req) throws ServiceException {
try { try {
master.checkServiceStarted(); master.checkServiceStarted();
Collection<HTableDescriptor> descriptors = master.getTableDescriptors().getAll().values();
final String regex = req.hasRegex() ? req.getRegex() : null;
List<TableName> tableNames = master.listTableNames(regex, req.getIncludeSysTables());
GetTableNamesResponse.Builder builder = GetTableNamesResponse.newBuilder(); GetTableNamesResponse.Builder builder = GetTableNamesResponse.newBuilder();
for (HTableDescriptor descriptor: descriptors) { if (tableNames != null && tableNames.size() > 0) {
if (descriptor.getTableName().isSystemTable()) { // Add the table names to the response
continue; for (TableName table: tableNames) {
builder.addTableNames(ProtobufUtil.toProtoTableName(table));
} }
builder.addTableNames(ProtobufUtil.toProtoTableName(descriptor.getTableName()));
} }
return builder.build(); return builder.build();
} catch (IOException e) { } catch (IOException e) {

View File

@ -430,6 +430,36 @@ public class AccessController extends BaseMasterAndRegionObserver
} }
} }
/**
* Authorizes that the current user has any of the given permissions to access the table.
*
* @param tableName Table requested
* @param permissions Actions being requested
* @throws IOException if obtaining the current user fails
* @throws AccessDeniedException if user has no authorization
*/
private void requireAccess(String request, TableName tableName,
Action... permissions) throws IOException {
User user = getActiveUser();
AuthResult result = null;
for (Action permission : permissions) {
if (authManager.hasAccess(user, tableName, permission)) {
result = AuthResult.allow(request, "Table permission granted", user,
permission, tableName, null, null);
break;
} else {
// rest of the world
result = AuthResult.deny(request, "Insufficient permissions", user,
permission, tableName, null, null);
}
}
logResult(result);
if (!result.isAllowed()) {
throw new AccessDeniedException("Insufficient permissions " + result.toContextString());
}
}
/** /**
* Authorizes that the current user has global privileges for the given action. * Authorizes that the current user has global privileges for the given action.
* @param perm The action being requested * @param perm The action being requested
@ -2255,51 +2285,56 @@ public class AccessController extends BaseMasterAndRegionObserver
List<TableName> tableNamesList, List<HTableDescriptor> descriptors, List<TableName> tableNamesList, List<HTableDescriptor> descriptors,
String regex) throws IOException { String regex) throws IOException {
// We are delegating the authorization check to postGetTableDescriptors as we don't have // We are delegating the authorization check to postGetTableDescriptors as we don't have
// any concrete set of table names when regex is present. // any concrete set of table names when a regex is present or the full list is requested.
if(regex == null) { if (regex == null && tableNamesList != null && !tableNamesList.isEmpty()) {
// If the list is empty, this is a request for all table descriptors and requires GLOBAL
// ADMIN privs.
if (tableNamesList == null || tableNamesList.isEmpty()) {
requireGlobalPermission("getTableDescriptors", Action.ADMIN, null, null);
}
// Otherwise, if the requestor has ADMIN or CREATE privs for all listed tables, the // Otherwise, if the requestor has ADMIN or CREATE privs for all listed tables, the
// request can be granted. // request can be granted.
else { MasterServices masterServices = ctx.getEnvironment().getMasterServices();
MasterServices masterServices = ctx.getEnvironment().getMasterServices(); for (TableName tableName: tableNamesList) {
for (TableName tableName: tableNamesList) { // Skip checks for a table that does not exist
// Skip checks for a table that does not exist if (!masterServices.getTableStateManager().isTablePresent(tableName))
if (!masterServices.getTableStateManager().isTablePresent(tableName)) continue;
continue; requirePermission("getTableDescriptors", tableName, null, null,
requirePermission("getTableDescriptors", tableName, null, null, Action.ADMIN, Action.CREATE);
Action.ADMIN, Action.CREATE);
}
} }
} }
} }
@Override @Override
public void postGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx, public void postGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<HTableDescriptor> descriptors, String regex) throws IOException { List<TableName> tableNamesList, List<HTableDescriptor> descriptors,
String regex) throws IOException {
// Skipping as checks in this case are already done by preGetTableDescriptors. // Skipping as checks in this case are already done by preGetTableDescriptors.
if (regex == null) { if (regex == null && tableNamesList != null && !tableNamesList.isEmpty()) {
return; return;
} }
int numMatchedTables = descriptors.size();
// Retains only those which passes authorization checks, as the checks weren't done as part // Retains only those which passes authorization checks, as the checks weren't done as part
// of preGetTableDescriptors. // of preGetTableDescriptors.
for(Iterator<HTableDescriptor> itr = descriptors.iterator(); itr.hasNext();) { Iterator<HTableDescriptor> itr = descriptors.iterator();
while (itr.hasNext()) {
HTableDescriptor htd = itr.next(); HTableDescriptor htd = itr.next();
try { try {
requirePermission("getTableDescriptors", htd.getTableName(), null, null, requirePermission("getTableDescriptors", htd.getTableName(), null, null,
Action.ADMIN, Action.CREATE); Action.ADMIN, Action.CREATE);
} catch(AccessDeniedException exception) { } catch (AccessDeniedException e) {
itr.remove(); itr.remove();
} }
} }
}
// Throws exception if none of the matched tables are authorized for the user. @Override
if(numMatchedTables > 0 && descriptors.size() == 0) { public void postGetTableNames(ObserverContext<MasterCoprocessorEnvironment> ctx,
throw new AccessDeniedException("Insufficient permissions for accessing tables"); List<HTableDescriptor> descriptors, String regex) throws IOException {
// Retains only those which passes authorization checks.
Iterator<HTableDescriptor> itr = descriptors.iterator();
while (itr.hasNext()) {
HTableDescriptor htd = itr.next();
try {
requireAccess("getTableNames", htd.getTableName(), Action.values());
} catch (AccessDeniedException e) {
itr.remove();
}
} }
} }

View File

@ -349,6 +349,20 @@ public class TableAuthManager {
return false; return false;
} }
private boolean hasAccess(List<TablePermission> perms,
TableName table, Permission.Action action) {
if (perms != null) {
for (TablePermission p : perms) {
if (p.implies(action)) {
return true;
}
}
} else if (LOG.isDebugEnabled()) {
LOG.debug("No permissions found for table="+table);
}
return false;
}
/** /**
* Authorize a user for a given KV. This is called from AccessControlFilter. * Authorize a user for a given KV. This is called from AccessControlFilter.
*/ */
@ -450,6 +464,25 @@ public class TableAuthManager {
qualifier, action); qualifier, action);
} }
/**
* Checks if the user has access to the full table or at least a family/qualifier
* for the specified action.
*
* @param user
* @param table
* @param action
* @return true if the user has access to the table, false otherwise
*/
public boolean userHasAccess(User user, TableName table, Permission.Action action) {
if (table == null) table = AccessControlLists.ACL_TABLE_NAME;
// Global and namespace authorizations supercede table level
if (authorize(user, table.getNamespaceAsString(), action)) {
return true;
}
// Check table permissions
return hasAccess(getTablePermissions(table).getUser(user.getShortName()), table, action);
}
/** /**
* Checks global authorization for a given action for a group, based on the stored * Checks global authorization for a given action for a group, based on the stored
* permissions. * permissions.
@ -483,6 +516,29 @@ public class TableAuthManager {
return authorize(getTablePermissions(table).getGroup(groupName), table, family, action); return authorize(getTablePermissions(table).getGroup(groupName), table, family, action);
} }
/**
* Checks if the user has access to the full table or at least a family/qualifier
* for the specified action.
* @param groupName
* @param table
* @param action
* @return true if the group has access to the table, false otherwise
*/
public boolean groupHasAccess(String groupName, TableName table, Permission.Action action) {
// Global authorization supercedes table level
if (authorizeGroup(groupName, action)) {
return true;
}
if (table == null) table = AccessControlLists.ACL_TABLE_NAME;
// Namespace authorization supercedes table level
if (hasAccess(getNamespacePermissions(table.getNamespaceAsString()).getGroup(groupName),
table, action)) {
return true;
}
// Check table level
return hasAccess(getTablePermissions(table).getGroup(groupName), table, action);
}
public boolean authorize(User user, TableName table, byte[] family, public boolean authorize(User user, TableName table, byte[] family,
byte[] qualifier, Permission.Action action) { byte[] qualifier, Permission.Action action) {
if (authorizeUser(user, table, family, qualifier, action)) { if (authorizeUser(user, table, family, qualifier, action)) {
@ -500,6 +556,22 @@ public class TableAuthManager {
return false; return false;
} }
public boolean hasAccess(User user, TableName table, Permission.Action action) {
if (userHasAccess(user, table, action)) {
return true;
}
String[] groups = user.getGroupNames();
if (groups != null) {
for (String group : groups) {
if (groupHasAccess(group, table, action)) {
return true;
}
}
}
return false;
}
public boolean authorize(User user, TableName table, byte[] family, public boolean authorize(User user, TableName table, byte[] family,
Permission.Action action) { Permission.Action action) {
return authorize(user, table, family, null, action); return authorize(user, table, family, null, action);

View File

@ -54,6 +54,7 @@ import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.protobuf.RequestConverter; import org.apache.hadoop.hbase.protobuf.RequestConverter;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription; import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsRequest; import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableNamesRequest;
import org.apache.hadoop.hbase.protobuf.generated.QuotaProtos.Quotas; import org.apache.hadoop.hbase.protobuf.generated.QuotaProtos.Quotas;
import org.apache.hadoop.hbase.regionserver.HRegionServer; import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.testclassification.CoprocessorTests; import org.apache.hadoop.hbase.testclassification.CoprocessorTests;
@ -150,6 +151,8 @@ public class TestMasterObserver {
private boolean postModifyTableHandlerCalled; private boolean postModifyTableHandlerCalled;
private boolean preGetTableDescriptorsCalled; private boolean preGetTableDescriptorsCalled;
private boolean postGetTableDescriptorsCalled; private boolean postGetTableDescriptorsCalled;
private boolean postGetTableNamesCalled;
private boolean preGetTableNamesCalled;
public void enableBypass(boolean bypass) { public void enableBypass(boolean bypass) {
this.bypass = bypass; this.bypass = bypass;
@ -224,6 +227,8 @@ public class TestMasterObserver {
postModifyTableHandlerCalled = false; postModifyTableHandlerCalled = false;
preGetTableDescriptorsCalled = false; preGetTableDescriptorsCalled = false;
postGetTableDescriptorsCalled = false; postGetTableDescriptorsCalled = false;
postGetTableNamesCalled = false;
preGetTableNamesCalled = false;
} }
@Override @Override
@ -773,11 +778,6 @@ public class TestMasterObserver {
postDeleteSnapshotCalled = true; postDeleteSnapshotCalled = true;
} }
@Override
public void preGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<TableName> tableNamesList, List<HTableDescriptor> descriptors) throws IOException {
}
public boolean wasDeleteSnapshotCalled() { public boolean wasDeleteSnapshotCalled() {
return preDeleteSnapshotCalled && postDeleteSnapshotCalled; return preDeleteSnapshotCalled && postDeleteSnapshotCalled;
} }
@ -1018,12 +1018,8 @@ public class TestMasterObserver {
@Override @Override
public void postGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx, public void postGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<HTableDescriptor> descriptors) throws IOException { List<TableName> tableNamesList, List<HTableDescriptor> descriptors,
} String regex) throws IOException {
@Override
public void postGetTableDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<HTableDescriptor> descriptors, String regex) throws IOException {
postGetTableDescriptorsCalled = true; postGetTableDescriptorsCalled = true;
} }
@ -1031,6 +1027,22 @@ public class TestMasterObserver {
return preGetTableDescriptorsCalled && postGetTableDescriptorsCalled; return preGetTableDescriptorsCalled && postGetTableDescriptorsCalled;
} }
@Override
public void preGetTableNames(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<HTableDescriptor> descriptors, String regex) throws IOException {
preGetTableNamesCalled = true;
}
@Override
public void postGetTableNames(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<HTableDescriptor> descriptors, String regex) throws IOException {
postGetTableNamesCalled = true;
}
public boolean wasGetTableNamesCalled() {
return preGetTableNamesCalled && postGetTableNamesCalled;
}
@Override @Override
public void preTableFlush(ObserverContext<MasterCoprocessorEnvironment> ctx, public void preTableFlush(ObserverContext<MasterCoprocessorEnvironment> ctx,
TableName tableName) throws IOException { TableName tableName) throws IOException {
@ -1552,4 +1564,19 @@ public class TestMasterObserver {
cp.wasGetTableDescriptorsCalled()); cp.wasGetTableDescriptorsCalled());
} }
@Test
public void testTableNamesEnumeration() throws Exception {
MiniHBaseCluster cluster = UTIL.getHBaseCluster();
HMaster master = cluster.getMaster();
MasterCoprocessorHost host = master.getMasterCoprocessorHost();
CPMasterObserver cp = (CPMasterObserver)host.findCoprocessor(
CPMasterObserver.class.getName());
cp.resetStates();
master.getMasterRpcServices().getTableNames(null,
GetTableNamesRequest.newBuilder().build());
assertTrue("Coprocessor should be called on table names request",
cp.wasGetTableNamesCalled());
}
} }

View File

@ -26,6 +26,7 @@ import static org.junit.Assert.fail;
import java.io.IOException; import java.io.IOException;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import java.util.Arrays;
import java.util.List; import java.util.List;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -264,7 +265,7 @@ public class TestAccessController extends SecureTestUtil {
try { try {
assertEquals(4, AccessControlClient.getUserPermissions(conf, TEST_TABLE.toString()).size()); assertEquals(4, AccessControlClient.getUserPermissions(conf, TEST_TABLE.toString()).size());
} catch (Throwable e) { } catch (Throwable e) {
LOG.error("error during call of AccessControlClient.getUserPermissions. " + e.getStackTrace()); LOG.error("error during call of AccessControlClient.getUserPermissions. ", e);
} }
} }
@ -2059,11 +2060,14 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction listTablesAction = new AccessTestAction() { AccessTestAction listTablesAction = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
Admin admin = TEST_UTIL.getHBaseAdmin(); Connection unmanagedConnection =
ConnectionFactory.createConnection(TEST_UTIL.getConfiguration());
Admin admin = unmanagedConnection.getAdmin();
try { try {
admin.listTables(); admin.listTables();
} finally { } finally {
admin.close(); admin.close();
unmanagedConnection.close();
} }
return null; return null;
} }
@ -2072,23 +2076,47 @@ public class TestAccessController extends SecureTestUtil {
AccessTestAction getTableDescAction = new AccessTestAction() { AccessTestAction getTableDescAction = new AccessTestAction() {
@Override @Override
public Object run() throws Exception { public Object run() throws Exception {
Admin admin = TEST_UTIL.getHBaseAdmin(); Connection unmanagedConnection =
ConnectionFactory.createConnection(TEST_UTIL.getConfiguration());
Admin admin = unmanagedConnection.getAdmin();
try { try {
admin.getTableDescriptor(TEST_TABLE.getTableName()); admin.getTableDescriptor(TEST_TABLE.getTableName());
} finally { } finally {
admin.close(); admin.close();
unmanagedConnection.close();
} }
return null; return null;
} }
}; };
verifyAllowed(listTablesAction, SUPERUSER, USER_ADMIN); verifyAllowed(listTablesAction, SUPERUSER, USER_ADMIN, USER_CREATE, TABLE_ADMIN);
verifyDenied(listTablesAction, USER_CREATE, USER_RW, USER_RO, USER_NONE, TABLE_ADMIN); verifyDenied(listTablesAction, USER_RW, USER_RO, USER_NONE);
verifyAllowed(getTableDescAction, SUPERUSER, USER_ADMIN, USER_CREATE, TABLE_ADMIN); verifyAllowed(getTableDescAction, SUPERUSER, USER_ADMIN, USER_CREATE, TABLE_ADMIN);
verifyDenied(getTableDescAction, USER_RW, USER_RO, USER_NONE); verifyDenied(getTableDescAction, USER_RW, USER_RO, USER_NONE);
} }
@Test
public void testTableNameEnumeration() throws Exception {
AccessTestAction listTablesAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
Connection unmanagedConnection =
ConnectionFactory.createConnection(TEST_UTIL.getConfiguration());
Admin admin = unmanagedConnection.getAdmin();
try {
return Arrays.asList(admin.listTableNames());
} finally {
admin.close();
unmanagedConnection.close();
}
}
};
verifyAllowed(listTablesAction, SUPERUSER, USER_ADMIN, USER_CREATE, USER_RW, USER_RO);
verifyDenied(listTablesAction, USER_NONE);
}
@Test @Test
public void testTableDeletion() throws Exception { public void testTableDeletion() throws Exception {
User TABLE_ADMIN = User.createUserForTesting(conf, "TestUser", new String[0]); User TABLE_ADMIN = User.createUserForTesting(conf, "TestUser", new String[0]);
@ -2166,7 +2194,7 @@ public class TestAccessController extends SecureTestUtil {
grantOnTableUsingAccessControlClient(TEST_UTIL, conf, testGrantRevoke.getShortName(), grantOnTableUsingAccessControlClient(TEST_UTIL, conf, testGrantRevoke.getShortName(),
TEST_TABLE.getTableName(), null, null, Permission.Action.READ); TEST_TABLE.getTableName(), null, null, Permission.Action.READ);
} catch (Throwable e) { } catch (Throwable e) {
LOG.error("error during call of AccessControlClient.grant. " + e.getStackTrace()); LOG.error("error during call of AccessControlClient.grant. ", e);
} }
// Now testGrantRevoke should be able to read also // Now testGrantRevoke should be able to read also
@ -2177,7 +2205,7 @@ public class TestAccessController extends SecureTestUtil {
revokeFromTableUsingAccessControlClient(TEST_UTIL, conf, testGrantRevoke.getShortName(), revokeFromTableUsingAccessControlClient(TEST_UTIL, conf, testGrantRevoke.getShortName(),
TEST_TABLE.getTableName(), null, null, Permission.Action.READ); TEST_TABLE.getTableName(), null, null, Permission.Action.READ);
} catch (Throwable e) { } catch (Throwable e) {
LOG.error("error during call of AccessControlClient.revoke " + e.getStackTrace()); LOG.error("error during call of AccessControlClient.revoke ", e);
} }
// Now testGrantRevoke shouldn't be able read // Now testGrantRevoke shouldn't be able read
@ -2207,7 +2235,7 @@ public class TestAccessController extends SecureTestUtil {
grantOnNamespaceUsingAccessControlClient(TEST_UTIL, conf, testNS.getShortName(), grantOnNamespaceUsingAccessControlClient(TEST_UTIL, conf, testNS.getShortName(),
TEST_TABLE.getTableName().getNamespaceAsString(), Permission.Action.READ); TEST_TABLE.getTableName().getNamespaceAsString(), Permission.Action.READ);
} catch (Throwable e) { } catch (Throwable e) {
LOG.error("error during call of AccessControlClient.grant. " + e.getStackTrace()); LOG.error("error during call of AccessControlClient.grant. ", e);
} }
// Now testNS should be able to read also // Now testNS should be able to read also
@ -2218,7 +2246,7 @@ public class TestAccessController extends SecureTestUtil {
revokeFromNamespaceUsingAccessControlClient(TEST_UTIL, conf, testNS.getShortName(), revokeFromNamespaceUsingAccessControlClient(TEST_UTIL, conf, testNS.getShortName(),
TEST_TABLE.getTableName().getNamespaceAsString(), Permission.Action.READ); TEST_TABLE.getTableName().getNamespaceAsString(), Permission.Action.READ);
} catch (Throwable e) { } catch (Throwable e) {
LOG.error("error during call of AccessControlClient.revoke " + e.getStackTrace()); LOG.error("error during call of AccessControlClient.revoke ", e);
} }
// Now testNS shouldn't be able read // Now testNS shouldn't be able read
@ -2451,8 +2479,7 @@ public class TestAccessController extends SecureTestUtil {
try { try {
return AccessControlClient.getUserPermissions(conf, regex); return AccessControlClient.getUserPermissions(conf, regex);
} catch (Throwable e) { } catch (Throwable e) {
LOG.error("error during call of AccessControlClient.getUserPermissions. " LOG.error("error during call of AccessControlClient.getUserPermissions.", e);
+ e.getStackTrace());
return null; return null;
} }
} }
@ -2462,10 +2489,12 @@ public class TestAccessController extends SecureTestUtil {
@Test @Test
public void testAccessControlClientUserPerms() throws Exception { public void testAccessControlClientUserPerms() throws Exception {
// adding default prefix explicitly as it is not included in the table name. // adding default prefix explicitly as it is not included in the table name.
final String regex = TEST_TABLE.getTableName().getNamespaceAsString() + ":" assertEquals(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR,
+ TEST_TABLE.getTableName().getNameAsString(); TEST_TABLE.getTableName().getNamespaceAsString());
final String regex = NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR +
TableName.NAMESPACE_DELIM + TEST_TABLE.getTableName().getNameAsString();
User testUserPerms = User.createUserForTesting(conf, "testUserPerms", new String[0]); User testUserPerms = User.createUserForTesting(conf, "testUserPerms", new String[0]);
assertNull(testUserPerms.runAs(getPrivilegedAction(regex))); assertEquals(0, testUserPerms.runAs(getPrivilegedAction(regex)).size());
// Grant TABLE ADMIN privs to testUserPerms // Grant TABLE ADMIN privs to testUserPerms
grantOnTable(TEST_UTIL, testUserPerms.getShortName(), TEST_TABLE.getTableName(), null, grantOnTable(TEST_UTIL, testUserPerms.getShortName(), TEST_TABLE.getTableName(), null,
null, Action.ADMIN); null, Action.ADMIN);
@ -2475,12 +2504,12 @@ public class TestAccessController extends SecureTestUtil {
assertEquals(5, perms.size()); assertEquals(5, perms.size());
} }
@Test @Test
public void testAccessControllerRegexHandling() throws Exception { public void testAccessControllerUserPermsRegexHandling() throws Exception {
User testRegexHandler = User.createUserForTesting(conf, "testRegexHandling", new String[0]); User testRegexHandler = User.createUserForTesting(conf, "testRegexHandling", new String[0]);
String tableName = "testRegex";
final String REGEX_ALL_TABLES = ".*";
final String tableName = "testRegex";
final TableName table1 = TableName.valueOf(tableName); final TableName table1 = TableName.valueOf(tableName);
final byte[] family = Bytes.toBytes("f1"); final byte[] family = Bytes.toBytes("f1");
@ -2494,20 +2523,32 @@ public class TestAccessController extends SecureTestUtil {
// creating the ns and table in it // creating the ns and table in it
String ns = "testNamespace"; String ns = "testNamespace";
NamespaceDescriptor desc = NamespaceDescriptor.create(ns).build(); NamespaceDescriptor desc = NamespaceDescriptor.create(ns).build();
final TableName table2 = TableName.valueOf(ns + ":" + tableName); final TableName table2 = TableName.valueOf(ns, tableName);
TEST_UTIL.getMiniHBaseCluster().getMaster().createNamespace(desc); TEST_UTIL.getMiniHBaseCluster().getMaster().createNamespace(desc);
htd = new HTableDescriptor(table2); htd = new HTableDescriptor(table2);
htd.addFamily(new HColumnDescriptor(family)); htd.addFamily(new HColumnDescriptor(family));
admin.createTable(htd); admin.createTable(htd);
TEST_UTIL.waitUntilAllRegionsAssigned(table2);
// Verify that we can read sys-tables
String aclTableName = AccessControlLists.ACL_TABLE_NAME.getNameAsString();
assertEquals(1, SUPERUSER.runAs(getPrivilegedAction(aclTableName)).size());
assertEquals(0, testRegexHandler.runAs(getPrivilegedAction(aclTableName)).size());
// Grant TABLE ADMIN privs to testUserPerms // Grant TABLE ADMIN privs to testUserPerms
assertEquals(0, testRegexHandler.runAs(getPrivilegedAction(REGEX_ALL_TABLES)).size());
grantOnTable(TEST_UTIL, testRegexHandler.getShortName(), table1, null, null, Action.ADMIN); grantOnTable(TEST_UTIL, testRegexHandler.getShortName(), table1, null, null, Action.ADMIN);
assertEquals(2, testRegexHandler.runAs(getPrivilegedAction(REGEX_ALL_TABLES)).size());
grantOnTable(TEST_UTIL, testRegexHandler.getShortName(), table2, null, null, Action.ADMIN); grantOnTable(TEST_UTIL, testRegexHandler.getShortName(), table2, null, null, Action.ADMIN);
assertEquals(4, testRegexHandler.runAs(getPrivilegedAction(REGEX_ALL_TABLES)).size());
// USER_ADMIN, testUserPerms must have a row each. // USER_ADMIN, testUserPerms must have a row each.
assertEquals(2, testRegexHandler.runAs(getPrivilegedAction(tableName)).size()); assertEquals(2, testRegexHandler.runAs(getPrivilegedAction(tableName)).size());
assertEquals(2, testRegexHandler.runAs(getPrivilegedAction("default:" + tableName)).size()); assertEquals(2, testRegexHandler.runAs(getPrivilegedAction(
assertEquals(2, testRegexHandler.runAs(getPrivilegedAction(ns + ":" + tableName)).size()); NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR + TableName.NAMESPACE_DELIM + tableName)
).size());
assertEquals(2, testRegexHandler.runAs(getPrivilegedAction(
ns + TableName.NAMESPACE_DELIM + tableName)).size());
assertEquals(0, testRegexHandler.runAs(getPrivilegedAction("notMatchingAny")).size()); assertEquals(0, testRegexHandler.runAs(getPrivilegedAction("notMatchingAny")).size());
TEST_UTIL.deleteTable(table1); TEST_UTIL.deleteTable(table1);

View File

@ -43,7 +43,7 @@ module Hbase
#---------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------
# Returns a list of tables in hbase # Returns a list of tables in hbase
def list(regex = ".*") def list(regex = ".*")
@admin.getTableNames(regex).to_a @admin.listTableNames(regex).map { |t| t.getNameAsString }
end end
#---------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------