You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2014/09/15 19:13:02 UTC
[3/6] HBASE-7767 Get rid of ZKTable,
and table enable/disable state in ZK (Andrey Stepachev)
http://git-wip-us.apache.org/repos/asf/hbase/blob/3cc5d190/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/ZooKeeperProtos.java
----------------------------------------------------------------------
diff --git a/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/ZooKeeperProtos.java b/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/ZooKeeperProtos.java
index 6da497e..a86c4a6 100644
--- a/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/ZooKeeperProtos.java
+++ b/hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/ZooKeeperProtos.java
@@ -3242,12 +3242,12 @@ public final class ZooKeeperProtos {
// @@protoc_insertion_point(class_scope:SplitLogTask)
}
- public interface TableOrBuilder
+ public interface DeprecatedTableStateOrBuilder
extends com.google.protobuf.MessageOrBuilder {
- // required .Table.State state = 1 [default = ENABLED];
+ // required .DeprecatedTableState.State state = 1 [default = ENABLED];
/**
- * <code>required .Table.State state = 1 [default = ENABLED];</code>
+ * <code>required .DeprecatedTableState.State state = 1 [default = ENABLED];</code>
*
* <pre>
* This is the table's state. If no znode for a table,
@@ -3257,7 +3257,7 @@ public final class ZooKeeperProtos {
*/
boolean hasState();
/**
- * <code>required .Table.State state = 1 [default = ENABLED];</code>
+ * <code>required .DeprecatedTableState.State state = 1 [default = ENABLED];</code>
*
* <pre>
* This is the table's state. If no znode for a table,
@@ -3265,32 +3265,33 @@ public final class ZooKeeperProtos {
* for more.
* </pre>
*/
- org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State getState();
+ org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState.State getState();
}
/**
- * Protobuf type {@code Table}
+ * Protobuf type {@code DeprecatedTableState}
*
* <pre>
**
* The znode that holds state of table.
+ * Deprected, table state is stored in table descriptor on HDFS.
* </pre>
*/
- public static final class Table extends
+ public static final class DeprecatedTableState extends
com.google.protobuf.GeneratedMessage
- implements TableOrBuilder {
- // Use Table.newBuilder() to construct.
- private Table(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
+ implements DeprecatedTableStateOrBuilder {
+ // Use DeprecatedTableState.newBuilder() to construct.
+ private DeprecatedTableState(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
super(builder);
this.unknownFields = builder.getUnknownFields();
}
- private Table(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
+ private DeprecatedTableState(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
- private static final Table defaultInstance;
- public static Table getDefaultInstance() {
+ private static final DeprecatedTableState defaultInstance;
+ public static DeprecatedTableState getDefaultInstance() {
return defaultInstance;
}
- public Table getDefaultInstanceForType() {
+ public DeprecatedTableState getDefaultInstanceForType() {
return defaultInstance;
}
@@ -3300,7 +3301,7 @@ public final class ZooKeeperProtos {
getUnknownFields() {
return this.unknownFields;
}
- private Table(
+ private DeprecatedTableState(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
@@ -3325,7 +3326,7 @@ public final class ZooKeeperProtos {
}
case 8: {
int rawValue = input.readEnum();
- org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State value = org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State.valueOf(rawValue);
+ org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState.State value = org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState.State.valueOf(rawValue);
if (value == null) {
unknownFields.mergeVarintField(1, rawValue);
} else {
@@ -3348,33 +3349,33 @@ public final class ZooKeeperProtos {
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
- return org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.internal_static_Table_descriptor;
+ return org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.internal_static_DeprecatedTableState_descriptor;
}
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {
- return org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.internal_static_Table_fieldAccessorTable
+ return org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.internal_static_DeprecatedTableState_fieldAccessorTable
.ensureFieldAccessorsInitialized(
- org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.class, org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.Builder.class);
+ org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState.class, org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState.Builder.class);
}
- public static com.google.protobuf.Parser<Table> PARSER =
- new com.google.protobuf.AbstractParser<Table>() {
- public Table parsePartialFrom(
+ public static com.google.protobuf.Parser<DeprecatedTableState> PARSER =
+ new com.google.protobuf.AbstractParser<DeprecatedTableState>() {
+ public DeprecatedTableState parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
- return new Table(input, extensionRegistry);
+ return new DeprecatedTableState(input, extensionRegistry);
}
};
@java.lang.Override
- public com.google.protobuf.Parser<Table> getParserForType() {
+ public com.google.protobuf.Parser<DeprecatedTableState> getParserForType() {
return PARSER;
}
/**
- * Protobuf enum {@code Table.State}
+ * Protobuf enum {@code DeprecatedTableState.State}
*
* <pre>
* Table's current state
@@ -3452,7 +3453,7 @@ public final class ZooKeeperProtos {
}
public static final com.google.protobuf.Descriptors.EnumDescriptor
getDescriptor() {
- return org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.getDescriptor().getEnumTypes().get(0);
+ return org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState.getDescriptor().getEnumTypes().get(0);
}
private static final State[] VALUES = values();
@@ -3474,15 +3475,15 @@ public final class ZooKeeperProtos {
this.value = value;
}
- // @@protoc_insertion_point(enum_scope:Table.State)
+ // @@protoc_insertion_point(enum_scope:DeprecatedTableState.State)
}
private int bitField0_;
- // required .Table.State state = 1 [default = ENABLED];
+ // required .DeprecatedTableState.State state = 1 [default = ENABLED];
public static final int STATE_FIELD_NUMBER = 1;
- private org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State state_;
+ private org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState.State state_;
/**
- * <code>required .Table.State state = 1 [default = ENABLED];</code>
+ * <code>required .DeprecatedTableState.State state = 1 [default = ENABLED];</code>
*
* <pre>
* This is the table's state. If no znode for a table,
@@ -3494,7 +3495,7 @@ public final class ZooKeeperProtos {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
- * <code>required .Table.State state = 1 [default = ENABLED];</code>
+ * <code>required .DeprecatedTableState.State state = 1 [default = ENABLED];</code>
*
* <pre>
* This is the table's state. If no znode for a table,
@@ -3502,12 +3503,12 @@ public final class ZooKeeperProtos {
* for more.
* </pre>
*/
- public org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State getState() {
+ public org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState.State getState() {
return state_;
}
private void initFields() {
- state_ = org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State.ENABLED;
+ state_ = org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState.State.ENABLED;
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
@@ -3558,10 +3559,10 @@ public final class ZooKeeperProtos {
if (obj == this) {
return true;
}
- if (!(obj instanceof org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table)) {
+ if (!(obj instanceof org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState)) {
return super.equals(obj);
}
- org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table other = (org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table) obj;
+ org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState other = (org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState) obj;
boolean result = true;
result = result && (hasState() == other.hasState());
@@ -3591,53 +3592,53 @@ public final class ZooKeeperProtos {
return hash;
}
- public static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table parseFrom(
+ public static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
- public static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table parseFrom(
+ public static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
- public static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table parseFrom(byte[] data)
+ public static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
- public static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table parseFrom(
+ public static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
- public static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table parseFrom(java.io.InputStream input)
+ public static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState parseFrom(java.io.InputStream input)
throws java.io.IOException {
return PARSER.parseFrom(input);
}
- public static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table parseFrom(
+ public static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return PARSER.parseFrom(input, extensionRegistry);
}
- public static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table parseDelimitedFrom(java.io.InputStream input)
+ public static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return PARSER.parseDelimitedFrom(input);
}
- public static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table parseDelimitedFrom(
+ public static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return PARSER.parseDelimitedFrom(input, extensionRegistry);
}
- public static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table parseFrom(
+ public static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return PARSER.parseFrom(input);
}
- public static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table parseFrom(
+ public static org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
@@ -3646,7 +3647,7 @@ public final class ZooKeeperProtos {
public static Builder newBuilder() { return Builder.create(); }
public Builder newBuilderForType() { return newBuilder(); }
- public static Builder newBuilder(org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table prototype) {
+ public static Builder newBuilder(org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState prototype) {
return newBuilder().mergeFrom(prototype);
}
public Builder toBuilder() { return newBuilder(this); }
@@ -3658,29 +3659,30 @@ public final class ZooKeeperProtos {
return builder;
}
/**
- * Protobuf type {@code Table}
+ * Protobuf type {@code DeprecatedTableState}
*
* <pre>
**
* The znode that holds state of table.
+ * Deprected, table state is stored in table descriptor on HDFS.
* </pre>
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessage.Builder<Builder>
- implements org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.TableOrBuilder {
+ implements org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableStateOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
- return org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.internal_static_Table_descriptor;
+ return org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.internal_static_DeprecatedTableState_descriptor;
}
protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable() {
- return org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.internal_static_Table_fieldAccessorTable
+ return org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.internal_static_DeprecatedTableState_fieldAccessorTable
.ensureFieldAccessorsInitialized(
- org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.class, org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.Builder.class);
+ org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState.class, org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState.Builder.class);
}
- // Construct using org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.newBuilder()
+ // Construct using org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
@@ -3700,7 +3702,7 @@ public final class ZooKeeperProtos {
public Builder clear() {
super.clear();
- state_ = org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State.ENABLED;
+ state_ = org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState.State.ENABLED;
bitField0_ = (bitField0_ & ~0x00000001);
return this;
}
@@ -3711,23 +3713,23 @@ public final class ZooKeeperProtos {
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
- return org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.internal_static_Table_descriptor;
+ return org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.internal_static_DeprecatedTableState_descriptor;
}
- public org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table getDefaultInstanceForType() {
- return org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.getDefaultInstance();
+ public org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState getDefaultInstanceForType() {
+ return org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState.getDefaultInstance();
}
- public org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table build() {
- org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table result = buildPartial();
+ public org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState build() {
+ org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
- public org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table buildPartial() {
- org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table result = new org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table(this);
+ public org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState buildPartial() {
+ org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState result = new org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState(this);
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
@@ -3740,16 +3742,16 @@ public final class ZooKeeperProtos {
}
public Builder mergeFrom(com.google.protobuf.Message other) {
- if (other instanceof org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table) {
- return mergeFrom((org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table)other);
+ if (other instanceof org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState) {
+ return mergeFrom((org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState)other);
} else {
super.mergeFrom(other);
return this;
}
}
- public Builder mergeFrom(org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table other) {
- if (other == org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.getDefaultInstance()) return this;
+ public Builder mergeFrom(org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState other) {
+ if (other == org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState.getDefaultInstance()) return this;
if (other.hasState()) {
setState(other.getState());
}
@@ -3769,11 +3771,11 @@ public final class ZooKeeperProtos {
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
- org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table parsedMessage = null;
+ org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
- parsedMessage = (org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table) e.getUnfinishedMessage();
+ parsedMessage = (org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState) e.getUnfinishedMessage();
throw e;
} finally {
if (parsedMessage != null) {
@@ -3784,10 +3786,10 @@ public final class ZooKeeperProtos {
}
private int bitField0_;
- // required .Table.State state = 1 [default = ENABLED];
- private org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State state_ = org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State.ENABLED;
+ // required .DeprecatedTableState.State state = 1 [default = ENABLED];
+ private org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState.State state_ = org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState.State.ENABLED;
/**
- * <code>required .Table.State state = 1 [default = ENABLED];</code>
+ * <code>required .DeprecatedTableState.State state = 1 [default = ENABLED];</code>
*
* <pre>
* This is the table's state. If no znode for a table,
@@ -3799,7 +3801,7 @@ public final class ZooKeeperProtos {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
- * <code>required .Table.State state = 1 [default = ENABLED];</code>
+ * <code>required .DeprecatedTableState.State state = 1 [default = ENABLED];</code>
*
* <pre>
* This is the table's state. If no znode for a table,
@@ -3807,11 +3809,11 @@ public final class ZooKeeperProtos {
* for more.
* </pre>
*/
- public org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State getState() {
+ public org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState.State getState() {
return state_;
}
/**
- * <code>required .Table.State state = 1 [default = ENABLED];</code>
+ * <code>required .DeprecatedTableState.State state = 1 [default = ENABLED];</code>
*
* <pre>
* This is the table's state. If no znode for a table,
@@ -3819,7 +3821,7 @@ public final class ZooKeeperProtos {
* for more.
* </pre>
*/
- public Builder setState(org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State value) {
+ public Builder setState(org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState.State value) {
if (value == null) {
throw new NullPointerException();
}
@@ -3829,7 +3831,7 @@ public final class ZooKeeperProtos {
return this;
}
/**
- * <code>required .Table.State state = 1 [default = ENABLED];</code>
+ * <code>required .DeprecatedTableState.State state = 1 [default = ENABLED];</code>
*
* <pre>
* This is the table's state. If no znode for a table,
@@ -3839,20 +3841,20 @@ public final class ZooKeeperProtos {
*/
public Builder clearState() {
bitField0_ = (bitField0_ & ~0x00000001);
- state_ = org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table.State.ENABLED;
+ state_ = org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.DeprecatedTableState.State.ENABLED;
onChanged();
return this;
}
- // @@protoc_insertion_point(builder_scope:Table)
+ // @@protoc_insertion_point(builder_scope:DeprecatedTableState)
}
static {
- defaultInstance = new Table(true);
+ defaultInstance = new DeprecatedTableState(true);
defaultInstance.initFields();
}
- // @@protoc_insertion_point(class_scope:Table)
+ // @@protoc_insertion_point(class_scope:DeprecatedTableState)
}
public interface ReplicationPeerOrBuilder
@@ -9512,10 +9514,10 @@ public final class ZooKeeperProtos {
com.google.protobuf.GeneratedMessage.FieldAccessorTable
internal_static_SplitLogTask_fieldAccessorTable;
private static com.google.protobuf.Descriptors.Descriptor
- internal_static_Table_descriptor;
+ internal_static_DeprecatedTableState_descriptor;
private static
com.google.protobuf.GeneratedMessage.FieldAccessorTable
- internal_static_Table_fieldAccessorTable;
+ internal_static_DeprecatedTableState_fieldAccessorTable;
private static com.google.protobuf.Descriptors.Descriptor
internal_static_ReplicationPeer_descriptor;
private static
@@ -9573,27 +9575,28 @@ public final class ZooKeeperProtos {
"UNASSIGNED\020\000\022\t\n\005OWNED\020\001\022\014\n\010RESIGNED\020\002\022\010\n" +
"\004DONE\020\003\022\007\n\003ERR\020\004\">\n\014RecoveryMode\022\013\n\007UNKN" +
"OWN\020\000\022\021\n\rLOG_SPLITTING\020\001\022\016\n\nLOG_REPLAY\020\002" +
- "\"n\n\005Table\022$\n\005state\030\001 \002(\0162\014.Table.State:\007" +
- "ENABLED\"?\n\005State\022\013\n\007ENABLED\020\000\022\014\n\010DISABLE" +
- "D\020\001\022\r\n\tDISABLING\020\002\022\014\n\010ENABLING\020\003\"\215\001\n\017Rep" +
- "licationPeer\022\022\n\nclusterkey\030\001 \002(\t\022\037\n\027repl" +
- "icationEndpointImpl\030\002 \001(\t\022\035\n\004data\030\003 \003(\0132" +
- "\017.BytesBytesPair\022&\n\rconfiguration\030\004 \003(\0132" +
- "\017.NameStringPair\"^\n\020ReplicationState\022&\n\005",
- "state\030\001 \002(\0162\027.ReplicationState.State\"\"\n\005" +
- "State\022\013\n\007ENABLED\020\000\022\014\n\010DISABLED\020\001\"+\n\027Repl" +
- "icationHLogPosition\022\020\n\010position\030\001 \002(\003\"%\n" +
- "\017ReplicationLock\022\022\n\nlock_owner\030\001 \002(\t\"\230\001\n" +
- "\tTableLock\022\036\n\ntable_name\030\001 \001(\0132\n.TableNa" +
- "me\022\037\n\nlock_owner\030\002 \001(\0132\013.ServerName\022\021\n\tt" +
- "hread_id\030\003 \001(\003\022\021\n\tis_shared\030\004 \001(\010\022\017\n\007pur" +
- "pose\030\005 \001(\t\022\023\n\013create_time\030\006 \001(\003\";\n\017Store" +
- "SequenceId\022\023\n\013family_name\030\001 \002(\014\022\023\n\013seque" +
- "nce_id\030\002 \002(\004\"g\n\026RegionStoreSequenceIds\022 ",
- "\n\030last_flushed_sequence_id\030\001 \002(\004\022+\n\021stor" +
- "e_sequence_id\030\002 \003(\0132\020.StoreSequenceIdBE\n" +
- "*org.apache.hadoop.hbase.protobuf.genera" +
- "tedB\017ZooKeeperProtosH\001\210\001\001\240\001\001"
+ "\"\214\001\n\024DeprecatedTableState\0223\n\005state\030\001 \002(\016" +
+ "2\033.DeprecatedTableState.State:\007ENABLED\"?" +
+ "\n\005State\022\013\n\007ENABLED\020\000\022\014\n\010DISABLED\020\001\022\r\n\tDI" +
+ "SABLING\020\002\022\014\n\010ENABLING\020\003\"\215\001\n\017ReplicationP" +
+ "eer\022\022\n\nclusterkey\030\001 \002(\t\022\037\n\027replicationEn" +
+ "dpointImpl\030\002 \001(\t\022\035\n\004data\030\003 \003(\0132\017.BytesBy" +
+ "tesPair\022&\n\rconfiguration\030\004 \003(\0132\017.NameStr",
+ "ingPair\"^\n\020ReplicationState\022&\n\005state\030\001 \002" +
+ "(\0162\027.ReplicationState.State\"\"\n\005State\022\013\n\007" +
+ "ENABLED\020\000\022\014\n\010DISABLED\020\001\"+\n\027ReplicationHL" +
+ "ogPosition\022\020\n\010position\030\001 \002(\003\"%\n\017Replicat" +
+ "ionLock\022\022\n\nlock_owner\030\001 \002(\t\"\230\001\n\tTableLoc" +
+ "k\022\036\n\ntable_name\030\001 \001(\0132\n.TableName\022\037\n\nloc" +
+ "k_owner\030\002 \001(\0132\013.ServerName\022\021\n\tthread_id\030" +
+ "\003 \001(\003\022\021\n\tis_shared\030\004 \001(\010\022\017\n\007purpose\030\005 \001(" +
+ "\t\022\023\n\013create_time\030\006 \001(\003\";\n\017StoreSequenceI" +
+ "d\022\023\n\013family_name\030\001 \002(\014\022\023\n\013sequence_id\030\002 ",
+ "\002(\004\"g\n\026RegionStoreSequenceIds\022 \n\030last_fl" +
+ "ushed_sequence_id\030\001 \002(\004\022+\n\021store_sequenc" +
+ "e_id\030\002 \003(\0132\020.StoreSequenceIdBE\n*org.apac" +
+ "he.hadoop.hbase.protobuf.generatedB\017ZooK" +
+ "eeperProtosH\001\210\001\001\240\001\001"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@@ -9624,11 +9627,11 @@ public final class ZooKeeperProtos {
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_SplitLogTask_descriptor,
new java.lang.String[] { "State", "ServerName", "Mode", });
- internal_static_Table_descriptor =
+ internal_static_DeprecatedTableState_descriptor =
getDescriptor().getMessageTypes().get(4);
- internal_static_Table_fieldAccessorTable = new
+ internal_static_DeprecatedTableState_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
- internal_static_Table_descriptor,
+ internal_static_DeprecatedTableState_descriptor,
new java.lang.String[] { "State", });
internal_static_ReplicationPeer_descriptor =
getDescriptor().getMessageTypes().get(5);
http://git-wip-us.apache.org/repos/asf/hbase/blob/3cc5d190/hbase-protocol/src/main/protobuf/HBase.proto
----------------------------------------------------------------------
diff --git a/hbase-protocol/src/main/protobuf/HBase.proto b/hbase-protocol/src/main/protobuf/HBase.proto
index ca09777..252f532 100644
--- a/hbase-protocol/src/main/protobuf/HBase.proto
+++ b/hbase-protocol/src/main/protobuf/HBase.proto
@@ -44,6 +44,27 @@ message TableSchema {
repeated NameStringPair configuration = 4;
}
+/** Denotes state of the table */
+message TableState {
+ // Table's current state
+ enum State {
+ ENABLED = 0;
+ DISABLED = 1;
+ DISABLING = 2;
+ ENABLING = 3;
+ }
+ // This is the table's state.
+ required State state = 1;
+ required TableName table = 2;
+ optional uint64 timestamp = 3;
+}
+
+/** On HDFS representation of table state. */
+message TableDescriptor {
+ required TableSchema schema = 1;
+ optional TableState.State state = 2 [ default = ENABLED ];
+}
+
/**
* Column Family Schema
* Inspired by the rest ColumSchemaMessage
http://git-wip-us.apache.org/repos/asf/hbase/blob/3cc5d190/hbase-protocol/src/main/protobuf/Master.proto
----------------------------------------------------------------------
diff --git a/hbase-protocol/src/main/protobuf/Master.proto b/hbase-protocol/src/main/protobuf/Master.proto
index 94ea860..85daf43 100644
--- a/hbase-protocol/src/main/protobuf/Master.proto
+++ b/hbase-protocol/src/main/protobuf/Master.proto
@@ -326,6 +326,14 @@ message GetTableNamesResponse {
repeated TableName table_names = 1;
}
+message GetTableStateRequest {
+ required TableName table_name = 1;
+}
+
+message GetTableStateResponse {
+ required TableState table_state = 1;
+}
+
message GetClusterStatusRequest {
}
@@ -565,4 +573,8 @@ service MasterService {
/** returns a list of tables for a given namespace*/
rpc ListTableNamesByNamespace(ListTableNamesByNamespaceRequest)
returns(ListTableNamesByNamespaceResponse);
+
+ /** returns table state */
+ rpc GetTableState(GetTableStateRequest)
+ returns(GetTableStateResponse);
}
http://git-wip-us.apache.org/repos/asf/hbase/blob/3cc5d190/hbase-protocol/src/main/protobuf/ZooKeeper.proto
----------------------------------------------------------------------
diff --git a/hbase-protocol/src/main/protobuf/ZooKeeper.proto b/hbase-protocol/src/main/protobuf/ZooKeeper.proto
index 8acd778..c40fa77 100644
--- a/hbase-protocol/src/main/protobuf/ZooKeeper.proto
+++ b/hbase-protocol/src/main/protobuf/ZooKeeper.proto
@@ -87,8 +87,9 @@ message SplitLogTask {
/**
* The znode that holds state of table.
+ * Deprected, table state is stored in table descriptor on HDFS.
*/
-message Table {
+message DeprecatedTableState {
// Table's current state
enum State {
ENABLED = 0;
http://git-wip-us.apache.org/repos/asf/hbase/blob/3cc5d190/hbase-server/src/main/java/org/apache/hadoop/hbase/CoordinatedStateManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/CoordinatedStateManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/CoordinatedStateManager.java
index 2642e29..1019b2d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/CoordinatedStateManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/CoordinatedStateManager.java
@@ -55,12 +55,4 @@ public interface CoordinatedStateManager {
* @return instance of Server coordinated state manager runs within
*/
Server getServer();
-
- /**
- * Returns implementation of TableStateManager.
- * @throws InterruptedException if operation is interrupted
- * @throws CoordinatedStateException if error happens in underlying coordination mechanism
- */
- TableStateManager getTableStateManager() throws InterruptedException,
- CoordinatedStateException;
}
http://git-wip-us.apache.org/repos/asf/hbase/blob/3cc5d190/hbase-server/src/main/java/org/apache/hadoop/hbase/TableDescriptor.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/TableDescriptor.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/TableDescriptor.java
new file mode 100644
index 0000000..bf38ee5
--- /dev/null
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/TableDescriptor.java
@@ -0,0 +1,154 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase;
+
+import java.io.IOException;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.protobuf.InvalidProtocolBufferException;
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.client.TableState;
+import org.apache.hadoop.hbase.exceptions.DeserializationException;
+import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
+import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos;
+
+/**
+ * Class represents table state on HDFS.
+ */
+@InterfaceAudience.Private
+public class TableDescriptor {
+ private HTableDescriptor hTableDescriptor;
+ private TableState.State tableState;
+
+ /**
+ * Creates TableDescriptor with all fields.
+ * @param hTableDescriptor HTableDescriptor to use
+ * @param tableState table state
+ */
+ public TableDescriptor(HTableDescriptor hTableDescriptor,
+ TableState.State tableState) {
+ this.hTableDescriptor = hTableDescriptor;
+ this.tableState = tableState;
+ }
+
+ /**
+ * Creates TableDescriptor with Enabled table.
+ * @param hTableDescriptor HTableDescriptor to use
+ */
+ @VisibleForTesting
+ public TableDescriptor(HTableDescriptor hTableDescriptor) {
+ this(hTableDescriptor, TableState.State.ENABLED);
+ }
+
+ /**
+ * Associated HTableDescriptor
+ * @return instance of HTableDescriptor
+ */
+ public HTableDescriptor getHTableDescriptor() {
+ return hTableDescriptor;
+ }
+
+ public void setHTableDescriptor(HTableDescriptor hTableDescriptor) {
+ this.hTableDescriptor = hTableDescriptor;
+ }
+
+ public TableState.State getTableState() {
+ return tableState;
+ }
+
+ public void setTableState(TableState.State tableState) {
+ this.tableState = tableState;
+ }
+
+ /**
+ * Convert to PB.
+ */
+ public HBaseProtos.TableDescriptor convert() {
+ return HBaseProtos.TableDescriptor.newBuilder()
+ .setSchema(hTableDescriptor.convert())
+ .setState(tableState.convert())
+ .build();
+ }
+
+ /**
+ * Convert from PB
+ */
+ public static TableDescriptor convert(HBaseProtos.TableDescriptor proto) {
+ HTableDescriptor hTableDescriptor = HTableDescriptor.convert(proto.getSchema());
+ TableState.State state = TableState.State.convert(proto.getState());
+ return new TableDescriptor(hTableDescriptor, state);
+ }
+
+ /**
+ * @return This instance serialized with pb with pb magic prefix
+ * @see #parseFrom(byte[])
+ */
+ public byte [] toByteArray() {
+ return ProtobufUtil.prependPBMagic(convert().toByteArray());
+ }
+
+ /**
+ * @param bytes A pb serialized {@link TableDescriptor} instance with pb magic prefix
+ * @see #toByteArray()
+ */
+ public static TableDescriptor parseFrom(final byte [] bytes)
+ throws DeserializationException, IOException {
+ if (!ProtobufUtil.isPBMagicPrefix(bytes)) {
+ throw new DeserializationException("Expected PB encoded TableDescriptor");
+ }
+ int pblen = ProtobufUtil.lengthOfPBMagic();
+ HBaseProtos.TableDescriptor.Builder builder = HBaseProtos.TableDescriptor.newBuilder();
+ HBaseProtos.TableDescriptor ts;
+ try {
+ ts = builder.mergeFrom(bytes, pblen, bytes.length - pblen).build();
+ } catch (InvalidProtocolBufferException e) {
+ throw new DeserializationException(e);
+ }
+ return convert(ts);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ TableDescriptor that = (TableDescriptor) o;
+
+ if (hTableDescriptor != null ?
+ !hTableDescriptor.equals(that.hTableDescriptor) :
+ that.hTableDescriptor != null) return false;
+ if (tableState != that.tableState) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = hTableDescriptor != null ? hTableDescriptor.hashCode() : 0;
+ result = 31 * result + (tableState != null ? tableState.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "TableDescriptor{" +
+ "hTableDescriptor=" + hTableDescriptor +
+ ", tableState=" + tableState +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/hbase/blob/3cc5d190/hbase-server/src/main/java/org/apache/hadoop/hbase/TableDescriptors.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/TableDescriptors.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/TableDescriptors.java
index a0c246b..ff5f0b3 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/TableDescriptors.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/TableDescriptors.java
@@ -21,7 +21,6 @@ import java.io.IOException;
import java.util.Map;
import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.classification.InterfaceStability;
/**
* Get, remove and modify table descriptors.
@@ -38,6 +37,14 @@ public interface TableDescriptors {
throws IOException;
/**
+ * @param tableName
+ * @return TableDescriptor for tablename
+ * @throws IOException
+ */
+ TableDescriptor getDescriptor(final TableName tableName)
+ throws IOException;
+
+ /**
* Get Map of all NamespaceDescriptors for a given namespace.
* @return Map of all descriptors.
* @throws IOException
@@ -55,6 +62,15 @@ public interface TableDescriptors {
throws IOException;
/**
+ * Get Map of all TableDescriptors. Populates the descriptor cache as a
+ * side effect.
+ * @return Map of all descriptors.
+ * @throws IOException
+ */
+ Map<String, TableDescriptor> getAllDescriptors()
+ throws IOException;
+
+ /**
* Add or update descriptor
* @param htd Descriptor to set into TableDescriptors
* @throws IOException
@@ -63,6 +79,14 @@ public interface TableDescriptors {
throws IOException;
/**
+ * Add or update descriptor
+ * @param htd Descriptor to set into TableDescriptors
+ * @throws IOException
+ */
+ void add(final TableDescriptor htd)
+ throws IOException;
+
+ /**
* @param tablename
* @return Instance of table descriptor or null if none found.
* @throws IOException
http://git-wip-us.apache.org/repos/asf/hbase/blob/3cc5d190/hbase-server/src/main/java/org/apache/hadoop/hbase/TableStateManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/TableStateManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/TableStateManager.java
deleted file mode 100644
index 56cd4ae..0000000
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/TableStateManager.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.hbase;
-
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos;
-
-import java.io.InterruptedIOException;
-import java.util.Set;
-
-/**
- * Helper class for table state management for operations running inside
- * RegionServer or HMaster.
- * Depending on implementation, fetches information from HBase system table,
- * local data store, ZooKeeper ensemble or somewhere else.
- * Code running on client side (with no coordinated state context) shall instead use
- * {@link org.apache.hadoop.hbase.zookeeper.ZKTableStateClientSideReader}
- */
-@InterfaceAudience.Private
-public interface TableStateManager {
-
- /**
- * Sets the table into desired state. Fails silently if the table is already in this state.
- * @param tableName table to process
- * @param state new state of this table
- * @throws CoordinatedStateException if error happened when trying to set table state
- */
- void setTableState(TableName tableName, ZooKeeperProtos.Table.State state)
- throws CoordinatedStateException;
-
- /**
- * Sets the specified table into the newState, but only if the table is already in
- * one of the possibleCurrentStates (otherwise no operation is performed).
- * @param tableName table to process
- * @param newState new state for the table
- * @param states table should be in one of these states for the operation
- * to be performed
- * @throws CoordinatedStateException if error happened while performing operation
- * @return true if operation succeeded, false otherwise
- */
- boolean setTableStateIfInStates(TableName tableName, ZooKeeperProtos.Table.State newState,
- ZooKeeperProtos.Table.State... states)
- throws CoordinatedStateException;
-
- /**
- * Sets the specified table into the newState, but only if the table is NOT in
- * one of the possibleCurrentStates (otherwise no operation is performed).
- * @param tableName table to process
- * @param newState new state for the table
- * @param states table should NOT be in one of these states for the operation
- * to be performed
- * @throws CoordinatedStateException if error happened while performing operation
- * @return true if operation succeeded, false otherwise
- */
- boolean setTableStateIfNotInStates(TableName tableName, ZooKeeperProtos.Table.State newState,
- ZooKeeperProtos.Table.State... states)
- throws CoordinatedStateException;
-
- /**
- * @return true if the table is in any one of the listed states, false otherwise.
- */
- boolean isTableState(TableName tableName, ZooKeeperProtos.Table.State... states);
-
- /**
- * Mark table as deleted. Fails silently if the table is not currently marked as disabled.
- * @param tableName table to be deleted
- * @throws CoordinatedStateException if error happened while performing operation
- */
- void setDeletedTable(TableName tableName) throws CoordinatedStateException;
-
- /**
- * Checks if table is present.
- *
- * @param tableName table we're checking
- * @return true if the table is present, false otherwise
- */
- boolean isTablePresent(TableName tableName);
-
- /**
- * @return set of tables which are in any one of the listed states, empty Set if none
- */
- Set<TableName> getTablesInStates(ZooKeeperProtos.Table.State... states)
- throws InterruptedIOException, CoordinatedStateException;
-
- /**
- * If the table is found in the given state the in-memory state is removed. This
- * helps in cases where CreateTable is to be retried by the client in case of
- * failures. If deletePermanentState is true - the flag kept permanently is
- * also reset.
- *
- * @param tableName table we're working on
- * @param states if table isn't in any one of these states, operation aborts
- * @param deletePermanentState if true, reset the permanent flag
- * @throws CoordinatedStateException if error happened in underlying coordination engine
- */
- void checkAndRemoveTableState(TableName tableName, ZooKeeperProtos.Table.State states,
- boolean deletePermanentState)
- throws CoordinatedStateException;
-}
http://git-wip-us.apache.org/repos/asf/hbase/blob/3cc5d190/hbase-server/src/main/java/org/apache/hadoop/hbase/client/CoprocessorHConnection.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/CoprocessorHConnection.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/CoprocessorHConnection.java
index db853ed..6654032 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/CoprocessorHConnection.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/CoprocessorHConnection.java
@@ -118,4 +118,4 @@ public class CoprocessorHConnection extends HConnectionImplementation {
public NonceGenerator getNonceGenerator() {
return NO_NONCE_GEN; // don't use nonces for coprocessor connection
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/hbase/blob/3cc5d190/hbase-server/src/main/java/org/apache/hadoop/hbase/coordination/BaseCoordinatedStateManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coordination/BaseCoordinatedStateManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coordination/BaseCoordinatedStateManager.java
index 295cefe..cb59dff 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coordination/BaseCoordinatedStateManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coordination/BaseCoordinatedStateManager.java
@@ -18,10 +18,8 @@
package org.apache.hadoop.hbase.coordination;
import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.hbase.CoordinatedStateException;
import org.apache.hadoop.hbase.CoordinatedStateManager;
import org.apache.hadoop.hbase.Server;
-import org.apache.hadoop.hbase.TableStateManager;
/**
* Base class for {@link org.apache.hadoop.hbase.CoordinatedStateManager} implementations.
@@ -49,10 +47,6 @@ public abstract class BaseCoordinatedStateManager implements CoordinatedStateMan
return null;
}
- @Override
- public abstract TableStateManager getTableStateManager() throws InterruptedException,
- CoordinatedStateException;
-
/**
* Method to retrieve coordination for split log worker
*/
@@ -61,4 +55,4 @@ public abstract class BaseCoordinatedStateManager implements CoordinatedStateMan
* Method to retrieve coordination for split log manager
*/
public abstract SplitLogManagerCoordination getSplitLogManagerCoordination();
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/hbase/blob/3cc5d190/hbase-server/src/main/java/org/apache/hadoop/hbase/coordination/ZkCoordinatedStateManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coordination/ZkCoordinatedStateManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coordination/ZkCoordinatedStateManager.java
index 98500d3..cce6091 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coordination/ZkCoordinatedStateManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coordination/ZkCoordinatedStateManager.java
@@ -18,14 +18,9 @@
package org.apache.hadoop.hbase.coordination;
import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.hbase.CoordinatedStateException;
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
import org.apache.hadoop.hbase.Server;
-import org.apache.hadoop.hbase.TableStateManager;
-import org.apache.hadoop.hbase.master.HMaster;
-import org.apache.hadoop.hbase.zookeeper.ZKTableStateManager;
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
-import org.apache.zookeeper.KeeperException;
/**
* ZooKeeper-based implementation of {@link org.apache.hadoop.hbase.CoordinatedStateManager}.
@@ -52,16 +47,6 @@ public class ZkCoordinatedStateManager extends BaseCoordinatedStateManager {
}
@Override
- public TableStateManager getTableStateManager() throws InterruptedException,
- CoordinatedStateException {
- try {
- return new ZKTableStateManager(server.getZooKeeper());
- } catch (KeeperException e) {
- throw new CoordinatedStateException(e);
- }
- }
-
- @Override
public SplitLogWorkerCoordination getSplitLogWorkerCoordination() {
return splitLogWorkerCoordination;
}
http://git-wip-us.apache.org/repos/asf/hbase/blob/3cc5d190/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
index 5b9ff36..7e0a5e2 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
@@ -19,7 +19,6 @@
package org.apache.hadoop.hbase.master;
import java.io.IOException;
-import java.io.InterruptedIOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -47,7 +46,6 @@ import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.CoordinatedStateException;
import org.apache.hadoop.hbase.HBaseIOException;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
@@ -60,9 +58,9 @@ import org.apache.hadoop.hbase.Server;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.TableNotFoundException;
-import org.apache.hadoop.hbase.TableStateManager;
import org.apache.hadoop.hbase.client.RegionReplicaUtil;
import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.TableState;
import org.apache.hadoop.hbase.executor.EventHandler;
import org.apache.hadoop.hbase.executor.EventType;
import org.apache.hadoop.hbase.executor.ExecutorService;
@@ -76,8 +74,6 @@ import org.apache.hadoop.hbase.master.handler.DisableTableHandler;
import org.apache.hadoop.hbase.master.handler.EnableTableHandler;
import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionStateTransition;
import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode;
-import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos;
-import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.Table;
import org.apache.hadoop.hbase.regionserver.RegionOpeningState;
import org.apache.hadoop.hbase.regionserver.RegionServerStoppedException;
import org.apache.hadoop.hbase.regionserver.wal.HLog;
@@ -207,14 +203,14 @@ public class AssignmentManager {
* @param service Executor service
* @param metricsMaster metrics manager
* @param tableLockManager TableLock manager
- * @throws CoordinatedStateException
* @throws IOException
*/
public AssignmentManager(Server server, ServerManager serverManager,
final LoadBalancer balancer,
final ExecutorService service, MetricsMaster metricsMaster,
- final TableLockManager tableLockManager)
- throws IOException, CoordinatedStateException {
+ final TableLockManager tableLockManager,
+ final TableStateManager tableStateManager)
+ throws IOException {
this.server = server;
this.serverManager = serverManager;
this.executorService = service;
@@ -226,15 +222,9 @@ public class AssignmentManager {
this.shouldAssignRegionsWithFavoredNodes = conf.getClass(
HConstants.HBASE_MASTER_LOADBALANCER_CLASS, Object.class).equals(
FavoredNodeLoadBalancer.class);
- try {
- if (server.getCoordinatedStateManager() != null) {
- this.tableStateManager = server.getCoordinatedStateManager().getTableStateManager();
- } else {
- this.tableStateManager = null;
- }
- } catch (InterruptedException e) {
- throw new InterruptedIOException();
- }
+
+ this.tableStateManager = tableStateManager;
+
// This is the max attempts, not retries, so it should be at least 1.
this.maximumAttempts = Math.max(1,
this.server.getConfiguration().getInt("hbase.assignment.maximum.attempts", 10));
@@ -392,10 +382,9 @@ public class AssignmentManager {
* @throws IOException
* @throws KeeperException
* @throws InterruptedException
- * @throws CoordinatedStateException
*/
void joinCluster() throws IOException,
- KeeperException, InterruptedException, CoordinatedStateException {
+ KeeperException, InterruptedException {
long startTime = System.currentTimeMillis();
// Concurrency note: In the below the accesses on regionsInTransition are
// outside of a synchronization block where usually all accesses to RIT are
@@ -430,10 +419,9 @@ public class AssignmentManager {
* Map of dead servers and their regions. Can be null.
* @throws IOException
* @throws InterruptedException
- * @throws CoordinatedStateException
*/
boolean processDeadServersAndRegionsInTransition(final Set<ServerName> deadServers)
- throws IOException, InterruptedException, CoordinatedStateException {
+ throws IOException, InterruptedException {
boolean failover = !serverManager.getDeadServers().isEmpty();
if (failover) {
// This may not be a failover actually, especially if meta is on this master.
@@ -502,8 +490,8 @@ public class AssignmentManager {
if (!failover) {
disabledOrDisablingOrEnabling = tableStateManager.getTablesInStates(
- ZooKeeperProtos.Table.State.DISABLED, ZooKeeperProtos.Table.State.DISABLING,
- ZooKeeperProtos.Table.State.ENABLING);
+ TableState.State.DISABLED, TableState.State.DISABLING,
+ TableState.State.ENABLING);
// Clean re/start, mark all user regions closed before reassignment
allRegions = regionStates.closeAllUserRegions(
@@ -1011,7 +999,7 @@ public class AssignmentManager {
// will not be in ENABLING or ENABLED state.
TableName tableName = region.getTable();
if (!tableStateManager.isTableState(tableName,
- ZooKeeperProtos.Table.State.ENABLED, ZooKeeperProtos.Table.State.ENABLING)) {
+ TableState.State.ENABLED, TableState.State.ENABLING)) {
LOG.debug("Setting table " + tableName + " to ENABLED state.");
setEnabledTable(tableName);
}
@@ -1147,8 +1135,8 @@ public class AssignmentManager {
private boolean isDisabledorDisablingRegionInRIT(final HRegionInfo region) {
if (this.tableStateManager.isTableState(region.getTable(),
- ZooKeeperProtos.Table.State.DISABLED,
- ZooKeeperProtos.Table.State.DISABLING) || replicasToClose.contains(region)) {
+ TableState.State.DISABLED,
+ TableState.State.DISABLING) || replicasToClose.contains(region)) {
LOG.info("Table " + region.getTable() + " is disabled or disabling;"
+ " skipping assign of " + region.getRegionNameAsString());
offlineDisabledRegion(region);
@@ -1480,7 +1468,7 @@ public class AssignmentManager {
for (HRegionInfo hri : regionsFromMetaScan) {
TableName tableName = hri.getTable();
if (!tableStateManager.isTableState(tableName,
- ZooKeeperProtos.Table.State.ENABLED)) {
+ TableState.State.ENABLED)) {
setEnabledTable(tableName);
}
}
@@ -1525,14 +1513,14 @@ public class AssignmentManager {
* @throws IOException
*/
Set<ServerName> rebuildUserRegions() throws
- IOException, KeeperException, CoordinatedStateException {
+ IOException, KeeperException {
Set<TableName> disabledOrEnablingTables = tableStateManager.getTablesInStates(
- ZooKeeperProtos.Table.State.DISABLED, ZooKeeperProtos.Table.State.ENABLING);
+ TableState.State.DISABLED, TableState.State.ENABLING);
Set<TableName> disabledOrDisablingOrEnabling = tableStateManager.getTablesInStates(
- ZooKeeperProtos.Table.State.DISABLED,
- ZooKeeperProtos.Table.State.DISABLING,
- ZooKeeperProtos.Table.State.ENABLING);
+ TableState.State.DISABLED,
+ TableState.State.DISABLING,
+ TableState.State.ENABLING);
// Region assignment from META
List<Result> results = MetaTableAccessor.fullScanOfMeta(server.getShortCircuitConnection());
@@ -1597,7 +1585,7 @@ public class AssignmentManager {
// this will be used in rolling restarts
if (!disabledOrDisablingOrEnabling.contains(tableName)
&& !getTableStateManager().isTableState(tableName,
- ZooKeeperProtos.Table.State.ENABLED)) {
+ TableState.State.ENABLED)) {
setEnabledTable(tableName);
}
}
@@ -1614,9 +1602,9 @@ public class AssignmentManager {
* @throws IOException
*/
private void recoverTableInDisablingState()
- throws KeeperException, IOException, CoordinatedStateException {
+ throws KeeperException, IOException {
Set<TableName> disablingTables =
- tableStateManager.getTablesInStates(ZooKeeperProtos.Table.State.DISABLING);
+ tableStateManager.getTablesInStates(TableState.State.DISABLING);
if (disablingTables.size() != 0) {
for (TableName tableName : disablingTables) {
// Recover by calling DisableTableHandler
@@ -1638,9 +1626,9 @@ public class AssignmentManager {
* @throws IOException
*/
private void recoverTableInEnablingState()
- throws KeeperException, IOException, CoordinatedStateException {
+ throws KeeperException, IOException {
Set<TableName> enablingTables = tableStateManager.
- getTablesInStates(ZooKeeperProtos.Table.State.ENABLING);
+ getTablesInStates(TableState.State.ENABLING);
if (enablingTables.size() != 0) {
for (TableName tableName : enablingTables) {
// Recover by calling EnableTableHandler
@@ -1675,7 +1663,7 @@ public class AssignmentManager {
if (!serverManager.isServerOnline(regionState.getServerName())) {
continue; // SSH will handle it
}
- State state = regionState.getState();
+ RegionState.State state = regionState.getState();
LOG.info("Processing " + regionState);
switch (state) {
case CLOSED:
@@ -1809,7 +1797,7 @@ public class AssignmentManager {
} catch (InterruptedException ie) {
LOG.warn("Failed to unassign "
+ hri.getRegionNameAsString() + " since interrupted", ie);
- regionStates.updateRegionState(hri, State.FAILED_CLOSE);
+ regionStates.updateRegionState(hri, RegionState.State.FAILED_CLOSE);
Thread.currentThread().interrupt();
return;
}
@@ -1987,7 +1975,7 @@ public class AssignmentManager {
it.remove();
} else {
if (tableStateManager.isTableState(hri.getTable(),
- ZooKeeperProtos.Table.State.DISABLED, ZooKeeperProtos.Table.State.DISABLING)) {
+ TableState.State.DISABLED, TableState.State.DISABLING)) {
regionStates.regionOffline(hri);
it.remove();
continue;
@@ -2009,7 +1997,7 @@ public class AssignmentManager {
HRegionInfo hri = plan.getRegionInfo();
TableName tableName = hri.getTable();
if (tableStateManager.isTableState(tableName,
- ZooKeeperProtos.Table.State.DISABLED, ZooKeeperProtos.Table.State.DISABLING)) {
+ TableState.State.DISABLED, TableState.State.DISABLING)) {
LOG.info("Ignored moving region of disabling/disabled table "
+ tableName);
return;
@@ -2043,8 +2031,8 @@ public class AssignmentManager {
protected void setEnabledTable(TableName tableName) {
try {
this.tableStateManager.setTableState(tableName,
- ZooKeeperProtos.Table.State.ENABLED);
- } catch (CoordinatedStateException e) {
+ TableState.State.ENABLED);
+ } catch (IOException e) {
// here we can abort as it is the start up flow
String errorMsg = "Unable to ensure that the table " + tableName
+ " will be" + " enabled because of a ZooKeeper issue";
@@ -2087,8 +2075,9 @@ public class AssignmentManager {
if (regionState != null) {
// When there are more than one region server a new RS is selected as the
// destination and the same is updated in the region plan. (HBASE-5546)
- if (getTableStateManager().isTableState(hri.getTable(), Table.State.DISABLED,
- Table.State.DISABLING) || replicasToClose.contains(hri)) {
+ if (getTableStateManager().isTableState(hri.getTable(),
+ TableState.State.DISABLED, TableState.State.DISABLING) ||
+ replicasToClose.contains(hri)) {
offlineDisabledRegion(hri);
return null;
}
@@ -2131,7 +2120,7 @@ public class AssignmentManager {
// reset the count, if any
failedOpenTracker.remove(hri.getEncodedName());
if (getTableStateManager().isTableState(hri.getTable(),
- Table.State.DISABLED, Table.State.DISABLING)) {
+ TableState.State.DISABLED, TableState.State.DISABLING)) {
invokeUnAssign(hri);
}
return null;
@@ -2149,8 +2138,8 @@ public class AssignmentManager {
if (current == null || !current.isOnServer(serverName) || !current.isClosing()) {
return hri.getShortNameToLog() + " is not closing on " + serverName;
}
- if (getTableStateManager().isTableState(hri.getTable(), Table.State.DISABLED,
- Table.State.DISABLING) || replicasToClose.contains(hri)) {
+ if (getTableStateManager().isTableState(hri.getTable(), TableState.State.DISABLED,
+ TableState.State.DISABLING) || replicasToClose.contains(hri)) {
offlineDisabledRegion(hri);
return null;
}
@@ -2263,7 +2252,7 @@ public class AssignmentManager {
// User could disable the table before master knows the new region.
if (getTableStateManager().isTableState(hri.getTable(),
- Table.State.DISABLED, Table.State.DISABLING)) {
+ TableState.State.DISABLED, TableState.State.DISABLING)) {
invokeUnAssign(a);
invokeUnAssign(b);
} else {
@@ -2308,7 +2297,7 @@ public class AssignmentManager {
regionOffline(a);
regionOffline(b);
if (getTableStateManager().isTableState(hri.getTable(),
- Table.State.DISABLED, Table.State.DISABLING)) {
+ TableState.State.DISABLED, TableState.State.DISABLING)) {
invokeUnAssign(hri);
}
return null;
@@ -2419,7 +2408,7 @@ public class AssignmentManager {
// User could disable the table before master knows the new region.
if (getTableStateManager().isTableState(hri.getTable(),
- Table.State.DISABLED, Table.State.DISABLING)) {
+ TableState.State.DISABLED, TableState.State.DISABLING)) {
invokeUnAssign(hri);
} else {
Callable<Object> mergeReplicasCallable = new Callable<Object>() {
@@ -2464,7 +2453,7 @@ public class AssignmentManager {
regionOffline(hri);
if (getTableStateManager().isTableState(hri.getTable(),
- Table.State.DISABLED, Table.State.DISABLING)) {
+ TableState.State.DISABLED, TableState.State.DISABLING)) {
invokeUnAssign(a);
invokeUnAssign(b);
}
http://git-wip-us.apache.org/repos/asf/hbase/blob/3cc5d190/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
index 714b5a8..dfde451 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
@@ -71,6 +71,7 @@ import org.apache.hadoop.hbase.client.MetaScanner;
import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitor;
import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase;
import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.TableState;
import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
import org.apache.hadoop.hbase.exceptions.DeserializationException;
import org.apache.hadoop.hbase.executor.ExecutorType;
@@ -100,7 +101,6 @@ import org.apache.hadoop.hbase.monitoring.TaskMonitor;
import org.apache.hadoop.hbase.procedure.MasterProcedureManagerHost;
import org.apache.hadoop.hbase.procedure.flush.MasterFlushTableProcedureManager;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo;
-import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos;
import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.SplitLogTask.RecoveryMode;
import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.regionserver.RSRpcServices;
@@ -114,6 +114,7 @@ import org.apache.hadoop.hbase.util.HFileArchiveUtil;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.hbase.util.Threads;
import org.apache.hadoop.hbase.util.VersionInfo;
+import org.apache.hadoop.hbase.util.ZKDataMigrator;
import org.apache.hadoop.hbase.zookeeper.DrainingServerTracker;
import org.apache.hadoop.hbase.zookeeper.LoadBalancerTracker;
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker;
@@ -224,6 +225,9 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
// monitor for distributed procedures
MasterProcedureManagerHost mpmHost;
+ // handle table states
+ private TableStateManager tableStateManager;
+
/** flag used in test cases in order to simulate RS failures during master initialization */
private volatile boolean initializationBeforeMetaAssignment = false;
@@ -409,7 +413,7 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
this.loadBalancerTracker.start();
this.assignmentManager = new AssignmentManager(this, serverManager,
this.balancer, this.service, this.metricsMaster,
- this.tableLockManager);
+ this.tableLockManager, tableStateManager);
this.regionServerTracker = new RegionServerTracker(zooKeeper, this,
this.serverManager);
@@ -436,6 +440,14 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
this.mpmHost.register(new MasterFlushTableProcedureManager());
this.mpmHost.loadProcedures(conf);
this.mpmHost.initialize(this, this.metricsMaster);
+
+ // migrating existent table state from zk
+ for (Map.Entry<TableName, TableState.State> entry : ZKDataMigrator
+ .queryForTableStates(getZooKeeper()).entrySet()) {
+ LOG.info("Converting state from zk to new states:" + entry);
+ tableStateManager.setTableState(entry.getKey(), entry.getValue());
+ }
+ ZKUtil.deleteChildrenRecursively(getZooKeeper(), getZooKeeper().tableZNode);
}
/**
@@ -490,6 +502,9 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
// Invalidate all write locks held previously
this.tableLockManager.reapWriteLocks();
+ this.tableStateManager = new TableStateManager(this);
+ this.tableStateManager.start();
+
status.setStatus("Initializing ZK system trackers");
initializeZKBasedSystemTrackers();
@@ -737,8 +752,8 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
}
private void enableMeta(TableName metaTableName) {
- if (!this.assignmentManager.getTableStateManager().isTableState(metaTableName,
- ZooKeeperProtos.Table.State.ENABLED)) {
+ if (!this.tableStateManager.isTableState(metaTableName,
+ TableState.State.ENABLED)) {
this.assignmentManager.setEnabledTable(metaTableName);
}
}
@@ -777,6 +792,11 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
return this.fileSystemManager;
}
+ @Override
+ public TableStateManager getTableStateManager() {
+ return tableStateManager;
+ }
+
/*
* Start up all services. If any of these threads gets an unhandled exception
* then they just die with a logged message. This should be fine because
@@ -1452,7 +1472,7 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
throw new TableNotFoundException(tableName);
}
if (!getAssignmentManager().getTableStateManager().
- isTableState(tableName, ZooKeeperProtos.Table.State.DISABLED)) {
+ isTableState(tableName, TableState.State.DISABLED)) {
throw new TableNotDisabledException(tableName);
}
}
http://git-wip-us.apache.org/repos/asf/hbase/blob/3cc5d190/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
index be702ab..49225c4 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
@@ -43,8 +43,10 @@ import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.InvalidFamilyOperationException;
import org.apache.hadoop.hbase.Server;
import org.apache.hadoop.hbase.ServerName;
+import org.apache.hadoop.hbase.TableDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.backup.HFileArchiver;
+import org.apache.hadoop.hbase.client.TableState;
import org.apache.hadoop.hbase.exceptions.DeserializationException;
import org.apache.hadoop.hbase.fs.HFileSystem;
import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.SplitLogTask.RecoveryMode;
@@ -454,7 +456,9 @@ public class MasterFileSystem {
}
// Create tableinfo-s for hbase:meta if not already there.
- new FSTableDescriptors(fs, rd).createTableDescriptor(HTableDescriptor.META_TABLEDESC);
+ // assume, created table descriptor is for enabling table
+ new FSTableDescriptors(fs, rd).createTableDescriptor(
+ new TableDescriptor(HTableDescriptor.META_TABLEDESC, TableState.State.ENABLING));
return rd;
}
http://git-wip-us.apache.org/repos/asf/hbase/blob/3cc5d190/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java
index bb4a09c..54f8777 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java
@@ -37,8 +37,10 @@ import org.apache.hadoop.hbase.PleaseHoldException;
import org.apache.hadoop.hbase.ServerLoad;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.TableNotFoundException;
import org.apache.hadoop.hbase.UnknownRegionException;
import org.apache.hadoop.hbase.MetaTableAccessor;
+import org.apache.hadoop.hbase.client.TableState;
import org.apache.hadoop.hbase.exceptions.MergeRegionException;
import org.apache.hadoop.hbase.exceptions.UnknownProtocolException;
import org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface;
@@ -848,7 +850,7 @@ public class MasterRpcServices extends RSRpcServices
public GetTableNamesResponse getTableNames(RpcController controller,
GetTableNamesRequest req) throws ServiceException {
try {
- master.checkInitialized();
+ master.checkServiceStarted();
Collection<HTableDescriptor> descriptors = master.getTableDescriptors().getAll().values();
GetTableNamesResponse.Builder builder = GetTableNamesResponse.newBuilder();
for (HTableDescriptor descriptor: descriptors) {
@@ -864,6 +866,25 @@ public class MasterRpcServices extends RSRpcServices
}
@Override
+ public MasterProtos.GetTableStateResponse getTableState(RpcController controller,
+ MasterProtos.GetTableStateRequest request) throws ServiceException {
+ try {
+ master.checkServiceStarted();
+ TableName tableName = ProtobufUtil.toTableName(request.getTableName());
+ TableState.State state = master.getTableStateManager()
+ .getTableState(tableName);
+ if (state == null)
+ throw new TableNotFoundException(tableName);
+ MasterProtos.GetTableStateResponse.Builder builder =
+ MasterProtos.GetTableStateResponse.newBuilder();
+ builder.setTableState(new TableState(tableName, state).convert());
+ return builder.build();
+ } catch (IOException e) {
+ throw new ServiceException(e);
+ }
+ }
+
+ @Override
public IsCatalogJanitorEnabledResponse isCatalogJanitorEnabled(RpcController c,
IsCatalogJanitorEnabledRequest req) throws ServiceException {
return IsCatalogJanitorEnabledResponse.newBuilder().setValue(
http://git-wip-us.apache.org/repos/asf/hbase/blob/3cc5d190/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterServices.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterServices.java
index c1334f5..213f7f8 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterServices.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterServices.java
@@ -66,6 +66,11 @@ public interface MasterServices extends Server {
TableLockManager getTableLockManager();
/**
+ * @return Master's instance of {@link TableStateManager}
+ */
+ TableStateManager getTableStateManager();
+
+ /**
* @return Master's instance of {@link MasterCoprocessorHost}
*/
MasterCoprocessorHost getMasterCoprocessorHost();
http://git-wip-us.apache.org/repos/asf/hbase/blob/3cc5d190/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
index 6a0882c..38e972f 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
@@ -29,6 +29,8 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
@@ -40,16 +42,12 @@ import org.apache.hadoop.hbase.Server;
import org.apache.hadoop.hbase.ServerLoad;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.TableStateManager;
import org.apache.hadoop.hbase.client.RegionReplicaUtil;
import org.apache.hadoop.hbase.master.RegionState.State;
-import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos;
+import org.apache.hadoop.hbase.client.TableState;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.Pair;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
-
/**
* Region state accountant. It holds the states of all regions in the memory.
* In normal scenario, it should match the meta table and the true region states.
@@ -509,7 +507,7 @@ public class RegionStates {
if (oldServerName != null && serverHoldings.containsKey(oldServerName)
&& (newState == State.MERGED || newState == State.SPLIT
|| hri.isMetaRegion() || tableStateManager.isTableState(hri.getTable(),
- ZooKeeperProtos.Table.State.DISABLED, ZooKeeperProtos.Table.State.DISABLING))) {
+ TableState.State.DISABLED, TableState.State.DISABLING))) {
// Offline the region only if it's merged/split, or the table is disabled/disabling.
// Otherwise, offline it from this server only when it is online on a different server.
LOG.info("Offlined " + hri.getShortNameToLog() + " from " + oldServerName);
@@ -937,8 +935,8 @@ public class RegionStates {
* Update a region state. It will be put in transition if not already there.
*/
private RegionState updateRegionState(final HRegionInfo hri,
- final State state, final ServerName serverName, long openSeqNum) {
- if (state == State.FAILED_CLOSE || state == State.FAILED_OPEN) {
+ final RegionState.State state, final ServerName serverName, long openSeqNum) {
+ if (state == RegionState.State.FAILED_CLOSE || state == RegionState.State.FAILED_OPEN) {
LOG.warn("Failed to open/close " + hri.getShortNameToLog()
+ " on " + serverName + ", set to " + state);
}
http://git-wip-us.apache.org/repos/asf/hbase/blob/3cc5d190/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableNamespaceManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableNamespaceManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableNamespaceManager.java
index a78e225..8ad0d1a 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableNamespaceManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableNamespaceManager.java
@@ -46,6 +46,7 @@ import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.client.TableState;
import org.apache.hadoop.hbase.constraint.ConstraintException;
import org.apache.hadoop.hbase.master.handler.CreateTableHandler;
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
@@ -258,7 +259,7 @@ public class TableNamespaceManager {
}
// Now check if the table is assigned, if not then fail fast
- if (isTableAssigned()) {
+ if (isTableAssigned() && isTableEnabled()) {
try {
nsTable = new HTable(conf, TableName.NAMESPACE_TABLE_NAME);
zkNamespaceManager = new ZKNamespaceManager(masterServices.getZooKeeper());
@@ -298,6 +299,12 @@ public class TableNamespaceManager {
return false;
}
+ private boolean isTableEnabled() throws IOException {
+ return masterServices.getTableStateManager().getTableState(
+ TableName.NAMESPACE_TABLE_NAME
+ ).equals(TableState.State.ENABLED);
+ }
+
private boolean isTableAssigned() {
return !masterServices.getAssignmentManager()
.getRegionStates().getRegionsOfTable(TableName.NAMESPACE_TABLE_NAME).isEmpty();