7777import java .util .concurrent .Future ;
7878import java .util .concurrent .TimeUnit ;
7979import java .util .concurrent .atomic .AtomicBoolean ;
80- import java .util .function .BiConsumer ;
8180import java .util .function .Function ;
8281
8382import static org .hamcrest .Matchers .containsString ;
@@ -126,7 +125,7 @@ public class TransportBulkActionIngestTests extends ESTestCase {
126125 @ Captor
127126 ArgumentCaptor <TriConsumer <Integer , Exception , IndexDocFailureStoreStatus >> failureHandler ;
128127 @ Captor
129- ArgumentCaptor <BiConsumer < Thread , Exception >> completionHandler ;
128+ ArgumentCaptor <ActionListener < Void >> listener ;
130129 @ Captor
131130 ArgumentCaptor <TransportResponseHandler <BulkResponse >> remoteResponseHandler ;
132131 @ Captor
@@ -424,9 +423,9 @@ public void testIngestLocal() throws Exception {
424423 redirectPredicate .capture (),
425424 redirectHandler .capture (),
426425 failureHandler .capture (),
427- completionHandler .capture ()
426+ listener .capture ()
428427 );
429- completionHandler .getValue ().accept ( null , exception );
428+ listener .getValue ().onFailure ( exception );
430429 assertTrue (failureCalled .get ());
431430
432431 // now check success
@@ -439,7 +438,7 @@ public void testIngestLocal() throws Exception {
439438 assertNull (redirectPredicate .getValue ().apply (WITH_DEFAULT_PIPELINE )); // no redirects for random existing indices
440439 assertNull (redirectPredicate .getValue ().apply ("index" )); // no redirects for non-existent indices with no templates
441440 redirectHandler .getValue ().apply (2 , WITH_FAILURE_STORE_ENABLED + "-1" , exception ); // exception and redirect for request 3 (slot 2)
442- completionHandler .getValue ().accept ( DUMMY_WRITE_THREAD , null ); // all ingestion completed
441+ listener .getValue ().onResponse ( null ); // all ingestion completed
443442 assertTrue (action .isExecuted );
444443 assertFalse (responseCalled .get ()); // listener would only be called by real index action, not our mocked one
445444 verifyNoMoreInteractions (transportService );
@@ -474,14 +473,14 @@ public void testSingleItemBulkActionIngestLocal() throws Exception {
474473 any (),
475474 any (),
476475 failureHandler .capture (),
477- completionHandler .capture ()
476+ listener .capture ()
478477 );
479- completionHandler .getValue ().accept ( null , exception );
478+ listener .getValue ().onFailure ( exception );
480479 assertTrue (failureCalled .get ());
481480
482481 // now check success
483482 indexRequest .setPipeline (IngestService .NOOP_PIPELINE_NAME ); // this is done by the real pipeline execution service when processing
484- completionHandler .getValue ().accept ( DUMMY_WRITE_THREAD , null );
483+ listener .getValue ().onResponse ( null );
485484 assertTrue (action .isExecuted );
486485 assertFalse (responseCalled .get ()); // listener would only be called by real index action, not our mocked one
487486 verifyNoMoreInteractions (transportService );
@@ -522,17 +521,17 @@ public void testIngestSystemLocal() throws Exception {
522521 any (),
523522 any (),
524523 failureHandler .capture (),
525- completionHandler .capture ()
524+ listener .capture ()
526525 );
527- completionHandler .getValue ().accept ( null , exception );
526+ listener .getValue ().onFailure ( exception );
528527 assertTrue (failureCalled .get ());
529528
530529 // now check success
531530 Iterator <DocWriteRequest <?>> req = bulkDocsItr .getValue ().iterator ();
532531 // have an exception for our one index request
533532 failureHandler .getValue ().apply (0 , exception , IndexDocFailureStoreStatus .NOT_APPLICABLE_OR_UNKNOWN );
534533 indexRequest2 .setPipeline (IngestService .NOOP_PIPELINE_NAME ); // this is done by the real pipeline execution service when processing
535- completionHandler .getValue ().accept ( DUMMY_WRITE_THREAD , null );
534+ listener .getValue ().onResponse ( null );
536535 assertTrue (action .isExecuted );
537536 assertFalse (responseCalled .get ()); // listener would only be called by real index action, not our mocked one
538537 verifyNoMoreInteractions (transportService );
@@ -682,19 +681,19 @@ private void validatePipelineWithBulkUpsert(@Nullable String indexRequestIndexNa
682681 any (),
683682 any (),
684683 failureHandler .capture (),
685- completionHandler .capture ()
684+ listener .capture ()
686685 );
687686 assertEquals (indexRequest1 .getPipeline (), "default_pipeline" );
688687 assertEquals (indexRequest2 .getPipeline (), "default_pipeline" );
689688 assertEquals (indexRequest3 .getPipeline (), "default_pipeline" );
690- completionHandler .getValue ().accept ( null , exception );
689+ listener .getValue ().onFailure ( exception );
691690 assertTrue (failureCalled .get ());
692691
693692 // now check success of the transport bulk action
694693 indexRequest1 .setPipeline (IngestService .NOOP_PIPELINE_NAME ); // this is done by the real pipeline execution service when processing
695694 indexRequest2 .setPipeline (IngestService .NOOP_PIPELINE_NAME ); // this is done by the real pipeline execution service when processing
696695 indexRequest3 .setPipeline (IngestService .NOOP_PIPELINE_NAME ); // this is done by the real pipeline execution service when processing
697- completionHandler .getValue ().accept ( DUMMY_WRITE_THREAD , null );
696+ listener .getValue ().onResponse ( null );
698697 assertTrue (action .isExecuted );
699698 assertFalse (responseCalled .get ()); // listener would only be called by real index action, not our mocked one
700699 verifyNoMoreInteractions (transportService );
@@ -732,15 +731,15 @@ public void testDoExecuteCalledTwiceCorrectly() throws Exception {
732731 any (),
733732 any (),
734733 failureHandler .capture (),
735- completionHandler .capture ()
734+ listener .capture ()
736735 );
737- completionHandler .getValue ().accept ( null , exception );
736+ listener .getValue ().onFailure ( exception );
738737 assertFalse (action .indexCreated ); // still no index yet, the ingest node failed.
739738 assertTrue (failureCalled .get ());
740739
741740 // now check success
742741 indexRequest .setPipeline (IngestService .NOOP_PIPELINE_NAME ); // this is done by the real pipeline execution service when processing
743- completionHandler .getValue ().accept ( DUMMY_WRITE_THREAD , null );
742+ listener .getValue ().onResponse ( null );
744743 assertTrue (action .isExecuted );
745744 assertTrue (action .indexCreated ); // now the index is created since we skipped the ingest node path.
746745 assertFalse (responseCalled .get ()); // listener would only be called by real index action, not our mocked one
@@ -825,7 +824,7 @@ public void testFindDefaultPipelineFromTemplateMatch() {
825824 any (),
826825 any (),
827826 failureHandler .capture (),
828- completionHandler .capture ()
827+ listener .capture ()
829828 );
830829 }
831830
@@ -865,7 +864,7 @@ public void testFindDefaultPipelineFromV2TemplateMatch() {
865864 any (),
866865 any (),
867866 failureHandler .capture (),
868- completionHandler .capture ()
867+ listener .capture ()
869868 );
870869 }
871870
@@ -894,10 +893,10 @@ public void testIngestCallbackExceptionHandled() throws Exception {
894893 any (),
895894 any (),
896895 failureHandler .capture (),
897- completionHandler .capture ()
896+ listener .capture ()
898897 );
899898 indexRequest1 .autoGenerateId ();
900- completionHandler .getValue ().accept ( Thread . currentThread (), null );
899+ listener .getValue ().onResponse ( null );
901900
902901 // check failure passed through to the listener
903902 assertFalse (action .isExecuted );
@@ -933,15 +932,15 @@ private void validateDefaultPipeline(IndexRequest indexRequest) {
933932 any (),
934933 any (),
935934 failureHandler .capture (),
936- completionHandler .capture ()
935+ listener .capture ()
937936 );
938937 assertEquals (indexRequest .getPipeline (), "default_pipeline" );
939- completionHandler .getValue ().accept ( null , exception );
938+ listener .getValue ().onFailure ( exception );
940939 assertTrue (failureCalled .get ());
941940
942941 // now check success
943942 indexRequest .setPipeline (IngestService .NOOP_PIPELINE_NAME ); // this is done by the real pipeline execution service when processing
944- completionHandler .getValue ().accept ( DUMMY_WRITE_THREAD , null );
943+ listener .getValue ().onResponse ( null );
945944 assertTrue (action .isExecuted );
946945 assertFalse (responseCalled .get ()); // listener would only be called by real index action, not our mocked one
947946 verifyNoMoreInteractions (transportService );
0 commit comments