diff --git a/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/MasterProtos.java b/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/MasterProtos.java index 8297a61..dbe9e41 100644 --- a/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/MasterProtos.java +++ b/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/MasterProtos.java @@ -33972,6 +33972,46 @@ public final class MasterProtos { */ org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.TableNameOrBuilder getTableNamesOrBuilder( int index); + + // optional string regex = 2; + /** + * optional string regex = 2; + */ + boolean hasRegex(); + /** + * optional string regex = 2; + */ + java.lang.String getRegex(); + /** + * optional string regex = 2; + */ + com.google.protobuf.ByteString + getRegexBytes(); + + // optional bool include_sys_tables = 3 [default = false]; + /** + * optional bool include_sys_tables = 3 [default = false]; + */ + boolean hasIncludeSysTables(); + /** + * optional bool include_sys_tables = 3 [default = false]; + */ + boolean getIncludeSysTables(); + + // optional string namespace = 4; + /** + * optional string namespace = 4; + */ + boolean hasNamespace(); + /** + * optional string namespace = 4; + */ + java.lang.String getNamespace(); + /** + * optional string namespace = 4; + */ + com.google.protobuf.ByteString + getNamespaceBytes(); } /** * Protobuf type {@code GetTableDescriptorsRequest} @@ -34032,6 +34072,21 @@ public final class MasterProtos { tableNames_.add(input.readMessage(org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.TableName.PARSER, extensionRegistry)); break; } + case 18: { + bitField0_ |= 0x00000001; + regex_ = input.readBytes(); + break; + } + case 24: { + bitField0_ |= 0x00000002; + includeSysTables_ = input.readBool(); + break; + } + case 34: { + bitField0_ |= 0x00000004; + namespace_ = input.readBytes(); + break; + } } } } catch (com.google.protobuf.InvalidProtocolBufferException e) { @@ -34074,6 +34129,7 @@ public final class MasterProtos { return PARSER; } + private int bitField0_; // repeated .TableName table_names = 1; public static final int TABLE_NAMES_FIELD_NUMBER = 1; private java.util.List tableNames_; @@ -34110,8 +34166,113 @@ public final class MasterProtos { return tableNames_.get(index); } + // optional string regex = 2; + public static final int REGEX_FIELD_NUMBER = 2; + private java.lang.Object regex_; + /** + * optional string regex = 2; + */ + public boolean hasRegex() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional string regex = 2; + */ + 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; + } + } + /** + * optional string regex = 2; + */ + 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 = 3 [default = false]; + public static final int INCLUDE_SYS_TABLES_FIELD_NUMBER = 3; + private boolean includeSysTables_; + /** + * optional bool include_sys_tables = 3 [default = false]; + */ + public boolean hasIncludeSysTables() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional bool include_sys_tables = 3 [default = false]; + */ + public boolean getIncludeSysTables() { + return includeSysTables_; + } + + // optional string namespace = 4; + public static final int NAMESPACE_FIELD_NUMBER = 4; + private java.lang.Object namespace_; + /** + * optional string namespace = 4; + */ + public boolean hasNamespace() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional string namespace = 4; + */ + public java.lang.String getNamespace() { + java.lang.Object ref = namespace_; + 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()) { + namespace_ = s; + } + return s; + } + } + /** + * optional string namespace = 4; + */ + public com.google.protobuf.ByteString + getNamespaceBytes() { + java.lang.Object ref = namespace_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + namespace_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + private void initFields() { tableNames_ = java.util.Collections.emptyList(); + regex_ = ""; + includeSysTables_ = false; + namespace_ = ""; } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { @@ -34134,6 +34295,15 @@ public final class MasterProtos { for (int i = 0; i < tableNames_.size(); i++) { output.writeMessage(1, tableNames_.get(i)); } + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(2, getRegexBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeBool(3, includeSysTables_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeBytes(4, getNamespaceBytes()); + } getUnknownFields().writeTo(output); } @@ -34147,6 +34317,18 @@ public final class MasterProtos { size += com.google.protobuf.CodedOutputStream .computeMessageSize(1, tableNames_.get(i)); } + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, getRegexBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(3, includeSysTables_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(4, getNamespaceBytes()); + } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; @@ -34172,6 +34354,21 @@ public final class MasterProtos { boolean result = true; result = result && getTableNamesList() .equals(other.getTableNamesList()); + 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 && (hasNamespace() == other.hasNamespace()); + if (hasNamespace()) { + result = result && getNamespace() + .equals(other.getNamespace()); + } result = result && getUnknownFields().equals(other.getUnknownFields()); return result; @@ -34189,6 +34386,18 @@ public final class MasterProtos { hash = (37 * hash) + TABLE_NAMES_FIELD_NUMBER; hash = (53 * hash) + getTableNamesList().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()); + } + if (hasNamespace()) { + hash = (37 * hash) + NAMESPACE_FIELD_NUMBER; + hash = (53 * hash) + getNamespace().hashCode(); + } hash = (29 * hash) + getUnknownFields().hashCode(); memoizedHashCode = hash; return hash; @@ -34305,6 +34514,12 @@ public final class MasterProtos { } else { tableNamesBuilder_.clear(); } + regex_ = ""; + bitField0_ = (bitField0_ & ~0x00000002); + includeSysTables_ = false; + bitField0_ = (bitField0_ & ~0x00000004); + namespace_ = ""; + bitField0_ = (bitField0_ & ~0x00000008); return this; } @@ -34332,6 +34547,7 @@ public final class MasterProtos { public org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsRequest buildPartial() { org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsRequest result = new org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsRequest(this); int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; if (tableNamesBuilder_ == null) { if (((bitField0_ & 0x00000001) == 0x00000001)) { tableNames_ = java.util.Collections.unmodifiableList(tableNames_); @@ -34341,6 +34557,19 @@ public final class MasterProtos { } else { result.tableNames_ = tableNamesBuilder_.build(); } + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000001; + } + result.regex_ = regex_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000002; + } + result.includeSysTables_ = includeSysTables_; + if (((from_bitField0_ & 0x00000008) == 0x00000008)) { + to_bitField0_ |= 0x00000004; + } + result.namespace_ = namespace_; + result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -34382,6 +34611,19 @@ public final class MasterProtos { } } } + if (other.hasRegex()) { + bitField0_ |= 0x00000002; + regex_ = other.regex_; + onChanged(); + } + if (other.hasIncludeSysTables()) { + setIncludeSysTables(other.getIncludeSysTables()); + } + if (other.hasNamespace()) { + bitField0_ |= 0x00000008; + namespace_ = other.namespace_; + onChanged(); + } this.mergeUnknownFields(other.getUnknownFields()); return this; } @@ -34655,6 +34897,187 @@ public final class MasterProtos { return tableNamesBuilder_; } + // optional string regex = 2; + private java.lang.Object regex_ = ""; + /** + * optional string regex = 2; + */ + public boolean hasRegex() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional string regex = 2; + */ + 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; + } + } + /** + * optional string regex = 2; + */ + 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; + } + } + /** + * optional string regex = 2; + */ + public Builder setRegex( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + regex_ = value; + onChanged(); + return this; + } + /** + * optional string regex = 2; + */ + public Builder clearRegex() { + bitField0_ = (bitField0_ & ~0x00000002); + regex_ = getDefaultInstance().getRegex(); + onChanged(); + return this; + } + /** + * optional string regex = 2; + */ + public Builder setRegexBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + regex_ = value; + onChanged(); + return this; + } + + // optional bool include_sys_tables = 3 [default = false]; + private boolean includeSysTables_ ; + /** + * optional bool include_sys_tables = 3 [default = false]; + */ + public boolean hasIncludeSysTables() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional bool include_sys_tables = 3 [default = false]; + */ + public boolean getIncludeSysTables() { + return includeSysTables_; + } + /** + * optional bool include_sys_tables = 3 [default = false]; + */ + public Builder setIncludeSysTables(boolean value) { + bitField0_ |= 0x00000004; + includeSysTables_ = value; + onChanged(); + return this; + } + /** + * optional bool include_sys_tables = 3 [default = false]; + */ + public Builder clearIncludeSysTables() { + bitField0_ = (bitField0_ & ~0x00000004); + includeSysTables_ = false; + onChanged(); + return this; + } + + // optional string namespace = 4; + private java.lang.Object namespace_ = ""; + /** + * optional string namespace = 4; + */ + public boolean hasNamespace() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * optional string namespace = 4; + */ + public java.lang.String getNamespace() { + java.lang.Object ref = namespace_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + namespace_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string namespace = 4; + */ + public com.google.protobuf.ByteString + getNamespaceBytes() { + java.lang.Object ref = namespace_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + namespace_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string namespace = 4; + */ + public Builder setNamespace( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000008; + namespace_ = value; + onChanged(); + return this; + } + /** + * optional string namespace = 4; + */ + public Builder clearNamespace() { + bitField0_ = (bitField0_ & ~0x00000008); + namespace_ = getDefaultInstance().getNamespace(); + onChanged(); + return this; + } + /** + * optional string namespace = 4; + */ + public Builder setNamespaceBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000008; + namespace_ = value; + onChanged(); + return this; + } + // @@protoc_insertion_point(builder_scope:GetTableDescriptorsRequest) } @@ -35389,6 +35812,46 @@ public final class MasterProtos { public interface GetTableNamesRequestOrBuilder extends com.google.protobuf.MessageOrBuilder { + + // optional string regex = 1; + /** + * optional string regex = 1; + */ + boolean hasRegex(); + /** + * optional string regex = 1; + */ + java.lang.String getRegex(); + /** + * optional string regex = 1; + */ + com.google.protobuf.ByteString + getRegexBytes(); + + // optional bool include_sys_tables = 2 [default = false]; + /** + * optional bool include_sys_tables = 2 [default = false]; + */ + boolean hasIncludeSysTables(); + /** + * optional bool include_sys_tables = 2 [default = false]; + */ + boolean getIncludeSysTables(); + + // optional string namespace = 3; + /** + * optional string namespace = 3; + */ + boolean hasNamespace(); + /** + * optional string namespace = 3; + */ + java.lang.String getNamespace(); + /** + * optional string namespace = 3; + */ + com.google.protobuf.ByteString + getNamespaceBytes(); } /** * Protobuf type {@code GetTableNamesRequest} @@ -35423,6 +35886,7 @@ public final class MasterProtos { com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { initFields(); + int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -35440,6 +35904,21 @@ public final class MasterProtos { } break; } + case 10: { + bitField0_ |= 0x00000001; + regex_ = input.readBytes(); + break; + } + case 16: { + bitField0_ |= 0x00000002; + includeSysTables_ = input.readBool(); + break; + } + case 26: { + bitField0_ |= 0x00000004; + namespace_ = input.readBytes(); + break; + } } } } catch (com.google.protobuf.InvalidProtocolBufferException e) { @@ -35479,7 +35958,113 @@ public final class MasterProtos { return PARSER; } + private int bitField0_; + // optional string regex = 1; + public static final int REGEX_FIELD_NUMBER = 1; + private java.lang.Object regex_; + /** + * optional string regex = 1; + */ + public boolean hasRegex() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional string regex = 1; + */ + 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; + } + } + /** + * optional string regex = 1; + */ + 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_; + /** + * optional bool include_sys_tables = 2 [default = false]; + */ + public boolean hasIncludeSysTables() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional bool include_sys_tables = 2 [default = false]; + */ + public boolean getIncludeSysTables() { + return includeSysTables_; + } + + // optional string namespace = 3; + public static final int NAMESPACE_FIELD_NUMBER = 3; + private java.lang.Object namespace_; + /** + * optional string namespace = 3; + */ + public boolean hasNamespace() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional string namespace = 3; + */ + public java.lang.String getNamespace() { + java.lang.Object ref = namespace_; + 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()) { + namespace_ = s; + } + return s; + } + } + /** + * optional string namespace = 3; + */ + public com.google.protobuf.ByteString + getNamespaceBytes() { + java.lang.Object ref = namespace_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + namespace_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + private void initFields() { + regex_ = ""; + includeSysTables_ = false; + namespace_ = ""; } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { @@ -35493,6 +36078,15 @@ public final class MasterProtos { public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getRegexBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeBool(2, includeSysTables_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeBytes(3, getNamespaceBytes()); + } getUnknownFields().writeTo(output); } @@ -35502,6 +36096,18 @@ public final class MasterProtos { if (size != -1) return size; 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_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, getNamespaceBytes()); + } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; @@ -35525,6 +36131,21 @@ public final class MasterProtos { org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableNamesRequest other = (org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableNamesRequest) obj; 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 && (hasNamespace() == other.hasNamespace()); + if (hasNamespace()) { + result = result && getNamespace() + .equals(other.getNamespace()); + } result = result && getUnknownFields().equals(other.getUnknownFields()); return result; @@ -35538,6 +36159,18 @@ public final class MasterProtos { } int hash = 41; 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()); + } + if (hasNamespace()) { + hash = (37 * hash) + NAMESPACE_FIELD_NUMBER; + hash = (53 * hash) + getNamespace().hashCode(); + } hash = (29 * hash) + getUnknownFields().hashCode(); memoizedHashCode = hash; return hash; @@ -35647,6 +36280,12 @@ public final class MasterProtos { public Builder clear() { super.clear(); + regex_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + includeSysTables_ = false; + bitField0_ = (bitField0_ & ~0x00000002); + namespace_ = ""; + bitField0_ = (bitField0_ & ~0x00000004); return this; } @@ -35673,6 +36312,21 @@ public final class MasterProtos { 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); + 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_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + result.namespace_ = namespace_; + result.bitField0_ = to_bitField0_; onBuilt(); return result; } @@ -35688,6 +36342,19 @@ public final class MasterProtos { 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.hasRegex()) { + bitField0_ |= 0x00000001; + regex_ = other.regex_; + onChanged(); + } + if (other.hasIncludeSysTables()) { + setIncludeSysTables(other.getIncludeSysTables()); + } + if (other.hasNamespace()) { + bitField0_ |= 0x00000004; + namespace_ = other.namespace_; + onChanged(); + } this.mergeUnknownFields(other.getUnknownFields()); return this; } @@ -35713,6 +36380,188 @@ public final class MasterProtos { } return this; } + private int bitField0_; + + // optional string regex = 1; + private java.lang.Object regex_ = ""; + /** + * optional string regex = 1; + */ + public boolean hasRegex() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional string regex = 1; + */ + 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; + } + } + /** + * optional string regex = 1; + */ + 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; + } + } + /** + * optional string regex = 1; + */ + public Builder setRegex( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + regex_ = value; + onChanged(); + return this; + } + /** + * optional string regex = 1; + */ + public Builder clearRegex() { + bitField0_ = (bitField0_ & ~0x00000001); + regex_ = getDefaultInstance().getRegex(); + onChanged(); + return this; + } + /** + * optional string regex = 1; + */ + 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_ ; + /** + * optional bool include_sys_tables = 2 [default = false]; + */ + public boolean hasIncludeSysTables() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional bool include_sys_tables = 2 [default = false]; + */ + public boolean getIncludeSysTables() { + return includeSysTables_; + } + /** + * optional bool include_sys_tables = 2 [default = false]; + */ + public Builder setIncludeSysTables(boolean value) { + bitField0_ |= 0x00000002; + includeSysTables_ = value; + onChanged(); + return this; + } + /** + * optional bool include_sys_tables = 2 [default = false]; + */ + public Builder clearIncludeSysTables() { + bitField0_ = (bitField0_ & ~0x00000002); + includeSysTables_ = false; + onChanged(); + return this; + } + + // optional string namespace = 3; + private java.lang.Object namespace_ = ""; + /** + * optional string namespace = 3; + */ + public boolean hasNamespace() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional string namespace = 3; + */ + public java.lang.String getNamespace() { + java.lang.Object ref = namespace_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + namespace_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string namespace = 3; + */ + public com.google.protobuf.ByteString + getNamespaceBytes() { + java.lang.Object ref = namespace_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + namespace_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string namespace = 3; + */ + public Builder setNamespace( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + namespace_ = value; + onChanged(); + return this; + } + /** + * optional string namespace = 3; + */ + public Builder clearNamespace() { + bitField0_ = (bitField0_ & ~0x00000004); + namespace_ = getDefaultInstance().getNamespace(); + onChanged(); + return this; + } + /** + * optional string namespace = 3; + */ + public Builder setNamespaceBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + namespace_ = value; + onChanged(); + return this; + } // @@protoc_insertion_point(builder_scope:GetTableNamesRequest) } @@ -46507,114 +47356,117 @@ public final class MasterProtos { "false\"=\n\033GetSchemaAlterStatusRequest\022\036\n\n" + "table_name\030\001 \002(\0132\n.TableName\"T\n\034GetSchem" + "aAlterStatusResponse\022\035\n\025yet_to_update_re", - "gions\030\001 \001(\r\022\025\n\rtotal_regions\030\002 \001(\r\"=\n\032Ge" + - "tTableDescriptorsRequest\022\037\n\013table_names\030" + - "\001 \003(\0132\n.TableName\"A\n\033GetTableDescriptors" + - "Response\022\"\n\014table_schema\030\001 \003(\0132\014.TableSc" + - "hema\"\026\n\024GetTableNamesRequest\"8\n\025GetTable" + - "NamesResponse\022\037\n\013table_names\030\001 \003(\0132\n.Tab" + - "leName\"\031\n\027GetClusterStatusRequest\"B\n\030Get" + - "ClusterStatusResponse\022&\n\016cluster_status\030" + - "\001 \002(\0132\016.ClusterStatus\"\030\n\026IsMasterRunning" + - "Request\"4\n\027IsMasterRunningResponse\022\031\n\021is", - "_master_running\030\001 \002(\010\"@\n\024ExecProcedureRe" + - "quest\022(\n\tprocedure\030\001 \002(\0132\025.ProcedureDesc" + - "ription\"1\n\025ExecProcedureResponse\022\030\n\020expe" + - "cted_timeout\030\001 \002(\003\"B\n\026IsProcedureDoneReq" + - "uest\022(\n\tprocedure\030\001 \001(\0132\025.ProcedureDescr" + - "iption\"W\n\027IsProcedureDoneResponse\022\023\n\004don" + - "e\030\001 \001(\010:\005false\022\'\n\010snapshot\030\002 \001(\0132\025.Proce" + - "dureDescription\"T\n\024TruncateTableRequest\022" + - "\035\n\ttableName\030\001 \002(\0132\n.TableName\022\035\n\016preser" + - "veSplits\030\002 \001(\010:\005false\"\027\n\025TruncateTableRe", - "sponse\"\035\n\033SecurityCapabilitiesRequest\"\343\001" + - "\n\034SecurityCapabilitiesResponse\022>\n\014capabi" + - "lities\030\001 \003(\0162(.SecurityCapabilitiesRespo" + - "nse.Capability\"\202\001\n\nCapability\022\031\n\025SIMPLE_" + - "AUTHENTICATION\020\000\022\031\n\025SECURE_AUTHENTICATIO" + - "N\020\001\022\021\n\rAUTHORIZATION\020\002\022\026\n\022CELL_AUTHORIZA" + - "TION\020\003\022\023\n\017CELL_VISIBILITY\020\0042\322\030\n\rMasterSe" + - "rvice\022S\n\024GetSchemaAlterStatus\022\034.GetSchem" + - "aAlterStatusRequest\032\035.GetSchemaAlterStat" + - "usResponse\022P\n\023GetTableDescriptors\022\033.GetT", - "ableDescriptorsRequest\032\034.GetTableDescrip" + - "torsResponse\022>\n\rGetTableNames\022\025.GetTable" + - "NamesRequest\032\026.GetTableNamesResponse\022G\n\020" + - "GetClusterStatus\022\030.GetClusterStatusReque" + - "st\032\031.GetClusterStatusResponse\022D\n\017IsMaste" + - "rRunning\022\027.IsMasterRunningRequest\032\030.IsMa" + - "sterRunningResponse\0222\n\tAddColumn\022\021.AddCo" + - "lumnRequest\032\022.AddColumnResponse\022;\n\014Delet" + - "eColumn\022\024.DeleteColumnRequest\032\025.DeleteCo" + - "lumnResponse\022;\n\014ModifyColumn\022\024.ModifyCol", - "umnRequest\032\025.ModifyColumnResponse\0225\n\nMov" + - "eRegion\022\022.MoveRegionRequest\032\023.MoveRegion" + - "Response\022Y\n\026DispatchMergingRegions\022\036.Dis" + - "patchMergingRegionsRequest\032\037.DispatchMer" + - "gingRegionsResponse\022;\n\014AssignRegion\022\024.As" + - "signRegionRequest\032\025.AssignRegionResponse" + - "\022A\n\016UnassignRegion\022\026.UnassignRegionReque" + - "st\032\027.UnassignRegionResponse\022>\n\rOfflineRe" + - "gion\022\025.OfflineRegionRequest\032\026.OfflineReg" + - "ionResponse\0228\n\013DeleteTable\022\023.DeleteTable", - "Request\032\024.DeleteTableResponse\0228\n\013EnableT" + - "able\022\023.EnableTableRequest\032\024.EnableTableR" + - "esponse\022;\n\014DisableTable\022\024.DisableTableRe" + - "quest\032\025.DisableTableResponse\0228\n\013ModifyTa" + - "ble\022\023.ModifyTableRequest\032\024.ModifyTableRe" + - "sponse\0228\n\013CreateTable\022\023.CreateTableReque" + - "st\032\024.CreateTableResponse\022/\n\010Shutdown\022\020.S" + - "hutdownRequest\032\021.ShutdownResponse\0225\n\nSto" + - "pMaster\022\022.StopMasterRequest\032\023.StopMaster" + - "Response\022,\n\007Balance\022\017.BalanceRequest\032\020.B", - "alanceResponse\022M\n\022SetBalancerRunning\022\032.S" + - "etBalancerRunningRequest\032\033.SetBalancerRu" + - "nningResponse\022J\n\021IsBalancerEnabled\022\031.IsB" + - "alancerEnabledRequest\032\032.IsBalancerEnable" + - "dResponse\022A\n\016RunCatalogScan\022\026.RunCatalog" + - "ScanRequest\032\027.RunCatalogScanResponse\022S\n\024" + - "EnableCatalogJanitor\022\034.EnableCatalogJani" + - "torRequest\032\035.EnableCatalogJanitorRespons" + - "e\022\\\n\027IsCatalogJanitorEnabled\022\037.IsCatalog" + - "JanitorEnabledRequest\032 .IsCatalogJanitor", - "EnabledResponse\022L\n\021ExecMasterService\022\032.C" + - "oprocessorServiceRequest\032\033.CoprocessorSe" + - "rviceResponse\022/\n\010Snapshot\022\020.SnapshotRequ" + - "est\032\021.SnapshotResponse\022V\n\025GetCompletedSn" + - "apshots\022\035.GetCompletedSnapshotsRequest\032\036" + - ".GetCompletedSnapshotsResponse\022A\n\016Delete" + - "Snapshot\022\026.DeleteSnapshotRequest\032\027.Delet" + - "eSnapshotResponse\022A\n\016IsSnapshotDone\022\026.Is" + - "SnapshotDoneRequest\032\027.IsSnapshotDoneResp" + - "onse\022D\n\017RestoreSnapshot\022\027.RestoreSnapsho", - "tRequest\032\030.RestoreSnapshotResponse\022V\n\025Is" + - "RestoreSnapshotDone\022\035.IsRestoreSnapshotD" + - "oneRequest\032\036.IsRestoreSnapshotDoneRespon" + - "se\022>\n\rExecProcedure\022\025.ExecProcedureReque" + - "st\032\026.ExecProcedureResponse\022D\n\017IsProcedur" + - "eDone\022\027.IsProcedureDoneRequest\032\030.IsProce" + - "dureDoneResponse\022D\n\017ModifyNamespace\022\027.Mo" + - "difyNamespaceRequest\032\030.ModifyNamespaceRe" + - "sponse\022D\n\017CreateNamespace\022\027.CreateNamesp" + - "aceRequest\032\030.CreateNamespaceResponse\022D\n\017", - "DeleteNamespace\022\027.DeleteNamespaceRequest" + - "\032\030.DeleteNamespaceResponse\022Y\n\026GetNamespa" + - "ceDescriptor\022\036.GetNamespaceDescriptorReq" + - "uest\032\037.GetNamespaceDescriptorResponse\022_\n" + - "\030ListNamespaceDescriptors\022 .ListNamespac" + - "eDescriptorsRequest\032!.ListNamespaceDescr" + - "iptorsResponse\022t\n\037ListTableDescriptorsBy" + - "Namespace\022\'.ListTableDescriptorsByNamesp" + - "aceRequest\032(.ListTableDescriptorsByNames" + - "paceResponse\022b\n\031ListTableNamesByNamespac", - "e\022!.ListTableNamesByNamespaceRequest\032\".L" + - "istTableNamesByNamespaceResponse\022>\n\rtrun" + - "cateTable\022\025.TruncateTableRequest\032\026.Trunc" + - "ateTableResponse\022V\n\027getSecurityCapabilit" + - "ies\022\034.SecurityCapabilitiesRequest\032\035.Secu" + - "rityCapabilitiesResponseBB\n*org.apache.h" + - "adoop.hbase.protobuf.generatedB\014MasterPr" + - "otosH\001\210\001\001\240\001\001" + "gions\030\001 \001(\r\022\025\n\rtotal_regions\030\002 \001(\r\"\202\001\n\032G" + + "etTableDescriptorsRequest\022\037\n\013table_names" + + "\030\001 \003(\0132\n.TableName\022\r\n\005regex\030\002 \001(\t\022!\n\022inc" + + "lude_sys_tables\030\003 \001(\010:\005false\022\021\n\tnamespac" + + "e\030\004 \001(\t\"A\n\033GetTableDescriptorsResponse\022\"" + + "\n\014table_schema\030\001 \003(\0132\014.TableSchema\"[\n\024Ge" + + "tTableNamesRequest\022\r\n\005regex\030\001 \001(\t\022!\n\022inc" + + "lude_sys_tables\030\002 \001(\010:\005false\022\021\n\tnamespac" + + "e\030\003 \001(\t\"8\n\025GetTableNamesResponse\022\037\n\013tabl" + + "e_names\030\001 \003(\0132\n.TableName\"\031\n\027GetClusterS", + "tatusRequest\"B\n\030GetClusterStatusResponse" + + "\022&\n\016cluster_status\030\001 \002(\0132\016.ClusterStatus" + + "\"\030\n\026IsMasterRunningRequest\"4\n\027IsMasterRu" + + "nningResponse\022\031\n\021is_master_running\030\001 \002(\010" + + "\"@\n\024ExecProcedureRequest\022(\n\tprocedure\030\001 " + + "\002(\0132\025.ProcedureDescription\"1\n\025ExecProced" + + "ureResponse\022\030\n\020expected_timeout\030\001 \002(\003\"B\n" + + "\026IsProcedureDoneRequest\022(\n\tprocedure\030\001 \001" + + "(\0132\025.ProcedureDescription\"W\n\027IsProcedure" + + "DoneResponse\022\023\n\004done\030\001 \001(\010:\005false\022\'\n\010sna", + "pshot\030\002 \001(\0132\025.ProcedureDescription\"T\n\024Tr" + + "uncateTableRequest\022\035\n\ttableName\030\001 \002(\0132\n." + + "TableName\022\035\n\016preserveSplits\030\002 \001(\010:\005false" + + "\"\027\n\025TruncateTableResponse\"\035\n\033SecurityCap" + + "abilitiesRequest\"\343\001\n\034SecurityCapabilitie" + + "sResponse\022>\n\014capabilities\030\001 \003(\0162(.Securi" + + "tyCapabilitiesResponse.Capability\"\202\001\n\nCa" + + "pability\022\031\n\025SIMPLE_AUTHENTICATION\020\000\022\031\n\025S" + + "ECURE_AUTHENTICATION\020\001\022\021\n\rAUTHORIZATION\020" + + "\002\022\026\n\022CELL_AUTHORIZATION\020\003\022\023\n\017CELL_VISIBI", + "LITY\020\0042\322\030\n\rMasterService\022S\n\024GetSchemaAlt" + + "erStatus\022\034.GetSchemaAlterStatusRequest\032\035" + + ".GetSchemaAlterStatusResponse\022P\n\023GetTabl" + + "eDescriptors\022\033.GetTableDescriptorsReques" + + "t\032\034.GetTableDescriptorsResponse\022>\n\rGetTa" + + "bleNames\022\025.GetTableNamesRequest\032\026.GetTab" + + "leNamesResponse\022G\n\020GetClusterStatus\022\030.Ge" + + "tClusterStatusRequest\032\031.GetClusterStatus" + + "Response\022D\n\017IsMasterRunning\022\027.IsMasterRu" + + "nningRequest\032\030.IsMasterRunningResponse\0222", + "\n\tAddColumn\022\021.AddColumnRequest\032\022.AddColu" + + "mnResponse\022;\n\014DeleteColumn\022\024.DeleteColum" + + "nRequest\032\025.DeleteColumnResponse\022;\n\014Modif" + + "yColumn\022\024.ModifyColumnRequest\032\025.ModifyCo" + + "lumnResponse\0225\n\nMoveRegion\022\022.MoveRegionR" + + "equest\032\023.MoveRegionResponse\022Y\n\026DispatchM" + + "ergingRegions\022\036.DispatchMergingRegionsRe" + + "quest\032\037.DispatchMergingRegionsResponse\022;" + + "\n\014AssignRegion\022\024.AssignRegionRequest\032\025.A" + + "ssignRegionResponse\022A\n\016UnassignRegion\022\026.", + "UnassignRegionRequest\032\027.UnassignRegionRe" + + "sponse\022>\n\rOfflineRegion\022\025.OfflineRegionR" + + "equest\032\026.OfflineRegionResponse\0228\n\013Delete" + + "Table\022\023.DeleteTableRequest\032\024.DeleteTable" + + "Response\0228\n\013EnableTable\022\023.EnableTableReq" + + "uest\032\024.EnableTableResponse\022;\n\014DisableTab" + + "le\022\024.DisableTableRequest\032\025.DisableTableR" + + "esponse\0228\n\013ModifyTable\022\023.ModifyTableRequ" + + "est\032\024.ModifyTableResponse\0228\n\013CreateTable" + + "\022\023.CreateTableRequest\032\024.CreateTableRespo", + "nse\022/\n\010Shutdown\022\020.ShutdownRequest\032\021.Shut" + + "downResponse\0225\n\nStopMaster\022\022.StopMasterR" + + "equest\032\023.StopMasterResponse\022,\n\007Balance\022\017" + + ".BalanceRequest\032\020.BalanceResponse\022M\n\022Set" + + "BalancerRunning\022\032.SetBalancerRunningRequ" + + "est\032\033.SetBalancerRunningResponse\022J\n\021IsBa" + + "lancerEnabled\022\031.IsBalancerEnabledRequest" + + "\032\032.IsBalancerEnabledResponse\022A\n\016RunCatal" + + "ogScan\022\026.RunCatalogScanRequest\032\027.RunCata" + + "logScanResponse\022S\n\024EnableCatalogJanitor\022", + "\034.EnableCatalogJanitorRequest\032\035.EnableCa" + + "talogJanitorResponse\022\\\n\027IsCatalogJanitor" + + "Enabled\022\037.IsCatalogJanitorEnabledRequest" + + "\032 .IsCatalogJanitorEnabledResponse\022L\n\021Ex" + + "ecMasterService\022\032.CoprocessorServiceRequ" + + "est\032\033.CoprocessorServiceResponse\022/\n\010Snap" + + "shot\022\020.SnapshotRequest\032\021.SnapshotRespons" + + "e\022V\n\025GetCompletedSnapshots\022\035.GetComplete" + + "dSnapshotsRequest\032\036.GetCompletedSnapshot" + + "sResponse\022A\n\016DeleteSnapshot\022\026.DeleteSnap", + "shotRequest\032\027.DeleteSnapshotResponse\022A\n\016" + + "IsSnapshotDone\022\026.IsSnapshotDoneRequest\032\027" + + ".IsSnapshotDoneResponse\022D\n\017RestoreSnapsh" + + "ot\022\027.RestoreSnapshotRequest\032\030.RestoreSna" + + "pshotResponse\022V\n\025IsRestoreSnapshotDone\022\035" + + ".IsRestoreSnapshotDoneRequest\032\036.IsRestor" + + "eSnapshotDoneResponse\022>\n\rExecProcedure\022\025" + + ".ExecProcedureRequest\032\026.ExecProcedureRes" + + "ponse\022D\n\017IsProcedureDone\022\027.IsProcedureDo" + + "neRequest\032\030.IsProcedureDoneResponse\022D\n\017M", + "odifyNamespace\022\027.ModifyNamespaceRequest\032" + + "\030.ModifyNamespaceResponse\022D\n\017CreateNames" + + "pace\022\027.CreateNamespaceRequest\032\030.CreateNa" + + "mespaceResponse\022D\n\017DeleteNamespace\022\027.Del" + + "eteNamespaceRequest\032\030.DeleteNamespaceRes" + + "ponse\022Y\n\026GetNamespaceDescriptor\022\036.GetNam" + + "espaceDescriptorRequest\032\037.GetNamespaceDe" + + "scriptorResponse\022_\n\030ListNamespaceDescrip" + + "tors\022 .ListNamespaceDescriptorsRequest\032!" + + ".ListNamespaceDescriptorsResponse\022t\n\037Lis", + "tTableDescriptorsByNamespace\022\'.ListTable" + + "DescriptorsByNamespaceRequest\032(.ListTabl" + + "eDescriptorsByNamespaceResponse\022b\n\031ListT" + + "ableNamesByNamespace\022!.ListTableNamesByN" + + "amespaceRequest\032\".ListTableNamesByNamesp" + + "aceResponse\022>\n\rtruncateTable\022\025.TruncateT" + + "ableRequest\032\026.TruncateTableResponse\022V\n\027g" + + "etSecurityCapabilities\022\034.SecurityCapabil" + + "itiesRequest\032\035.SecurityCapabilitiesRespo" + + "nseBB\n*org.apache.hadoop.hbase.protobuf.", + "generatedB\014MasterProtosH\001\210\001\001\240\001\001" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { @@ -47046,7 +47898,7 @@ public final class MasterProtos { internal_static_GetTableDescriptorsRequest_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_GetTableDescriptorsRequest_descriptor, - new java.lang.String[] { "TableNames", }); + new java.lang.String[] { "TableNames", "Regex", "IncludeSysTables", "Namespace", }); internal_static_GetTableDescriptorsResponse_descriptor = getDescriptor().getMessageTypes().get(71); internal_static_GetTableDescriptorsResponse_fieldAccessorTable = new @@ -47058,7 +47910,7 @@ public final class MasterProtos { internal_static_GetTableNamesRequest_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_GetTableNamesRequest_descriptor, - new java.lang.String[] { }); + new java.lang.String[] { "Regex", "IncludeSysTables", "Namespace", }); internal_static_GetTableNamesResponse_descriptor = getDescriptor().getMessageTypes().get(73); internal_static_GetTableNamesResponse_fieldAccessorTable = new diff --git a/hbase-protocol/src/main/protobuf/Master.proto b/hbase-protocol/src/main/protobuf/Master.proto index 7400e10..68aab8c 100644 --- a/hbase-protocol/src/main/protobuf/Master.proto +++ b/hbase-protocol/src/main/protobuf/Master.proto @@ -312,6 +312,9 @@ message GetSchemaAlterStatusResponse { message GetTableDescriptorsRequest { repeated TableName table_names = 1; + optional string regex = 2; + optional bool include_sys_tables = 3 [default=false]; + optional string namespace = 4; } message GetTableDescriptorsResponse { @@ -319,6 +322,9 @@ message GetTableDescriptorsResponse { } message GetTableNamesRequest { + optional string regex = 1; + optional bool include_sys_tables = 2 [default=false]; + optional string namespace = 3; } message GetTableNamesResponse { diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseMasterAndRegionObserver.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseMasterAndRegionObserver.java index 1aff956..d828c56 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseMasterAndRegionObserver.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseMasterAndRegionObserver.java @@ -136,6 +136,26 @@ public abstract class BaseMasterAndRegionObserver extends BaseRegionObserver } @Override + public void preGetNamespaceDescriptor(ObserverContext ctx, + String namespace) throws IOException { + } + + @Override + public void postGetNamespaceDescriptor(ObserverContext ctx, + NamespaceDescriptor ns) throws IOException { + } + + @Override + public void preListNamespaceDescriptors(ObserverContext ctx, + List descriptors) throws IOException { + } + + @Override + public void postListNamespaceDescriptors(ObserverContext ctx, + List descriptors) throws IOException { + } + + @Override public void preAddColumn(ObserverContext ctx, TableName tableName, HColumnDescriptor column) throws IOException { } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseMasterObserver.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseMasterObserver.java index 29be365..03204ec 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseMasterObserver.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseMasterObserver.java @@ -151,6 +151,26 @@ public class BaseMasterObserver implements MasterObserver { } @Override + public void preGetNamespaceDescriptor(ObserverContext ctx, + String namespace) throws IOException { + } + + @Override + public void postGetNamespaceDescriptor(ObserverContext ctx, + NamespaceDescriptor ns) throws IOException { + } + + @Override + public void preListNamespaceDescriptors(ObserverContext ctx, + List descriptors) throws IOException { + } + + @Override + public void postListNamespaceDescriptors(ObserverContext ctx, + List descriptors) throws IOException { + } + + @Override public void preAddColumn(ObserverContext ctx, TableName tableName, HColumnDescriptor column) throws IOException { } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MasterObserver.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MasterObserver.java index d6cb609..7ea1376 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MasterObserver.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MasterObserver.java @@ -740,4 +740,41 @@ public interface MasterObserver extends Coprocessor { */ void postModifyNamespace(final ObserverContext ctx, NamespaceDescriptor ns) throws IOException; + + /** + * Called before a getNamespaceDescriptor request has been processed. + * @param ctx the environment to interact with the framework and master + * @param namespace the name of the namespace + * @throws IOException + */ + void preGetNamespaceDescriptor(ObserverContext ctx, + String namespace) throws IOException; + + /** + * Called after a getNamespaceDescriptor request has been processed. + * @param ctx the environment to interact with the framework and master + * @param ns the NamespaceDescriptor + * @throws IOException + */ + void postGetNamespaceDescriptor(ObserverContext ctx, + NamespaceDescriptor ns) throws IOException; + + /** + * Called before a listNamespaceDescriptors 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 + * @throws IOException + */ + void preListNamespaceDescriptors(ObserverContext ctx, + List descriptors) throws IOException; + + /** + * Called after a listNamespaceDescriptors 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 + * @throws IOException + */ + void postListNamespaceDescriptors(ObserverContext ctx, + List descriptors) throws IOException; + } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java index dc862a9..071104b 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -29,6 +29,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -38,6 +39,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; +import java.util.regex.Pattern; import javax.management.ObjectName; @@ -262,6 +264,7 @@ import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.Watcher; import com.google.common.collect.Lists; +import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Maps; import com.google.protobuf.Descriptors; import com.google.protobuf.Message; @@ -1232,11 +1235,6 @@ MasterServices, Server { return result; } - @Override - public TableDescriptors getTableDescriptors() { - return this.tableDescriptors; - } - /** @return InfoServer object. Maybe null.*/ public InfoServer getInfoServer() { return this.infoServer; @@ -1248,6 +1246,11 @@ MasterServices, Server { } @Override + public TableDescriptors getTableDescriptors() { + return this.tableDescriptors; + } + + @Override public ServerManager getServerManager() { return this.serverManager; } @@ -1852,7 +1855,7 @@ MasterServices, Server { } String namespace = hTableDescriptor.getTableName().getNamespaceAsString(); - getNamespaceDescriptor(namespace); // ensure namespace exists + ensureNamespaceExists(namespace); HRegionInfo[] newRegions = getHRegionInfos(hTableDescriptor, splitKeys); checkInitialized(); @@ -3521,39 +3524,80 @@ MasterServices, Server { } } - @Override - public NamespaceDescriptor getNamespaceDescriptor(String name) throws IOException { + private void checkNamespaceManagerReady() throws IOException { boolean ready = tableNamespaceManager != null && tableNamespaceManager.isTableAvailableAndInitialized(); if (!ready) { throw new IOException("Table Namespace Manager not ready yet, try again later"); } + } + + /** + * Ensure that the specified namespace exists, otherwise throws a NamespaceNotFoundException + * + * @param name the namespace to check + * @throws IOException if the namespace manager is not ready yet. + * @throws NamespaceNotFoundException if the namespace does not exists + */ + private void ensureNamespaceExists(final String name) + throws IOException, NamespaceNotFoundException { + checkNamespaceManagerReady(); NamespaceDescriptor nsd = tableNamespaceManager.get(name); if (nsd == null) { throw new NamespaceNotFoundException(name); } + } + + @Override + public NamespaceDescriptor getNamespaceDescriptor(String name) throws IOException { + checkNamespaceManagerReady(); + + if (cpHost != null) { + cpHost.preGetNamespaceDescriptor(name); + } + + NamespaceDescriptor nsd = tableNamespaceManager.get(name); + if (nsd == null) { + throw new NamespaceNotFoundException(name); + } + + if (cpHost != null) { + cpHost.postGetNamespaceDescriptor(nsd); + } + return nsd; } @Override public List listNamespaceDescriptors() throws IOException { - return Lists.newArrayList(tableNamespaceManager.list()); + checkNamespaceManagerReady(); + + final List descriptors = new ArrayList(); + boolean bypass = false; + if (cpHost != null) { + bypass = cpHost.preListNamespaceDescriptors(descriptors); + } + + if (!bypass) { + descriptors.addAll(tableNamespaceManager.list()); + + if (cpHost != null) { + cpHost.postListNamespaceDescriptors(descriptors); + } + } + return descriptors; } @Override public List listTableDescriptorsByNamespace(String name) throws IOException { - getNamespaceDescriptor(name); // check that namespace exists - return Lists.newArrayList(tableDescriptors.getByNamespace(name).values()); + ensureNamespaceExists(name); + return listTableDescriptors(name, null, null, true); } @Override public List listTableNamesByNamespace(String name) throws IOException { - List tableNames = Lists.newArrayList(); - getNamespaceDescriptor(name); // check that namespace exists - for (HTableDescriptor descriptor: tableDescriptors.getByNamespace(name).values()) { - tableNames.add(descriptor.getTableName()); - } - return tableNames; + ensureNamespaceExists(name); + return listTableNames(name, null, true); } @Override @@ -3599,7 +3643,6 @@ MasterServices, Server { } } - @Override public TruncateTableResponse truncateTable(RpcController controller, TruncateTableRequest request) throws ServiceException { @@ -3620,6 +3663,119 @@ MasterServices, Server { } /** + * Returns the list of table descriptors that match the specified request + * + * @param namespace the namespace to query, or null if querying for all + * @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 listTableDescriptors(final String namespace, final String regex, + final List tableNameList, final boolean includeSysTables) + throws IOException { + final List descriptors = new ArrayList(); + + boolean bypass = false; + if (cpHost != null) { + bypass = cpHost.preGetTableDescriptors(tableNameList, descriptors); + } + + if (!bypass) { + if (tableNameList == null || tableNameList.size() == 0) { + // request for all TableDescriptors + Collection htds; + if (namespace != null && namespace.length() > 0) { + htds = tableDescriptors.getByNamespace(namespace).values(); + } else { + 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(descriptors); + } + } + 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 namespace the namespace to query, or null if querying for all + * @param includeSysTables False to match only against userspace tables + * @return the list of table names + */ + public List listTableNames(final String namespace, final String regex, + final boolean includeSysTables) throws IOException { + final List descriptors = new ArrayList(); + // get all descriptors + Collection htds; + if (namespace != null && namespace.length() > 0) { + htds = tableDescriptors.getByNamespace(namespace).values(); + } else { + 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)); + } + + List 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 descriptors, + final Pattern pattern) { + final String defaultNS = NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR; + Iterator 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(); + } + } + } + + /** * Queries the state of the {@link LoadBalancerTracker}. If the balancer is not initialized, * false is returned. * @@ -3679,4 +3835,5 @@ MasterServices, Server { } return response.build(); } + } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java index b431c7c..f585bb7 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java @@ -160,6 +160,50 @@ public class MasterCoprocessorHost }); } + public void preGetNamespaceDescriptor(final String namespaceName) + throws IOException { + execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() { + @Override + public void call(MasterObserver oserver, ObserverContext ctx) + throws IOException { + oserver.preGetNamespaceDescriptor(ctx, namespaceName); + } + }); + } + + public void postGetNamespaceDescriptor(final NamespaceDescriptor ns) + throws IOException { + execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() { + @Override + public void call(MasterObserver oserver, ObserverContext ctx) + throws IOException { + oserver.postGetNamespaceDescriptor(ctx, ns); + } + }); + } + + public boolean preListNamespaceDescriptors(final List descriptors) + throws IOException { + return execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() { + @Override + public void call(MasterObserver oserver, ObserverContext ctx) + throws IOException { + oserver.preListNamespaceDescriptors(ctx, descriptors); + } + }); + } + + public void postListNamespaceDescriptors(final List descriptors) + throws IOException { + execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() { + @Override + public void call(MasterObserver oserver, ObserverContext ctx) + throws IOException { + oserver.postListNamespaceDescriptors(ctx, descriptors); + } + }); + } + /* Implementation of hooks for invoking MasterObservers */ public void preCreateTable(final HTableDescriptor htd, final HRegionInfo[] regions) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java index 742d6e3..eaf1521 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java @@ -523,8 +523,7 @@ public class AccessController extends BaseMasterAndRegionObserver private void requireGlobalPermission(String request, Action perm, TableName tableName, Map> familyMap) throws IOException { User user = getActiveUser(); - if (authManager.authorize(user, perm) || (tableName != null && - authManager.authorize(user, tableName.getNamespaceAsString(), perm))) { + if (authManager.authorize(user, perm)) { logResult(AuthResult.allow(request, "Global check allowed", user, perm, tableName, familyMap)); } else { logResult(AuthResult.deny(request, "Global check failed", user, perm, tableName, familyMap)); @@ -546,8 +545,7 @@ public class AccessController extends BaseMasterAndRegionObserver private void requireGlobalPermission(String request, Action perm, String namespace) throws IOException { User user = getActiveUser(); - if (authManager.authorize(user, perm) - || (namespace != null && authManager.authorize(user, namespace, perm))) { + if (authManager.authorize(user, perm)) { logResult(AuthResult.allow(request, "Global check allowed", user, perm, namespace)); } else { logResult(AuthResult.deny(request, "Global check failed", user, perm, namespace)); @@ -920,7 +918,7 @@ public class AccessController extends BaseMasterAndRegionObserver } /* ---- MasterObserver implementation ---- */ - + @Override public void start(CoprocessorEnvironment env) throws IOException { CompoundConfiguration conf = new CompoundConfiguration(); conf.add(env.getConfiguration()); @@ -981,6 +979,7 @@ public class AccessController extends BaseMasterAndRegionObserver tableAcls = new MapMaker().weakValues().makeMap(); } + @Override public void stop(CoprocessorEnvironment env) { if (this.authManager != null) { TableAuthManager.release(authManager); @@ -1039,7 +1038,7 @@ public class AccessController extends BaseMasterAndRegionObserver for (byte[] family: families) { familyMap.put(family, null); } - requireGlobalPermission("createTable", Action.CREATE, desc.getTableName(), familyMap); + requireNamespacePermission("createTable", desc.getTableName().getNamespaceAsString(), Action.CREATE); } @Override @@ -1274,7 +1273,7 @@ public class AccessController extends BaseMasterAndRegionObserver @Override public void preCreateNamespace(ObserverContext ctx, NamespaceDescriptor ns) throws IOException { - requirePermission("createNamespace", Action.ADMIN); + requireGlobalPermission("createNamespace", Action.ADMIN, ns.getName()); } @Override @@ -1301,9 +1300,33 @@ public class AccessController extends BaseMasterAndRegionObserver @Override public void preModifyNamespace(ObserverContext ctx, NamespaceDescriptor ns) throws IOException { + // We require only global permission so that + // a user with NS admin cannot altering namespace configurations. i.e. namespace quota requireGlobalPermission("modifyNamespace", Action.ADMIN, ns.getName()); } + @Override + public void preGetNamespaceDescriptor(ObserverContext ctx, String namespace) + throws IOException { + requireNamespacePermission("getNamespaceDescriptor", namespace, Action.ADMIN); + } + + @Override + public void postListNamespaceDescriptors(ObserverContext ctx, + List descriptors) throws IOException { + // Retains only those which passes authorization checks, as the checks weren't done as part + // of preGetTableDescriptors. + Iterator itr = descriptors.iterator(); + while (itr.hasNext()) { + NamespaceDescriptor desc = itr.next(); + try { + requireNamespacePermission("listNamespaces", desc.getName(), Action.ADMIN); + } catch (AccessDeniedException e) { + itr.remove(); + } + } + } + /* ---- RegionObserver implementation ---- */ @Override @@ -2129,7 +2152,7 @@ public class AccessController extends BaseMasterAndRegionObserver perm.getQualifier(), Action.ADMIN); break; case Namespace : - requireGlobalPermission("grant", Action.ADMIN, perm.getNamespace()); + requireNamespacePermission("grant", perm.getNamespace(), Action.ADMIN); break; } @@ -2180,7 +2203,7 @@ public class AccessController extends BaseMasterAndRegionObserver perm.getQualifier(), Action.ADMIN); break; case Namespace : - requireGlobalPermission("revoke", Action.ADMIN, perm.getNamespace()); + requireNamespacePermission("revoke", perm.getNamespace(), Action.ADMIN); break; } @@ -2232,7 +2255,7 @@ public class AccessController extends BaseMasterAndRegionObserver }); } else if (request.getType() == AccessControlProtos.Permission.Type.Namespace) { final String namespace = request.getNamespaceName().toStringUtf8(); - requireGlobalPermission("userPermissions", Action.ADMIN, namespace); + requireNamespacePermission("userPermissions", namespace, Action.ADMIN); perms = User.runAsLoginUser(new PrivilegedExceptionAction>() { @Override public List run() throws Exception { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java index bbabf3a..20ab627 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java @@ -82,6 +82,10 @@ public class TestMasterObserver { private boolean postDeleteNamespaceCalled; private boolean preModifyNamespaceCalled; private boolean postModifyNamespaceCalled; + private boolean preGetNamespaceDescriptorCalled; + private boolean postGetNamespaceDescriptorCalled; + private boolean preListNamespaceDescriptorsCalled; + private boolean postListNamespaceDescriptorsCalled; private boolean preAddColumnCalled; private boolean postAddColumnCalled; private boolean preModifyColumnCalled; @@ -158,6 +162,10 @@ public class TestMasterObserver { postDeleteNamespaceCalled = false; preModifyNamespaceCalled = false; postModifyNamespaceCalled = false; + preGetNamespaceDescriptorCalled = false; + postGetNamespaceDescriptorCalled = false; + preListNamespaceDescriptorsCalled = false; + postListNamespaceDescriptorsCalled = false; preAddColumnCalled = false; postAddColumnCalled = false; preModifyColumnCalled = false; @@ -375,6 +383,46 @@ public class TestMasterObserver { return preModifyNamespaceCalled && !postModifyNamespaceCalled; } + + @Override + public void preGetNamespaceDescriptor(ObserverContext ctx, + String namespace) throws IOException { + preGetNamespaceDescriptorCalled = true; + } + + @Override + public void postGetNamespaceDescriptor(ObserverContext ctx, + NamespaceDescriptor ns) throws IOException { + postGetNamespaceDescriptorCalled = true; + } + + public boolean wasGetNamespaceDescriptorCalled() { + return preGetNamespaceDescriptorCalled && postGetNamespaceDescriptorCalled; + } + + @Override + public void preListNamespaceDescriptors(ObserverContext env, + List descriptors) throws IOException { + if (bypass) { + env.bypass(); + } + preListNamespaceDescriptorsCalled = true; + } + + @Override + public void postListNamespaceDescriptors(ObserverContext env, + List descriptors) throws IOException { + postListNamespaceDescriptorsCalled = true; + } + + public boolean wasListNamespaceDescriptorsCalled() { + return preListNamespaceDescriptorsCalled && postListNamespaceDescriptorsCalled; + } + + public boolean preListNamespaceDescriptorsCalledOnly() { + return preListNamespaceDescriptorsCalled && !postListNamespaceDescriptorsCalled; + } + @Override public void preAddColumn(ObserverContext env, TableName tableName, HColumnDescriptor column) throws IOException { @@ -1281,6 +1329,8 @@ public class TestMasterObserver { assertTrue("Test namespace should be created", cp.wasCreateNamespaceCalled()); assertNotNull(admin.getNamespaceDescriptor(testNamespace)); + assertTrue("Test namespace descriptor should have been called", + cp.wasGetNamespaceDescriptorCalled()); // turn off bypass, run the tests again cp.enableBypass(true); @@ -1291,11 +1341,15 @@ public class TestMasterObserver { cp.preModifyNamespaceCalledOnly()); assertNotNull(admin.getNamespaceDescriptor(testNamespace)); + assertTrue("Test namespace descriptor should have been called", + cp.wasGetNamespaceDescriptorCalled()); admin.deleteNamespace(testNamespace); assertTrue("Test namespace should not have been deleted", cp.preDeleteNamespaceCalledOnly()); assertNotNull(admin.getNamespaceDescriptor(testNamespace)); + assertTrue("Test namespace descriptor should have been called", + cp.wasGetNamespaceDescriptorCalled()); cp.enableBypass(false); cp.resetStates(); @@ -1312,6 +1366,22 @@ public class TestMasterObserver { admin.createNamespace(NamespaceDescriptor.create(testNamespace).build()); assertTrue("Test namespace should not be created", cp.preCreateNamespaceCalledOnly()); + + // turn on bypass, run the test + cp.enableBypass(true); + cp.resetStates(); + + admin.listNamespaceDescriptors(); + assertTrue("post listNamespace should not have been called", + cp.preListNamespaceDescriptorsCalledOnly()); + + // turn off bypass, run the tests again + cp.enableBypass(false); + cp.resetStates(); + + admin.listNamespaceDescriptors(); + assertTrue("post listNamespace should have been called", + cp.wasListNamespaceDescriptorsCalled()); } private void modifyTableSync(HBaseAdmin admin, TableName tableName, HTableDescriptor htd) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java index 60b3e46..d5d47ca 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java @@ -302,6 +302,9 @@ public class TestAccessController extends SecureTestUtil { LOG.info("Test deleted table " + TEST_TABLE); } assertEquals(0, AccessControlLists.getTablePermissions(conf, TEST_TABLE).size()); + // Verify all table/namespace permissions are erased + assertEquals(0, AccessControlLists.getTablePermissions(conf, TEST_TABLE).size()); + assertEquals(0, AccessControlLists.getNamespacePermissions(conf, TEST_TABLE.getNameAsString()).size()); } @Test diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestNamespaceCommands.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestNamespaceCommands.java index f80bceb..dad1990 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestNamespaceCommands.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestNamespaceCommands.java @@ -22,7 +22,11 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.List; +import java.util.Arrays; +import java.util.Map; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HColumnDescriptor; @@ -33,6 +37,7 @@ import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.Get; +import org.apache.hadoop.hbase.client.HBaseAdmin; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment; import org.apache.hadoop.hbase.coprocessor.ObserverContext; @@ -52,6 +57,7 @@ import com.google.protobuf.BlockingRpcChannel; @Category(MediumTests.class) public class TestNamespaceCommands extends SecureTestUtil { private static HBaseTestingUtility UTIL = new HBaseTestingUtility(); + private static final Log LOG = LogFactory.getLog(TestNamespaceCommands.class); private static String TEST_NAMESPACE = "ns1"; private static String TEST_NAMESPACE2 = "ns2"; private static Configuration conf; @@ -60,21 +66,42 @@ public class TestNamespaceCommands extends SecureTestUtil { // user with all permissions private static User SUPERUSER; + + // user with A permission on global + private static User USER_GLOBAL_ADMIN; + // user with C permission on global + private static User USER_GLOBAL_CREATE; + // user with W permission on global + private static User USER_GLOBAL_WRITE; + // user with R permission on global + private static User USER_GLOBAL_READ; + // user with X permission on global + private static User USER_GLOBAL_EXEC; + + // user with A permission on namespace + private static User USER_NS_ADMIN; + // user with C permission on namespace + private static User USER_NS_CREATE; + // user with W permission on namespace + private static User USER_NS_WRITE; + // user with R permission on namespace. + private static User USER_NS_READ; + // user with X permission on namespace. + private static User USER_NS_EXEC; + // user with rw permissions - private static User USER_RW; - // user with create table permissions alone - private static User USER_CREATE; - // user with permission on namespace for testing all operations. - private static User USER_NSP_WRITE; - // user with admin permission on namespace. - private static User USER_NSP_ADMIN; + private static User USER_TABLE_WRITE; // TODO: WE DO NOT GIVE ANY PERMS TO THIS USER + //user with create table permissions alone + private static User USER_TABLE_CREATE; // TODO: WE DO NOT GIVE ANY PERMS TO THIS USER private static final String GROUP_ADMIN = "group_admin"; + private static final String GROUP_NS_ADMIN = "group_ns_admin"; private static final String GROUP_CREATE = "group_create"; private static final String GROUP_READ = "group_read"; private static final String GROUP_WRITE = "group_write"; private static User USER_GROUP_ADMIN; + private static User USER_GROUP_NS_ADMIN; private static User USER_GROUP_CREATE; private static User USER_GROUP_READ; private static User USER_GROUP_WRITE; @@ -88,13 +115,27 @@ public class TestNamespaceCommands extends SecureTestUtil { enableSecurity(conf); SUPERUSER = User.createUserForTesting(conf, "admin", new String[] { "supergroup" }); - USER_RW = User.createUserForTesting(conf, "rw_user", new String[0]); - USER_CREATE = User.createUserForTesting(conf, "create_user", new String[0]); - USER_NSP_WRITE = User.createUserForTesting(conf, "namespace_write", new String[0]); - USER_NSP_ADMIN = User.createUserForTesting(conf, "namespace_admin", new String[0]); + // Users with global permissions + USER_GLOBAL_ADMIN = User.createUserForTesting(conf, "global_admin", new String[0]); + USER_GLOBAL_CREATE = User.createUserForTesting(conf, "global_create", new String[0]); + USER_GLOBAL_WRITE = User.createUserForTesting(conf, "global_write", new String[0]); + USER_GLOBAL_READ = User.createUserForTesting(conf, "global_read", new String[0]); + USER_GLOBAL_EXEC = User.createUserForTesting(conf, "global_exec", new String[0]); + + USER_NS_ADMIN = User.createUserForTesting(conf, "namespace_admin", new String[0]); + USER_NS_CREATE = User.createUserForTesting(conf, "namespace_create", new String[0]); + USER_NS_WRITE = User.createUserForTesting(conf, "namespace_write", new String[0]); + USER_NS_READ = User.createUserForTesting(conf, "namespace_read", new String[0]); + USER_NS_EXEC = User.createUserForTesting(conf, "namespace_exec", new String[0]); + + USER_TABLE_CREATE = User.createUserForTesting(conf, "table_create", new String[0]); + USER_TABLE_WRITE = User.createUserForTesting(conf, "table_write", new String[0]); + // TODO: other table perms USER_GROUP_ADMIN = User.createUserForTesting(conf, "user_group_admin", new String[] { GROUP_ADMIN }); + USER_GROUP_NS_ADMIN = + User.createUserForTesting(conf, "user_group_ns_admin", new String[] { GROUP_NS_ADMIN }); USER_GROUP_CREATE = User.createUserForTesting(conf, "user_group_create", new String[] { GROUP_CREATE }); USER_GROUP_READ = @@ -113,16 +154,27 @@ public class TestNamespaceCommands extends SecureTestUtil { UTIL.getHBaseAdmin().createNamespace(NamespaceDescriptor.create(TEST_NAMESPACE).build()); UTIL.getHBaseAdmin().createNamespace(NamespaceDescriptor.create(TEST_NAMESPACE2).build()); - grantOnNamespace(UTIL, USER_NSP_WRITE.getShortName(), - TEST_NAMESPACE, Permission.Action.WRITE, Permission.Action.CREATE); - - grantOnNamespace(UTIL, USER_NSP_ADMIN.getShortName(), TEST_NAMESPACE, Permission.Action.ADMIN); - grantOnNamespace(UTIL, USER_NSP_ADMIN.getShortName(), TEST_NAMESPACE2, Permission.Action.ADMIN); + // grants on global + grantGlobal(UTIL, USER_GLOBAL_ADMIN.getShortName(), Permission.Action.ADMIN); + grantGlobal(UTIL, USER_GLOBAL_CREATE.getShortName(), Permission.Action.CREATE); + grantGlobal(UTIL, USER_GLOBAL_WRITE.getShortName(), Permission.Action.WRITE); + grantGlobal(UTIL, USER_GLOBAL_READ.getShortName(), Permission.Action.READ); + grantGlobal(UTIL, USER_GLOBAL_EXEC.getShortName(), Permission.Action.EXEC); grantGlobal(UTIL, toGroupEntry(GROUP_ADMIN), Permission.Action.ADMIN); grantGlobal(UTIL, toGroupEntry(GROUP_CREATE), Permission.Action.CREATE); grantGlobal(UTIL, toGroupEntry(GROUP_READ), Permission.Action.READ); grantGlobal(UTIL, toGroupEntry(GROUP_WRITE), Permission.Action.WRITE); + + // grants on namespace + grantOnNamespace(UTIL, USER_NS_ADMIN.getShortName(), TEST_NAMESPACE, Permission.Action.ADMIN); + grantOnNamespace(UTIL, USER_NS_CREATE.getShortName(), TEST_NAMESPACE, Permission.Action.CREATE); + grantOnNamespace(UTIL, USER_NS_WRITE.getShortName(), TEST_NAMESPACE, Permission.Action.WRITE); + grantOnNamespace(UTIL, USER_NS_READ.getShortName(), TEST_NAMESPACE, Permission.Action.READ); + grantOnNamespace(UTIL, USER_NS_EXEC.getShortName(), TEST_NAMESPACE, Permission.Action.EXEC); + + grantOnNamespace(UTIL, USER_NS_ADMIN.getShortName(), TEST_NAMESPACE2, Permission.Action.ADMIN); + grantOnNamespace(UTIL, toGroupEntry(GROUP_NS_ADMIN), TEST_NAMESPACE, Permission.Action.ADMIN); } @AfterClass @@ -137,15 +189,23 @@ public class TestNamespaceCommands extends SecureTestUtil { String userTestNamespace = "userTestNsp"; HTable acl = new HTable(conf, AccessControlLists.ACL_TABLE_NAME); try { + ListMultimap perms = + AccessControlLists.getNamespacePermissions(conf, TEST_NAMESPACE); + + perms = AccessControlLists.getNamespacePermissions(conf, TEST_NAMESPACE); + for (Map.Entry entry : perms.entries()) { + LOG.debug(entry); + } + assertEquals(6, perms.size()); + // Grant and check state in ACL table grantOnNamespace(UTIL, userTestNamespace, TEST_NAMESPACE, Permission.Action.WRITE); Result result = acl.get(new Get(Bytes.toBytes(userTestNamespace))); assertTrue(result != null); - ListMultimap perms = - AccessControlLists.getNamespacePermissions(conf, TEST_NAMESPACE); - assertEquals(3, perms.size()); + perms = AccessControlLists.getNamespacePermissions(conf, TEST_NAMESPACE); + assertEquals(7, perms.size()); List namespacePerms = perms.get(userTestNamespace); assertTrue(perms.containsKey(userTestNamespace)); assertEquals(1, namespacePerms.size()); @@ -161,7 +221,7 @@ public class TestNamespaceCommands extends SecureTestUtil { Permission.Action.WRITE); perms = AccessControlLists.getNamespacePermissions(conf, TEST_NAMESPACE); - assertEquals(2, perms.size()); + assertEquals(6, perms.size()); } finally { acl.close(); } @@ -176,16 +236,28 @@ public class TestNamespaceCommands extends SecureTestUtil { return null; } }; - // verify that superuser or hbase admin can modify namespaces. - verifyAllowed(modifyNamespace, SUPERUSER, USER_NSP_ADMIN, USER_GROUP_ADMIN); - // all others should be denied - verifyDenied(modifyNamespace, USER_NSP_WRITE, USER_CREATE, USER_RW, USER_GROUP_READ, - USER_GROUP_WRITE, USER_GROUP_CREATE); + + // modifyNamespace: superuser | global(A) | NS(A) + verifyAllowed(modifyNamespace, + SUPERUSER, + USER_GLOBAL_ADMIN); + + verifyDenied(modifyNamespace, + USER_GLOBAL_CREATE, + USER_GLOBAL_WRITE, + USER_GLOBAL_READ, + USER_GLOBAL_EXEC, + USER_NS_ADMIN, + USER_NS_CREATE, + USER_NS_WRITE, + USER_NS_READ, + USER_NS_EXEC); } @Test public void testCreateAndDeleteNamespace() throws Exception { AccessTestAction createNamespace = new AccessTestAction() { + @Override public Object run() throws Exception { ACCESS_CONTROLLER.preCreateNamespace(ObserverContext.createAndPrepare(CP_ENV, null), NamespaceDescriptor.create(TEST_NAMESPACE2).build()); @@ -194,6 +266,7 @@ public class TestNamespaceCommands extends SecureTestUtil { }; AccessTestAction deleteNamespace = new AccessTestAction() { + @Override public Object run() throws Exception { ACCESS_CONTROLLER.preDeleteNamespace(ObserverContext.createAndPrepare(CP_ENV, null), TEST_NAMESPACE2); @@ -201,16 +274,111 @@ public class TestNamespaceCommands extends SecureTestUtil { } }; - // verify that only superuser can create namespaces. - verifyAllowed(createNamespace, SUPERUSER, USER_GROUP_ADMIN); - // verify that superuser or hbase admin can delete namespaces. - verifyAllowed(deleteNamespace, SUPERUSER, USER_NSP_ADMIN, USER_GROUP_ADMIN); + // createNamespace: superuser | global(A) + verifyAllowed(createNamespace, + SUPERUSER, + USER_GLOBAL_ADMIN); // all others should be denied - verifyDenied(createNamespace, USER_NSP_WRITE, USER_CREATE, USER_RW, USER_NSP_ADMIN, - USER_GROUP_READ, USER_GROUP_WRITE, USER_GROUP_CREATE); - verifyDenied(deleteNamespace, USER_NSP_WRITE, USER_CREATE, USER_RW, USER_GROUP_READ, - USER_GROUP_WRITE, USER_GROUP_CREATE); + verifyDenied(createNamespace, + USER_GLOBAL_CREATE, + USER_GLOBAL_WRITE, + USER_GLOBAL_READ, + USER_GLOBAL_EXEC, + USER_NS_ADMIN, + USER_NS_CREATE, + USER_NS_WRITE, + USER_NS_READ, + USER_NS_EXEC, + USER_TABLE_CREATE, + USER_TABLE_WRITE); + + // deleteNamespace: superuser | global(A) | NS(A) + verifyAllowed(deleteNamespace, + SUPERUSER, + USER_GLOBAL_ADMIN); + + verifyDenied(deleteNamespace, + USER_GLOBAL_CREATE, + USER_GLOBAL_WRITE, + USER_GLOBAL_READ, + USER_GLOBAL_EXEC, + USER_NS_ADMIN, + USER_NS_CREATE, + USER_NS_WRITE, + USER_NS_READ, + USER_NS_EXEC, + USER_TABLE_CREATE, + USER_TABLE_WRITE); + } + + @Test + public void testGetNamespaceDescriptor() throws Exception { + AccessTestAction getNamespaceAction = new AccessTestAction() { + @Override + public Object run() throws Exception { + ACCESS_CONTROLLER.preGetNamespaceDescriptor(ObserverContext.createAndPrepare(CP_ENV, null), + TEST_NAMESPACE); + return null; + } + }; + // getNamespaceDescriptor : superuser | global(A) | NS(A) + verifyAllowed(getNamespaceAction, + SUPERUSER, + USER_GLOBAL_ADMIN, + USER_NS_ADMIN); + + verifyDenied(getNamespaceAction, + USER_GLOBAL_CREATE, + USER_GLOBAL_WRITE, + USER_GLOBAL_READ, + USER_GLOBAL_EXEC, + USER_NS_CREATE, + USER_NS_WRITE, + USER_NS_READ, + USER_NS_EXEC, + USER_TABLE_CREATE, + USER_TABLE_WRITE); + } + + @Test + public void testListNamespaces() throws Exception { + AccessTestAction listAction = new AccessTestAction() { + @Override + public Object run() throws Exception { + HBaseAdmin admin = new HBaseAdmin(UTIL.getConfiguration()); + try { + return Arrays.asList(admin.listNamespaceDescriptors()); + } finally { + admin.close(); + } + } + }; + + // listNamespaces : All access* + // * Returned list will only show what you can call getNamespaceDescriptor() + + verifyAllowed(listAction, + SUPERUSER, + USER_GLOBAL_ADMIN, + USER_NS_ADMIN); + + // we have 3 namespaces: [default, hbase, TEST_NAMESPACE, TEST_NAMESPACE2] + assertEquals(4, ((List)SUPERUSER.runAs(listAction)).size()); + assertEquals(4, ((List)USER_GLOBAL_ADMIN.runAs(listAction)).size()); + + assertEquals(2, ((List)USER_NS_ADMIN.runAs(listAction)).size()); + + assertEquals(0, ((List)USER_GLOBAL_CREATE.runAs(listAction)).size()); + assertEquals(0, ((List)USER_GLOBAL_WRITE.runAs(listAction)).size()); + assertEquals(0, ((List)USER_GLOBAL_READ.runAs(listAction)).size()); + assertEquals(0, ((List)USER_GLOBAL_EXEC.runAs(listAction)).size()); + assertEquals(0, ((List)USER_NS_CREATE.runAs(listAction)).size()); + assertEquals(0, ((List)USER_NS_WRITE.runAs(listAction)).size()); + assertEquals(0, ((List)USER_NS_READ.runAs(listAction)).size()); + assertEquals(0, ((List)USER_NS_EXEC.runAs(listAction)).size()); + assertEquals(0, ((List)USER_TABLE_CREATE.runAs(listAction)).size()); + assertEquals(0, ((List)USER_TABLE_WRITE.runAs(listAction)).size()); } @Test @@ -220,6 +388,7 @@ public class TestNamespaceCommands extends SecureTestUtil { // Test if client API actions are authorized AccessTestAction grantAction = new AccessTestAction() { + @Override public Object run() throws Exception { HTable acl = new HTable(conf, AccessControlLists.ACL_TABLE_NAME); try { @@ -235,6 +404,23 @@ public class TestNamespaceCommands extends SecureTestUtil { } }; + AccessTestAction grantNamespaceAction = new AccessTestAction() { + @Override + public Object run() throws Exception { + HTable acl = new HTable(conf, AccessControlLists.ACL_TABLE_NAME); + try { + BlockingRpcChannel service = acl.coprocessorService(HConstants.EMPTY_START_ROW); + AccessControlService.BlockingInterface protocol = + AccessControlService.newBlockingStub(service); + ProtobufUtil.grant(protocol, USER_GROUP_NS_ADMIN.getShortName(), + TEST_NAMESPACE, Action.READ); + } finally { + acl.close(); + } + return null; + } + }; + AccessTestAction revokeAction = new AccessTestAction() { public Object run() throws Exception { HTable acl = new HTable(conf, AccessControlLists.ACL_TABLE_NAME); @@ -251,6 +437,23 @@ public class TestNamespaceCommands extends SecureTestUtil { } }; + AccessTestAction revokeNamespaceAction = new AccessTestAction() { + public Object run() throws Exception { + HTable acl = new HTable(conf, AccessControlLists.ACL_TABLE_NAME); + try { + BlockingRpcChannel service = + acl.coprocessorService(HConstants.EMPTY_START_ROW); + AccessControlService.BlockingInterface protocol = + AccessControlService.newBlockingStub(service); + ProtobufUtil.revoke(protocol, USER_GROUP_NS_ADMIN.getShortName(), + TEST_NAMESPACE, Action.READ); + } finally { + acl.close(); + } + return null; + } + }; + AccessTestAction getPermissionsAction = new AccessTestAction() { @Override public Object run() throws Exception { @@ -267,18 +470,106 @@ public class TestNamespaceCommands extends SecureTestUtil { } }; - // Only HBase super user should be able to grant and revoke permissions to - // namespaces - verifyAllowed(grantAction, SUPERUSER, USER_NSP_ADMIN, USER_GROUP_ADMIN); - verifyDenied(grantAction, USER_CREATE, USER_RW, USER_GROUP_READ, USER_GROUP_WRITE, + verifyAllowed(grantAction, + SUPERUSER, + USER_GLOBAL_ADMIN, + USER_GROUP_ADMIN, + USER_NS_ADMIN); + verifyDenied(grantAction, + USER_GLOBAL_CREATE, + USER_GLOBAL_WRITE, + USER_GLOBAL_READ, + USER_GLOBAL_EXEC, + USER_NS_CREATE, + USER_NS_WRITE, + USER_NS_READ, + USER_NS_EXEC, + USER_TABLE_CREATE, + USER_TABLE_WRITE, + USER_GROUP_READ, + USER_GROUP_WRITE, USER_GROUP_CREATE); - verifyAllowed(revokeAction, SUPERUSER, USER_NSP_ADMIN, USER_GROUP_ADMIN); - verifyDenied(revokeAction, USER_CREATE, USER_RW, USER_GROUP_READ, USER_GROUP_WRITE, + + verifyAllowed(grantNamespaceAction, + SUPERUSER, + USER_GLOBAL_ADMIN, + USER_GROUP_ADMIN, + USER_NS_ADMIN, + USER_GROUP_NS_ADMIN); + verifyDenied(grantNamespaceAction, + USER_GLOBAL_CREATE, + USER_GLOBAL_WRITE, + USER_GLOBAL_READ, + USER_GLOBAL_EXEC, + USER_NS_CREATE, + USER_NS_WRITE, + USER_NS_READ, + USER_NS_EXEC, + USER_TABLE_CREATE, + USER_TABLE_WRITE, + USER_GROUP_READ, + USER_GROUP_WRITE, + USER_GROUP_CREATE); + + verifyAllowed(revokeAction, + SUPERUSER, + USER_GLOBAL_ADMIN, + USER_GROUP_ADMIN, + USER_NS_ADMIN); + verifyDenied(revokeAction, + USER_GLOBAL_CREATE, + USER_GLOBAL_WRITE, + USER_GLOBAL_READ, + USER_GLOBAL_EXEC, + USER_NS_CREATE, + USER_NS_WRITE, + USER_NS_READ, + USER_NS_EXEC, + USER_TABLE_CREATE, + USER_TABLE_WRITE, + USER_GROUP_READ, + USER_GROUP_WRITE, USER_GROUP_CREATE); - // Only an admin should be able to get the user permission - verifyAllowed(revokeAction, SUPERUSER, USER_NSP_ADMIN, USER_GROUP_ADMIN); - verifyDenied(revokeAction, USER_CREATE, USER_RW, USER_GROUP_READ, USER_GROUP_WRITE, + verifyAllowed(revokeNamespaceAction, + SUPERUSER, + USER_GLOBAL_ADMIN, + USER_GROUP_ADMIN, + USER_NS_ADMIN, + USER_GROUP_NS_ADMIN); + verifyDenied(revokeNamespaceAction, + USER_GLOBAL_CREATE, + USER_GLOBAL_WRITE, + USER_GLOBAL_READ, + USER_GLOBAL_EXEC, + USER_NS_CREATE, + USER_NS_WRITE, + USER_NS_READ, + USER_NS_EXEC, + USER_TABLE_CREATE, + USER_TABLE_WRITE, + USER_GROUP_READ, + USER_GROUP_WRITE, + USER_GROUP_CREATE); + + verifyAllowed(getPermissionsAction, + SUPERUSER, + USER_GLOBAL_ADMIN, + USER_NS_ADMIN, + USER_GROUP_ADMIN); + verifyDenied(getPermissionsAction, + USER_GLOBAL_CREATE, + USER_GLOBAL_WRITE, + USER_GLOBAL_READ, + USER_GLOBAL_EXEC, + USER_NS_CREATE, + USER_NS_WRITE, + USER_NS_READ, + USER_NS_EXEC, + USER_TABLE_CREATE, + USER_TABLE_WRITE, + USER_GROUP_READ, + USER_GROUP_WRITE, USER_GROUP_CREATE); } @@ -294,11 +585,22 @@ public class TestNamespaceCommands extends SecureTestUtil { } }; - // Only users with create permissions on namespace should be able to create a new table - verifyAllowed(createTable, SUPERUSER, USER_NSP_WRITE, USER_GROUP_CREATE); - - // all others should be denied - verifyDenied(createTable, USER_CREATE, USER_RW, USER_GROUP_READ, USER_GROUP_WRITE, - USER_GROUP_ADMIN); + //createTable : superuser | global(C) | NS(C) + verifyAllowed(createTable, + SUPERUSER, + USER_GLOBAL_CREATE, + USER_NS_CREATE); + + verifyDenied(createTable, + USER_GLOBAL_ADMIN, + USER_GLOBAL_WRITE, + USER_GLOBAL_READ, + USER_GLOBAL_EXEC, + USER_NS_ADMIN, + USER_NS_WRITE, + USER_NS_READ, + USER_NS_EXEC, + USER_TABLE_CREATE, + USER_TABLE_WRITE); } }