public class BulkIndexer
extends java.lang.Object
implements java.io.Closeable
| Constructor and Description |
|---|
BulkIndexer(BulkIndexerConfig config,
RefreshLimiter refreshLimiter) |
| Modifier and Type | Method and Description |
|---|---|
java.util.Optional<java.util.concurrent.Future<java.lang.Boolean>> |
add(BulkOperation op,
boolean forceFlush)
Adds a bulk operation to the pending batch, and returns a
ListenableFuture that
represents that bulk update (or null if a batch operation is not available yet). |
void |
close()
Called during shutdown to terminate the scheduled executor thread.
|
void |
delete(java.util.Collection<?> documents)
Deletes a list of documents from their respective Elastic indexes.
|
void |
delete(java.lang.Object document)
Delete specified document from Elastic index.
|
com.google.common.util.concurrent.ListenableFuture<BulkResponse> |
flush()
Flushes any pending bulk operations to Elastic asynchronously, and returns a future that
corresponds to the batch (or null if no batch operation is required).
|
BulkIndexerConfig |
getConfig() |
RefreshLimiter |
getRefreshLimiter() |
BulkIndexerStats |
getStats() |
void |
index(java.util.Collection<?> documents)
Adds a list of documents to the Elastic index without immediate index refresh and optional
flush.
|
void |
index(java.lang.Object document)
Adds a document to the Elastic index.
|
boolean |
isClosed()
Returns true if indexer has closed
|
java.lang.String |
toString() |
public BulkIndexer(BulkIndexerConfig config, RefreshLimiter refreshLimiter)
public java.util.Optional<java.util.concurrent.Future<java.lang.Boolean>> add(BulkOperation op, boolean forceFlush) throws java.util.concurrent.RejectedExecutionException
ListenableFuture that
represents that bulk update (or null if a batch operation is not available yet).op - bulk operationforceFlush - true if flush operation should be forced, even if batch is not fulljava.util.concurrent.RejectedExecutionException - if indexer is closed or background queue is fullpublic void close()
throws BulkIndexerFailed
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableBulkIndexerFailed - if exception occurs while closing indexerpublic void delete(java.util.Collection<?> documents)
throws java.util.concurrent.RejectedExecutionException,
java.io.IOException
documents - list of documents to be removedjava.util.concurrent.RejectedExecutionException - if indexer is closed or background queue is fulljava.io.IOException - if document could not be serializedpublic void delete(java.lang.Object document)
throws java.util.concurrent.RejectedExecutionException,
java.io.IOException
document - document to be deletedjava.util.concurrent.RejectedExecutionException - if indexer is closed or background queue is fulljava.io.IOException - if document could not be serializedpublic com.google.common.util.concurrent.ListenableFuture<BulkResponse> flush() throws java.util.concurrent.RejectedExecutionException
java.util.concurrent.RejectedExecutionException - if indexer is closed (and we have pending operations) or background queue is fullpublic final BulkIndexerConfig getConfig()
public RefreshLimiter getRefreshLimiter()
public BulkIndexerStats getStats()
public void index(java.util.Collection<?> documents)
throws java.util.concurrent.RejectedExecutionException,
java.io.IOException
documents - list of documents to indexjava.util.concurrent.RejectedExecutionException - if indexer is closed or background queue is fulljava.io.IOException - if document could not be serializedpublic void index(java.lang.Object document)
throws java.util.concurrent.RejectedExecutionException,
java.io.IOException
document - document to be indexedjava.util.concurrent.RejectedExecutionException - if indexer is closed or background queue is fulljava.io.IOException - if document could not be serializedpublic boolean isClosed()
public java.lang.String toString()
toString in class java.lang.Object