public class BulkProcessor extends Object implements Closeable
In order to create a new bulk processor, use the BulkProcessor.Builder
.
Modifier and Type | Class and Description |
---|---|
static class |
BulkProcessor.Builder
A builder used to create a build an instance of a bulk processor.
|
static interface |
BulkProcessor.Listener
A listener for the execution.
|
Modifier and Type | Method and Description |
---|---|
BulkProcessor |
add(ActionRequest request)
Adds either a delete or an index request.
|
BulkProcessor |
add(ActionRequest request,
Object payload) |
BulkProcessor |
add(BytesReference data,
String defaultIndex,
String defaultType) |
BulkProcessor |
add(BytesReference data,
String defaultIndex,
String defaultType,
Object payload) |
BulkProcessor |
add(DeleteRequest request)
Adds an
DeleteRequest to the list of actions to execute. |
BulkProcessor |
add(IndexRequest request)
Adds an
IndexRequest to the list of actions to execute. |
boolean |
awaitClose(long timeout,
TimeUnit unit)
Closes the processor.
|
static BulkProcessor.Builder |
builder(Client client,
BulkProcessor.Listener listener) |
void |
close()
Closes the processor.
|
protected void |
ensureOpen() |
void |
flush()
Flush pending delete or index requests.
|
public static BulkProcessor.Builder builder(Client client, BulkProcessor.Listener listener)
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public boolean awaitClose(long timeout, TimeUnit unit) throws InterruptedException
true
immediately.
If concurrent requests are enabled, waits for up to the specified timeout for all bulk requests to complete then returns true
,
If the specified waiting time elapses before all bulk requests complete, false
is returned.timeout
- The maximum time to wait for the bulk requests to completeunit
- The time unit of the timeout
argumenttrue
if all bulk requests completed and false
if the waiting time elapsed before all the bulk requests completedInterruptedException
- If the current thread is interruptedpublic BulkProcessor add(IndexRequest request)
IndexRequest
to the list of actions to execute. Follows the same behavior of IndexRequest
(for example, if no id is provided, one will be generated, or usage of the create flag).public BulkProcessor add(DeleteRequest request)
DeleteRequest
to the list of actions to execute.public BulkProcessor add(ActionRequest request)
public BulkProcessor add(ActionRequest request, @Nullable Object payload)
protected void ensureOpen()
public BulkProcessor add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType) throws Exception
Exception
public BulkProcessor add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, @Nullable Object payload) throws Exception
Exception
public void flush()
Copyright © 2009–2016. All rights reserved.