-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-29075 Balancer conditionals should support system table isolation #6746
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
Merged
Merged
Changes from all commits
Commits
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
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
41 changes: 41 additions & 0 deletions
41
.../java/org/apache/hadoop/hbase/master/balancer/SystemTableIsolationCandidateGenerator.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,41 @@ | ||
| /* | ||
| * 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.master.balancer; | ||
|
|
||
| import org.apache.hadoop.hbase.client.RegionInfo; | ||
| import org.apache.yetus.audience.InterfaceAudience; | ||
|
|
||
| @InterfaceAudience.Private | ||
| public class SystemTableIsolationCandidateGenerator extends TableIsolationCandidateGenerator { | ||
|
|
||
| private final BalancerConditionals balancerConditionals; | ||
|
|
||
| SystemTableIsolationCandidateGenerator(BalancerConditionals balancerConditionals) { | ||
| super(balancerConditionals); | ||
| this.balancerConditionals = balancerConditionals; | ||
| } | ||
|
|
||
| @Override | ||
| boolean shouldBeIsolated(RegionInfo regionInfo) { | ||
| if (balancerConditionals.isMetaTableIsolationEnabled() && regionInfo.isMetaRegion()) { | ||
| // If meta isolation is enabled, we can ignore meta regions here | ||
| return false; | ||
| } | ||
| return regionInfo.getTable().isSystemTable(); | ||
| } | ||
| } | ||
43 changes: 43 additions & 0 deletions
43
...rc/main/java/org/apache/hadoop/hbase/master/balancer/SystemTableIsolationConditional.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,43 @@ | ||
| /* | ||
| * 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.master.balancer; | ||
|
|
||
| import org.apache.hadoop.hbase.client.RegionInfo; | ||
| import org.apache.yetus.audience.InterfaceAudience; | ||
|
|
||
| @InterfaceAudience.Private | ||
| public class SystemTableIsolationConditional extends TableIsolationConditional { | ||
rmdmattingly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| private final BalancerConditionals balancerConditionals; | ||
|
|
||
| SystemTableIsolationConditional(BalancerConditionals balancerConditionals, | ||
| BalancerClusterState cluster) { | ||
| super(new SystemTableIsolationCandidateGenerator(balancerConditionals), balancerConditionals, | ||
| cluster); | ||
| this.balancerConditionals = balancerConditionals; | ||
| } | ||
|
|
||
| @Override | ||
| boolean isRegionToIsolate(RegionInfo regionInfo) { | ||
| if (balancerConditionals.isMetaTableIsolationEnabled() && regionInfo.isMetaRegion()) { | ||
| // If meta isolation is enabled, we can ignore meta regions here | ||
| return false; | ||
| } | ||
| return regionInfo.getTable().isSystemTable(); | ||
| } | ||
| } | ||
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
102 changes: 102 additions & 0 deletions
102
...rg/apache/hadoop/hbase/master/balancer/TestLargeClusterBalancingSystemTableIsolation.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,102 @@ | ||
| /* | ||
| * 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.master.balancer; | ||
|
|
||
| import static org.apache.hadoop.hbase.master.balancer.CandidateGeneratorTestUtil.isTableIsolated; | ||
| import static org.apache.hadoop.hbase.master.balancer.CandidateGeneratorTestUtil.runBalancerToExhaustion; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.hbase.HBaseClassTestRule; | ||
| import org.apache.hadoop.hbase.ServerName; | ||
| import org.apache.hadoop.hbase.TableName; | ||
| import org.apache.hadoop.hbase.client.RegionInfo; | ||
| import org.apache.hadoop.hbase.client.RegionInfoBuilder; | ||
| import org.apache.hadoop.hbase.testclassification.MasterTests; | ||
| import org.apache.hadoop.hbase.testclassification.MediumTests; | ||
| import org.junit.BeforeClass; | ||
| import org.junit.ClassRule; | ||
| import org.junit.Test; | ||
| import org.junit.experimental.categories.Category; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| @Category({ MediumTests.class, MasterTests.class }) | ||
| public class TestLargeClusterBalancingSystemTableIsolation { | ||
|
|
||
| @ClassRule | ||
| public static final HBaseClassTestRule CLASS_RULE = | ||
| HBaseClassTestRule.forClass(TestLargeClusterBalancingSystemTableIsolation.class); | ||
|
|
||
| private static final Logger LOG = | ||
| LoggerFactory.getLogger(TestLargeClusterBalancingSystemTableIsolation.class); | ||
|
|
||
| private static final TableName SYSTEM_TABLE_NAME = TableName.valueOf("hbase:system"); | ||
| private static final TableName NON_SYSTEM_TABLE_NAME = TableName.valueOf("userTable"); | ||
|
|
||
| private static final int NUM_SERVERS = 1000; | ||
| private static final int NUM_REGIONS = 20_000; | ||
|
|
||
| private static final ServerName[] servers = new ServerName[NUM_SERVERS]; | ||
| private static final Map<ServerName, List<RegionInfo>> serverToRegions = new HashMap<>(); | ||
|
|
||
| @BeforeClass | ||
| public static void setup() { | ||
| // Initialize servers | ||
| for (int i = 0; i < NUM_SERVERS; i++) { | ||
| servers[i] = ServerName.valueOf("server" + i, i, System.currentTimeMillis()); | ||
| } | ||
|
|
||
| // Create regions | ||
| List<RegionInfo> allRegions = new ArrayList<>(); | ||
| for (int i = 0; i < NUM_REGIONS; i++) { | ||
| TableName tableName = i < 3 ? SYSTEM_TABLE_NAME : NON_SYSTEM_TABLE_NAME; | ||
| byte[] startKey = new byte[1]; | ||
| startKey[0] = (byte) i; | ||
| byte[] endKey = new byte[1]; | ||
| endKey[0] = (byte) (i + 1); | ||
|
|
||
| RegionInfo regionInfo = | ||
| RegionInfoBuilder.newBuilder(tableName).setStartKey(startKey).setEndKey(endKey).build(); | ||
| allRegions.add(regionInfo); | ||
| } | ||
|
|
||
| // Assign all regions to the first server | ||
| serverToRegions.put(servers[0], new ArrayList<>(allRegions)); | ||
| for (int i = 1; i < NUM_SERVERS; i++) { | ||
| serverToRegions.put(servers[i], new ArrayList<>()); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testSystemTableIsolation() { | ||
| Configuration conf = new Configuration(false); | ||
| conf.setBoolean(BalancerConditionals.ISOLATE_SYSTEM_TABLES_KEY, true); | ||
| runBalancerToExhaustion(conf, serverToRegions, Set.of(this::isSystemTableIsolated), 10.0f); | ||
| LOG.info("Meta table regions are successfully isolated."); | ||
| } | ||
|
|
||
| private boolean isSystemTableIsolated(BalancerClusterState cluster) { | ||
| return isTableIsolated(cluster, SYSTEM_TABLE_NAME, "System"); | ||
| } | ||
|
|
||
| } |
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
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.