|
24 | 24 | import org.elasticsearch.index.shard.ShardId; |
25 | 25 | import org.elasticsearch.search.SearchHits; |
26 | 26 | import org.elasticsearch.search.SearchPhaseResult; |
27 | | -import org.elasticsearch.search.SearchShardTarget; |
28 | 27 | import org.elasticsearch.search.internal.AliasFilter; |
29 | 28 | import org.elasticsearch.search.internal.ShardSearchContextId; |
30 | 29 | import org.elasticsearch.test.ESTestCase; |
@@ -119,16 +118,15 @@ public void testSkipSearchShards() throws InterruptedException { |
119 | 118 | @Override |
120 | 119 | protected void executePhaseOnShard( |
121 | 120 | SearchShardIterator shardIt, |
122 | | - SearchShardTarget shard, |
| 121 | + Transport.Connection connection, |
123 | 122 | SearchActionListener<TestSearchPhaseResult> listener |
124 | 123 | ) { |
125 | | - seenShard.computeIfAbsent(shard.getShardId(), (i) -> { |
| 124 | + seenShard.computeIfAbsent(shardIt.shardId(), (i) -> { |
126 | 125 | numRequests.incrementAndGet(); // only count this once per replica |
127 | 126 | return Boolean.TRUE; |
128 | 127 | }); |
129 | 128 |
|
130 | 129 | new Thread(() -> { |
131 | | - Transport.Connection connection = getConnection(null, shard.getNodeId()); |
132 | 130 | TestSearchPhaseResult testSearchPhaseResult = new TestSearchPhaseResult( |
133 | 131 | new ShardSearchContextId(UUIDs.randomBase64UUID(), contextIdGenerator.incrementAndGet()), |
134 | 132 | connection.getNode() |
@@ -227,23 +225,22 @@ public void testLimitConcurrentShardRequests() throws InterruptedException { |
227 | 225 | @Override |
228 | 226 | protected void executePhaseOnShard( |
229 | 227 | SearchShardIterator shardIt, |
230 | | - SearchShardTarget shard, |
| 228 | + Transport.Connection connection, |
231 | 229 | SearchActionListener<TestSearchPhaseResult> listener |
232 | 230 | ) { |
233 | | - seenShard.computeIfAbsent(shard.getShardId(), (i) -> { |
| 231 | + seenShard.computeIfAbsent(shardIt.shardId(), (i) -> { |
234 | 232 | numRequests.incrementAndGet(); // only count this once per shard copy |
235 | 233 | return Boolean.TRUE; |
236 | 234 | }); |
237 | 235 |
|
238 | 236 | new Thread(() -> { |
239 | 237 | safeAwait(awaitInitialRequests); |
240 | | - Transport.Connection connection = getConnection(null, shard.getNodeId()); |
241 | 238 | TestSearchPhaseResult testSearchPhaseResult = new TestSearchPhaseResult( |
242 | 239 | new ShardSearchContextId(UUIDs.randomBase64UUID(), contextIdGenerator.incrementAndGet()), |
243 | 240 | connection.getNode() |
244 | 241 | ); |
245 | 242 | try { |
246 | | - if (shardFailures[shard.getShardId().id()]) { |
| 243 | + if (shardFailures[shardIt.shardId().id()]) { |
247 | 244 | listener.onFailure(new RuntimeException()); |
248 | 245 | } else { |
249 | 246 | listener.onResponse(testSearchPhaseResult); |
@@ -340,11 +337,11 @@ public void sendFreeContext(Transport.Connection connection, ShardSearchContextI |
340 | 337 | @Override |
341 | 338 | protected void executePhaseOnShard( |
342 | 339 | SearchShardIterator shardIt, |
343 | | - SearchShardTarget shard, |
| 340 | + Transport.Connection connection, |
344 | 341 | SearchActionListener<TestSearchPhaseResult> listener |
345 | 342 | ) { |
346 | | - assertTrue("shard: " + shard.getShardId() + " has been queried twice", testResponse.queried.add(shard.getShardId())); |
347 | | - Transport.Connection connection = getConnection(null, shard.getNodeId()); |
| 343 | + var shardId = shardIt.shardId(); |
| 344 | + assertTrue("shard: " + shardId + " has been queried twice", testResponse.queried.add(shardId)); |
348 | 345 | TestSearchPhaseResult testSearchPhaseResult = new TestSearchPhaseResult( |
349 | 346 | new ShardSearchContextId(UUIDs.randomBase64UUID(), contextIdGenerator.incrementAndGet()), |
350 | 347 | connection.getNode() |
@@ -464,13 +461,13 @@ public void sendFreeContext(Transport.Connection connection, ShardSearchContextI |
464 | 461 | @Override |
465 | 462 | protected void executePhaseOnShard( |
466 | 463 | SearchShardIterator shardIt, |
467 | | - SearchShardTarget shard, |
| 464 | + Transport.Connection connection, |
468 | 465 | SearchActionListener<TestSearchPhaseResult> listener |
469 | 466 | ) { |
470 | | - assertTrue("shard: " + shard.getShardId() + " has been queried twice", response.queried.add(shard.getShardId())); |
471 | | - Transport.Connection connection = getConnection(null, shard.getNodeId()); |
| 467 | + var shardId = shardIt.shardId(); |
| 468 | + assertTrue("shard: " + shardId + " has been queried twice", response.queried.add(shardId)); |
472 | 469 | final TestSearchPhaseResult testSearchPhaseResult; |
473 | | - if (shard.getShardId().id() == 0) { |
| 470 | + if (shardId.id() == 0) { |
474 | 471 | testSearchPhaseResult = new TestSearchPhaseResult(null, connection.getNode()); |
475 | 472 | } else { |
476 | 473 | testSearchPhaseResult = new TestSearchPhaseResult( |
@@ -573,15 +570,14 @@ public void testAllowPartialResults() throws InterruptedException { |
573 | 570 | @Override |
574 | 571 | protected void executePhaseOnShard( |
575 | 572 | SearchShardIterator shardIt, |
576 | | - SearchShardTarget shard, |
| 573 | + Transport.Connection connection, |
577 | 574 | SearchActionListener<TestSearchPhaseResult> listener |
578 | 575 | ) { |
579 | | - seenShard.computeIfAbsent(shard.getShardId(), (i) -> { |
| 576 | + seenShard.computeIfAbsent(shardIt.shardId(), (i) -> { |
580 | 577 | numRequests.incrementAndGet(); // only count this once per shard copy |
581 | 578 | return Boolean.TRUE; |
582 | 579 | }); |
583 | 580 | new Thread(() -> { |
584 | | - Transport.Connection connection = getConnection(null, shard.getNodeId()); |
585 | 581 | TestSearchPhaseResult testSearchPhaseResult = new TestSearchPhaseResult( |
586 | 582 | new ShardSearchContextId(UUIDs.randomBase64UUID(), contextIdGenerator.incrementAndGet()), |
587 | 583 | connection.getNode() |
@@ -673,7 +669,7 @@ public void testSkipUnavailableSearchShards() throws InterruptedException { |
673 | 669 | @Override |
674 | 670 | protected void executePhaseOnShard( |
675 | 671 | SearchShardIterator shardIt, |
676 | | - SearchShardTarget shard, |
| 672 | + Transport.Connection connection, |
677 | 673 | SearchActionListener<TestSearchPhaseResult> listener |
678 | 674 | ) { |
679 | 675 | assert false : "Expected to skip all shards"; |
|
0 commit comments