public class DocumentQueueDrainer extends ExecutorProxy
executor| Constructor and Description |
|---|
DocumentQueueDrainer(DocumentQueue queue,
java.util.function.Consumer<TikaDocument> consumer)
Create a new drainer that will drain documents from the given queue to the given consumer on a single thread.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearLatch()
Clear the latch.
|
void |
clearPollTimeout()
Causes the consumer to wait until a new file is available, without any timeout.
|
DocumentQueueDrainer |
configure(Options<String> options) |
Future<Long> |
drain()
Drain the queue in a non-blocking way until the draining thread is interrupted, the task is cancelled or the
given timeout is reached (if any is set).
|
Future<Long> |
drain(TikaDocument poison)
Like
drain() except that draining will stop when the given poison pill is returned from the queue. |
SealableLatch |
getLatch()
Get the poll latch.
|
java.time.Duration |
getPollTimeout()
Get the poll timeout.
|
void |
setLatch(SealableLatch latch)
If given, the latch should be used to signal that the queue should be polled.
|
void |
setPollTimeout(java.time.Duration pollTimeout)
Set the amount of time to wait until an item becomes available.
|
awaitTermination, shutdown, shutdownNowpublic DocumentQueueDrainer(DocumentQueue queue, java.util.function.Consumer<TikaDocument> consumer)
queue - the queue to drainconsumer - must accept documents drained from the queuepublic DocumentQueueDrainer configure(Options<String> options)
public void setPollTimeout(java.time.Duration pollTimeout)
pollTimeout - the amount of time to waitpublic void clearPollTimeout()
setPollTimeout(Duration pollTimeout) with a value of 0.public java.time.Duration getPollTimeout()
public void setLatch(SealableLatch latch)
latch - the latch to await before pollingpublic SealableLatch getLatch()
public void clearLatch()
public Future<Long> drain()
Future representing the draining task that returns the number of documents consumed as a
result.public Future<Long> drain(TikaDocument poison)
drain() except that draining will stop when the given poison pill is returned from the queue.poison - the poison pill to test for when pollingdrain()Copyright © 2018 The International Consortium of Investigative Journalists. All rights reserved.