Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Ray Mattingly committed Dec 27, 2024
1 parent e5ab24c commit ee8c552
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -978,8 +978,8 @@ int[] removeRegions(int[] regions, Set<Integer> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -109,8 +110,8 @@ private boolean checkViolation(ReplicaKey movingReplicaKey, Set<RegionInfo> 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<ByteArrayWrapper, ByteArrayWrapper> startAndStopKeys;
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<MoveRegionAction> moveActions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,6 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
protected Map<Class<? extends CandidateGenerator>, CandidateGenerator> candidateGenerators;
private Map<Class<? extends CandidateGenerator>, Double> weightsOfGenerators;

public enum GeneratorType {
RANDOM,
LOAD,
LOCALITY,
RACK,
SYSTEM_TABLE_ISOLATION,
META_TABLE_ISOLATION,
}

private final BalancerConditionals balancerConditionals = BalancerConditionals.INSTANCE;

/**
Expand Down Expand Up @@ -497,6 +488,7 @@ private long calculateMaxSteps(BalancerClusterState cluster) {
* approach the optimal state given enough steps.
*/
@Override
@SuppressWarnings("checkstyle:MethodLength")
protected List<RegionPlan> balanceTable(TableName tableName,
Map<ServerName, List<RegionInfo>> loadOfOneTable) {
// On clusters with lots of HFileLinks or lots of reference files,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ServerName, List<RegionInfo>> serverToRegions,
Set<Function<BalancerClusterState, Boolean>> expectations) {
Expand Down Expand Up @@ -144,9 +147,8 @@ static void printClusterDistribution(BalancerClusterState cluster, long actionsT
}

/**
* Partitions the given serverToRegions map by table, returning a structure of Map<TableName,
* Map<ServerName, List<RegionInfo>>>. 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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ee8c552

Please sign in to comment.