-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-29081: Add HBase Read Replica Cluster feature #8044
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
anmolnar
wants to merge
43
commits into
master
Choose a base branch
from
HBASE-29081
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 37 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
4ad03c8
HBASE-29082: Support for custom meta table name suffix (#6632)
kabhishek4 2ed18d7
HBASE-29083: Add global read-only mode to HBase (#6757)
sharmaar12 a8beb21
HBASE-29236: Add Support for Dynamic Configuration at the Coprocessor…
kgeisz 0a7b45c
HBASE-29228 Add support to prevent running multiple active clusters (…
kabhishek4 8e4f705
HBASE-29291: Add a command to refresh/sync hbase:meta table (#7058)
Kota-SH 56691db
HBASE-29328: Implement new HBase command: refresh_hfiles (#7149)
sharmaar12 8bdbb62
HBASE-29579: AssignmentManager is trying to pick up the other cluster…
Kota-SH 97f337d
HBASE-29597 Supply meta table name for replica to the tests in TestMe…
kabhishek4 a8c7311
HBASE-29621: Remove the leading whitespace in the active.cluster.suff…
Kota-SH f4b7804
HBASE-29580: Clean-up hardcoded meta table names from log entries (#7…
kgeisz c37a90c
HBASE-29594: Add suffix to Master Region data directory (#7330)
Kota-SH fbc6e61
HBASE-29611: With FILE based SFT, the list of HFiles we maintain in .…
sharmaar12 446bca9
HBASE-29644: Refresh_meta triggering compaction on user table (#7385)
sharmaar12 f845a75
HBASE-29642 Active cluster file is not being updated after promoting …
kabhishek4 d6f454d
HBASE-29693: Implement the missing observer functions in the read-onl…
sharmaar12 1a4976e
HBASE-29715: AssignmentManager is trying to pick up the active cluste…
kgeisz 4f08baa
HBASE-29778: Abort the retry operation if not allowed in read-only mo…
sharmaar12 38ef36a
HBASE-29779: Call super coprocessor instead of returning for system t…
sharmaar12 dbf093c
HBASE-29780: Addendum to HBASE-29715: Add an additional test case tha…
kgeisz 900ce15
HBASE-29841: Split bulky ReadOnlyController into multiple smaller con…
sharmaar12 06cbbfb
HBASE-29756: Programmatically register related co-processor during in…
sharmaar12 33ff835
HBASE-29961 Secondary cluster is unable to replayWAL for meta (#7854)
sharmaar12 365e3f2
HBASE-29959 Cluster started in read-only mode mistakenly deletes suff…
sharmaar12 6150153
Build fix
anmolnar aa9dc68
Spotless apply
anmolnar a4b91da
Spotbugs check
anmolnar 26b68a7
HBASE-29992: Implement regex check for configured replica suffix (#7923)
Kota-SH 2b21a67
HBASE-30014: refresh_meta not working due to regionNode lock (#7974)
Kota-SH 5a72893
HBASE-29960 java.lang.IllegalStateException: Should not call create w…
sharmaar12 b3675b1
HBASE-29958 Improve log messages (#7922)
sharmaar12 bcdd021
HBASE-29965: Unable to dynamically change readonly flag (#7964)
kgeisz b77465b
HBASE-29993. Refactor ClusterId/ActiveClusterSuffix reading and writi…
anmolnar ab3cf0d
HBASE-29081. Fix build errors
anmolnar 07d825e
HBASE-30069:Instead of generic DoNotRetryIOException send specific Ex…
sharmaar12 f0ef8a6
HBASE-29081. Junit 5 fix
anmolnar 9f129eb
HBASE-30080: Send exception to user when refreshing store file fails …
sharmaar12 6293a0e
Run spotless (#8083)
sharmaar12 4ca19d4
Update hbase-server/src/test/java/org/apache/hadoop/hbase/security/ac…
anmolnar d0cad05
Update hbase-client/src/main/java/org/apache/hadoop/hbase/ActiveClust…
anmolnar 72dd3b6
Update hbase-server/src/main/java/org/apache/hadoop/hbase/regionserve…
anmolnar 6f5624f
Update hbase-server/src/main/java/org/apache/hadoop/hbase/regionserve…
anmolnar 0d662c6
HBASE-29081. Code review feedback
anmolnar eacf4d1
HBASE-30085: Migrate all unit tests to JUnit 5 (#8096)
sharmaar12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
hbase-client/src/main/java/org/apache/hadoop/hbase/ActiveClusterSuffix.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| /* | ||
| * 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 java.util.Objects; | ||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.hbase.exceptions.DeserializationException; | ||
| import org.apache.hadoop.hbase.util.Bytes; | ||
| import org.apache.yetus.audience.InterfaceAudience; | ||
|
|
||
| import org.apache.hbase.thirdparty.com.google.common.base.Strings; | ||
|
|
||
| import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; | ||
| import org.apache.hadoop.hbase.shaded.protobuf.generated.ActiveClusterSuffixProtos; | ||
|
|
||
| /** | ||
| * The read-replica cluster id for this cluster. It is serialized to the filesystem and up into | ||
| * zookeeper. This is a container for the id. Also knows how to serialize and deserialize the | ||
| * cluster id. | ||
| */ | ||
| @InterfaceAudience.Private | ||
| public class ActiveClusterSuffix implements ClusterIdFile { | ||
| private final String cluster_id; | ||
| private final String suffix; | ||
|
|
||
| public static class Parser implements ClusterIdFileParser<ActiveClusterSuffix> { | ||
|
|
||
| @Override | ||
| public String getFileName() { | ||
| return HConstants.ACTIVE_CLUSTER_SUFFIX_FILE_NAME; | ||
| } | ||
|
|
||
| /** | ||
| * Parse the serialized representation of the {@link ActiveClusterSuffix} | ||
| * @param bytes A pb serialized {@link ActiveClusterSuffix} instance with pb magic prefix | ||
| * @return An instance of {@link ActiveClusterSuffix} made from <code>bytes</code> | ||
| * @see #toByteArray() | ||
| */ | ||
| @Override | ||
| public ActiveClusterSuffix parseFrom(byte[] bytes) throws DeserializationException { | ||
| if (ProtobufUtil.isPBMagicPrefix(bytes)) { | ||
| int pblen = ProtobufUtil.lengthOfPBMagic(); | ||
| ActiveClusterSuffixProtos.ActiveClusterSuffix.Builder builder = | ||
| ActiveClusterSuffixProtos.ActiveClusterSuffix.newBuilder(); | ||
| ActiveClusterSuffixProtos.ActiveClusterSuffix cs = null; | ||
| try { | ||
| ProtobufUtil.mergeFrom(builder, bytes, pblen, bytes.length - pblen); | ||
| cs = builder.build(); | ||
| } catch (IOException e) { | ||
| throw new DeserializationException(e); | ||
| } | ||
| return convert(cs); | ||
| } else { | ||
| // Presume it was written out this way, the old way. | ||
| return new ActiveClusterSuffix(Bytes.toString(bytes)); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public ActiveClusterSuffix readString(String input) { | ||
| return new ActiveClusterSuffix(input); | ||
| } | ||
| } | ||
|
|
||
| public ActiveClusterSuffix(final String ci, final String suffix) { | ||
| this.cluster_id = ci; | ||
|
anmolnar marked this conversation as resolved.
Outdated
|
||
| this.suffix = suffix; | ||
| } | ||
|
|
||
| public ActiveClusterSuffix(final String input) { | ||
| String[] parts = input.split(":", 2); | ||
| this.cluster_id = parts[0]; | ||
| if (parts.length > 1) { | ||
| this.suffix = parts[1]; | ||
| } else { | ||
| this.suffix = ""; | ||
| } | ||
| } | ||
|
|
||
| public static ActiveClusterSuffix parseFrom(byte[] bytes) throws DeserializationException { | ||
| return new Parser().parseFrom(bytes); | ||
| } | ||
|
|
||
| public static ActiveClusterSuffix fromConfig(Configuration conf, ClusterId clusterId) { | ||
| return new ActiveClusterSuffix(clusterId.toString(), conf | ||
| .get(HConstants.HBASE_META_TABLE_SUFFIX, HConstants.HBASE_META_TABLE_SUFFIX_DEFAULT_VALUE)); | ||
| } | ||
|
|
||
| /** Returns The active cluster suffix serialized using pb w/ pb magic prefix */ | ||
| public byte[] toByteArray() { | ||
| return ProtobufUtil.prependPBMagic(convert().toByteArray()); | ||
| } | ||
|
|
||
| /** Returns A pb instance to represent this instance. */ | ||
| public ActiveClusterSuffixProtos.ActiveClusterSuffix convert() { | ||
| return ActiveClusterSuffixProtos.ActiveClusterSuffix.newBuilder().setClusterId(cluster_id) | ||
| .setSuffix(suffix).build(); | ||
| } | ||
|
|
||
| /** Returns A {@link ActiveClusterSuffix} made from the passed in <code>cs</code> */ | ||
| public static ActiveClusterSuffix | ||
| convert(final ActiveClusterSuffixProtos.ActiveClusterSuffix cs) { | ||
| return new ActiveClusterSuffix(cs.getClusterId(), cs.getSuffix()); | ||
| } | ||
|
|
||
| /** | ||
| * @see java.lang.Object#toString() | ||
| */ | ||
| @Override | ||
| public String toString() { | ||
| return String.format("%s:%s", this.cluster_id, | ||
| Strings.isNullOrEmpty(this.suffix) ? "<blank>" : this.suffix); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (o == null || getClass() != o.getClass()) return false; | ||
| ActiveClusterSuffix that = (ActiveClusterSuffix) o; | ||
| return Objects.equals(cluster_id, that.cluster_id) && Objects.equals(suffix, that.suffix); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(cluster_id, suffix); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterIdFile.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /* | ||
| * 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.yetus.audience.InterfaceAudience; | ||
|
|
||
| /** | ||
| * Represents a cluster identification file on the master file system. e.g. Cluster ID = hbase.id | ||
| * Active read-replica cluster ID = active.cluster.suffix.id | ||
| */ | ||
| @InterfaceAudience.Private | ||
| public interface ClusterIdFile { | ||
|
|
||
| /** | ||
| * Return file contents in a byte array. | ||
| */ | ||
| byte[] toByteArray(); | ||
|
|
||
| } |
48 changes: 48 additions & 0 deletions
48
hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterIdFileParser.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /* | ||
| * 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.hbase.exceptions.DeserializationException; | ||
| import org.apache.yetus.audience.InterfaceAudience; | ||
|
|
||
| /** | ||
| * Generic parser interface for Cluster Id files. | ||
| * @see ClusterIdFile | ||
| */ | ||
| @InterfaceAudience.Private | ||
| public interface ClusterIdFileParser<T> { | ||
|
|
||
| /** | ||
| * Get default file name of cluster id file. | ||
| */ | ||
| String getFileName(); | ||
|
|
||
| /** | ||
| * Parse cluster id data from byte representation. | ||
| * @param bytes the protobuf data | ||
| * @return the cluster id data object | ||
| */ | ||
| T parseFrom(final byte[] bytes) throws DeserializationException; | ||
|
|
||
| /** | ||
| * Parser cluster id data from String representation. | ||
| * @param input the input string | ||
| * @return the cluster id data object | ||
| */ | ||
| T readString(String input); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.