From 788df35e339d5f1c90592d5e12c929b3f959bc78 Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Wed, 26 Jan 2022 12:07:22 +0100 Subject: [PATCH] Make AllocationService#adaptAutoExpandReplicas Faster (#83092) This method is getting fairly expensive for large cluster states. In most cases it is not necessary to actually compute the `RoutingAllocation` so I made that lazy to save potentially needlessly building routing nodes. Also, parsing the auto-expand-replicas setting gets quite expensive when looping over thousands of shards in this method so I moved the auto-expand setting value into the index metadata. These changes make the method disappear from profiling in most cases and help make reroute yet a bit faster. --- docs/changelog/83092.yaml | 5 ++ ...ansportClusterAllocationExplainAction.java | 3 -- .../cluster/metadata/AutoExpandReplicas.java | 54 +++++++++++-------- .../cluster/metadata/IndexMetadata.java | 16 ++++-- .../routing/allocation/AllocationService.java | 12 ++--- .../routing/allocation/RoutingAllocation.java | 54 ++++++++++--------- .../decider/AwarenessAllocationDecider.java | 3 +- .../decider/SameShardAllocationDecider.java | 5 +- .../ClusterAllocationExplainActionTests.java | 3 +- .../allocation/AllocationServiceTests.java | 1 - .../allocation/AwarenessAllocationTests.java | 1 - .../MaxRetryAllocationDeciderTests.java | 8 +-- .../NodeVersionAllocationDeciderTests.java | 2 +- .../ResizeAllocationDeciderTests.java | 8 +-- .../allocation/SameShardRoutingTests.java | 1 - .../decider/AllocationDecidersTests.java | 11 +--- .../DiskThresholdDeciderUnitTests.java | 18 ++----- .../decider/FilterAllocationDeciderTests.java | 4 +- ...NodeReplacementAllocationDeciderTests.java | 8 +-- .../NodeShutdownAllocationDeciderTests.java | 12 ++--- ...storeInProgressAllocationDeciderTests.java | 1 - .../ReactiveStorageDeciderService.java | 18 +------ .../ReactiveStorageDeciderServiceTests.java | 18 +------ .../xpack/core/ilm/AllocationRoutedStep.java | 9 +--- .../core/ilm/SetSingleNodeAllocateStep.java | 6 +-- .../DataTierAllocationDeciderTests.java | 4 +- .../TransportGetShutdownStatusAction.java | 1 - 27 files changed, 123 insertions(+), 163 deletions(-) create mode 100644 docs/changelog/83092.yaml diff --git a/docs/changelog/83092.yaml b/docs/changelog/83092.yaml new file mode 100644 index 0000000000000..ebe3f8c9d84d1 --- /dev/null +++ b/docs/changelog/83092.yaml @@ -0,0 +1,5 @@ +pr: 83092 +summary: Make `AllocationService#adaptAutoExpandReplicas` Faster +area: Allocation +type: enhancement +issues: [] diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/TransportClusterAllocationExplainAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/TransportClusterAllocationExplainAction.java index 4089f6ce3703c..09ce5606b0a74 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/TransportClusterAllocationExplainAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/TransportClusterAllocationExplainAction.java @@ -20,7 +20,6 @@ import org.elasticsearch.cluster.block.ClusterBlockLevel; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.cluster.routing.RoutingNodes; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.cluster.routing.allocation.RoutingAllocation; @@ -92,11 +91,9 @@ protected void masterOperation( final ClusterState state, final ActionListener listener ) { - final RoutingNodes routingNodes = state.getRoutingNodes(); final ClusterInfo clusterInfo = clusterInfoService.getClusterInfo(); final RoutingAllocation allocation = new RoutingAllocation( allocationDeciders, - routingNodes, state, clusterInfo, snapshotsInfoService.snapshotShardSizes(), diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/AutoExpandReplicas.java b/server/src/main/java/org/elasticsearch/cluster/metadata/AutoExpandReplicas.java index 5e37bd62a2dc4..6c76fb41c5270 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/AutoExpandReplicas.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/AutoExpandReplicas.java @@ -19,6 +19,7 @@ import java.util.List; import java.util.Map; import java.util.OptionalInt; +import java.util.function.Supplier; import static org.elasticsearch.cluster.metadata.MetadataIndexStateService.isIndexVerifiedBeforeClosed; @@ -100,28 +101,27 @@ public boolean expandToAllNodes() { return maxReplicas == Integer.MAX_VALUE; } - private OptionalInt getDesiredNumberOfReplicas(IndexMetadata indexMetadata, RoutingAllocation allocation) { - if (enabled) { - int numMatchingDataNodes = 0; - for (DiscoveryNode discoveryNode : allocation.nodes().getDataNodes().values()) { - Decision decision = allocation.deciders().shouldAutoExpandToNode(indexMetadata, discoveryNode, allocation); - if (decision.type() != Decision.Type.NO) { - numMatchingDataNodes++; - } + public OptionalInt getDesiredNumberOfReplicas(IndexMetadata indexMetadata, RoutingAllocation allocation) { + assert enabled : "should only be called when enabled"; + int numMatchingDataNodes = 0; + for (DiscoveryNode discoveryNode : allocation.nodes().getDataNodes().values()) { + Decision decision = allocation.deciders().shouldAutoExpandToNode(indexMetadata, discoveryNode, allocation); + if (decision.type() != Decision.Type.NO) { + numMatchingDataNodes++; } + } - final int min = minReplicas(); - final int max = getMaxReplicas(numMatchingDataNodes); - int numberOfReplicas = numMatchingDataNodes - 1; - if (numberOfReplicas < min) { - numberOfReplicas = min; - } else if (numberOfReplicas > max) { - numberOfReplicas = max; - } + final int min = minReplicas(); + final int max = getMaxReplicas(numMatchingDataNodes); + int numberOfReplicas = numMatchingDataNodes - 1; + if (numberOfReplicas < min) { + numberOfReplicas = min; + } else if (numberOfReplicas > max) { + numberOfReplicas = max; + } - if (numberOfReplicas >= min && numberOfReplicas <= max) { - return OptionalInt.of(numberOfReplicas); - } + if (numberOfReplicas >= min && numberOfReplicas <= max) { + return OptionalInt.of(numberOfReplicas); } return OptionalInt.empty(); } @@ -137,12 +137,22 @@ public String toString() { * The map has the desired number of replicas as key and the indices to update as value, as this allows the result * of this method to be directly applied to RoutingTable.Builder#updateNumberOfReplicas. */ - public static Map> getAutoExpandReplicaChanges(Metadata metadata, RoutingAllocation allocation) { + public static Map> getAutoExpandReplicaChanges( + Metadata metadata, + Supplier allocationSupplier + ) { Map> nrReplicasChanged = new HashMap<>(); - + // RoutingAllocation is fairly expensive to compute, only lazy create it via the supplier if we actually need it + RoutingAllocation allocation = null; for (final IndexMetadata indexMetadata : metadata) { if (indexMetadata.getState() == IndexMetadata.State.OPEN || isIndexVerifiedBeforeClosed(indexMetadata)) { - AutoExpandReplicas autoExpandReplicas = SETTING.get(indexMetadata.getSettings()); + AutoExpandReplicas autoExpandReplicas = indexMetadata.getAutoExpandReplicas(); + if (autoExpandReplicas.enabled() == false) { + continue; + } + if (allocation == null) { + allocation = allocationSupplier.get(); + } autoExpandReplicas.getDesiredNumberOfReplicas(indexMetadata, allocation).ifPresent(numberOfReplicas -> { if (numberOfReplicas != indexMetadata.getNumberOfReplicas()) { nrReplicasChanged.computeIfAbsent(numberOfReplicas, ArrayList::new).add(indexMetadata.getIndex().getName()); diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java index 10ff36a5b855f..ff8da8ddd0df2 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java @@ -503,6 +503,8 @@ public static APIBlock readFrom(StreamInput input) throws IOException { private final LifecycleExecutionState lifecycleExecutionState; + private final AutoExpandReplicas autoExpandReplicas; + private IndexMetadata( final Index index, final long version, @@ -536,7 +538,8 @@ private IndexMetadata( final boolean ignoreDiskWatermarks, @Nullable final List tierPreference, final int shardsPerNodeLimit, - final LifecycleExecutionState lifecycleExecutionState + final LifecycleExecutionState lifecycleExecutionState, + final AutoExpandReplicas autoExpandReplicas ) { this.index = index; this.version = version; @@ -578,6 +581,7 @@ private IndexMetadata( this.tierPreference = tierPreference; this.shardsPerNodeLimit = shardsPerNodeLimit; this.lifecycleExecutionState = lifecycleExecutionState; + this.autoExpandReplicas = autoExpandReplicas; assert numberOfShards * routingFactor == routingNumShards : routingNumShards + " must be a multiple of " + numberOfShards; } @@ -618,7 +622,8 @@ IndexMetadata withMappingMetadata(MappingMetadata mapping) { this.ignoreDiskWatermarks, this.tierPreference, this.shardsPerNodeLimit, - this.lifecycleExecutionState + this.lifecycleExecutionState, + this.autoExpandReplicas ); } @@ -746,6 +751,10 @@ public LifecycleExecutionState getLifecycleExecutionState() { return lifecycleExecutionState; } + public AutoExpandReplicas getAutoExpandReplicas() { + return autoExpandReplicas; + } + /** * Return the concrete mapping for this index or {@code null} if this index has no mappings at all. */ @@ -1612,7 +1621,8 @@ public IndexMetadata build() { DiskThresholdDecider.SETTING_IGNORE_DISK_WATERMARKS.get(settings), tierPreference, ShardsLimitAllocationDecider.INDEX_TOTAL_SHARDS_PER_NODE_SETTING.get(settings), - lifecycleExecutionState + lifecycleExecutionState, + AutoExpandReplicas.SETTING.get(settings) ); } diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java index 420168b5c670e..859621247e92c 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java @@ -51,6 +51,7 @@ import java.util.Optional; import java.util.Set; import java.util.function.Function; +import java.util.function.Supplier; import java.util.stream.Collectors; import static java.util.Collections.emptyList; @@ -71,7 +72,7 @@ public class AllocationService { private Map existingShardsAllocators; private final ShardsAllocator shardsAllocator; private final ClusterInfoService clusterInfoService; - private SnapshotsInfoService snapshotsInfoService; + private final SnapshotsInfoService snapshotsInfoService; // only for tests that use the GatewayAllocator as the unique ExistingShardsAllocator public AllocationService( @@ -298,9 +299,8 @@ public ClusterState disassociateDeadNodes(ClusterState clusterState, boolean rer * Returns an updated cluster state if changes were necessary, or the identical cluster if no changes were required. */ public ClusterState adaptAutoExpandReplicas(ClusterState clusterState) { - RoutingAllocation allocation = new RoutingAllocation( + final Supplier allocationSupplier = () -> new RoutingAllocation( allocationDeciders, - clusterState.getRoutingNodes(), clusterState, clusterInfoService.getClusterInfo(), snapshotsInfoService.snapshotShardSizes(), @@ -308,7 +308,7 @@ public ClusterState adaptAutoExpandReplicas(ClusterState clusterState) { ); final Map> autoExpandReplicaChanges = AutoExpandReplicas.getAutoExpandReplicaChanges( clusterState.metadata(), - allocation + allocationSupplier ); if (autoExpandReplicaChanges.isEmpty()) { return clusterState; @@ -336,7 +336,7 @@ public ClusterState adaptAutoExpandReplicas(ClusterState clusterState) { .routingTable(routingTableBuilder.build()) .metadata(metadataBuilder) .build(); - assert AutoExpandReplicas.getAutoExpandReplicaChanges(fixedState.metadata(), allocation).isEmpty(); + assert AutoExpandReplicas.getAutoExpandReplicaChanges(fixedState.metadata(), allocationSupplier).isEmpty(); return fixedState; } } @@ -514,7 +514,7 @@ private boolean hasDeadNodes(RoutingAllocation allocation) { private void reroute(RoutingAllocation allocation) { assert hasDeadNodes(allocation) == false : "dead nodes should be explicitly cleaned up. See disassociateDeadNodes"; - assert AutoExpandReplicas.getAutoExpandReplicaChanges(allocation.metadata(), allocation).isEmpty() + assert AutoExpandReplicas.getAutoExpandReplicaChanges(allocation.metadata(), () -> allocation).isEmpty() : "auto-expand replicas out of sync with number of nodes in the cluster"; assert assertInitialized(); diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/RoutingAllocation.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/RoutingAllocation.java index 84486f774d4df..d9827add4a2f1 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/RoutingAllocation.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/RoutingAllocation.java @@ -21,6 +21,7 @@ import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders; import org.elasticsearch.cluster.routing.allocation.decider.Decision; import org.elasticsearch.common.collect.ImmutableOpenMap; +import org.elasticsearch.core.Nullable; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.snapshots.RestoreService.RestoreInProgressUpdater; import org.elasticsearch.snapshots.SnapshotShardSizeInfo; @@ -42,15 +43,10 @@ public class RoutingAllocation { private final AllocationDeciders deciders; + @Nullable private final RoutingNodes routingNodes; - private final Metadata metadata; - - private final RoutingTable routingTable; - - private final DiscoveryNodes nodes; - - private final ImmutableOpenMap customs; + private final ClusterState clusterState; private final ClusterInfo clusterInfo; @@ -75,19 +71,28 @@ public class RoutingAllocation { restoreInProgressUpdater ); - private final Map nodeShutdowns; private final Map nodeReplacementTargets; + public RoutingAllocation( + AllocationDeciders deciders, + ClusterState clusterState, + ClusterInfo clusterInfo, + SnapshotShardSizeInfo shardSizeInfo, + long currentNanoTime + ) { + this(deciders, null, clusterState, clusterInfo, shardSizeInfo, currentNanoTime); + } + /** * Creates a new {@link RoutingAllocation} - * @param deciders {@link AllocationDeciders} to used to make decisions for routing allocations - * @param routingNodes Routing nodes in the current cluster + * @param deciders {@link AllocationDeciders} to used to make decisions for routing allocations + * @param routingNodes Routing nodes in the current cluster or {@code null} if using those in the given cluster state * @param clusterState cluster state before rerouting * @param currentNanoTime the nano time to use for all delay allocation calculation (typically {@link System#nanoTime()}) */ public RoutingAllocation( AllocationDeciders deciders, - RoutingNodes routingNodes, + @Nullable RoutingNodes routingNodes, ClusterState clusterState, ClusterInfo clusterInfo, SnapshotShardSizeInfo shardSizeInfo, @@ -95,16 +100,12 @@ public RoutingAllocation( ) { this.deciders = deciders; this.routingNodes = routingNodes; - this.metadata = clusterState.metadata(); - this.routingTable = clusterState.routingTable(); - this.nodes = clusterState.nodes(); - this.customs = clusterState.customs(); + this.clusterState = clusterState; this.clusterInfo = clusterInfo; this.shardSizeInfo = shardSizeInfo; this.currentNanoTime = currentNanoTime; - this.nodeShutdowns = metadata.nodeShutdowns(); Map targetNameToShutdown = new HashMap<>(); - for (SingleNodeShutdownMetadata shutdown : this.nodeShutdowns.values()) { + for (SingleNodeShutdownMetadata shutdown : clusterState.metadata().nodeShutdowns().values()) { if (shutdown.getType() == SingleNodeShutdownMetadata.Type.REPLACE) { targetNameToShutdown.put(shutdown.getTargetNodeName(), shutdown); } @@ -130,7 +131,7 @@ public AllocationDeciders deciders() { * @return current routing table */ public RoutingTable routingTable() { - return routingTable; + return clusterState.routingTable(); } /** @@ -138,7 +139,10 @@ public RoutingTable routingTable() { * @return routing nodes */ public RoutingNodes routingNodes() { - return routingNodes; + if (routingNodes != null) { + return routingNodes; + } + return clusterState.getRoutingNodes(); } /** @@ -146,7 +150,7 @@ public RoutingNodes routingNodes() { * @return Metadata of routing nodes */ public Metadata metadata() { - return metadata; + return clusterState.metadata(); } /** @@ -154,7 +158,7 @@ public Metadata metadata() { * @return discovery nodes */ public DiscoveryNodes nodes() { - return nodes; + return clusterState.nodes(); } public ClusterInfo clusterInfo() { @@ -169,7 +173,7 @@ public SnapshotShardSizeInfo snapshotShardSizeInfo() { * Returns the map of node id to shutdown metadata currently in the cluster */ public Map nodeShutdowns() { - return this.nodeShutdowns; + return metadata().nodeShutdowns(); } /** @@ -181,11 +185,11 @@ public Map replacementTargetShutdowns() { @SuppressWarnings("unchecked") public T custom(String key) { - return (T) customs.get(key); + return (T) clusterState.customs().get(key); } public ImmutableOpenMap getCustoms() { - return customs; + return clusterState.getCustoms(); } public void ignoreDisable(boolean ignoreDisable) { @@ -267,7 +271,7 @@ public RoutingChangesObserver changes() { * Returns updated {@link Metadata} based on the changes that were made to the routing nodes */ public Metadata updateMetadataWithRoutingChanges(RoutingTable newRoutingTable) { - return indexMetadataUpdater.applyChanges(metadata, newRoutingTable); + return indexMetadataUpdater.applyChanges(metadata(), newRoutingTable); } /** diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AwarenessAllocationDecider.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AwarenessAllocationDecider.java index 99e6093de02ee..5f981123e2c53 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AwarenessAllocationDecider.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AwarenessAllocationDecider.java @@ -29,7 +29,6 @@ import static java.util.Collections.emptyList; import static java.util.stream.Collectors.toList; -import static org.elasticsearch.cluster.metadata.IndexMetadata.INDEX_AUTO_EXPAND_REPLICAS_SETTING; /** * This {@link AllocationDecider} controls shard allocation based on @@ -164,7 +163,7 @@ private Decision underCapacity(ShardRouting shardRouting, RoutingNode node, Rout final boolean debug = allocation.debugDecision(); final IndexMetadata indexMetadata = allocation.metadata().getIndexSafe(shardRouting.index()); - if (INDEX_AUTO_EXPAND_REPLICAS_SETTING.get(indexMetadata.getSettings()).expandToAllNodes()) { + if (indexMetadata.getAutoExpandReplicas().expandToAllNodes()) { return YES_AUTO_EXPAND_ALL; } diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/SameShardAllocationDecider.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/SameShardAllocationDecider.java index 10682cf1912ce..2ee5c3812d7fa 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/SameShardAllocationDecider.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/SameShardAllocationDecider.java @@ -18,8 +18,6 @@ import org.elasticsearch.common.settings.Setting.Property; import org.elasticsearch.common.settings.Settings; -import static org.elasticsearch.cluster.metadata.IndexMetadata.INDEX_AUTO_EXPAND_REPLICAS_SETTING; - /** * An allocation decider that prevents multiple instances of the same shard to * be allocated on the same {@code node}. @@ -82,8 +80,7 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing // if its already a NO decision looking at the node, or we aren't configured to look at the host, return the decision return decision; } - if (INDEX_AUTO_EXPAND_REPLICAS_SETTING.get(allocation.metadata().getIndexSafe(shardRouting.index()).getSettings()) - .expandToAllNodes()) { + if (allocation.metadata().getIndexSafe(shardRouting.index()).getAutoExpandReplicas().expandToAllNodes()) { return YES_AUTO_EXPAND_ALL; } if (node.node() != null) { diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainActionTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainActionTests.java index 13ce8462f1fb5..3f86bada8a579 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainActionTests.java @@ -52,7 +52,6 @@ public void testInitializingOrRelocatingShardExplanation() throws Exception { ShardRouting shard = clusterState.getRoutingTable().index("idx").shard(0).primaryShard(); RoutingAllocation allocation = new RoutingAllocation( new AllocationDeciders(Collections.emptyList()), - clusterState.getRoutingNodes(), clusterState, null, null, @@ -268,6 +267,6 @@ public void testFindShardAssignedToNode() { } private static RoutingAllocation routingAllocation(ClusterState clusterState) { - return new RoutingAllocation(NOOP_DECIDERS, clusterState.getRoutingNodes(), clusterState, null, null, System.nanoTime()); + return new RoutingAllocation(NOOP_DECIDERS, clusterState, null, null, System.nanoTime()); } } diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationServiceTests.java index 51a83612c33c9..d117d34bc95a4 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationServiceTests.java @@ -260,7 +260,6 @@ public void testExplainsNonAllocationOfShardWithUnknownAllocator() { final RoutingAllocation allocation = new RoutingAllocation( new AllocationDeciders(Collections.emptyList()), - clusterState.getRoutingNodes(), clusterState, ClusterInfo.EMPTY, null, diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/AwarenessAllocationTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/AwarenessAllocationTests.java index ba5e8d292509f..9e725a398445a 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/AwarenessAllocationTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/AwarenessAllocationTests.java @@ -1105,7 +1105,6 @@ private void testExplanation( final RoutingAllocation routingAllocation = new RoutingAllocation( new AllocationDeciders(singletonList(decider)), - clusterState.getRoutingNodes(), clusterState, null, null, diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/MaxRetryAllocationDeciderTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/MaxRetryAllocationDeciderTests.java index f8dde00ac4597..41710a7ba7fda 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/MaxRetryAllocationDeciderTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/MaxRetryAllocationDeciderTests.java @@ -202,7 +202,7 @@ public void testFailedAllocation() { new MaxRetryAllocationDecider().canForceAllocatePrimary( unassignedPrimary, null, - new RoutingAllocation(null, null, clusterState, null, null, 0) + new RoutingAllocation(null, clusterState, null, null, 0) ) ); } @@ -231,7 +231,7 @@ public void testFailedAllocation() { new MaxRetryAllocationDecider().canForceAllocatePrimary( unassignedPrimary, null, - new RoutingAllocation(null, null, clusterState, null, null, 0) + new RoutingAllocation(null, clusterState, null, null, 0) ) ); } @@ -271,7 +271,7 @@ public void testFailedAllocation() { new MaxRetryAllocationDecider().canForceAllocatePrimary( routingTable.index("idx").shard(0).shards().get(0), null, - new RoutingAllocation(null, null, clusterState, null, null, 0) + new RoutingAllocation(null, clusterState, null, null, 0) ) ); @@ -308,7 +308,7 @@ public void testFailedAllocation() { new MaxRetryAllocationDecider().canForceAllocatePrimary( unassignedPrimary, null, - new RoutingAllocation(null, null, clusterState, null, null, 0) + new RoutingAllocation(null, clusterState, null, null, 0) ) ); } diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeVersionAllocationDeciderTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeVersionAllocationDeciderTests.java index 36755b74b6d81..113beb2f90bd6 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeVersionAllocationDeciderTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/NodeVersionAllocationDeciderTests.java @@ -594,7 +594,7 @@ public void testMessages() { final ShardRouting primaryShard = clusterState.routingTable().shardRoutingTable(shardId).primaryShard(); final ShardRouting replicaShard = clusterState.routingTable().shardRoutingTable(shardId).replicaShards().get(0); - RoutingAllocation routingAllocation = new RoutingAllocation(null, clusterState.getRoutingNodes(), clusterState, null, null, 0); + RoutingAllocation routingAllocation = new RoutingAllocation(null, clusterState, null, null, 0); routingAllocation.debugDecision(true); final NodeVersionAllocationDecider allocationDecider = new NodeVersionAllocationDecider(); diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/ResizeAllocationDeciderTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/ResizeAllocationDeciderTests.java index 1c8bf5643219c..d47c6952db424 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/ResizeAllocationDeciderTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/ResizeAllocationDeciderTests.java @@ -105,7 +105,7 @@ private ClusterState createInitialClusterState(boolean startShards) { public void testNonResizeRouting() { ClusterState clusterState = createInitialClusterState(true); ResizeAllocationDecider resizeAllocationDecider = new ResizeAllocationDecider(); - RoutingAllocation routingAllocation = new RoutingAllocation(null, null, clusterState, null, null, 0); + RoutingAllocation routingAllocation = new RoutingAllocation(null, clusterState, null, null, 0); ShardRouting shardRouting = TestShardRouting.newShardRouting("non-resize", 0, null, true, ShardRoutingState.UNASSIGNED); assertEquals(Decision.ALWAYS, resizeAllocationDecider.canAllocate(shardRouting, routingAllocation)); assertEquals( @@ -134,7 +134,7 @@ public void testShrink() { // we don't handle shrink yet Index idx = clusterState.metadata().index("target").getIndex(); ResizeAllocationDecider resizeAllocationDecider = new ResizeAllocationDecider(); - RoutingAllocation routingAllocation = new RoutingAllocation(null, null, clusterState, null, null, 0); + RoutingAllocation routingAllocation = new RoutingAllocation(null, clusterState, null, null, 0); ShardRouting shardRouting = TestShardRouting.newShardRouting( new ShardId(idx, 0), null, @@ -173,7 +173,7 @@ public void testSourceNotActive() { Index idx = clusterState.metadata().index("target").getIndex(); ResizeAllocationDecider resizeAllocationDecider = new ResizeAllocationDecider(); - RoutingAllocation routingAllocation = new RoutingAllocation(null, clusterState.getRoutingNodes(), clusterState, null, null, 0); + RoutingAllocation routingAllocation = new RoutingAllocation(null, clusterState, null, null, 0); int shardId = randomIntBetween(0, 3); int sourceShardId = IndexMetadata.selectSplitShard(shardId, clusterState.metadata().index("source"), 4).id(); ShardRouting shardRouting = TestShardRouting.newShardRouting( @@ -230,7 +230,7 @@ public void testSourcePrimaryActive() { Index idx = clusterState.metadata().index("target").getIndex(); ResizeAllocationDecider resizeAllocationDecider = new ResizeAllocationDecider(); - RoutingAllocation routingAllocation = new RoutingAllocation(null, clusterState.getRoutingNodes(), clusterState, null, null, 0); + RoutingAllocation routingAllocation = new RoutingAllocation(null, clusterState, null, null, 0); int shardId = randomIntBetween(0, 3); int sourceShardId = IndexMetadata.selectSplitShard(shardId, clusterState.metadata().index("source"), 4).id(); ShardRouting shardRouting = TestShardRouting.newShardRouting( diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/SameShardRoutingTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/SameShardRoutingTests.java index de95b2f9d2c9d..419c1729d3329 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/SameShardRoutingTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/SameShardRoutingTests.java @@ -217,7 +217,6 @@ public void testSameHostCheckWithExplain() { final RoutingAllocation routingAllocation = new RoutingAllocation( new AllocationDeciders(singletonList(decider)), - clusterState.getRoutingNodes(), clusterState, null, null, diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/AllocationDecidersTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/AllocationDecidersTests.java index d310947434811..1c071a21605bc 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/AllocationDecidersTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/AllocationDecidersTests.java @@ -79,7 +79,7 @@ public Decision canRebalance(RoutingAllocation allocation) { })); ClusterState clusterState = ClusterState.builder(new ClusterName("test")).build(); - final RoutingAllocation allocation = new RoutingAllocation(deciders, clusterState.getRoutingNodes(), clusterState, null, null, 0L); + final RoutingAllocation allocation = new RoutingAllocation(deciders, clusterState, null, null, 0L); allocation.setDebugMode(mode); final UnassignedInfo unassignedInfo = new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, "_message"); @@ -217,14 +217,7 @@ private Decision decision(RoutingAllocation allocation) { .numberOfReplicas(0) .build(); - final RoutingAllocation allocation = new RoutingAllocation( - allocationDeciders, - clusterState.getRoutingNodes(), - clusterState, - null, - null, - 0L - ); + final RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, clusterState, null, null, 0L); assertSame(Decision.NO, allocationDeciders.canAllocate(shardRouting, routingNode, allocation)); assertSame(Decision.NO, allocationDeciders.canRebalance(shardRouting, allocation)); assertSame(Decision.NO, allocationDeciders.canRemain(shardRouting, routingNode, allocation)); diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderUnitTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderUnitTests.java index 7589c66f9f99b..6aad36b22482a 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderUnitTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderUnitTests.java @@ -113,7 +113,6 @@ public void testCanAllocateUsesMaxAvailableSpace() { ); RoutingAllocation allocation = new RoutingAllocation( new AllocationDeciders(Collections.singleton(decider)), - clusterState.getRoutingNodes(), clusterState, clusterInfo, null, @@ -196,7 +195,6 @@ public void testCannotAllocateDueToLackOfDiskResources() { ); RoutingAllocation allocation = new RoutingAllocation( new AllocationDeciders(Collections.singleton(decider)), - clusterState.getRoutingNodes(), clusterState, clusterInfo, null, @@ -319,7 +317,6 @@ public void testCanRemainUsesLeastAvailableSpace() { ); RoutingAllocation allocation = new RoutingAllocation( new AllocationDeciders(Collections.singleton(decider)), - clusterState.getRoutingNodes(), clusterState, clusterInfo, null, @@ -397,7 +394,7 @@ public void testShardSizeAndRelocatingSize() { ClusterState clusterState = ClusterState.builder( org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY) ).metadata(metadata).routingTable(routingTableBuilder.build()).build(); - RoutingAllocation allocation = new RoutingAllocation(null, null, clusterState, info, null, 0); + RoutingAllocation allocation = new RoutingAllocation(null, clusterState, info, null, 0); final Index index = new Index("test", "1234"); ShardRouting test_0 = ShardRouting.newUnassigned( @@ -547,7 +544,7 @@ public void testSizeShrinkIndex() { clusterState.getRoutingTable().index("test").shardsWithState(ShardRoutingState.UNASSIGNED) ); - RoutingAllocation allocation = new RoutingAllocation(null, clusterState.getRoutingNodes(), clusterState, info, null, 0); + RoutingAllocation allocation = new RoutingAllocation(null, clusterState, info, null, 0); final Index index = new Index("test", "1234"); ShardRouting test_0 = ShardRouting.newUnassigned( @@ -619,14 +616,7 @@ public void testSizeShrinkIndex() { .build(); allocationService.reroute(clusterState, "foo"); - RoutingAllocation allocationWithMissingSourceIndex = new RoutingAllocation( - null, - clusterStateWithMissingSourceIndex.getRoutingNodes(), - clusterStateWithMissingSourceIndex, - info, - null, - 0 - ); + RoutingAllocation allocationWithMissingSourceIndex = new RoutingAllocation(null, clusterStateWithMissingSourceIndex, info, null, 0); assertEquals(42L, getExpectedShardSize(target, 42L, allocationWithMissingSourceIndex)); assertEquals(42L, getExpectedShardSize(target2, 42L, allocationWithMissingSourceIndex)); } @@ -768,7 +758,6 @@ public void testDecidesYesIfWatermarksIgnored() { ); RoutingAllocation allocation = new RoutingAllocation( new AllocationDeciders(Collections.singleton(decider)), - clusterState.getRoutingNodes(), clusterState, clusterInfo, null, @@ -845,7 +834,6 @@ public void testCannotForceAllocateOver100PercentUsage() { ); RoutingAllocation allocation = new RoutingAllocation( new AllocationDeciders(Collections.singleton(decider)), - clusterState.getRoutingNodes(), clusterState, clusterInfo, null, diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/FilterAllocationDeciderTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/FilterAllocationDeciderTests.java index 81acdbc8d2168..4dec7b24e4645 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/FilterAllocationDeciderTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/FilterAllocationDeciderTests.java @@ -72,7 +72,7 @@ public void testFilterInitialRecovery() { assertNull(routingTable.index("idx").shard(0).shards().get(0).currentNodeId()); // after failing the shard we are unassigned since the node is blacklisted and we can't initialize on the other node - RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state, null, null, 0); + RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state, null, null, 0); allocation.debugDecision(true); Decision.Single decision = (Decision.Single) filterAllocationDecider.canAllocate( routingTable.index("idx").shard(0).primaryShard(), @@ -130,7 +130,7 @@ public void testFilterInitialRecovery() { assertEquals(routingTable.index("idx").shard(0).primaryShard().state(), INITIALIZING); assertEquals(routingTable.index("idx").shard(0).primaryShard().currentNodeId(), "node1"); - allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state, null, null, 0); + allocation = new RoutingAllocation(allocationDeciders, state, null, null, 0); allocation.debugDecision(true); decision = (Decision.Single) filterAllocationDecider.canAllocate( routingTable.index("idx").shard(0).shards().get(0), diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/NodeReplacementAllocationDeciderTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/NodeReplacementAllocationDeciderTests.java index bd22bfe215ff4..1d37e0f9c3572 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/NodeReplacementAllocationDeciderTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/NodeReplacementAllocationDeciderTests.java @@ -85,7 +85,7 @@ public void testNoReplacements() { .nodes(DiscoveryNodes.builder().add(NODE_A).add(NODE_B).add(NODE_C).build()) .build(); - RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state, null, null, 0); + RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state, null, null, 0); DiscoveryNode node = randomFrom(NODE_A, NODE_B, NODE_C); RoutingNode routingNode = new RoutingNode(node.getId(), node, shard); allocation.debugDecision(true); @@ -101,7 +101,7 @@ public void testNoReplacements() { public void testCanForceAllocate() { ClusterState state = prepareState(service.reroute(ClusterState.EMPTY_STATE, "initial state"), NODE_A.getId(), NODE_B.getName()); - RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state, null, null, 0); + RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state, null, null, 0); RoutingNode routingNode = new RoutingNode(NODE_A.getId(), NODE_A, shard); allocation.debugDecision(true); @@ -144,7 +144,7 @@ public void testCanForceAllocate() { public void testCannotRemainOnReplacedNode() { ClusterState state = prepareState(service.reroute(ClusterState.EMPTY_STATE, "initial state"), NODE_A.getId(), NODE_B.getName()); - RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state, null, null, 0); + RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state, null, null, 0); RoutingNode routingNode = new RoutingNode(NODE_A.getId(), NODE_A, shard); allocation.debugDecision(true); @@ -170,7 +170,7 @@ public void testCannotRemainOnReplacedNode() { public void testCanAllocateToNeitherSourceNorTarget() { ClusterState state = prepareState(service.reroute(ClusterState.EMPTY_STATE, "initial state"), NODE_A.getId(), NODE_B.getName()); - RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state, null, null, 0); + RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state, null, null, 0); RoutingNode routingNode = new RoutingNode(NODE_A.getId(), NODE_A, shard); allocation.debugDecision(true); diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/NodeShutdownAllocationDeciderTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/NodeShutdownAllocationDeciderTests.java index 7803bbc8e4279..6c85fe062dfd4 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/NodeShutdownAllocationDeciderTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/NodeShutdownAllocationDeciderTests.java @@ -81,7 +81,7 @@ public void testCanAllocateShardsToRestartingNode() { service.reroute(ClusterState.EMPTY_STATE, "initial state"), SingleNodeShutdownMetadata.Type.RESTART ); - RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state, null, null, 0); + RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state, null, null, 0); RoutingNode routingNode = new RoutingNode(DATA_NODE.getId(), DATA_NODE, shard); allocation.debugDecision(true); @@ -98,7 +98,7 @@ public void testCannotAllocateShardsToRemovingNode() { service.reroute(ClusterState.EMPTY_STATE, "initial state"), randomFrom(SingleNodeShutdownMetadata.Type.REMOVE, SingleNodeShutdownMetadata.Type.REPLACE) ); - RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state, null, null, 0); + RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state, null, null, 0); RoutingNode routingNode = new RoutingNode(DATA_NODE.getId(), DATA_NODE, shard); allocation.debugDecision(true); @@ -112,7 +112,7 @@ public void testShardsCanRemainOnRestartingNode() { service.reroute(ClusterState.EMPTY_STATE, "initial state"), SingleNodeShutdownMetadata.Type.RESTART ); - RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state, null, null, 0); + RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state, null, null, 0); RoutingNode routingNode = new RoutingNode(DATA_NODE.getId(), DATA_NODE, shard); allocation.debugDecision(true); @@ -129,7 +129,7 @@ public void testShardsCannotRemainOnRemovingNode() { service.reroute(ClusterState.EMPTY_STATE, "initial state"), randomFrom(SingleNodeShutdownMetadata.Type.REMOVE, SingleNodeShutdownMetadata.Type.REPLACE) ); - RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state, null, null, 0); + RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state, null, null, 0); RoutingNode routingNode = new RoutingNode(DATA_NODE.getId(), DATA_NODE, shard); allocation.debugDecision(true); @@ -143,7 +143,7 @@ public void testCannotAutoExpandToRestartingNode() { service.reroute(ClusterState.EMPTY_STATE, "initial state"), SingleNodeShutdownMetadata.Type.RESTART ); - RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state, null, null, 0); + RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state, null, null, 0); allocation.debugDecision(true); Decision decision = decider.shouldAutoExpandToNode(indexMetadata, DATA_NODE, allocation); @@ -159,7 +159,7 @@ public void testCannotAutoExpandToRemovingNode() { service.reroute(ClusterState.EMPTY_STATE, "initial state"), randomFrom(SingleNodeShutdownMetadata.Type.REMOVE, SingleNodeShutdownMetadata.Type.REPLACE) ); - RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state, null, null, 0); + RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state, null, null, 0); allocation.debugDecision(true); Decision decision = decider.shouldAutoExpandToNode(indexMetadata, DATA_NODE, allocation); diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/RestoreInProgressAllocationDeciderTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/RestoreInProgressAllocationDeciderTests.java index 7d5458118df7a..5b8f80101163c 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/RestoreInProgressAllocationDeciderTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/RestoreInProgressAllocationDeciderTests.java @@ -202,7 +202,6 @@ private Decision executeAllocation(final ClusterState clusterState, final ShardR final AllocationDecider decider = new RestoreInProgressAllocationDecider(); final RoutingAllocation allocation = new RoutingAllocation( new AllocationDeciders(Collections.singleton(decider)), - clusterState.getRoutingNodes(), clusterState, null, null, diff --git a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderService.java b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderService.java index 03a694511787e..cf4faaee98d30 100644 --- a/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderService.java +++ b/x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderService.java @@ -227,14 +227,7 @@ public static class AllocationState { } public long storagePreventsAllocation() { - RoutingAllocation allocation = new RoutingAllocation( - allocationDeciders, - state.getRoutingNodes(), - state, - info, - shardSizeInfo, - System.nanoTime() - ); + RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state, info, shardSizeInfo, System.nanoTime()); return StreamSupport.stream(state.getRoutingNodes().unassigned().spliterator(), false) .filter(shard -> canAllocate(shard, allocation) == false) .filter(shard -> cannotAllocateDueToStorage(shard, allocation)) @@ -243,14 +236,7 @@ public long storagePreventsAllocation() { } public long storagePreventsRemainOrMove() { - RoutingAllocation allocation = new RoutingAllocation( - allocationDeciders, - state.getRoutingNodes(), - state, - info, - shardSizeInfo, - System.nanoTime() - ); + RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state, info, shardSizeInfo, System.nanoTime()); List candidates = new LinkedList<>(); for (RoutingNode routingNode : state.getRoutingNodes()) { diff --git a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderServiceTests.java b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderServiceTests.java index 6cc2501e3079e..c644cbd656708 100644 --- a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderServiceTests.java +++ b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderServiceTests.java @@ -534,14 +534,7 @@ public boolean canRemainWithNoNodes(ClusterState clusterState, ShardRouting shar Set.of(DiscoveryNodeRole.DATA_WARM_NODE_ROLE) ); - RoutingAllocation allocation = new RoutingAllocation( - allocationDeciders, - clusterState.getRoutingNodes(), - clusterState, - null, - null, - randomLong() - ); + RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, clusterState, null, null, randomLong()); return allocationState.canRemainOnlyHighestTierPreference(shardRouting, allocation); } @@ -646,14 +639,7 @@ private void verifyNeedsWarmTier( Set.of(DiscoveryNodeRole.DATA_WARM_NODE_ROLE) ); - RoutingAllocation allocation = new RoutingAllocation( - allocationDeciders, - clusterState.getRoutingNodes(), - clusterState, - null, - null, - randomLong() - ); + RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, clusterState, null, null, randomLong()); assertThat(allocationState.needsThisTier(shardRouting, allocation), is(expected)); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/AllocationRoutedStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/AllocationRoutedStep.java index 6d099589a03a8..16362c36f8102 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/AllocationRoutedStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/AllocationRoutedStep.java @@ -90,14 +90,7 @@ public Result isConditionMet(Index index, ClusterState clusterState) { static int getPendingAllocations(Index index, AllocationDeciders allocationDeciders, ClusterState clusterState) { // All the allocation attributes are already set so just need to check // if the allocation has happened - RoutingAllocation allocation = new RoutingAllocation( - allocationDeciders, - clusterState.getRoutingNodes(), - clusterState, - null, - null, - System.nanoTime() - ); + RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, clusterState, null, null, System.nanoTime()); int allocationPendingAllShards = 0; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SetSingleNodeAllocateStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SetSingleNodeAllocateStep.java index 8d3b6a5324b43..0bfc3f92d4d4b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SetSingleNodeAllocateStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ilm/SetSingleNodeAllocateStep.java @@ -16,7 +16,6 @@ import org.elasticsearch.cluster.ClusterStateObserver; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.routing.RoutingNode; -import org.elasticsearch.cluster.routing.RoutingNodes; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.allocation.RoutingAllocation; import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders; @@ -80,8 +79,7 @@ public void performAction( new NodeReplacementAllocationDecider() ) ); - final RoutingNodes routingNodes = clusterState.getRoutingNodes(); - RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, routingNodes, clusterState, null, null, System.nanoTime()); + RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, clusterState, null, null, System.nanoTime()); List validNodeIds = new ArrayList<>(); String indexName = indexMetadata.getIndex().getName(); final Map> routingsByShardId = clusterState.getRoutingTable() @@ -90,7 +88,7 @@ public void performAction( .collect(Collectors.groupingBy(ShardRouting::shardId)); if (routingsByShardId.isEmpty() == false) { - for (RoutingNode node : routingNodes) { + for (RoutingNode node : allocation.routingNodes()) { boolean canAllocateOneCopyOfEachShard = routingsByShardId.values() .stream() // For each shard .allMatch( diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierAllocationDeciderTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierAllocationDeciderTests.java index b7dea77029521..2777aeb076897 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierAllocationDeciderTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierAllocationDeciderTests.java @@ -106,7 +106,7 @@ public void testIndexPrefer() { .build() ) .build(); - RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state, null, null, 0); + RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, state, null, null, 0); allocation.debugDecision(true); Decision d; RoutingNode node; @@ -154,7 +154,7 @@ public void testIndexPrefer() { .build() ) .build(); - allocation = new RoutingAllocation(allocationDeciders, state.getRoutingNodes(), state, null, null, 0); + allocation = new RoutingAllocation(allocationDeciders, state, null, null, 0); allocation.debugDecision(true); for (DiscoveryNode n : Arrays.asList(HOT_NODE, WARM_NODE)) { diff --git a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java index 01fba0a336a63..441f967410f87 100644 --- a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java +++ b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java @@ -217,7 +217,6 @@ static ShutdownShardMigrationStatus shardMigrationStatus( // If there's no relocating shards and shards still on this node, we need to figure out why final RoutingAllocation allocation = new RoutingAllocation( allocationDeciders, - currentState.getRoutingNodes(), currentState, clusterInfoService.getClusterInfo(), snapshotsInfoService.snapshotShardSizes(),