49
49
import org .opensearch .core .common .breaker .NoopCircuitBreaker ;
50
50
import org .opensearch .core .index .Index ;
51
51
import org .opensearch .core .index .shard .ShardId ;
52
- import org .opensearch .core .tasks .TaskCancelledException ;
53
52
import org .opensearch .core .tasks .resourcetracker .TaskResourceInfo ;
54
53
import org .opensearch .core .tasks .resourcetracker .TaskResourceUsage ;
55
54
import org .opensearch .index .query .MatchAllQueryBuilder ;
67
66
import org .opensearch .threadpool .TestThreadPool ;
68
67
import org .opensearch .threadpool .ThreadPool ;
69
68
import org .opensearch .transport .Transport ;
70
- import org .opensearch .transport .TransportException ;
71
69
import org .junit .After ;
72
70
import org .junit .Before ;
73
71
@@ -138,7 +136,6 @@ private AbstractSearchAsyncAction<SearchPhaseResult> createAction(
138
136
controlled ,
139
137
false ,
140
138
false ,
141
- false ,
142
139
expected ,
143
140
resourceUsage ,
144
141
new SearchShardIterator (null , null , Collections .emptyList (), null )
@@ -151,7 +148,6 @@ private AbstractSearchAsyncAction<SearchPhaseResult> createAction(
151
148
ActionListener <SearchResponse > listener ,
152
149
final boolean controlled ,
153
150
final boolean failExecutePhaseOnShard ,
154
- final boolean throw4xxExceptionOnShard ,
155
151
final boolean catchExceptionWhenExecutePhaseOnShard ,
156
152
final AtomicLong expected ,
157
153
final TaskResourceUsage resourceUsage ,
@@ -221,11 +217,7 @@ protected void executePhaseOnShard(
221
217
final SearchActionListener <SearchPhaseResult > listener
222
218
) {
223
219
if (failExecutePhaseOnShard ) {
224
- if (throw4xxExceptionOnShard ) {
225
- listener .onFailure (new TransportException (new TaskCancelledException (shardIt .shardId ().toString ())));
226
- } else {
227
- listener .onFailure (new ShardNotFoundException (shardIt .shardId ()));
228
- }
220
+ listener .onFailure (new ShardNotFoundException (shardIt .shardId ()));
229
221
} else {
230
222
if (catchExceptionWhenExecutePhaseOnShard ) {
231
223
try {
@@ -593,7 +585,6 @@ public void onFailure(Exception e) {
593
585
false ,
594
586
true ,
595
587
false ,
596
- false ,
597
588
new AtomicLong (),
598
589
new TaskResourceUsage (randomLong (), randomLong ()),
599
590
shards
@@ -610,62 +601,6 @@ public void onFailure(Exception e) {
610
601
assertThat (searchResponse .getSuccessfulShards (), equalTo (0 ));
611
602
}
612
603
613
- public void testSkipInValidRetryInMultiReplicas () throws InterruptedException {
614
- final Index index = new Index ("test" , UUID .randomUUID ().toString ());
615
- final CountDownLatch latch = new CountDownLatch (1 );
616
- final AtomicBoolean fail = new AtomicBoolean (true );
617
-
618
- List <String > targetNodeIds = List .of ("n1" , "n2" , "n3" );
619
- final SearchShardIterator [] shards = IntStream .range (2 , 4 )
620
- .mapToObj (i -> new SearchShardIterator (null , new ShardId (index , i ), targetNodeIds , null , null , null ))
621
- .toArray (SearchShardIterator []::new );
622
-
623
- SearchRequest searchRequest = new SearchRequest ().allowPartialSearchResults (true );
624
- searchRequest .setMaxConcurrentShardRequests (1 );
625
-
626
- final ArraySearchPhaseResults <SearchPhaseResult > queryResult = new ArraySearchPhaseResults <>(shards .length );
627
- AbstractSearchAsyncAction <SearchPhaseResult > action = createAction (
628
- searchRequest ,
629
- queryResult ,
630
- new ActionListener <SearchResponse >() {
631
- @ Override
632
- public void onResponse (SearchResponse response ) {
633
-
634
- }
635
-
636
- @ Override
637
- public void onFailure (Exception e ) {
638
- if (fail .compareAndExchange (true , false )) {
639
- try {
640
- throw new RuntimeException ("Simulated exception" );
641
- } finally {
642
- executor .submit (() -> latch .countDown ());
643
- }
644
- }
645
- }
646
- },
647
- false ,
648
- true ,
649
- true ,
650
- false ,
651
- new AtomicLong (),
652
- new TaskResourceUsage (randomLong (), randomLong ()),
653
- shards
654
- );
655
- action .run ();
656
- assertTrue (latch .await (1 , TimeUnit .SECONDS ));
657
- InternalSearchResponse internalSearchResponse = InternalSearchResponse .empty ();
658
- SearchResponse searchResponse = action .buildSearchResponse (internalSearchResponse , action .buildShardFailures (), null , null );
659
- assertSame (searchResponse .getAggregations (), internalSearchResponse .aggregations ());
660
- assertSame (searchResponse .getSuggest (), internalSearchResponse .suggest ());
661
- assertSame (searchResponse .getProfileResults (), internalSearchResponse .profile ());
662
- assertSame (searchResponse .getHits (), internalSearchResponse .hits ());
663
- assertThat (searchResponse .getSuccessfulShards (), equalTo (0 ));
664
- for (int i = 0 ; i < shards .length ; i ++) {
665
- assertEquals (targetNodeIds .size () - 1 , shards [i ].remaining ());
666
- }
667
- }
668
-
669
604
public void testOnShardSuccessPhaseDoneFailure () throws InterruptedException {
670
605
final Index index = new Index ("test" , UUID .randomUUID ().toString ());
671
606
final CountDownLatch latch = new CountDownLatch (1 );
@@ -698,7 +633,6 @@ public void onFailure(Exception e) {
698
633
false ,
699
634
false ,
700
635
false ,
701
- false ,
702
636
new AtomicLong (),
703
637
new TaskResourceUsage (randomLong (), randomLong ()),
704
638
shards
@@ -751,7 +685,6 @@ public void onFailure(Exception e) {
751
685
},
752
686
false ,
753
687
false ,
754
- false ,
755
688
catchExceptionWhenExecutePhaseOnShard ,
756
689
new AtomicLong (),
757
690
new TaskResourceUsage (randomLong (), randomLong ()),
0 commit comments