Class FrameProcessorExecutor

java.lang.Object
org.apache.druid.frame.processor.FrameProcessorExecutor

public class FrameProcessorExecutor extends Object
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 Details

    • FrameProcessorExecutor

      public FrameProcessorExecutor(com.google.common.util.concurrent.ListeningExecutorService exec)
  • 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 with registerCancellationId(java.lang.String). Then, it can be used with the cancel(String) method to cancel all processors with that same cancellationId.
    • runAllFully

      public <T, R> com.google.common.util.concurrent.ListenableFuture<R> runAllFully(ProcessorManager<T,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 provided accumulateFn.
      Parameters:
      processorManager - processors to run
      maxOutstandingProcessors - maximum number of processors to run at once
      bouncer - 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 for runFully(org.apache.druid.frame.processor.FrameProcessor<T>, java.lang.String).
    • registerCancellationId

      public void registerCancellationId(String cancellationId)
      Registers a cancellationId, so it can be provided to runFully(org.apache.druid.frame.processor.FrameProcessor<T>, java.lang.String) or runAllFully(org.apache.druid.frame.processor.manager.ProcessorManager<T, R>, int, org.apache.druid.frame.processor.Bouncer, java.lang.String). To avoid the set of active cancellationIds growing without bound, callers must also call cancel(String) on the same cancellationId when done using it.
    • cancel

      public void cancel(String cancellationId)
      Deregisters a cancellationId and cancels any currently-running processors associated with that cancellationId. Waits for any canceled processors to exit before returning.
    • asExecutor

      public Executor asExecutor(@Nullable String cancellationId)
      Returns an Executor that executes using the same underlying service, and that is also connected to cancellation through cancel(String).
      Parameters:
      cancellationId - cancellation ID for the executor
    • shutdownNow

      public void shutdownNow()
      Shuts down the underlying executor service immediately.