Class OperationSubmitter
- java.lang.Object
-
- org.hibernate.search.engine.backend.work.execution.OperationSubmitter
-
@Incubating public abstract class OperationSubmitter extends Object
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
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static OperationSubmitterblocking()When using this submitter, dding a new element will block the thread when the underlying queue is aBlockingQueueand it is at its maximum capacity, until some elements are removed from the queuestatic OperationSubmitteroffloading(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 OperationSubmitterrejecting()When using this submitter adding a new element will cause aRejectedExecutionExceptionwhen the underlying queue is aBlockingQueueand 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> voidsubmitToQueue(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 Detail
-
submitToQueue
public abstract <T> void submitToQueue(BlockingQueue<? super T> queue, T element, Consumer<? super T> blockingRetryProducer, BiConsumer<? super T,Throwable> asyncFailureReporter) throws InterruptedException
Defines how an element will be submitted to the queue. Depending on the implementation might throwRejectedExecutionExceptionor 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 InterruptedException
Defines how an element will be submitted to the executor. Depending on the implementation might throwRejectedExecutionExceptionor offload the submit operation to an offload executor.- Throws:
InterruptedException
-
blocking
public static OperationSubmitter blocking()
When using this submitter, dding a new element will block the thread when the underlying queue is aBlockingQueueand it is at its maximum capacity, until some elements are removed from the queue
-
rejecting
public static OperationSubmitter rejecting()
When using this submitter adding a new element will cause aRejectedExecutionExceptionwhen the underlying queue is aBlockingQueueand it is at its maximum capacity.
-
offloading
public static 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. 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
-
-