Skip to content

Commit f1302a5

Browse files
committed
Revert "Short-circuit rebalancing when disabled (#40942)"
This reverts commit 2ae9e27. This reverts commit 314890b.
1 parent 2ae9e27 commit f1302a5

File tree

2 files changed

+3
-262
lines changed

2 files changed

+3
-262
lines changed

server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/EnableAllocationDecider.java

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -86,21 +86,16 @@ public EnableAllocationDecider(Settings settings, ClusterSettings clusterSetting
8686
clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING, this::setEnableRebalance);
8787
}
8888

89-
private void setEnableRebalance(Rebalance enableRebalance) {
89+
public void setEnableRebalance(Rebalance enableRebalance) {
9090
this.enableRebalance = enableRebalance;
9191
}
9292

93-
private void setEnableAllocation(Allocation enableAllocation) {
93+
public void setEnableAllocation(Allocation enableAllocation) {
9494
this.enableAllocation = enableAllocation;
9595
}
9696

9797
@Override
9898
public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) {
99-
return canAllocate(shardRouting, allocation);
100-
}
101-
102-
@Override
103-
public Decision canAllocate(ShardRouting shardRouting, RoutingAllocation allocation) {
10499
if (allocation.ignoreDisable()) {
105100
return allocation.decision(Decision.YES, NAME,
106101
"explicitly ignoring any disabling of allocation due to manual allocation commands via the reroute API");
@@ -141,29 +136,10 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingAllocation allocat
141136
}
142137
}
143138

144-
@Override
145-
public Decision canRebalance(RoutingAllocation allocation) {
146-
if (allocation.ignoreDisable()) {
147-
return allocation.decision(Decision.YES, NAME, "allocation is explicitly ignoring any disabling of rebalancing");
148-
}
149-
150-
if (enableRebalance == Rebalance.NONE) {
151-
for (IndexMetaData indexMetaData : allocation.metaData()) {
152-
if (INDEX_ROUTING_REBALANCE_ENABLE_SETTING.exists(indexMetaData.getSettings())
153-
&& INDEX_ROUTING_REBALANCE_ENABLE_SETTING.get(indexMetaData.getSettings()) != Rebalance.NONE) {
154-
return allocation.decision(Decision.YES, NAME, "rebalancing is permitted on one or more indices");
155-
}
156-
}
157-
return allocation.decision(Decision.NO, NAME, "no rebalancing is allowed due to %s", setting(enableRebalance, false));
158-
}
159-
160-
return allocation.decision(Decision.YES, NAME, "rebalancing is not globally disabled");
161-
}
162-
163139
@Override
164140
public Decision canRebalance(ShardRouting shardRouting, RoutingAllocation allocation) {
165141
if (allocation.ignoreDisable()) {
166-
return allocation.decision(Decision.YES, NAME, "allocation is explicitly ignoring any disabling of rebalancing");
142+
return allocation.decision(Decision.YES, NAME, "allocation is explicitly ignoring any disabling of relocation");
167143
}
168144

169145
Settings indexSettings = allocation.metaData().getIndexSafe(shardRouting.index()).getSettings();

server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/EnableAllocationShortCircuitTests.java

Lines changed: 0 additions & 235 deletions
This file was deleted.

0 commit comments

Comments
 (0)