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

View File

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

View File

@ -158,6 +158,16 @@ public abstract class BaseMasterAndRegionObserver extends BaseRegionObserver
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
public void preAddColumn(ObserverContext<MasterCoprocessorEnvironment> ctx,
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 {
}
@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
public void preAddColumn(ObserverContext<MasterCoprocessorEnvironment> ctx,
TableName tableName, HColumnDescriptor column) throws IOException {

View File

@ -788,6 +788,25 @@ public interface MasterObserver extends Coprocessor {
void postModifyNamespace(final ObserverContext<MasterCoprocessorEnvironment> 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<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.
* @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 com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.protobuf.Descriptors;
import com.google.protobuf.Service;
@ -2042,34 +2041,45 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
@Override
public List<NamespaceDescriptor> listNamespaceDescriptors() throws IOException {
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
public List<HTableDescriptor> listTableDescriptorsByNamespace(String name) throws IOException {
getNamespaceDescriptor(name); // check that namespace exists
return Lists.newArrayList(tableDescriptors.getByNamespace(name).values());
return listTableDescriptors(name, null, null, true);
}
@Override
public List<TableName> listTableNamesByNamespace(String name) throws IOException {
List<TableName> tableNames = Lists.newArrayList();
getNamespaceDescriptor(name); // check that namespace exists
for (HTableDescriptor descriptor: tableDescriptors.getByNamespace(name).values()) {
tableNames.add(descriptor.getTableName());
}
return tableNames;
return listTableNames(name, null, true);
}
/**
* 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<HTableDescriptor> listTableDescriptors(final String regex,
public List<HTableDescriptor> listTableDescriptors(final String namespace, final String regex,
final List<TableName> tableNameList, final boolean includeSysTables)
throws IOException {
final List<HTableDescriptor> descriptors = new ArrayList<HTableDescriptor>();
@ -2082,7 +2092,13 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
if (!bypass) {
if (tableNameList == null || tableNameList.size() == 0) {
// 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) {
if (includeSysTables || !desc.getTableName().isSystemTable()) {
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
* @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<TableName> listTableNames(final String regex, final boolean includeSysTables)
throws IOException {
public List<TableName> listTableNames(final String namespace, final String regex,
final boolean includeSysTables) throws IOException {
final List<HTableDescriptor> descriptors = new ArrayList<HTableDescriptor>();
boolean bypass = false;
@ -2126,7 +2143,13 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
if (!bypass) {
// 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) {
if (includeSysTables || !htd.getTableName().isSystemTable()) {
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 */
public void preCreateTable(final HTableDescriptor htd, final HRegionInfo[] regions)

View File

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

View File

@ -1206,6 +1206,22 @@ public class AccessController extends BaseMasterAndRegionObserver
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
public void preTableFlush(final ObserverContext<MasterCoprocessorEnvironment> ctx,
final TableName tableName) throws IOException {

View File

@ -93,6 +93,8 @@ public class TestMasterObserver {
private boolean postDeleteNamespaceCalled;
private boolean preModifyNamespaceCalled;
private boolean postModifyNamespaceCalled;
private boolean preListNamespaceDescriptorsCalled;
private boolean postListNamespaceDescriptorsCalled;
private boolean preAddColumnCalled;
private boolean postAddColumnCalled;
private boolean preModifyColumnCalled;
@ -173,6 +175,8 @@ public class TestMasterObserver {
postDeleteNamespaceCalled = false;
preModifyNamespaceCalled = false;
postModifyNamespaceCalled = false;
preListNamespaceDescriptorsCalled = false;
postListNamespaceDescriptorsCalled = false;
preAddColumnCalled = false;
postAddColumnCalled = false;
preModifyColumnCalled = false;
@ -394,6 +398,29 @@ public class TestMasterObserver {
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
public void preAddColumn(ObserverContext<MasterCoprocessorEnvironment> env,
TableName tableName, HColumnDescriptor column) throws IOException {
@ -1428,6 +1455,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(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 java.util.List;
import java.util.Arrays;
import org.apache.hadoop.conf.Configuration;
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.NamespaceDescriptor;
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.HTable;
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);
}
@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
public void testGrantRevoke() throws Exception{
final String testUser = "testUser";