Class AsyncIOProcessor<Item>
java.lang.Object
org.elasticsearch.common.util.concurrent.AsyncIOProcessor<Item>
public abstract class AsyncIOProcessor<Item>
extends java.lang.Object
This async IO processor allows to batch IO operations and have a single writer processing the write operations.
This can be used to ensure that threads can continue with other work while the actual IO operation is still processed
by a single worker. A worker in this context can be any caller of the
put(Object, Consumer)
method since it will
hijack a worker if nobody else is currently processing queued items. If the internal queue has reached it's capacity incoming threads
might be blocked until other items are processed-
Constructor Summary
Constructors Modifier Constructor Description protected
AsyncIOProcessor(org.apache.logging.log4j.Logger logger, int queueSize, ThreadContext threadContext)
-
Method Summary
Modifier and Type Method Description void
put(Item item, java.util.function.Consumer<java.lang.Exception> listener)
Adds the given item to the queue.protected abstract void
write(java.util.List<org.elasticsearch.common.collect.Tuple<Item,java.util.function.Consumer<java.lang.Exception>>> candidates)
Writes or processes the items out or to disk.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
AsyncIOProcessor
protected AsyncIOProcessor(org.apache.logging.log4j.Logger logger, int queueSize, ThreadContext threadContext)
-
-
Method Details
-
put
Adds the given item to the queue. The listener is notified once the item is processed -
write
protected abstract void write(java.util.List<org.elasticsearch.common.collect.Tuple<Item,java.util.function.Consumer<java.lang.Exception>>> candidates) throws java.io.IOExceptionWrites or processes the items out or to disk.- Throws:
java.io.IOException
-