Class BulkIndexComputation

  • All Implemented Interfaces:
    org.elasticsearch.action.bulk.BulkProcessor.Listener, Computation

    public class BulkIndexComputation
    extends AbstractComputation
    implements org.elasticsearch.action.bulk.BulkProcessor.Listener
    A computation that submits elasticsearch requests using the bulk API.

    Note that the retry policy is handled by the elasticsearch bulk processor.

    Since:
    10.3
    • Field Detail

      • esBulkSize

        protected final int esBulkSize
      • esBulkActions

        protected final int esBulkActions
      • flushIntervalMs

        protected final int flushIntervalMs
      • bulkProcessor

        protected org.elasticsearch.action.bulk.BulkProcessor bulkProcessor
      • updates

        protected boolean updates
      • continueOnFailure

        protected boolean continueOnFailure
      • abort

        protected volatile boolean abort
    • Constructor Detail

      • BulkIndexComputation

        public BulkIndexComputation​(int esBulkSize,
                                    int esBulkActions,
                                    int flushInterval)
    • Method Detail

      • init

        public void init​(ComputationContext context)
        Description copied from interface: Computation
        Called when the framework has registered the computation successfully. Gives users a first opportunity to schedule timer callbacks and produce records. This method can be called multiple times.
        Specified by:
        init in interface Computation
        Overrides:
        init in class AbstractComputation
        Parameters:
        context - The computation context object provided by the system.
      • processRecord

        public void processRecord​(ComputationContext context,
                                  String inputStream,
                                  Record record)
        Description copied from interface: Computation
        Process an incoming record on one of the computation's input streams.
        Specified by:
        processRecord in interface Computation
        Parameters:
        context - The computation context object provided by the system.
        inputStream - Name of the input stream that provides the record.
        record - The record.
      • destroy

        public void destroy()
        Description copied from interface: Computation
        Called when the framework is ready to shutdown the computation. Gives users a chance to perform some cleanup before the process is killed.
        Specified by:
        destroy in interface Computation
      • getESClient

        protected ESClient getESClient()
      • decodeRequest

        protected org.elasticsearch.action.bulk.BulkRequest decodeRequest​(DataBucket bucket)
      • beforeBulk

        public void beforeBulk​(long executionId,
                               org.elasticsearch.action.bulk.BulkRequest request)
        Specified by:
        beforeBulk in interface org.elasticsearch.action.bulk.BulkProcessor.Listener
      • afterBulk

        public void afterBulk​(long executionId,
                              org.elasticsearch.action.bulk.BulkRequest request,
                              org.elasticsearch.action.bulk.BulkResponse response)
        Specified by:
        afterBulk in interface org.elasticsearch.action.bulk.BulkProcessor.Listener
      • afterBulk

        public void afterBulk​(long executionId,
                              org.elasticsearch.action.bulk.BulkRequest request,
                              Throwable failure)
        Specified by:
        afterBulk in interface org.elasticsearch.action.bulk.BulkProcessor.Listener