@Value.Immutable(copy=false) public abstract class BulkOperator extends Object implements Closeable
BulkOperator controls batch execution against Elasticsearch via
the Elasticsearch Bulk API. It contains control over concurrency, throttling
and lifecycle monitoring.
To create an operator, you must go via the BulkOperator.Builder in
order to get sane defaults and validation.| Constructor and Description |
|---|
BulkOperator() |
| Modifier and Type | Method and Description |
|---|---|
BulkOperator |
add(BulkAction... bulkActions)
Adds new
BulkAction instances to the internal
bulk operation builder. |
static io.whitfin.elasticsearch.bulk.BulkOperator.Builder |
builder(org.elasticsearch.client.RestClient client)
Returns a builder in order to create an operator.
|
abstract org.elasticsearch.client.RestClient |
client()
The client instance for Elasticsearch communication.
|
void |
close()
Closes all internal resources and sets the operator as closed.
|
int |
concurrency()
The concurrency level for this operator instance.
|
void |
flush()
Flushes all actions contained in the current buffer.
|
abstract Integer |
interval()
The interval on which this operator will flush.
|
BulkLifecycle |
lifecycle()
The lifecycle hooks being fired by this operator.
|
abstract Integer |
maxActions()
The maximum number of actions to buffer before flushing.
|
public abstract org.elasticsearch.client.RestClient client()
RestClient instance.@Value.Default public int concurrency()
The concurrency can not be set below 1, the builder will enforce this lower bound.
@Value.Default public BulkLifecycle lifecycle()
Rather than making use of null values, a NoopLifecycle
will be used to represent an unset lifecycle.
BulkLifecycle instance.@Nullable public abstract Integer interval()
Setting this to null will disable scheduling flushing.
@Nullable public abstract Integer maxActions()
public BulkOperator add(BulkAction... bulkActions)
BulkAction instances to the internal
bulk operation builder.bulkActions - the BulkAction instances to add.BulkOperator instance for chaining.public void flush()
This uses a synchronized lock to ensure that the internal operation is reset without causing any potential race conditions.
The internal semaphore is used to control concurrency, by waiting for an acquired lock before executing the request internally.
public void close()
We don't close the provided RestClient instance as
it was provided and may be used in other classes.
close in interface Closeableclose in interface AutoCloseablepublic static io.whitfin.elasticsearch.bulk.BulkOperator.Builder builder(@Nonnull org.elasticsearch.client.RestClient client)
client - the RestClient to use to talk to Elasticsearch.Builder instance from the provided client.Copyright © 2017. All rights reserved.