Class OperationSubmitter
java.lang.Object
org.hibernate.search.engine.backend.work.execution.OperationSubmitter
Interface defining how operation should be submitted to the queue or executor.
WARNING: while this type is API, because instances should be manipulated by users, all of its methods are considered SPIs and therefore should never be called directly by users. In short, users are only expected to get instances of this type from an API and pass it to another API.
Currently supported implementations:
-
Method Summary
Modifier and TypeMethodDescriptionstatic OperationSubmitter
blocking()
When using this submitter, dding a new element will block the thread when the underlying queue is aBlockingQueue
and it is at its maximum capacity, until some elements are removed from the queuestatic OperationSubmitter
offloading
(Consumer<Runnable> executor) Creates an operation submitter that would attempt to submit work to a queue, but in case the queue is full it would offload the submitting of the operation to provided executor.static OperationSubmitter
When using this submitter adding a new element will cause aRejectedExecutionException
when the underlying queue is aBlockingQueue
and it is at its maximum capacity.abstract <T extends Runnable>
voidsubmitToExecutor
(SimpleScheduledExecutor executor, T element, Consumer<? super T> blockingRetryProducer, BiConsumer<? super T, Throwable> asyncFailureReporter) Defines how an element will be submitted to the executor.abstract <T> void
submitToQueue
(BlockingQueue<? super T> queue, T element, Consumer<? super T> blockingRetryProducer, BiConsumer<? super T, Throwable> asyncFailureReporter) Defines how an element will be submitted to the queue.
-
Method Details
-
submitToQueue
public abstract <T> void submitToQueue(BlockingQueue<? super T> queue, T element, Consumer<? super T> blockingRetryProducer, BiConsumer<? super T, Throwable> asyncFailureReporter) throws InterruptedExceptionDefines how an element will be submitted to the queue. Depending on the implementation might throwRejectedExecutionException
or offload the submit operation to a provided executor.- Throws:
InterruptedException
-
submitToExecutor
public abstract <T extends Runnable> void submitToExecutor(SimpleScheduledExecutor executor, T element, Consumer<? super T> blockingRetryProducer, BiConsumer<? super T, Throwable> asyncFailureReporter) throws InterruptedExceptionDefines how an element will be submitted to the executor. Depending on the implementation might throwRejectedExecutionException
or offload the submit operation to an offload executor.- Throws:
InterruptedException
-
blocking
When using this submitter, dding a new element will block the thread when the underlying queue is aBlockingQueue
and it is at its maximum capacity, until some elements are removed from the queue -
rejecting
When using this submitter adding a new element will cause aRejectedExecutionException
when the underlying queue is aBlockingQueue
and it is at its maximum capacity. -
offloading
Creates an operation submitter that would attempt to submit work to a queue, but in case the queue is full it would offload the submitting of the operation to provided executor. This would never block the current thread, but the one to which the work is offloaded.- Parameters:
executor
- executor to offload submit operation to if the queue is full
-