From b85d6900c512f1e86094b1d0ba0c2e65f7635171 Mon Sep 17 00:00:00 2001 From: Ray Mattingly Date: Fri, 27 Dec 2024 18:02:53 -0500 Subject: [PATCH] cleanup --- .../master/balancer/BalancerClusterState.java | 9 ++- .../master/balancer/BalancerConditionals.java | 77 ++++++++++--------- .../DistributeReplicasCandidateGenerator.java | 7 +- .../DistributeReplicasConditional.java | 13 +++- .../balancer/FavoredStochasticBalancer.java | 3 +- .../MetaTableIsolationCandidateGenerator.java | 2 +- .../master/balancer/MoveBatchAction.java | 5 +- .../balancer/RegionPlanConditional.java | 2 +- ...gionPlanConditionalCandidateGenerator.java | 7 ++ .../balancer/StochasticLoadBalancer.java | 29 ++++--- ...ystemTableIsolationCandidateGenerator.java | 2 +- .../TableIsolationCandidateGenerator.java | 5 +- .../balancer/CandidateGeneratorTestUtil.java | 8 +- .../balancer/TestBalancerConditionals.java | 12 +-- ...ultiTableIsolationReplicaDistribution.java | 6 +- ...geClusterBalancingReplicaDistribution.java | 6 +- .../BalancerConditionalsTestUtil.java | 2 +- ...eplicaDistributionBalancerConditional.java | 6 +- ...temTableIsolationBalancerConditionals.java | 9 +-- 19 files changed, 121 insertions(+), 89 deletions(-) rename hbase-server/src/test/java/org/apache/hadoop/hbase/{ => master}/balancer/BalancerConditionalsTestUtil.java (99%) rename hbase-server/src/test/java/org/apache/hadoop/hbase/{ => master}/balancer/TestReplicaDistributionBalancerConditional.java (94%) rename hbase-server/src/test/java/org/apache/hadoop/hbase/{ => master}/balancer/TestSystemTableIsolationBalancerConditionals.java (92%) diff --git a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/BalancerClusterState.java b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/BalancerClusterState.java index 52e94455f4d6..6050b915217b 100644 --- a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/BalancerClusterState.java +++ b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/BalancerClusterState.java @@ -778,11 +778,12 @@ public List doAction(BalanceAction action) { List mbRegionPlans = new ArrayList<>(); for (int serverIndex : mba.getServerToRegionsToRemove().keySet()) { Set regionsToRemove = mba.getServerToRegionsToRemove().get(serverIndex); - removeRegions(regionsPerServer[serverIndex], regionsToRemove); + regionsPerServer[serverIndex] = + removeRegions(regionsPerServer[serverIndex], regionsToRemove); } for (int serverIndex : mba.getServerToRegionsToAdd().keySet()) { Set regionsToAdd = mba.getServerToRegionsToRemove().get(serverIndex); - addRegions(regionsPerServer[serverIndex], regionsToAdd); + regionsPerServer[serverIndex] = addRegions(regionsPerServer[serverIndex], regionsToAdd); } for (MoveRegionAction moveRegionAction : mba.getMoveActions()) { mbRegionPlans.add(regionMoved(moveRegionAction.getRegion(), @@ -978,8 +979,8 @@ int[] removeRegions(int[] regions, Set regionIndicesToRemove) { // If the newIndex is smaller than newSize, some regions were missing from the input array if (newIndex != newSize) { - throw new IllegalStateException( - "Region indices mismatch: some regions in the removal set were not found in the regions array"); + throw new IllegalStateException("Region indices mismatch: some regions in the removal " + + "set were not found in the regions array"); } return newRegions; diff --git a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/BalancerConditionals.java b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/BalancerConditionals.java index 2f21c56b97c0..00c4442a4272 100644 --- a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/BalancerConditionals.java +++ b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/BalancerConditionals.java @@ -25,6 +25,7 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; +import org.apache.hadoop.conf.Configurable; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.master.RegionPlan; import org.apache.hadoop.hbase.util.ReflectionUtils; @@ -47,7 +48,7 @@ * make it easy to define that system tables will ideally be isolated on their own RegionServer. */ @InterfaceAudience.Private -public final class BalancerConditionals { +final class BalancerConditionals implements Configurable { private static final Logger LOG = LoggerFactory.getLogger(BalancerConditionals.class); @@ -109,40 +110,6 @@ void clearConditionalWeightCaches() { .flatMap(Optional::stream).forEach(RegionPlanConditionalCandidateGenerator::clearWeightCache); } - void loadConf(Configuration conf) { - this.conf = conf; - ImmutableSet.Builder> conditionalClasses = - ImmutableSet.builder(); - - boolean isolateSystemTables = - conf.getBoolean(ISOLATE_SYSTEM_TABLES_KEY, ISOLATE_SYSTEM_TABLES_DEFAULT); - if (isolateSystemTables) { - conditionalClasses.add(SystemTableIsolationConditional.class); - } - - boolean isolateMetaTable = conf.getBoolean(ISOLATE_META_TABLE_KEY, ISOLATE_META_TABLE_DEFAULT); - if (isolateMetaTable) { - conditionalClasses.add(MetaTableIsolationConditional.class); - } - - boolean distributeReplicas = conf.getBoolean(DISTRIBUTE_REPLICAS_CONDITIONALS_KEY, - DISTRIBUTE_REPLICAS_CONDITIONALS_DEFAULT); - if (distributeReplicas) { - conditionalClasses.add(DistributeReplicasConditional.class); - } - - Class[] classes = conf.getClasses(ADDITIONAL_CONDITIONALS_KEY); - for (Class clazz : classes) { - if (!RegionPlanConditional.class.isAssignableFrom(clazz)) { - LOG.warn("Class {} is not a RegionPlanConditional", clazz.getName()); - continue; - } - conditionalClasses.add(clazz.asSubclass(RegionPlanConditional.class)); - } - this.conditionalClasses = conditionalClasses.build(); - loadClusterState(null); - } - void loadClusterState(BalancerClusterState cluster) { conditionals = conditionalClasses.stream().map(clazz -> createConditional(clazz, conf, cluster)) .filter(Objects::nonNull).collect(Collectors.toSet()); @@ -216,4 +183,44 @@ private RegionPlanConditional createConditional(Class> conditionalClasses = + ImmutableSet.builder(); + + boolean isolateSystemTables = + conf.getBoolean(ISOLATE_SYSTEM_TABLES_KEY, ISOLATE_SYSTEM_TABLES_DEFAULT); + if (isolateSystemTables) { + conditionalClasses.add(SystemTableIsolationConditional.class); + } + + boolean isolateMetaTable = conf.getBoolean(ISOLATE_META_TABLE_KEY, ISOLATE_META_TABLE_DEFAULT); + if (isolateMetaTable) { + conditionalClasses.add(MetaTableIsolationConditional.class); + } + + boolean distributeReplicas = conf.getBoolean(DISTRIBUTE_REPLICAS_CONDITIONALS_KEY, + DISTRIBUTE_REPLICAS_CONDITIONALS_DEFAULT); + if (distributeReplicas) { + conditionalClasses.add(DistributeReplicasConditional.class); + } + + Class[] classes = conf.getClasses(ADDITIONAL_CONDITIONALS_KEY); + for (Class clazz : classes) { + if (!RegionPlanConditional.class.isAssignableFrom(clazz)) { + LOG.warn("Class {} is not a RegionPlanConditional", clazz.getName()); + continue; + } + conditionalClasses.add(clazz.asSubclass(RegionPlanConditional.class)); + } + this.conditionalClasses = conditionalClasses.build(); + loadClusterState(null); + } + + @Override + public Configuration getConf() { + return conf; + } } diff --git a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/DistributeReplicasCandidateGenerator.java b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/DistributeReplicasCandidateGenerator.java index 183f571b4c77..e3ab6d559394 100644 --- a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/DistributeReplicasCandidateGenerator.java +++ b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/DistributeReplicasCandidateGenerator.java @@ -32,7 +32,7 @@ * CandidateGenerator to distribute colocated replicas across different servers. */ @InterfaceAudience.Private -class DistributeReplicasCandidateGenerator extends RegionPlanConditionalCandidateGenerator { +final class DistributeReplicasCandidateGenerator extends RegionPlanConditionalCandidateGenerator { static DistributeReplicasCandidateGenerator INSTANCE = new DistributeReplicasCandidateGenerator(); @@ -94,6 +94,7 @@ BalanceAction generateCandidate(BalancerClusterState cluster, boolean isWeighing if (isForced) { return possibleAction; } else if (willBeAccepted(cluster, possibleAction)) { + cluster.doAction(possibleAction); // Update cluster state to reflect move moveRegionActions.add(possibleAction); break; } @@ -112,7 +113,9 @@ BalanceAction generateCandidate(BalancerClusterState cluster, boolean isWeighing } if (!moveRegionActions.isEmpty()) { - return new MoveBatchAction(moveRegionActions); + MoveBatchAction batchAction = new MoveBatchAction(moveRegionActions); + undoBatchAction(cluster, batchAction); // Reset cluster state to before batch + return batchAction; } // If no colocated replicas are found, return NULL_ACTION if (foundColocatedReplicas) { diff --git a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/DistributeReplicasConditional.java b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/DistributeReplicasConditional.java index ed202f8388ab..eb7d85452d35 100644 --- a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/DistributeReplicasConditional.java +++ b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/DistributeReplicasConditional.java @@ -23,6 +23,7 @@ import java.util.Set; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.client.RegionInfo; +import org.apache.hadoop.hbase.client.RegionReplicaUtil; import org.apache.hadoop.hbase.master.RegionPlan; import org.apache.hadoop.hbase.util.Pair; import org.apache.yetus.audience.InterfaceAudience; @@ -109,8 +110,8 @@ private boolean checkViolation(ReplicaKey movingReplicaKey, Set dest /** * This is necessary because it would be too expensive to use - * {@link org.apache.hadoop.hbase.client.RegionReplicaUtil#isReplicasForSameRegion(RegionInfo, RegionInfo)} - * for every combo of regions. + * {@link RegionReplicaUtil#isReplicasForSameRegion(RegionInfo, RegionInfo)} for every combo of + * regions. */ static class ReplicaKey { private final Pair startAndStopKeys; @@ -122,8 +123,12 @@ static class ReplicaKey { @Override public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof ReplicaKey)) return false; + if (this == o) { + return true; + } + if (!(o instanceof ReplicaKey)) { + return false; + } ReplicaKey other = (ReplicaKey) o; return this.startAndStopKeys.equals(other.startAndStopKeys); } diff --git a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredStochasticBalancer.java b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredStochasticBalancer.java index 62368d934530..657410f0aeb4 100644 --- a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredStochasticBalancer.java +++ b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredStochasticBalancer.java @@ -91,7 +91,8 @@ public void setFavoredNodesManager(FavoredNodesManager fnm) { /** Returns any candidate generator in random */ @Override protected CandidateGenerator getRandomGenerator(BalancerClusterState cluster) { - return candidateGenerators.get(ThreadLocalRandom.current().nextInt(candidateGenerators.size())); + return candidateGenerators.values().stream().toList() + .get(ThreadLocalRandom.current().nextInt(candidateGenerators.size())); } /** diff --git a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/MetaTableIsolationCandidateGenerator.java b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/MetaTableIsolationCandidateGenerator.java index 4570d574a26e..8160f4cf677b 100644 --- a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/MetaTableIsolationCandidateGenerator.java +++ b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/MetaTableIsolationCandidateGenerator.java @@ -21,7 +21,7 @@ import org.apache.yetus.audience.InterfaceAudience; @InterfaceAudience.Private -public class MetaTableIsolationCandidateGenerator extends TableIsolationCandidateGenerator { +public final class MetaTableIsolationCandidateGenerator extends TableIsolationCandidateGenerator { static MetaTableIsolationCandidateGenerator INSTANCE = new MetaTableIsolationCandidateGenerator(); diff --git a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/MoveBatchAction.java b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/MoveBatchAction.java index adde90dbd3dc..9aded615a468 100644 --- a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/MoveBatchAction.java +++ b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/MoveBatchAction.java @@ -18,10 +18,11 @@ package org.apache.hadoop.hbase.master.balancer; import java.util.List; -import org.apache.curator.shaded.com.google.common.collect.HashMultimap; -import org.apache.curator.shaded.com.google.common.collect.Multimaps; import org.apache.yetus.audience.InterfaceAudience; +import org.apache.hbase.thirdparty.com.google.common.collect.HashMultimap; +import org.apache.hbase.thirdparty.com.google.common.collect.Multimaps; + @InterfaceAudience.Private public class MoveBatchAction extends BalanceAction { private final List moveActions; diff --git a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/RegionPlanConditional.java b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/RegionPlanConditional.java index 1240b45e971e..9df449986db2 100644 --- a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/RegionPlanConditional.java +++ b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/RegionPlanConditional.java @@ -30,7 +30,7 @@ @InterfaceAudience.Private @InterfaceStability.Evolving -public abstract class RegionPlanConditional { // todo rename to BalancerConditional +public abstract class RegionPlanConditional { private static final Logger LOG = LoggerFactory.getLogger(RegionPlanConditional.class); private BalancerClusterState cluster; diff --git a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/RegionPlanConditionalCandidateGenerator.java b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/RegionPlanConditionalCandidateGenerator.java index aab1d32e93c5..9535a63a664e 100644 --- a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/RegionPlanConditionalCandidateGenerator.java +++ b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/RegionPlanConditionalCandidateGenerator.java @@ -46,6 +46,13 @@ boolean willBeAccepted(BalancerClusterState cluster, BalanceAction action) { return !BalancerConditionals.INSTANCE.isViolating(cluster, action); } + void undoBatchAction(BalancerClusterState cluster, MoveBatchAction batchAction) { + for (int i = batchAction.getMoveActions().size() - 1; i >= 0; i--) { + MoveRegionAction action = batchAction.getMoveActions().get(i); + cluster.doAction(action.undoAction()); + } + } + void clearWeightCache() { lastWeighedAt = -1; } diff --git a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java index 694ff0039dc3..a64b7b44ab9e 100644 --- a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java +++ b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java @@ -160,15 +160,6 @@ public class StochasticLoadBalancer extends BaseLoadBalancer { protected Map, CandidateGenerator> candidateGenerators; private Map, Double> weightsOfGenerators; - public enum GeneratorType { - RANDOM, - LOAD, - LOCALITY, - RACK, - SYSTEM_TABLE_ISOLATION, - META_TABLE_ISOLATION, - } - private final BalancerConditionals balancerConditionals = BalancerConditionals.INSTANCE; /** @@ -270,7 +261,7 @@ protected void loadConf(Configuration conf) { rackLocalityCost = new RackLocalityCostFunction(conf); // Order is important here. We need to construct conditionals to load candidate generators - balancerConditionals.loadConf(conf); + balancerConditionals.setConf(conf); this.candidateGenerators = createCandidateGenerators(); regionReplicaHostCostFunction = new RegionReplicaHostCostFunction(conf); @@ -466,20 +457,25 @@ protected CandidateGenerator getRandomGenerator(BalancerClusterState cluster) { } double rand = ThreadLocalRandom.current().nextDouble(); - Class greatestWeightClazz = null; + CandidateGenerator greatestWeightGenerator = null; double greatestWeight = 0; - for (Class clazz : candidateGenerators.keySet()) { + for (Map.Entry, + CandidateGenerator> entry : candidateGenerators.entrySet()) { + Class clazz = entry.getKey(); double generatorWeight = weightsOfGenerators.get(clazz); if (generatorWeight > greatestWeight) { greatestWeight = generatorWeight; - greatestWeightClazz = clazz; + greatestWeightGenerator = entry.getValue(); } if (rand <= generatorWeight) { - return candidateGenerators.get(clazz); + return entry.getValue(); } } - return candidateGenerators.getOrDefault(greatestWeightClazz, new RandomCandidateGenerator()); + if (greatestWeightGenerator != null) { + return greatestWeightGenerator; + } + return candidateGenerators.values().stream().findAny().orElseThrow(); } @RestrictedApi(explanation = "Should only be called in tests", link = "", @@ -497,6 +493,7 @@ private long calculateMaxSteps(BalancerClusterState cluster) { * approach the optimal state given enough steps. */ @Override + @SuppressWarnings("checkstyle:MethodLength") protected List balanceTable(TableName tableName, Map> loadOfOneTable) { // On clusters with lots of HFileLinks or lots of reference files, @@ -636,7 +633,7 @@ protected List balanceTable(TableName tableName, StringBuilder logMessage = new StringBuilder("CandidateGenerator activity summary:\n"); generatorToStepCount.forEach((generator, count) -> { long approvals = generatorToApprovedActionCount.getOrDefault(generator, 0L); - logMessage.append(String.format(" - %s: %d steps, %d approvals\n", generator.getSimpleName(), + logMessage.append(String.format(" - %s: %d steps, %d approvals%n", generator.getSimpleName(), count, approvals)); }); // Log the message diff --git a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/SystemTableIsolationCandidateGenerator.java b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/SystemTableIsolationCandidateGenerator.java index ae689afa6aea..f71ce45039d7 100644 --- a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/SystemTableIsolationCandidateGenerator.java +++ b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/SystemTableIsolationCandidateGenerator.java @@ -21,7 +21,7 @@ import org.apache.yetus.audience.InterfaceAudience; @InterfaceAudience.Private -public class SystemTableIsolationCandidateGenerator extends TableIsolationCandidateGenerator { +public final class SystemTableIsolationCandidateGenerator extends TableIsolationCandidateGenerator { static SystemTableIsolationCandidateGenerator INSTANCE = new SystemTableIsolationCandidateGenerator(); diff --git a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/TableIsolationCandidateGenerator.java b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/TableIsolationCandidateGenerator.java index a0bbf8ad9813..51d1ffd7d6bf 100644 --- a/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/TableIsolationCandidateGenerator.java +++ b/hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/TableIsolationCandidateGenerator.java @@ -73,6 +73,7 @@ BalanceAction generateCandidate(BalancerClusterState cluster, boolean isWeighing if (isWeighing) { return possibleMove; } + cluster.doAction(possibleMove); // Update cluster state to reflect move moves.add(possibleMove); break; } @@ -86,7 +87,9 @@ BalanceAction generateCandidate(BalancerClusterState cluster, boolean isWeighing if (moves.isEmpty()) { return BalanceAction.NULL_ACTION; } else { - return new MoveBatchAction(moves); + MoveBatchAction batchAction = new MoveBatchAction(moves); + undoBatchAction(cluster, batchAction); // Reset cluster state to before batch action + return batchAction; } } } diff --git a/hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/CandidateGeneratorTestUtil.java b/hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/CandidateGeneratorTestUtil.java index e8e7bb0671cc..1013b9866286 100644 --- a/hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/CandidateGeneratorTestUtil.java +++ b/hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/CandidateGeneratorTestUtil.java @@ -43,6 +43,9 @@ public final class CandidateGeneratorTestUtil { private static final Logger LOG = LoggerFactory.getLogger(CandidateGeneratorTestUtil.class); + private CandidateGeneratorTestUtil() { + } + static void runBalancerToExhaustion(Configuration conf, Map> serverToRegions, Set> expectations) { @@ -144,9 +147,8 @@ static void printClusterDistribution(BalancerClusterState cluster, long actionsT } /** - * Partitions the given serverToRegions map by table, returning a structure of Map>>. The tables are derived from the RegionInfo objects found in - * serverToRegions. + * Partitions the given serverToRegions map by table The tables are derived from the RegionInfo + * objects found in serverToRegions. * @param serverToRegions The map of servers to their assigned regions. * @return A map of tables to their server-to-region assignments. */ diff --git a/hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/TestBalancerConditionals.java b/hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/TestBalancerConditionals.java index 1149e017ef8b..5703c5085c16 100644 --- a/hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/TestBalancerConditionals.java +++ b/hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/TestBalancerConditionals.java @@ -47,7 +47,7 @@ public void setUp() { @Test public void testDefaultConfiguration() { Configuration conf = new Configuration(); - balancerConditionals.loadConf(conf); + balancerConditionals.setConf(conf); balancerConditionals.loadClusterState(mockCluster); assertEquals("No conditionals should be loaded by default", 0, @@ -59,7 +59,7 @@ public void testSystemTableIsolationConditionalEnabled() { Configuration conf = new Configuration(); conf.setBoolean(BalancerConditionals.ISOLATE_SYSTEM_TABLES_KEY, true); - balancerConditionals.loadConf(conf); + balancerConditionals.setConf(conf); balancerConditionals.loadClusterState(mockCluster); assertTrue("SystemTableIsolationConditional should be active", @@ -71,7 +71,7 @@ public void testMetaTableIsolationConditionalEnabled() { Configuration conf = new Configuration(); conf.setBoolean(BalancerConditionals.ISOLATE_META_TABLE_KEY, true); - balancerConditionals.loadConf(conf); + balancerConditionals.setConf(conf); balancerConditionals.loadClusterState(mockCluster); assertTrue("MetaTableIsolationConditional should be active", @@ -84,7 +84,7 @@ public void testCustomConditionalsViaConfiguration() { conf.set(BalancerConditionals.ADDITIONAL_CONDITIONALS_KEY, MetaTableIsolationConditional.class.getName()); - balancerConditionals.loadConf(conf); + balancerConditionals.setConf(conf); balancerConditionals.loadClusterState(mockCluster); assertTrue("Custom conditionals should be loaded", @@ -96,7 +96,7 @@ public void testInvalidCustomConditionalClass() { Configuration conf = new Configuration(); conf.set(BalancerConditionals.ADDITIONAL_CONDITIONALS_KEY, "java.lang.String"); - balancerConditionals.loadConf(conf); + balancerConditionals.setConf(conf); balancerConditionals.loadClusterState(mockCluster); assertEquals("Invalid classes should not be loaded as conditionals", 0, @@ -109,7 +109,7 @@ public void testShouldSkipSloppyServerEvaluationWithMixedConditionals() { conf.setBoolean(BalancerConditionals.ISOLATE_SYSTEM_TABLES_KEY, true); conf.setBoolean(BalancerConditionals.ISOLATE_META_TABLE_KEY, true); - balancerConditionals.loadConf(conf); + balancerConditionals.setConf(conf); balancerConditionals.loadClusterState(mockCluster); assertTrue("Sloppy server evaluation should be skipped with relevant conditionals", diff --git a/hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/TestLargeClusterBalancingMultiTableIsolationReplicaDistribution.java b/hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/TestLargeClusterBalancingMultiTableIsolationReplicaDistribution.java index 95592b49211f..c869dfd0e659 100644 --- a/hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/TestLargeClusterBalancingMultiTableIsolationReplicaDistribution.java +++ b/hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/TestLargeClusterBalancingMultiTableIsolationReplicaDistribution.java @@ -20,7 +20,11 @@ import static org.apache.hadoop.hbase.master.balancer.CandidateGeneratorTestUtil.isTableIsolated; import static org.apache.hadoop.hbase.master.balancer.CandidateGeneratorTestUtil.runBalancerToExhaustion; -import java.util.*; +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; diff --git a/hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/TestLargeClusterBalancingReplicaDistribution.java b/hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/TestLargeClusterBalancingReplicaDistribution.java index 08d311e87ac4..8f9469762e22 100644 --- a/hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/TestLargeClusterBalancingReplicaDistribution.java +++ b/hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/TestLargeClusterBalancingReplicaDistribution.java @@ -19,7 +19,11 @@ import static org.apache.hadoop.hbase.master.balancer.CandidateGeneratorTestUtil.runBalancerToExhaustion; -import java.util.*; +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; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/balancer/BalancerConditionalsTestUtil.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/BalancerConditionalsTestUtil.java similarity index 99% rename from hbase-server/src/test/java/org/apache/hadoop/hbase/balancer/BalancerConditionalsTestUtil.java rename to hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/BalancerConditionalsTestUtil.java index aab72d20b9d4..8a7169b09309 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/balancer/BalancerConditionalsTestUtil.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/BalancerConditionalsTestUtil.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.hadoop.hbase.balancer; +package org.apache.hadoop.hbase.master.balancer; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/balancer/TestReplicaDistributionBalancerConditional.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestReplicaDistributionBalancerConditional.java similarity index 94% rename from hbase-server/src/test/java/org/apache/hadoop/hbase/balancer/TestReplicaDistributionBalancerConditional.java rename to hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestReplicaDistributionBalancerConditional.java index 874d1f684ddf..1bd052777306 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/balancer/TestReplicaDistributionBalancerConditional.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestReplicaDistributionBalancerConditional.java @@ -15,9 +15,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.hadoop.hbase.balancer; +package org.apache.hadoop.hbase.master.balancer; -import static org.apache.hadoop.hbase.balancer.BalancerConditionalsTestUtil.validateAssertionsWithRetries; +import static org.apache.hadoop.hbase.master.balancer.BalancerConditionalsTestUtil.validateAssertionsWithRetries; import java.util.List; import org.apache.hadoop.hbase.HBaseClassTestRule; @@ -30,8 +30,6 @@ import org.apache.hadoop.hbase.client.RegionInfo; import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.client.TableDescriptorBuilder; -import org.apache.hadoop.hbase.master.balancer.BalancerConditionals; -import org.apache.hadoop.hbase.master.balancer.DistributeReplicasConditional; import org.apache.hadoop.hbase.testclassification.LargeTests; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.ServerRegionReplicaUtil; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/balancer/TestSystemTableIsolationBalancerConditionals.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestSystemTableIsolationBalancerConditionals.java similarity index 92% rename from hbase-server/src/test/java/org/apache/hadoop/hbase/balancer/TestSystemTableIsolationBalancerConditionals.java rename to hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestSystemTableIsolationBalancerConditionals.java index 01fb998235b7..2e2cc90d11ef 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/balancer/TestSystemTableIsolationBalancerConditionals.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestSystemTableIsolationBalancerConditionals.java @@ -15,11 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.hadoop.hbase.balancer; +package org.apache.hadoop.hbase.master.balancer; -import static org.apache.hadoop.hbase.balancer.BalancerConditionalsTestUtil.getTableToServers; -import static org.apache.hadoop.hbase.balancer.BalancerConditionalsTestUtil.validateAssertionsWithRetries; -import static org.apache.hadoop.hbase.balancer.BalancerConditionalsTestUtil.validateRegionLocations; +import static org.apache.hadoop.hbase.master.balancer.BalancerConditionalsTestUtil.getTableToServers; +import static org.apache.hadoop.hbase.master.balancer.BalancerConditionalsTestUtil.validateAssertionsWithRetries; +import static org.apache.hadoop.hbase.master.balancer.BalancerConditionalsTestUtil.validateRegionLocations; import java.io.IOException; import java.util.Collection; @@ -35,7 +35,6 @@ import org.apache.hadoop.hbase.client.RegionInfo; import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.client.TableDescriptorBuilder; -import org.apache.hadoop.hbase.master.balancer.BalancerConditionals; import org.apache.hadoop.hbase.quotas.QuotaUtil; import org.apache.hadoop.hbase.testclassification.LargeTests; import org.apache.hadoop.hbase.util.Bytes;