Package org.nuxeo.elasticsearch.bulk
Class BulkIndexComputation
java.lang.Object
org.nuxeo.lib.stream.computation.AbstractComputation
org.nuxeo.elasticsearch.bulk.BulkIndexComputation
- All Implemented Interfaces:
Computation,org.opensearch.action.bulk.BulkProcessor.Listener
public class BulkIndexComputation
extends AbstractComputation
implements org.opensearch.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 Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected org.opensearch.action.bulk.BulkProcessorprotected Codec<DataBucket>protected booleanprotected final intprotected final intprotected final intstatic final Stringprotected booleanFields inherited from class org.nuxeo.lib.stream.computation.AbstractComputation
INPUT_1, INPUT_2, INPUT_3, INPUT_NULL, metadata, OUTPUT_1, OUTPUT_2, OUTPUT_3, OUTPUT_4 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidafterBulk(long executionId, org.opensearch.action.bulk.BulkRequest request, org.opensearch.action.bulk.BulkResponse response) voidbeforeBulk(long executionId, org.opensearch.action.bulk.BulkRequest request) protected org.opensearch.action.bulk.BulkRequestdecodeRequest(DataBucket bucket) voiddestroy()Called when the framework is ready to shutdown the computation.protected ESClientvoidinit(ComputationContext context) Called when the framework has registered the computation successfully.voidprocessRecord(ComputationContext context, String inputStream, Record record) Process an incoming record on one of the computation's input streams.voidprocessTimer(ComputationContext context, String key, long timestamp) Process a timer callback previously set viaComputationContext.setTimer(String, long).Methods inherited from class org.nuxeo.lib.stream.computation.AbstractComputation
metadata, processFailure, processRetryMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.nuxeo.lib.stream.computation.Computation
signalStop
-
Field Details
-
NAME
- See Also:
-
esBulkSize
protected final int esBulkSize -
esBulkActions
protected final int esBulkActions -
flushIntervalMs
protected final int flushIntervalMs -
bulkProcessor
protected org.opensearch.action.bulk.BulkProcessor bulkProcessor -
codec
-
updates
protected boolean updates -
continueOnFailure
protected boolean continueOnFailure -
abort
protected volatile boolean abort
-
-
Constructor Details
-
BulkIndexComputation
public BulkIndexComputation(int esBulkSize, int esBulkActions, int flushInterval)
-
-
Method Details
-
init
Description copied from interface:ComputationCalled 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:
initin interfaceComputation- Overrides:
initin classAbstractComputation- Parameters:
context- The computation context object provided by the system.
-
processTimer
Description copied from interface:ComputationProcess a timer callback previously set viaComputationContext.setTimer(String, long).- Specified by:
processTimerin interfaceComputation- Overrides:
processTimerin classAbstractComputation- Parameters:
context- The computation context object provided by the system.key- The name of the timer.timestamp- The timestamp (in ms) for which the callback was scheduled.
-
processRecord
Description copied from interface:ComputationProcess an incoming record on one of the computation's input streams.- Specified by:
processRecordin interfaceComputation- 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:ComputationCalled when the framework is ready to shutdown the computation. Gives users a chance to perform some cleanup before the process is killed.- Specified by:
destroyin interfaceComputation
-
getESClient
-
decodeRequest
-
beforeBulk
public void beforeBulk(long executionId, org.opensearch.action.bulk.BulkRequest request) - Specified by:
beforeBulkin interfaceorg.opensearch.action.bulk.BulkProcessor.Listener
-
afterBulk
public void afterBulk(long executionId, org.opensearch.action.bulk.BulkRequest request, org.opensearch.action.bulk.BulkResponse response) - Specified by:
afterBulkin interfaceorg.opensearch.action.bulk.BulkProcessor.Listener
-
afterBulk
public void afterBulk(long executionId, org.opensearch.action.bulk.BulkRequest request, Throwable failure) - Specified by:
afterBulkin interfaceorg.opensearch.action.bulk.BulkProcessor.Listener
-