HBASE-12663 unify getTableDescriptors() and listTableDescriptors

This commit is contained in:
Matteo Bertozzi 2014-12-10 15:15:53 +00:00
parent a4318aa8aa
commit 8ab96c40d8
11 changed files with 635 additions and 127 deletions

View File

@ -34206,6 +34206,21 @@ public final class MasterProtos {
* <code>optional bool include_sys_tables = 3 [default = false];</code> * <code>optional bool include_sys_tables = 3 [default = false];</code>
*/ */
boolean getIncludeSysTables(); boolean getIncludeSysTables();
// optional string namespace = 4;
/**
* <code>optional string namespace = 4;</code>
*/
boolean hasNamespace();
/**
* <code>optional string namespace = 4;</code>
*/
java.lang.String getNamespace();
/**
* <code>optional string namespace = 4;</code>
*/
com.google.protobuf.ByteString
getNamespaceBytes();
} }
/** /**
* Protobuf type {@code GetTableDescriptorsRequest} * Protobuf type {@code GetTableDescriptorsRequest}
@ -34276,6 +34291,11 @@ public final class MasterProtos {
includeSysTables_ = input.readBool(); includeSysTables_ = input.readBool();
break; break;
} }
case 34: {
bitField0_ |= 0x00000004;
namespace_ = input.readBytes();
break;
}
} }
} }
} catch (com.google.protobuf.InvalidProtocolBufferException e) { } catch (com.google.protobuf.InvalidProtocolBufferException e) {
@ -34414,10 +34434,54 @@ public final class MasterProtos {
return includeSysTables_; return includeSysTables_;
} }
// optional string namespace = 4;
public static final int NAMESPACE_FIELD_NUMBER = 4;
private java.lang.Object namespace_;
/**
* <code>optional string namespace = 4;</code>
*/
public boolean hasNamespace() {
return ((bitField0_ & 0x00000004) == 0x00000004);
}
/**
* <code>optional string namespace = 4;</code>
*/
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;
}
}
/**
* <code>optional string namespace = 4;</code>
*/
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() { private void initFields() {
tableNames_ = java.util.Collections.emptyList(); tableNames_ = java.util.Collections.emptyList();
regex_ = ""; regex_ = "";
includeSysTables_ = false; includeSysTables_ = false;
namespace_ = "";
} }
private byte memoizedIsInitialized = -1; private byte memoizedIsInitialized = -1;
public final boolean isInitialized() { public final boolean isInitialized() {
@ -34446,6 +34510,9 @@ public final class MasterProtos {
if (((bitField0_ & 0x00000002) == 0x00000002)) { if (((bitField0_ & 0x00000002) == 0x00000002)) {
output.writeBool(3, includeSysTables_); output.writeBool(3, includeSysTables_);
} }
if (((bitField0_ & 0x00000004) == 0x00000004)) {
output.writeBytes(4, getNamespaceBytes());
}
getUnknownFields().writeTo(output); getUnknownFields().writeTo(output);
} }
@ -34467,6 +34534,10 @@ public final class MasterProtos {
size += com.google.protobuf.CodedOutputStream size += com.google.protobuf.CodedOutputStream
.computeBoolSize(3, includeSysTables_); .computeBoolSize(3, includeSysTables_);
} }
if (((bitField0_ & 0x00000004) == 0x00000004)) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(4, getNamespaceBytes());
}
size += getUnknownFields().getSerializedSize(); size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size; memoizedSerializedSize = size;
return size; return size;
@ -34502,6 +34573,11 @@ public final class MasterProtos {
result = result && (getIncludeSysTables() result = result && (getIncludeSysTables()
== other.getIncludeSysTables()); == other.getIncludeSysTables());
} }
result = result && (hasNamespace() == other.hasNamespace());
if (hasNamespace()) {
result = result && getNamespace()
.equals(other.getNamespace());
}
result = result && result = result &&
getUnknownFields().equals(other.getUnknownFields()); getUnknownFields().equals(other.getUnknownFields());
return result; return result;
@ -34527,6 +34603,10 @@ public final class MasterProtos {
hash = (37 * hash) + INCLUDE_SYS_TABLES_FIELD_NUMBER; hash = (37 * hash) + INCLUDE_SYS_TABLES_FIELD_NUMBER;
hash = (53 * hash) + hashBoolean(getIncludeSysTables()); hash = (53 * hash) + hashBoolean(getIncludeSysTables());
} }
if (hasNamespace()) {
hash = (37 * hash) + NAMESPACE_FIELD_NUMBER;
hash = (53 * hash) + getNamespace().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode(); hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash; memoizedHashCode = hash;
return hash; return hash;
@ -34647,6 +34727,8 @@ public final class MasterProtos {
bitField0_ = (bitField0_ & ~0x00000002); bitField0_ = (bitField0_ & ~0x00000002);
includeSysTables_ = false; includeSysTables_ = false;
bitField0_ = (bitField0_ & ~0x00000004); bitField0_ = (bitField0_ & ~0x00000004);
namespace_ = "";
bitField0_ = (bitField0_ & ~0x00000008);
return this; return this;
} }
@ -34692,6 +34774,10 @@ public final class MasterProtos {
to_bitField0_ |= 0x00000002; to_bitField0_ |= 0x00000002;
} }
result.includeSysTables_ = includeSysTables_; result.includeSysTables_ = includeSysTables_;
if (((from_bitField0_ & 0x00000008) == 0x00000008)) {
to_bitField0_ |= 0x00000004;
}
result.namespace_ = namespace_;
result.bitField0_ = to_bitField0_; result.bitField0_ = to_bitField0_;
onBuilt(); onBuilt();
return result; return result;
@ -34742,6 +34828,11 @@ public final class MasterProtos {
if (other.hasIncludeSysTables()) { if (other.hasIncludeSysTables()) {
setIncludeSysTables(other.getIncludeSysTables()); setIncludeSysTables(other.getIncludeSysTables());
} }
if (other.hasNamespace()) {
bitField0_ |= 0x00000008;
namespace_ = other.namespace_;
onChanged();
}
this.mergeUnknownFields(other.getUnknownFields()); this.mergeUnknownFields(other.getUnknownFields());
return this; return this;
} }
@ -35122,6 +35213,80 @@ public final class MasterProtos {
return this; return this;
} }
// optional string namespace = 4;
private java.lang.Object namespace_ = "";
/**
* <code>optional string namespace = 4;</code>
*/
public boolean hasNamespace() {
return ((bitField0_ & 0x00000008) == 0x00000008);
}
/**
* <code>optional string namespace = 4;</code>
*/
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;
}
}
/**
* <code>optional string namespace = 4;</code>
*/
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;
}
}
/**
* <code>optional string namespace = 4;</code>
*/
public Builder setNamespace(
java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
bitField0_ |= 0x00000008;
namespace_ = value;
onChanged();
return this;
}
/**
* <code>optional string namespace = 4;</code>
*/
public Builder clearNamespace() {
bitField0_ = (bitField0_ & ~0x00000008);
namespace_ = getDefaultInstance().getNamespace();
onChanged();
return this;
}
/**
* <code>optional string namespace = 4;</code>
*/
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) // @@protoc_insertion_point(builder_scope:GetTableDescriptorsRequest)
} }
@ -35881,6 +36046,21 @@ public final class MasterProtos {
* <code>optional bool include_sys_tables = 2 [default = false];</code> * <code>optional bool include_sys_tables = 2 [default = false];</code>
*/ */
boolean getIncludeSysTables(); boolean getIncludeSysTables();
// optional string namespace = 3;
/**
* <code>optional string namespace = 3;</code>
*/
boolean hasNamespace();
/**
* <code>optional string namespace = 3;</code>
*/
java.lang.String getNamespace();
/**
* <code>optional string namespace = 3;</code>
*/
com.google.protobuf.ByteString
getNamespaceBytes();
} }
/** /**
* Protobuf type {@code GetTableNamesRequest} * Protobuf type {@code GetTableNamesRequest}
@ -35943,6 +36123,11 @@ public final class MasterProtos {
includeSysTables_ = input.readBool(); includeSysTables_ = input.readBool();
break; break;
} }
case 26: {
bitField0_ |= 0x00000004;
namespace_ = input.readBytes();
break;
}
} }
} }
} catch (com.google.protobuf.InvalidProtocolBufferException e) { } catch (com.google.protobuf.InvalidProtocolBufferException e) {
@ -36042,9 +36227,53 @@ public final class MasterProtos {
return includeSysTables_; return includeSysTables_;
} }
// optional string namespace = 3;
public static final int NAMESPACE_FIELD_NUMBER = 3;
private java.lang.Object namespace_;
/**
* <code>optional string namespace = 3;</code>
*/
public boolean hasNamespace() {
return ((bitField0_ & 0x00000004) == 0x00000004);
}
/**
* <code>optional string namespace = 3;</code>
*/
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;
}
}
/**
* <code>optional string namespace = 3;</code>
*/
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() { private void initFields() {
regex_ = ""; regex_ = "";
includeSysTables_ = false; includeSysTables_ = false;
namespace_ = "";
} }
private byte memoizedIsInitialized = -1; private byte memoizedIsInitialized = -1;
public final boolean isInitialized() { public final boolean isInitialized() {
@ -36064,6 +36293,9 @@ public final class MasterProtos {
if (((bitField0_ & 0x00000002) == 0x00000002)) { if (((bitField0_ & 0x00000002) == 0x00000002)) {
output.writeBool(2, includeSysTables_); output.writeBool(2, includeSysTables_);
} }
if (((bitField0_ & 0x00000004) == 0x00000004)) {
output.writeBytes(3, getNamespaceBytes());
}
getUnknownFields().writeTo(output); getUnknownFields().writeTo(output);
} }
@ -36081,6 +36313,10 @@ public final class MasterProtos {
size += com.google.protobuf.CodedOutputStream size += com.google.protobuf.CodedOutputStream
.computeBoolSize(2, includeSysTables_); .computeBoolSize(2, includeSysTables_);
} }
if (((bitField0_ & 0x00000004) == 0x00000004)) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(3, getNamespaceBytes());
}
size += getUnknownFields().getSerializedSize(); size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size; memoizedSerializedSize = size;
return size; return size;
@ -36114,6 +36350,11 @@ public final class MasterProtos {
result = result && (getIncludeSysTables() result = result && (getIncludeSysTables()
== other.getIncludeSysTables()); == other.getIncludeSysTables());
} }
result = result && (hasNamespace() == other.hasNamespace());
if (hasNamespace()) {
result = result && getNamespace()
.equals(other.getNamespace());
}
result = result && result = result &&
getUnknownFields().equals(other.getUnknownFields()); getUnknownFields().equals(other.getUnknownFields());
return result; return result;
@ -36135,6 +36376,10 @@ public final class MasterProtos {
hash = (37 * hash) + INCLUDE_SYS_TABLES_FIELD_NUMBER; hash = (37 * hash) + INCLUDE_SYS_TABLES_FIELD_NUMBER;
hash = (53 * hash) + hashBoolean(getIncludeSysTables()); hash = (53 * hash) + hashBoolean(getIncludeSysTables());
} }
if (hasNamespace()) {
hash = (37 * hash) + NAMESPACE_FIELD_NUMBER;
hash = (53 * hash) + getNamespace().hashCode();
}
hash = (29 * hash) + getUnknownFields().hashCode(); hash = (29 * hash) + getUnknownFields().hashCode();
memoizedHashCode = hash; memoizedHashCode = hash;
return hash; return hash;
@ -36248,6 +36493,8 @@ public final class MasterProtos {
bitField0_ = (bitField0_ & ~0x00000001); bitField0_ = (bitField0_ & ~0x00000001);
includeSysTables_ = false; includeSysTables_ = false;
bitField0_ = (bitField0_ & ~0x00000002); bitField0_ = (bitField0_ & ~0x00000002);
namespace_ = "";
bitField0_ = (bitField0_ & ~0x00000004);
return this; return this;
} }
@ -36284,6 +36531,10 @@ public final class MasterProtos {
to_bitField0_ |= 0x00000002; to_bitField0_ |= 0x00000002;
} }
result.includeSysTables_ = includeSysTables_; result.includeSysTables_ = includeSysTables_;
if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
to_bitField0_ |= 0x00000004;
}
result.namespace_ = namespace_;
result.bitField0_ = to_bitField0_; result.bitField0_ = to_bitField0_;
onBuilt(); onBuilt();
return result; return result;
@ -36308,6 +36559,11 @@ public final class MasterProtos {
if (other.hasIncludeSysTables()) { if (other.hasIncludeSysTables()) {
setIncludeSysTables(other.getIncludeSysTables()); setIncludeSysTables(other.getIncludeSysTables());
} }
if (other.hasNamespace()) {
bitField0_ |= 0x00000004;
namespace_ = other.namespace_;
onChanged();
}
this.mergeUnknownFields(other.getUnknownFields()); this.mergeUnknownFields(other.getUnknownFields());
return this; return this;
} }
@ -36442,6 +36698,80 @@ public final class MasterProtos {
return this; return this;
} }
// optional string namespace = 3;
private java.lang.Object namespace_ = "";
/**
* <code>optional string namespace = 3;</code>
*/
public boolean hasNamespace() {
return ((bitField0_ & 0x00000004) == 0x00000004);
}
/**
* <code>optional string namespace = 3;</code>
*/
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;
}
}
/**
* <code>optional string namespace = 3;</code>
*/
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;
}
}
/**
* <code>optional string namespace = 3;</code>
*/
public Builder setNamespace(
java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
bitField0_ |= 0x00000004;
namespace_ = value;
onChanged();
return this;
}
/**
* <code>optional string namespace = 3;</code>
*/
public Builder clearNamespace() {
bitField0_ = (bitField0_ & ~0x00000004);
namespace_ = getDefaultInstance().getNamespace();
onChanged();
return this;
}
/**
* <code>optional string namespace = 3;</code>
*/
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) // @@protoc_insertion_point(builder_scope:GetTableNamesRequest)
} }
@ -48349,115 +48679,116 @@ 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\"o\n\032GetTableDescriptorsRequest\022\037\n\013ta" + " \001(\r\"\202\001\n\032GetTableDescriptorsRequest\022\037\n\013t" +
"ble_names\030\001 \003(\0132\n.TableName\022\r\n\005regex\030\002 \001" + "able_names\030\001 \003(\0132\n.TableName\022\r\n\005regex\030\002 " +
"(\t\022!\n\022include_sys_tables\030\003 \001(\010:\005false\"A\n" + "\001(\t\022!\n\022include_sys_tables\030\003 \001(\010:\005false\022\021" +
"\033GetTableDescriptorsResponse\022\"\n\014table_sc" + "\n\tnamespace\030\004 \001(\t\"A\n\033GetTableDescriptors" +
"hema\030\001 \003(\0132\014.TableSchema\"H\n\024GetTableName" + "Response\022\"\n\014table_schema\030\001 \003(\0132\014.TableSc" +
"sRequest\022\r\n\005regex\030\001 \001(\t\022!\n\022include_sys_t" + "hema\"[\n\024GetTableNamesRequest\022\r\n\005regex\030\001 " +
"ables\030\002 \001(\010:\005false\"8\n\025GetTableNamesRespo" + "\001(\t\022!\n\022include_sys_tables\030\002 \001(\010:\005false\022\021" +
"nse\022\037\n\013table_names\030\001 \003(\0132\n.TableName\"6\n\024", "\n\tnamespace\030\003 \001(\t\"8\n\025GetTableNamesRespon",
"GetTableStateRequest\022\036\n\ntable_name\030\001 \002(\013" + "se\022\037\n\013table_names\030\001 \003(\0132\n.TableName\"6\n\024G" +
"2\n.TableName\"9\n\025GetTableStateResponse\022 \n" + "etTableStateRequest\022\036\n\ntable_name\030\001 \002(\0132" +
"\013table_state\030\001 \002(\0132\013.TableState\"\031\n\027GetCl" + "\n.TableName\"9\n\025GetTableStateResponse\022 \n\013" +
"usterStatusRequest\"B\n\030GetClusterStatusRe" + "table_state\030\001 \002(\0132\013.TableState\"\031\n\027GetClu" +
"sponse\022&\n\016cluster_status\030\001 \002(\0132\016.Cluster" + "sterStatusRequest\"B\n\030GetClusterStatusRes" +
"Status\"\030\n\026IsMasterRunningRequest\"4\n\027IsMa" + "ponse\022&\n\016cluster_status\030\001 \002(\0132\016.ClusterS" +
"sterRunningResponse\022\031\n\021is_master_running" + "tatus\"\030\n\026IsMasterRunningRequest\"4\n\027IsMas" +
"\030\001 \002(\010\"@\n\024ExecProcedureRequest\022(\n\tproced" + "terRunningResponse\022\031\n\021is_master_running\030" +
"ure\030\001 \002(\0132\025.ProcedureDescription\"F\n\025Exec" + "\001 \002(\010\"@\n\024ExecProcedureRequest\022(\n\tprocedu" +
"ProcedureResponse\022\030\n\020expected_timeout\030\001 ", "re\030\001 \002(\0132\025.ProcedureDescription\"F\n\025ExecP",
"\001(\003\022\023\n\013return_data\030\002 \001(\014\"B\n\026IsProcedureD" + "rocedureResponse\022\030\n\020expected_timeout\030\001 \001" +
"oneRequest\022(\n\tprocedure\030\001 \001(\0132\025.Procedur" + "(\003\022\023\n\013return_data\030\002 \001(\014\"B\n\026IsProcedureDo" +
"eDescription\"W\n\027IsProcedureDoneResponse\022" + "neRequest\022(\n\tprocedure\030\001 \001(\0132\025.Procedure" +
"\023\n\004done\030\001 \001(\010:\005false\022\'\n\010snapshot\030\002 \001(\0132\025" + "Description\"W\n\027IsProcedureDoneResponse\022\023" +
".ProcedureDescription\"\273\001\n\017SetQuotaReques" + "\n\004done\030\001 \001(\010:\005false\022\'\n\010snapshot\030\002 \001(\0132\025." +
"t\022\021\n\tuser_name\030\001 \001(\t\022\022\n\nuser_group\030\002 \001(\t" + "ProcedureDescription\"\273\001\n\017SetQuotaRequest" +
"\022\021\n\tnamespace\030\003 \001(\t\022\036\n\ntable_name\030\004 \001(\0132" + "\022\021\n\tuser_name\030\001 \001(\t\022\022\n\nuser_group\030\002 \001(\t\022" +
"\n.TableName\022\022\n\nremove_all\030\005 \001(\010\022\026\n\016bypas" + "\021\n\tnamespace\030\003 \001(\t\022\036\n\ntable_name\030\004 \001(\0132\n" +
"s_globals\030\006 \001(\010\022\"\n\010throttle\030\007 \001(\0132\020.Thro" + ".TableName\022\022\n\nremove_all\030\005 \001(\010\022\026\n\016bypass" +
"ttleRequest\"\022\n\020SetQuotaResponse2\346\030\n\rMast", "_globals\030\006 \001(\010\022\"\n\010throttle\030\007 \001(\0132\020.Throt",
"erService\022S\n\024GetSchemaAlterStatus\022\034.GetS" + "tleRequest\"\022\n\020SetQuotaResponse2\346\030\n\rMaste" +
"chemaAlterStatusRequest\032\035.GetSchemaAlter" + "rService\022S\n\024GetSchemaAlterStatus\022\034.GetSc" +
"StatusResponse\022P\n\023GetTableDescriptors\022\033." + "hemaAlterStatusRequest\032\035.GetSchemaAlterS" +
"GetTableDescriptorsRequest\032\034.GetTableDes" + "tatusResponse\022P\n\023GetTableDescriptors\022\033.G" +
"criptorsResponse\022>\n\rGetTableNames\022\025.GetT" + "etTableDescriptorsRequest\032\034.GetTableDesc" +
"ableNamesRequest\032\026.GetTableNamesResponse" + "riptorsResponse\022>\n\rGetTableNames\022\025.GetTa" +
"\022G\n\020GetClusterStatus\022\030.GetClusterStatusR" + "bleNamesRequest\032\026.GetTableNamesResponse\022" +
"equest\032\031.GetClusterStatusResponse\022D\n\017IsM" + "G\n\020GetClusterStatus\022\030.GetClusterStatusRe" +
"asterRunning\022\027.IsMasterRunningRequest\032\030." + "quest\032\031.GetClusterStatusResponse\022D\n\017IsMa" +
"IsMasterRunningResponse\0222\n\tAddColumn\022\021.A", "sterRunning\022\027.IsMasterRunningRequest\032\030.I",
"ddColumnRequest\032\022.AddColumnResponse\022;\n\014D" + "sMasterRunningResponse\0222\n\tAddColumn\022\021.Ad" +
"eleteColumn\022\024.DeleteColumnRequest\032\025.Dele" + "dColumnRequest\032\022.AddColumnResponse\022;\n\014De" +
"teColumnResponse\022;\n\014ModifyColumn\022\024.Modif" + "leteColumn\022\024.DeleteColumnRequest\032\025.Delet" +
"yColumnRequest\032\025.ModifyColumnResponse\0225\n" + "eColumnResponse\022;\n\014ModifyColumn\022\024.Modify" +
"\nMoveRegion\022\022.MoveRegionRequest\032\023.MoveRe" + "ColumnRequest\032\025.ModifyColumnResponse\0225\n\n" +
"gionResponse\022Y\n\026DispatchMergingRegions\022\036" + "MoveRegion\022\022.MoveRegionRequest\032\023.MoveReg" +
".DispatchMergingRegionsRequest\032\037.Dispatc" + "ionResponse\022Y\n\026DispatchMergingRegions\022\036." +
"hMergingRegionsResponse\022;\n\014AssignRegion\022" + "DispatchMergingRegionsRequest\032\037.Dispatch" +
"\024.AssignRegionRequest\032\025.AssignRegionResp" + "MergingRegionsResponse\022;\n\014AssignRegion\022\024" +
"onse\022A\n\016UnassignRegion\022\026.UnassignRegionR", ".AssignRegionRequest\032\025.AssignRegionRespo",
"equest\032\027.UnassignRegionResponse\022>\n\rOffli" + "nse\022A\n\016UnassignRegion\022\026.UnassignRegionRe" +
"neRegion\022\025.OfflineRegionRequest\032\026.Offlin" + "quest\032\027.UnassignRegionResponse\022>\n\rOfflin" +
"eRegionResponse\0228\n\013DeleteTable\022\023.DeleteT" + "eRegion\022\025.OfflineRegionRequest\032\026.Offline" +
"ableRequest\032\024.DeleteTableResponse\022>\n\rtru" + "RegionResponse\0228\n\013DeleteTable\022\023.DeleteTa" +
"ncateTable\022\025.TruncateTableRequest\032\026.Trun" + "bleRequest\032\024.DeleteTableResponse\022>\n\rtrun" +
"cateTableResponse\0228\n\013EnableTable\022\023.Enabl" + "cateTable\022\025.TruncateTableRequest\032\026.Trunc" +
"eTableRequest\032\024.EnableTableResponse\022;\n\014D" + "ateTableResponse\0228\n\013EnableTable\022\023.Enable" +
"isableTable\022\024.DisableTableRequest\032\025.Disa" + "TableRequest\032\024.EnableTableResponse\022;\n\014Di" +
"bleTableResponse\0228\n\013ModifyTable\022\023.Modify" + "sableTable\022\024.DisableTableRequest\032\025.Disab" +
"TableRequest\032\024.ModifyTableResponse\0228\n\013Cr", "leTableResponse\0228\n\013ModifyTable\022\023.ModifyT",
"eateTable\022\023.CreateTableRequest\032\024.CreateT" + "ableRequest\032\024.ModifyTableResponse\0228\n\013Cre" +
"ableResponse\022/\n\010Shutdown\022\020.ShutdownReque" + "ateTable\022\023.CreateTableRequest\032\024.CreateTa" +
"st\032\021.ShutdownResponse\0225\n\nStopMaster\022\022.St" + "bleResponse\022/\n\010Shutdown\022\020.ShutdownReques" +
"opMasterRequest\032\023.StopMasterResponse\022,\n\007" + "t\032\021.ShutdownResponse\0225\n\nStopMaster\022\022.Sto" +
"Balance\022\017.BalanceRequest\032\020.BalanceRespon" + "pMasterRequest\032\023.StopMasterResponse\022,\n\007B" +
"se\022M\n\022SetBalancerRunning\022\032.SetBalancerRu" + "alance\022\017.BalanceRequest\032\020.BalanceRespons" +
"nningRequest\032\033.SetBalancerRunningRespons" + "e\022M\n\022SetBalancerRunning\022\032.SetBalancerRun" +
"e\022A\n\016RunCatalogScan\022\026.RunCatalogScanRequ" + "ningRequest\032\033.SetBalancerRunningResponse" +
"est\032\027.RunCatalogScanResponse\022S\n\024EnableCa" + "\022A\n\016RunCatalogScan\022\026.RunCatalogScanReque" +
"talogJanitor\022\034.EnableCatalogJanitorReque", "st\032\027.RunCatalogScanResponse\022S\n\024EnableCat",
"st\032\035.EnableCatalogJanitorResponse\022\\\n\027IsC" + "alogJanitor\022\034.EnableCatalogJanitorReques" +
"atalogJanitorEnabled\022\037.IsCatalogJanitorE" + "t\032\035.EnableCatalogJanitorResponse\022\\\n\027IsCa" +
"nabledRequest\032 .IsCatalogJanitorEnabledR" + "talogJanitorEnabled\022\037.IsCatalogJanitorEn" +
"esponse\022L\n\021ExecMasterService\022\032.Coprocess" + "abledRequest\032 .IsCatalogJanitorEnabledRe" +
"orServiceRequest\032\033.CoprocessorServiceRes" + "sponse\022L\n\021ExecMasterService\022\032.Coprocesso" +
"ponse\022/\n\010Snapshot\022\020.SnapshotRequest\032\021.Sn" + "rServiceRequest\032\033.CoprocessorServiceResp" +
"apshotResponse\022V\n\025GetCompletedSnapshots\022" + "onse\022/\n\010Snapshot\022\020.SnapshotRequest\032\021.Sna" +
"\035.GetCompletedSnapshotsRequest\032\036.GetComp" + "pshotResponse\022V\n\025GetCompletedSnapshots\022\035" +
"letedSnapshotsResponse\022A\n\016DeleteSnapshot" + ".GetCompletedSnapshotsRequest\032\036.GetCompl" +
"\022\026.DeleteSnapshotRequest\032\027.DeleteSnapsho", "etedSnapshotsResponse\022A\n\016DeleteSnapshot\022",
"tResponse\022A\n\016IsSnapshotDone\022\026.IsSnapshot" + "\026.DeleteSnapshotRequest\032\027.DeleteSnapshot" +
"DoneRequest\032\027.IsSnapshotDoneResponse\022D\n\017" + "Response\022A\n\016IsSnapshotDone\022\026.IsSnapshotD" +
"RestoreSnapshot\022\027.RestoreSnapshotRequest" + "oneRequest\032\027.IsSnapshotDoneResponse\022D\n\017R" +
"\032\030.RestoreSnapshotResponse\022V\n\025IsRestoreS" + "estoreSnapshot\022\027.RestoreSnapshotRequest\032" +
"napshotDone\022\035.IsRestoreSnapshotDoneReque" + "\030.RestoreSnapshotResponse\022V\n\025IsRestoreSn" +
"st\032\036.IsRestoreSnapshotDoneResponse\022>\n\rEx" + "apshotDone\022\035.IsRestoreSnapshotDoneReques" +
"ecProcedure\022\025.ExecProcedureRequest\032\026.Exe" + "t\032\036.IsRestoreSnapshotDoneResponse\022>\n\rExe" +
"cProcedureResponse\022E\n\024ExecProcedureWithR" + "cProcedure\022\025.ExecProcedureRequest\032\026.Exec" +
"et\022\025.ExecProcedureRequest\032\026.ExecProcedur" + "ProcedureResponse\022E\n\024ExecProcedureWithRe" +
"eResponse\022D\n\017IsProcedureDone\022\027.IsProcedu", "t\022\025.ExecProcedureRequest\032\026.ExecProcedure",
"reDoneRequest\032\030.IsProcedureDoneResponse\022" + "Response\022D\n\017IsProcedureDone\022\027.IsProcedur" +
"D\n\017ModifyNamespace\022\027.ModifyNamespaceRequ" + "eDoneRequest\032\030.IsProcedureDoneResponse\022D" +
"est\032\030.ModifyNamespaceResponse\022D\n\017CreateN" + "\n\017ModifyNamespace\022\027.ModifyNamespaceReque" +
"amespace\022\027.CreateNamespaceRequest\032\030.Crea" + "st\032\030.ModifyNamespaceResponse\022D\n\017CreateNa" +
"teNamespaceResponse\022D\n\017DeleteNamespace\022\027" + "mespace\022\027.CreateNamespaceRequest\032\030.Creat" +
".DeleteNamespaceRequest\032\030.DeleteNamespac" + "eNamespaceResponse\022D\n\017DeleteNamespace\022\027." +
"eResponse\022Y\n\026GetNamespaceDescriptor\022\036.Ge" + "DeleteNamespaceRequest\032\030.DeleteNamespace" +
"tNamespaceDescriptorRequest\032\037.GetNamespa" + "Response\022Y\n\026GetNamespaceDescriptor\022\036.Get" +
"ceDescriptorResponse\022_\n\030ListNamespaceDes" + "NamespaceDescriptorRequest\032\037.GetNamespac" +
"criptors\022 .ListNamespaceDescriptorsReque", "eDescriptorResponse\022_\n\030ListNamespaceDesc",
"st\032!.ListNamespaceDescriptorsResponse\022t\n" + "riptors\022 .ListNamespaceDescriptorsReques" +
"\037ListTableDescriptorsByNamespace\022\'.ListT" + "t\032!.ListNamespaceDescriptorsResponse\022t\n\037" +
"ableDescriptorsByNamespaceRequest\032(.List" + "ListTableDescriptorsByNamespace\022\'.ListTa" +
"TableDescriptorsByNamespaceResponse\022b\n\031L" + "bleDescriptorsByNamespaceRequest\032(.ListT" +
"istTableNamesByNamespace\022!.ListTableName" + "ableDescriptorsByNamespaceResponse\022b\n\031Li" +
"sByNamespaceRequest\032\".ListTableNamesByNa" + "stTableNamesByNamespace\022!.ListTableNames" +
"mespaceResponse\022>\n\rGetTableState\022\025.GetTa" + "ByNamespaceRequest\032\".ListTableNamesByNam" +
"bleStateRequest\032\026.GetTableStateResponse\022" + "espaceResponse\022>\n\rGetTableState\022\025.GetTab" +
"/\n\010SetQuota\022\020.SetQuotaRequest\032\021.SetQuota" + "leStateRequest\032\026.GetTableStateResponse\022/" +
"ResponseBB\n*org.apache.hadoop.hbase.prot", "\n\010SetQuota\022\020.SetQuotaRequest\032\021.SetQuotaR",
"obuf.generatedB\014MasterProtosH\001\210\001\001\240\001\001" "esponseBB\n*org.apache.hadoop.hbase.proto" +
"buf.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() {
@ -48889,7 +49220,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", "IncludeSysTables", }); new java.lang.String[] { "TableNames", "Regex", "IncludeSysTables", "Namespace", });
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
@ -48901,7 +49232,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[] { "Regex", "IncludeSysTables", }); new java.lang.String[] { "Regex", "IncludeSysTables", "Namespace", });
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

@ -316,6 +316,7 @@ 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]; optional bool include_sys_tables = 3 [default=false];
optional string namespace = 4;
} }
message GetTableDescriptorsResponse { message GetTableDescriptorsResponse {
@ -325,6 +326,7 @@ message GetTableDescriptorsResponse {
message GetTableNamesRequest { message GetTableNamesRequest {
optional string regex = 1; optional string regex = 1;
optional bool include_sys_tables = 2 [default=false]; optional bool include_sys_tables = 2 [default=false];
optional string namespace = 3;
} }
message GetTableNamesResponse { message GetTableNamesResponse {

View File

@ -158,6 +158,16 @@ public abstract class BaseMasterAndRegionObserver extends BaseRegionObserver
NamespaceDescriptor ns) throws IOException { NamespaceDescriptor ns) throws IOException {
} }
@Override
public void preListNamespaceDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<NamespaceDescriptor> descriptors) throws IOException {
}
@Override
public void postListNamespaceDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<NamespaceDescriptor> descriptors) throws IOException {
}
@Override @Override
public void preAddColumn(ObserverContext<MasterCoprocessorEnvironment> ctx, public void preAddColumn(ObserverContext<MasterCoprocessorEnvironment> ctx,
TableName tableName, HColumnDescriptor column) throws IOException { TableName tableName, HColumnDescriptor column) throws IOException {

View File

@ -151,6 +151,16 @@ public class BaseMasterObserver implements MasterObserver {
public void postModifyNamespace(ObserverContext<MasterCoprocessorEnvironment> ctx, NamespaceDescriptor ns) throws IOException { public void postModifyNamespace(ObserverContext<MasterCoprocessorEnvironment> ctx, NamespaceDescriptor ns) throws IOException {
} }
@Override
public void preListNamespaceDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<NamespaceDescriptor> descriptors) throws IOException {
}
@Override
public void postListNamespaceDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<NamespaceDescriptor> descriptors) throws IOException {
}
@Override @Override
public void preAddColumn(ObserverContext<MasterCoprocessorEnvironment> ctx, public void preAddColumn(ObserverContext<MasterCoprocessorEnvironment> ctx,
TableName tableName, HColumnDescriptor column) throws IOException { TableName tableName, HColumnDescriptor column) throws IOException {

View File

@ -788,6 +788,25 @@ public interface MasterObserver extends Coprocessor {
void postModifyNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx, void postModifyNamespace(final ObserverContext<MasterCoprocessorEnvironment> ctx,
NamespaceDescriptor ns) throws IOException; 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<MasterCoprocessorEnvironment> ctx,
List<NamespaceDescriptor> 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<MasterCoprocessorEnvironment> ctx,
List<NamespaceDescriptor> descriptors) throws IOException;
/** /**
* Called before the table memstore is flushed to disk. * Called before the table memstore is flushed to disk.
* @param ctx the environment to interact with the framework and master * @param ctx the environment to interact with the framework and master

View File

@ -140,7 +140,6 @@ import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.servlet.Context; import org.mortbay.jetty.servlet.Context;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.protobuf.Descriptors; import com.google.protobuf.Descriptors;
import com.google.protobuf.Service; import com.google.protobuf.Service;
@ -2042,34 +2041,45 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
@Override @Override
public List<NamespaceDescriptor> listNamespaceDescriptors() throws IOException { public List<NamespaceDescriptor> listNamespaceDescriptors() throws IOException {
checkNamespaceManagerReady(); checkNamespaceManagerReady();
return Lists.newArrayList(tableNamespaceManager.list());
final List<NamespaceDescriptor> descriptors = new ArrayList<NamespaceDescriptor>();
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 @Override
public List<HTableDescriptor> listTableDescriptorsByNamespace(String name) throws IOException { public List<HTableDescriptor> listTableDescriptorsByNamespace(String name) throws IOException {
getNamespaceDescriptor(name); // check that namespace exists getNamespaceDescriptor(name); // check that namespace exists
return Lists.newArrayList(tableDescriptors.getByNamespace(name).values()); return listTableDescriptors(name, null, null, true);
} }
@Override @Override
public List<TableName> listTableNamesByNamespace(String name) throws IOException { public List<TableName> listTableNamesByNamespace(String name) throws IOException {
List<TableName> tableNames = Lists.newArrayList();
getNamespaceDescriptor(name); // check that namespace exists getNamespaceDescriptor(name); // check that namespace exists
for (HTableDescriptor descriptor: tableDescriptors.getByNamespace(name).values()) { return listTableNames(name, null, true);
tableNames.add(descriptor.getTableName());
}
return tableNames;
} }
/** /**
* Returns the list of table descriptors that match the specified request * 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 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 tableNameList the list of table names, or null if querying for all
* @param includeSysTables False to match only against userspace tables * @param includeSysTables False to match only against userspace tables
* @return the list of table descriptors * @return the list of table descriptors
*/ */
public List<HTableDescriptor> listTableDescriptors(final String regex, public List<HTableDescriptor> listTableDescriptors(final String namespace, final String regex,
final List<TableName> tableNameList, final boolean includeSysTables) final List<TableName> tableNameList, final boolean includeSysTables)
throws IOException { throws IOException {
final List<HTableDescriptor> descriptors = new ArrayList<HTableDescriptor>(); final List<HTableDescriptor> descriptors = new ArrayList<HTableDescriptor>();
@ -2082,7 +2092,13 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
if (!bypass) { if (!bypass) {
if (tableNameList == null || tableNameList.size() == 0) { if (tableNameList == null || tableNameList.size() == 0) {
// request for all TableDescriptors // request for all TableDescriptors
Collection<HTableDescriptor> htds = tableDescriptors.getAll().values(); Collection<HTableDescriptor> htds;
if (namespace != null && namespace.length() > 0) {
htds = tableDescriptors.getByNamespace(namespace).values();
} else {
htds = tableDescriptors.getAll().values();
}
for (HTableDescriptor desc: htds) { for (HTableDescriptor desc: htds) {
if (includeSysTables || !desc.getTableName().isSystemTable()) { if (includeSysTables || !desc.getTableName().isSystemTable()) {
descriptors.add(desc); descriptors.add(desc);
@ -2112,11 +2128,12 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
/** /**
* Returns the list of table names that match the specified request * 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 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 * @param includeSysTables False to match only against userspace tables
* @return the list of table names * @return the list of table names
*/ */
public List<TableName> listTableNames(final String regex, final boolean includeSysTables) public List<TableName> listTableNames(final String namespace, final String regex,
throws IOException { final boolean includeSysTables) throws IOException {
final List<HTableDescriptor> descriptors = new ArrayList<HTableDescriptor>(); final List<HTableDescriptor> descriptors = new ArrayList<HTableDescriptor>();
boolean bypass = false; boolean bypass = false;
@ -2126,7 +2143,13 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
if (!bypass) { if (!bypass) {
// get all descriptors // get all descriptors
Collection<HTableDescriptor> htds = tableDescriptors.getAll().values(); Collection<HTableDescriptor> htds;
if (namespace != null && namespace.length() > 0) {
htds = tableDescriptors.getByNamespace(namespace).values();
} else {
htds = tableDescriptors.getAll().values();
}
for (HTableDescriptor htd: htds) { for (HTableDescriptor htd: htds) {
if (includeSysTables || !htd.getTableName().isSystemTable()) { if (includeSysTables || !htd.getTableName().isSystemTable()) {
descriptors.add(htd); descriptors.add(htd);

View File

@ -150,6 +150,28 @@ public class MasterCoprocessorHost
}); });
} }
public boolean preListNamespaceDescriptors(final List<NamespaceDescriptor> descriptors)
throws IOException {
return execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() {
@Override
public void call(MasterObserver oserver, ObserverContext<MasterCoprocessorEnvironment> ctx)
throws IOException {
oserver.preListNamespaceDescriptors(ctx, descriptors);
}
});
}
public void postListNamespaceDescriptors(final List<NamespaceDescriptor> descriptors)
throws IOException {
execOperation(coprocessors.isEmpty() ? null : new CoprocessorOperation() {
@Override
public void call(MasterObserver oserver, ObserverContext<MasterCoprocessorEnvironment> ctx)
throws IOException {
oserver.postListNamespaceDescriptors(ctx, descriptors);
}
});
}
/* Implementation of hooks for invoking MasterObservers */ /* Implementation of hooks for invoking MasterObservers */
public void preCreateTable(final HTableDescriptor htd, final HRegionInfo[] regions) public void preCreateTable(final HTableDescriptor htd, final HRegionInfo[] regions)

View File

@ -787,6 +787,7 @@ public class MasterRpcServices extends RSRpcServices
master.checkInitialized(); master.checkInitialized();
final String regex = req.hasRegex() ? req.getRegex() : null; final String regex = req.hasRegex() ? req.getRegex() : null;
final String namespace = req.hasNamespace() ? req.getNamespace() : null;
List<TableName> tableNameList = null; List<TableName> tableNameList = null;
if (req.getTableNamesCount() > 0) { if (req.getTableNamesCount() > 0) {
tableNameList = new ArrayList<TableName>(req.getTableNamesCount()); tableNameList = new ArrayList<TableName>(req.getTableNamesCount());
@ -795,8 +796,8 @@ public class MasterRpcServices extends RSRpcServices
} }
} }
List<HTableDescriptor> descriptors = master.listTableDescriptors(regex, tableNameList, List<HTableDescriptor> descriptors = master.listTableDescriptors(namespace, regex,
req.getIncludeSysTables()); tableNameList, req.getIncludeSysTables());
GetTableDescriptorsResponse.Builder builder = GetTableDescriptorsResponse.newBuilder(); GetTableDescriptorsResponse.Builder builder = GetTableDescriptorsResponse.newBuilder();
if (descriptors != null && descriptors.size() > 0) { if (descriptors != null && descriptors.size() > 0) {
@ -825,7 +826,9 @@ public class MasterRpcServices extends RSRpcServices
master.checkServiceStarted(); master.checkServiceStarted();
final String regex = req.hasRegex() ? req.getRegex() : null; final String regex = req.hasRegex() ? req.getRegex() : null;
List<TableName> tableNames = master.listTableNames(regex, req.getIncludeSysTables()); final String namespace = req.hasNamespace() ? req.getNamespace() : null;
List<TableName> tableNames = master.listTableNames(namespace, regex,
req.getIncludeSysTables());
GetTableNamesResponse.Builder builder = GetTableNamesResponse.newBuilder(); GetTableNamesResponse.Builder builder = GetTableNamesResponse.newBuilder();
if (tableNames != null && tableNames.size() > 0) { if (tableNames != null && tableNames.size() > 0) {

View File

@ -1206,6 +1206,22 @@ public class AccessController extends BaseMasterAndRegionObserver
requireGlobalPermission("modifyNamespace", Action.ADMIN, ns.getName()); requireGlobalPermission("modifyNamespace", Action.ADMIN, ns.getName());
} }
@Override
public void postListNamespaceDescriptors(ObserverContext<MasterCoprocessorEnvironment> ctx,
List<NamespaceDescriptor> descriptors) throws IOException {
// Retains only those which passes authorization checks, as the checks weren't done as part
// of preGetTableDescriptors.
Iterator<NamespaceDescriptor> itr = descriptors.iterator();
while (itr.hasNext()) {
NamespaceDescriptor desc = itr.next();
try {
requireGlobalPermission("listNamespaces", Action.ADMIN, desc.getName());
} catch (AccessDeniedException e) {
itr.remove();
}
}
}
@Override @Override
public void preTableFlush(final ObserverContext<MasterCoprocessorEnvironment> ctx, public void preTableFlush(final ObserverContext<MasterCoprocessorEnvironment> ctx,
final TableName tableName) throws IOException { final TableName tableName) throws IOException {

View File

@ -93,6 +93,8 @@ public class TestMasterObserver {
private boolean postDeleteNamespaceCalled; private boolean postDeleteNamespaceCalled;
private boolean preModifyNamespaceCalled; private boolean preModifyNamespaceCalled;
private boolean postModifyNamespaceCalled; private boolean postModifyNamespaceCalled;
private boolean preListNamespaceDescriptorsCalled;
private boolean postListNamespaceDescriptorsCalled;
private boolean preAddColumnCalled; private boolean preAddColumnCalled;
private boolean postAddColumnCalled; private boolean postAddColumnCalled;
private boolean preModifyColumnCalled; private boolean preModifyColumnCalled;
@ -173,6 +175,8 @@ public class TestMasterObserver {
postDeleteNamespaceCalled = false; postDeleteNamespaceCalled = false;
preModifyNamespaceCalled = false; preModifyNamespaceCalled = false;
postModifyNamespaceCalled = false; postModifyNamespaceCalled = false;
preListNamespaceDescriptorsCalled = false;
postListNamespaceDescriptorsCalled = false;
preAddColumnCalled = false; preAddColumnCalled = false;
postAddColumnCalled = false; postAddColumnCalled = false;
preModifyColumnCalled = false; preModifyColumnCalled = false;
@ -394,6 +398,29 @@ public class TestMasterObserver {
return preModifyNamespaceCalled && !postModifyNamespaceCalled; return preModifyNamespaceCalled && !postModifyNamespaceCalled;
} }
@Override
public void preListNamespaceDescriptors(ObserverContext<MasterCoprocessorEnvironment> env,
List<NamespaceDescriptor> descriptors) throws IOException {
if (bypass) {
env.bypass();
}
preListNamespaceDescriptorsCalled = true;
}
@Override
public void postListNamespaceDescriptors(ObserverContext<MasterCoprocessorEnvironment> env,
List<NamespaceDescriptor> descriptors) throws IOException {
postListNamespaceDescriptorsCalled = true;
}
public boolean wasListNamespaceDescriptorsCalled() {
return preListNamespaceDescriptorsCalled && postListNamespaceDescriptorsCalled;
}
public boolean preListNamespaceDescriptorsCalledOnly() {
return preListNamespaceDescriptorsCalled && !postListNamespaceDescriptorsCalled;
}
@Override @Override
public void preAddColumn(ObserverContext<MasterCoprocessorEnvironment> env, public void preAddColumn(ObserverContext<MasterCoprocessorEnvironment> env,
TableName tableName, HColumnDescriptor column) throws IOException { TableName tableName, HColumnDescriptor column) throws IOException {
@ -1428,6 +1455,22 @@ public class TestMasterObserver {
admin.createNamespace(NamespaceDescriptor.create(testNamespace).build()); admin.createNamespace(NamespaceDescriptor.create(testNamespace).build());
assertTrue("Test namespace should not be created", cp.preCreateNamespaceCalledOnly()); 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(Admin admin, TableName tableName, HTableDescriptor htd) private void modifyTableSync(Admin admin, TableName tableName, HTableDescriptor htd)

View File

@ -21,6 +21,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.util.List; import java.util.List;
import java.util.Arrays;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HBaseTestingUtility;
@ -29,6 +30,9 @@ import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.Result;
@ -187,6 +191,31 @@ public class TestNamespaceCommands extends SecureTestUtil {
verifyDenied(deleteNamespace, USER_NSP_WRITE, USER_CREATE, USER_RW); verifyDenied(deleteNamespace, USER_NSP_WRITE, USER_CREATE, USER_RW);
} }
@Test
public void testListNamespaces() throws Exception {
AccessTestAction listAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
Connection unmanagedConnection =
ConnectionFactory.createConnection(UTIL.getConfiguration());
Admin admin = unmanagedConnection.getAdmin();
try {
return Arrays.asList(admin.listNamespaceDescriptors());
} finally {
admin.close();
unmanagedConnection.close();
}
}
};
verifyAllowed(listAction, SUPERUSER, USER_NSP_ADMIN);
verifyDenied(listAction, USER_NSP_WRITE, USER_CREATE, USER_RW);
// we have 3 namespaces: [default, hbase, TEST_NAMESPACE, TEST_NAMESPACE2]
assertEquals(4, ((List)SUPERUSER.runAs(listAction)).size());
assertEquals(2, ((List)USER_NSP_ADMIN.runAs(listAction)).size());
}
@Test @Test
public void testGrantRevoke() throws Exception{ public void testGrantRevoke() throws Exception{
final String testUser = "testUser"; final String testUser = "testUser";