Skip to content

Commit dde7f9c

Browse files
committed
revert changes for eum
1 parent a7e0dda commit dde7f9c

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/CandidateGenerator.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
* Generates a candidate action to be applied to the cluster for cost function search
2828
*/
2929
@InterfaceAudience.Private
30-
@com.google.errorprone.annotations.Immutable
3130
abstract class CandidateGenerator {
3231

3332
abstract BalanceAction generate(BalancerClusterState cluster);

hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,9 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
138138
private double[] curFunctionCosts;
139139
private double[] weightsOfGenerators;
140140

141-
// Keep locality based cost function to alert them
141+
// Keep locality based picker and cost function to alert them
142142
// when new services are offered
143+
private LocalityBasedCandidateGenerator localityCandidateGenerator;
143144
private ServerLocalityCostFunction localityCost;
144145
private RackLocalityCostFunction rackLocalityCost;
145146
private RegionReplicaHostCostFunction regionReplicaHostCostFunction;
@@ -148,20 +149,7 @@ public class StochasticLoadBalancer extends BaseLoadBalancer {
148149
protected List<CandidateGenerator> candidateGenerators;
149150

150151
public enum GeneratorType {
151-
RANDOM(new RandomCandidateGenerator()),
152-
LOAD(new LoadCandidateGenerator()),
153-
LOCALITY(new LocalityBasedCandidateGenerator()),
154-
RACK(new RegionReplicaRackCandidateGenerator());
155-
156-
private final CandidateGenerator generator;
157-
158-
private GeneratorType(CandidateGenerator generator) {
159-
this.generator = generator;
160-
}
161-
162-
public CandidateGenerator getGenerator(){
163-
return generator;
164-
}
152+
RANDOM, LOAD, LOCALITY, RACK
165153
}
166154

167155
/**
@@ -209,16 +197,24 @@ private void loadCustomCostFunctions(Configuration conf) {
209197
}
210198
}
211199

200+
@RestrictedApi(explanation = "Should only be called in tests", link = "",
201+
allowedOnPath = ".*/src/test/.*")
202+
List<CandidateGenerator> getCandidateGenerators() {
203+
return this.candidateGenerators;
204+
}
205+
212206
@Override
213207
protected float getDefaultSlop() {
214208
return 0.001f;
215209
}
216210

217211
protected List<CandidateGenerator> createCandidateGenerators() {
218212
List<CandidateGenerator> candidateGenerators = new ArrayList<CandidateGenerator>(4);
219-
for (GeneratorType generatorType : GeneratorType.values()) {
220-
candidateGenerators.add(generatorType.getGenerator());
221-
}
213+
candidateGenerators.add(GeneratorType.RANDOM.ordinal(), new RandomCandidateGenerator());
214+
candidateGenerators.add(GeneratorType.LOAD.ordinal(), new LoadCandidateGenerator());
215+
candidateGenerators.add(GeneratorType.LOCALITY.ordinal(), localityCandidateGenerator);
216+
candidateGenerators.add(GeneratorType.RACK.ordinal(),
217+
new RegionReplicaRackCandidateGenerator());
222218
return candidateGenerators;
223219
}
224220

@@ -232,6 +228,7 @@ protected void loadConf(Configuration conf) {
232228

233229
numRegionLoadsToRemember = conf.getInt(KEEP_REGION_LOADS, numRegionLoadsToRemember);
234230
minCostNeedBalance = conf.getFloat(MIN_COST_NEED_BALANCE_KEY, minCostNeedBalance);
231+
localityCandidateGenerator = new LocalityBasedCandidateGenerator();
235232
localityCost = new ServerLocalityCostFunction(conf);
236233
rackLocalityCost = new RackLocalityCostFunction(conf);
237234

0 commit comments

Comments
 (0)