Skip to content

Commit b28f5e8

Browse files
committedMar 28, 2024
Address the comments
Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>
1 parent 0f9edb0 commit b28f5e8

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed
 

‎server/src/main/java/org/opensearch/cluster/routing/allocation/AllocationConstraints.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ public class AllocationConstraints {
3030

3131
public AllocationConstraints() {
3232
this.constraints = new HashMap<>();
33-
this.constraints.putIfAbsent(INDEX_SHARD_PER_NODE_BREACH_CONSTRAINT_ID, new Constraint(isIndexShardsPerNodeBreached()));
34-
this.constraints.putIfAbsent(INDEX_PRIMARY_SHARD_BALANCE_CONSTRAINT_ID, new Constraint(isPerIndexPrimaryShardsPerNodeBreached()));
35-
this.constraints.putIfAbsent(CLUSTER_PRIMARY_SHARD_BALANCE_CONSTRAINT_ID, new Constraint(isPrimaryShardsPerNodeBreached(0.0f)));
33+
this.constraints.put(INDEX_SHARD_PER_NODE_BREACH_CONSTRAINT_ID, new Constraint(isIndexShardsPerNodeBreached()));
34+
this.constraints.put(INDEX_PRIMARY_SHARD_BALANCE_CONSTRAINT_ID, new Constraint(isPerIndexPrimaryShardsPerNodeBreached()));
35+
this.constraints.put(CLUSTER_PRIMARY_SHARD_BALANCE_CONSTRAINT_ID, new Constraint(isPrimaryShardsPerNodeBreached(0.0f)));
3636
}
3737

3838
public void updateAllocationConstraint(String constraint, boolean enable) {

‎server/src/main/java/org/opensearch/cluster/routing/allocation/RebalanceConstraints.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public class RebalanceConstraints {
3131

3232
public RebalanceConstraints(RebalanceParameter rebalanceParameter) {
3333
this.constraints = new HashMap<>();
34-
this.constraints.putIfAbsent(INDEX_PRIMARY_SHARD_BALANCE_CONSTRAINT_ID, new Constraint(isPerIndexPrimaryShardsPerNodeBreached()));
35-
this.constraints.putIfAbsent(
34+
this.constraints.put(INDEX_PRIMARY_SHARD_BALANCE_CONSTRAINT_ID, new Constraint(isPerIndexPrimaryShardsPerNodeBreached()));
35+
this.constraints.put(
3636
CLUSTER_PRIMARY_SHARD_REBALANCE_CONSTRAINT_ID,
3737
new Constraint(isPrimaryShardsPerNodeBreached(rebalanceParameter.getPreferPrimaryBalanceBuffer()))
3838
);

‎server/src/main/java/org/opensearch/cluster/routing/allocation/allocator/BalancedShardsAllocator.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public BalancedShardsAllocator(Settings settings, ClusterSettings clusterSetting
182182
setShardBalanceFactor(SHARD_BALANCE_FACTOR_SETTING.get(settings));
183183
setIndexBalanceFactor(INDEX_BALANCE_FACTOR_SETTING.get(settings));
184184
setPreferPrimaryShardRebalanceBuffer(PRIMARY_SHARD_REBALANCE_BUFFER.get(settings));
185-
setWeightFunction();
185+
updateWeightFunction();
186186
setThreshold(THRESHOLD_SETTING.get(settings));
187187
setPreferPrimaryShardBalance(PREFER_PRIMARY_SHARD_BALANCE.get(settings));
188188
setPreferPrimaryShardRebalance(PREFER_PRIMARY_SHARD_REBALANCE.get(settings));
@@ -232,20 +232,20 @@ private void setPreferPrimaryShardRebalanceBuffer(float preferPrimaryShardRebala
232232

233233
private void updateIndexBalanceFactor(float indexBalanceFactor) {
234234
this.indexBalanceFactor = indexBalanceFactor;
235-
setWeightFunction();
235+
updateWeightFunction();
236236
}
237237

238238
private void updateShardBalanceFactor(float shardBalanceFactor) {
239239
this.shardBalanceFactor = shardBalanceFactor;
240-
setWeightFunction();
240+
updateWeightFunction();
241241
}
242242

243243
private void updatePreferPrimaryShardBalanceBuffer(float preferPrimaryShardBalanceBuffer) {
244244
this.preferPrimaryShardRebalanceBuffer = preferPrimaryShardBalanceBuffer;
245-
setWeightFunction();
245+
updateWeightFunction();
246246
}
247247

248-
private void setWeightFunction() {
248+
private void updateWeightFunction() {
249249
weightFunction = new WeightFunction(this.indexBalanceFactor, this.shardBalanceFactor, this.preferPrimaryShardRebalanceBuffer);
250250
}
251251

0 commit comments

Comments
 (0)