Class ExecutorServiceFuturePool

java.lang.Object
org.apache.hadoop.fs.impl.prefetch.ExecutorServiceFuturePool

public class ExecutorServiceFuturePool extends Object
A FuturePool implementation backed by a java.util.concurrent.ExecutorService. If a piece of work has started, it cannot (currently) be cancelled. This class is a simplified version of com.twitter:util-core_2.11 ExecutorServiceFuturePool designed to avoid depending on that Scala library. One problem with using a Scala library is that many downstream projects (eg Apache Spark) use Scala, and they might want to use a different version of Scala from the version that Hadoop chooses to use.
  • Constructor Details

    • ExecutorServiceFuturePool

      public ExecutorServiceFuturePool(ExecutorService executor)
  • Method Details

    • executeFunction

      public Future<Void> executeFunction(Supplier<Void> f)
      Parameters:
      f - function to run in future on executor pool
      Returns:
      future
      Throws:
      RejectedExecutionException - can be thrown
      NullPointerException - if f param is null
    • executeRunnable

      public Future<Void> executeRunnable(Runnable r)
      Parameters:
      r - runnable to run in future on executor pool
      Returns:
      future
      Throws:
      RejectedExecutionException - can be thrown
      NullPointerException - if r param is null
    • shutdown

      public void shutdown(org.slf4j.Logger logger, long timeout, TimeUnit unit)
      Utility to shutdown the ExecutorService used by this class. Will wait up to a certain timeout for the ExecutorService to gracefully shutdown.
      Parameters:
      logger - Logger
      timeout - the maximum time to wait
      unit - the time unit of the timeout argument
    • toString

      public String toString()
      Overrides:
      toString in class Object