|
@@ -35,7 +35,6 @@ import org.elasticsearch.common.settings.ClusterSettings;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
-import java.util.Iterator;
|
|
|
import java.util.Map;
|
|
|
import java.util.function.UnaryOperator;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -955,16 +954,14 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
|
|
|
AllocationCommands commands = new AllocationCommands();
|
|
|
final var unusedNodes = clusterState.nodes().stream().map(DiscoveryNode::getId).collect(Collectors.toSet());
|
|
|
// Cancel all initializing shards
|
|
|
- for (Iterator<ShardRouting> iterator = clusterState.routingTable().allShards().iterator(); iterator.hasNext();) {
|
|
|
- ShardRouting routing = iterator.next();
|
|
|
+ for (ShardRouting routing : clusterState.routingTable().allShardsIterator()) {
|
|
|
unusedNodes.remove(routing.currentNodeId());
|
|
|
if (routing.initializing()) {
|
|
|
commands.add(new CancelAllocationCommand(routing.shardId().getIndexName(), routing.id(), routing.currentNodeId(), false));
|
|
|
}
|
|
|
}
|
|
|
// Move started primary to another node.
|
|
|
- for (Iterator<ShardRouting> iterator = clusterState.routingTable().allShards().iterator(); iterator.hasNext();) {
|
|
|
- ShardRouting routing = iterator.next();
|
|
|
+ for (ShardRouting routing : clusterState.routingTable().allShardsIterator()) {
|
|
|
if (routing.primary()) {
|
|
|
var currentNodeId = routing.currentNodeId();
|
|
|
unusedNodes.remove(currentNodeId);
|