|
36 | 36 | import org.elasticsearch.index.shard.ShardId; |
37 | 37 |
|
38 | 38 | import java.util.ArrayList; |
39 | | -import java.util.Arrays; |
40 | 39 | import java.util.HashMap; |
41 | 40 | import java.util.HashSet; |
42 | 41 | import java.util.LinkedList; |
@@ -293,21 +292,23 @@ public DesiredBalance compute( |
293 | 292 | for (MoveAllocationCommand command : commands) { |
294 | 293 | try { |
295 | 294 | final var rerouteExplanation = command.execute(routingAllocation, false); |
296 | | - assert rerouteExplanation.decisions().type() != Decision.Type.NO; |
| 295 | + assert rerouteExplanation.decisions().type() != Decision.Type.NO : "should have thrown for NO decision"; |
297 | 296 | if (rerouteExplanation.decisions().type() != Decision.Type.NO) { |
298 | 297 | final ShardRouting[] initializingShards = routingNodes.node( |
299 | 298 | routingAllocation.nodes().resolveNode(command.toNode()).getId() |
300 | 299 | ).initializing(); |
301 | 300 | assert initializingShards.length == 1 |
302 | | - && routingAllocation.nodes() |
303 | | - .resolveNode(command.fromNode()) |
304 | | - .getId() |
305 | | - .equals(initializingShards[0].relocatingNodeId()) |
306 | | - : "expect one relocating shard, but got : " + List.of(initializingShards); |
307 | | - Arrays.stream(initializingShards).forEach(shard -> { |
308 | | - clusterInfoSimulator.simulateShardStarted(shard); |
309 | | - routingNodes.startShard(shard, changes, 0L); |
310 | | - }); |
| 301 | + : "expect exactly one relocating shard, but got: " + List.of(initializingShards); |
| 302 | + final var initializingShard = initializingShards[0]; |
| 303 | + assert routingAllocation.nodes() |
| 304 | + .resolveNode(command.fromNode()) |
| 305 | + .getId() |
| 306 | + .equals(initializingShard.relocatingNodeId()) |
| 307 | + : initializingShard |
| 308 | + + " has unexpected relocation source node, expect node " |
| 309 | + + routingAllocation.nodes().resolveNode(command.fromNode()); |
| 310 | + clusterInfoSimulator.simulateShardStarted(initializingShard); |
| 311 | + routingNodes.startShard(initializingShard, changes, 0L); |
311 | 312 | } |
312 | 313 | } catch (RuntimeException e) { |
313 | 314 | logger.debug( |
|
0 commit comments