Package org.apache.druid.frame.processor
Class FrameProcessorExecutor
java.lang.Object
org.apache.druid.frame.processor.FrameProcessorExecutor
Manages execution of
FrameProcessor in an ExecutorService.
If you want single threaded execution, use Execs.singleThreaded(). It is not a good idea to use this with a
same-thread executor like Execs.directExecutor(), because it will lead to deep call stacks.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasExecutor(String cancellationId) Returns anExecutorthat executes using the same underlying service, and that is also connected to cancellation throughcancel(String).voidDeregisters a cancellationId and cancels any currently-running processors associated with that cancellationId.voidregisterCancellationId(String cancellationId) Registers a cancellationId, so it can be provided torunFully(org.apache.druid.frame.processor.FrameProcessor<T>, java.lang.String)orrunAllFully(org.apache.druid.frame.processor.manager.ProcessorManager<T, ? extends R>, int, org.apache.druid.frame.processor.Bouncer, java.lang.String).<T,R> com.google.common.util.concurrent.ListenableFuture<R> runAllFully(ProcessorManager<T, ? extends R> processorManager, int maxOutstandingProcessors, Bouncer bouncer, String cancellationId) Runs a sequence of processors and returns a future that resolves when execution is complete.<T> com.google.common.util.concurrent.ListenableFuture<T>runFully(FrameProcessor<T> processor, String cancellationId) Runs a processor until it is done, and returns a future that resolves when execution is complete.voidShuts down the underlying executor service immediately.
-
Constructor Details
-
FrameProcessorExecutor
-
-
Method Details
-
runFully
public <T> com.google.common.util.concurrent.ListenableFuture<T> runFully(FrameProcessor<T> processor, @Nullable String cancellationId) Runs a processor until it is done, and returns a future that resolves when execution is complete. If "cancellationId" is provided, it must have previously been registered withregisterCancellationId(java.lang.String). Then, it can be used with thecancel(String)method to cancel all processors with that same cancellationId. -
runAllFully
public <T,R> com.google.common.util.concurrent.ListenableFuture<R> runAllFully(ProcessorManager<T, ? extends R> processorManager, int maxOutstandingProcessors, Bouncer bouncer, @Nullable String cancellationId) Runs a sequence of processors and returns a future that resolves when execution is complete. Returns a value accumulated using the providedaccumulateFn.- Parameters:
processorManager- processors to runmaxOutstandingProcessors- maximum number of processors to run at oncebouncer- additional limiter on outstanding processors, beyond maxOutstandingProcessors. Useful when there is some finite resource being shared against multiple different calls to this method.cancellationId- optional cancellation id forrunFully(org.apache.druid.frame.processor.FrameProcessor<T>, java.lang.String).
-
registerCancellationId
Registers a cancellationId, so it can be provided torunFully(org.apache.druid.frame.processor.FrameProcessor<T>, java.lang.String)orrunAllFully(org.apache.druid.frame.processor.manager.ProcessorManager<T, ? extends R>, int, org.apache.druid.frame.processor.Bouncer, java.lang.String). To avoid the set of active cancellationIds growing without bound, callers must also callcancel(String)on the same cancellationId when done using it. -
cancel
Deregisters a cancellationId and cancels any currently-running processors associated with that cancellationId. Waits for any canceled processors to exit before returning. -
asExecutor
Returns anExecutorthat executes using the same underlying service, and that is also connected to cancellation throughcancel(String).- Parameters:
cancellationId- cancellation ID for the executor
-
shutdownNow
public void shutdownNow()Shuts down the underlying executor service immediately.
-