Class TimedCallable<V>

java.lang.Object
org.apache.drill.exec.store.TimedCallable<V>
Type Parameters:
V - The time value that will be returned when the task is executed.
All Implemented Interfaces:
Callable<V>

public abstract class TimedCallable<V> extends Object implements Callable<V>
Allows parallel executions of tasks in a simplified way. Also maintains and reports timings of task completion.

TODO: look at switching to fork join.

  • Constructor Details

    • TimedCallable

      public TimedCallable()
  • Method Details

    • call

      public final V call() throws Exception
      Specified by:
      call in interface Callable<V>
      Throws:
      Exception
    • runInner

      protected abstract V runInner() throws Exception
      Throws:
      Exception
    • run

      public static <V> List<V> run(String activity, org.slf4j.Logger logger, List<TimedCallable<V>> tasks, int parallelism) throws IOException
      Execute the list of runnables with the given parallelization. At end, return values and report completion time stats to provided logger. Each runnable is allowed a certain timeout. If the timeout exceeds, existing/pending tasks will be cancelled and a UserException is thrown.
      Parameters:
      activity - Name of activity for reporting in logger.
      logger - The logger to use to report results.
      tasks - List of callable that should be executed and timed. If this list has one item, task will be completed in-thread. Each callable must handle InterruptedExceptions.
      parallelism - The number of threads that should be run to complete this task.
      Returns:
      The list of outcome objects.
      Throws:
      IOException - All exceptions are coerced to IOException since this was build for storage system tasks initially.