@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.| Modifier and Type | Class and Description |
|---|---|
static interface |
BulkOperator.Builder
Builder interface for all immutable implementations to mask the
use of the generated sources to avoid confusion.
|
| 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 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()
@Value.Default public BulkLifecycle lifecycle()
BulkLifecycle instance.@Nullable public abstract Integer interval()
@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 BulkOperator.Builder builder(@Nonnull org.elasticsearch.client.RestClient client)
client - the RestClient to use to talk to Elasticsearch.BulkOperator.Builder instance from the provided client.Copyright © 2017. All rights reserved.