@@ -670,12 +670,15 @@ void validatePipeline(Map<DiscoveryNode, IngestInfo> ingestInfos, String pipelin
670
670
}
671
671
672
672
private record IngestPipelinesExecutionResult (boolean success , boolean kept , Exception exception , String failedIndex ) {}
673
+
673
674
private static IngestPipelinesExecutionResult successResult () {
674
675
return new IngestPipelinesExecutionResult (true , true , null , null );
675
676
}
677
+
676
678
private static IngestPipelinesExecutionResult discardResult () {
677
679
return new IngestPipelinesExecutionResult (true , false , null , null );
678
680
}
681
+
679
682
private static IngestPipelinesExecutionResult failAndStoreFor (String index , Exception e ) {
680
683
return new IngestPipelinesExecutionResult (false , true , e , index );
681
684
}
@@ -726,43 +729,40 @@ protected void doRun() {
726
729
final IngestDocument ingestDocument = newIngestDocument (indexRequest , documentParsingObserver );
727
730
// the document listener gives us three-way logic: a document can fail processing (1), or it can
728
731
// be successfully processed. a successfully processed document can be kept (2) or dropped (3).
729
- final ActionListener <IngestPipelinesExecutionResult > documentListener = ActionListener .runAfter (new ActionListener <>() {
730
- @ Override
731
- public void onResponse (IngestPipelinesExecutionResult result ) {
732
- assert result != null ;
733
- if (result .success ) {
734
- if (result .kept == false ) {
735
- onDropped .accept (slot );
732
+ final ActionListener <IngestPipelinesExecutionResult > documentListener = ActionListener .runAfter (
733
+ new ActionListener <>() {
734
+ @ Override
735
+ public void onResponse (IngestPipelinesExecutionResult result ) {
736
+ assert result != null ;
737
+ if (result .success ) {
738
+ if (result .kept == false ) {
739
+ onDropped .accept (slot );
740
+ }
741
+ } else {
742
+ // We were given a failure result in the onResponse method, so we must store the failure
743
+ // Recover the original document state, track a failed ingest, and pass it along
744
+ updateIndexRequestMetadata (indexRequest , ingestDocument .getOriginalMetadata ());
745
+ totalMetrics .ingestFailed ();
746
+ onStoreFailure .apply (slot , result .failedIndex , result .exception );
736
747
}
737
- } else {
738
- // We were given a failure result in the onResponse method, so we must store the failure
739
- // Recover the original document state, track a failed ingest, and pass it along
740
- updateIndexRequestMetadata (indexRequest , ingestDocument .getOriginalMetadata ());
741
- totalMetrics .ingestFailed ();
742
- onStoreFailure .apply (slot , result .failedIndex , result .exception );
743
748
}
744
- }
745
749
746
- @ Override
747
- public void onFailure (Exception e ) {
748
- totalMetrics .ingestFailed ();
749
- onFailure .accept (slot , e );
750
+ @ Override
751
+ public void onFailure (Exception e ) {
752
+ totalMetrics .ingestFailed ();
753
+ onFailure .accept (slot , e );
754
+ }
755
+ },
756
+ () -> {
757
+ // regardless of success or failure, we always stop the ingest "stopwatch" and release the ref to indicate
758
+ // that we're finished with this document
759
+ final long ingestTimeInNanos = System .nanoTime () - startTimeInNanos ;
760
+ totalMetrics .postIngest (ingestTimeInNanos );
761
+ ref .close ();
750
762
}
751
- }, () -> {
752
- // regardless of success or failure, we always stop the ingest "stopwatch" and release the ref to indicate
753
- // that we're finished with this document
754
- final long ingestTimeInNanos = System .nanoTime () - startTimeInNanos ;
755
- totalMetrics .postIngest (ingestTimeInNanos );
756
- ref .close ();
757
- });
758
-
759
- executePipelines (
760
- pipelines ,
761
- indexRequest ,
762
- ingestDocument ,
763
- shouldStoreFailure ,
764
- documentListener
765
763
);
764
+
765
+ executePipelines (pipelines , indexRequest , ingestDocument , shouldStoreFailure , documentListener );
766
766
indexRequest .setPipelinesHaveRun ();
767
767
768
768
assert actionRequest .index () != null ;
0 commit comments