Package org.nuxeo.elasticsearch.bulk
Class BulkIndexComputation
- java.lang.Object
-
- org.nuxeo.lib.stream.computation.AbstractComputation
-
- org.nuxeo.elasticsearch.bulk.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 Summary
Fields Modifier and Type Field Description protected boolean
abort
protected org.elasticsearch.action.bulk.BulkProcessor
bulkProcessor
protected Codec<DataBucket>
codec
protected boolean
continueOnFailure
protected int
esBulkActions
protected int
esBulkSize
protected int
flushIntervalMs
static String
NAME
protected boolean
updates
-
Fields 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 Constructor Description BulkIndexComputation(int esBulkSize, int esBulkActions, int flushInterval)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterBulk(long executionId, org.elasticsearch.action.bulk.BulkRequest request, Throwable failure)
void
afterBulk(long executionId, org.elasticsearch.action.bulk.BulkRequest request, org.elasticsearch.action.bulk.BulkResponse response)
void
beforeBulk(long executionId, org.elasticsearch.action.bulk.BulkRequest request)
protected org.elasticsearch.action.bulk.BulkRequest
decodeRequest(DataBucket bucket)
void
destroy()
Called when the framework is ready to shutdown the computation.protected ESClient
getESClient()
void
init(ComputationContext context)
Called when the framework has registered the computation successfully.void
processRecord(ComputationContext context, String inputStream, Record record)
Process an incoming record on one of the computation's input streams.void
processTimer(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, processRetry
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.lib.stream.computation.Computation
signalStop
-
-
-
-
Field Detail
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
esBulkSize
protected final int esBulkSize
-
esBulkActions
protected final int esBulkActions
-
flushIntervalMs
protected final int flushIntervalMs
-
bulkProcessor
protected org.elasticsearch.action.bulk.BulkProcessor bulkProcessor
-
codec
protected Codec<DataBucket> codec
-
updates
protected boolean updates
-
continueOnFailure
protected boolean continueOnFailure
-
abort
protected volatile boolean abort
-
-
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 interfaceComputation
- Overrides:
init
in classAbstractComputation
- Parameters:
context
- The computation context object provided by the system.
-
processTimer
public void processTimer(ComputationContext context, String key, long timestamp)
Description copied from interface:Computation
Process a timer callback previously set viaComputationContext.setTimer(String, long)
.- Specified by:
processTimer
in interfaceComputation
- Overrides:
processTimer
in 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
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 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: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 interfaceComputation
-
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 interfaceorg.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 interfaceorg.elasticsearch.action.bulk.BulkProcessor.Listener
-
afterBulk
public void afterBulk(long executionId, org.elasticsearch.action.bulk.BulkRequest request, Throwable failure)
- Specified by:
afterBulk
in interfaceorg.elasticsearch.action.bulk.BulkProcessor.Listener
-
-