Packages

c

net.snowflake.spark.snowflake.s3upload

ExecutorServiceResultsHandler

class ExecutorServiceResultsHandler[V] extends Iterable[V]

Wrapper around an ExecutorService that allows you to easily submit Callables, get results via iteration, and handle failure quickly. When a submitted callable throws an exception in its thread this will result in a RuntimeException when iterating over results. Typical usage is as follows:

  • Create an ExecutorService and pass it to the constructor.
  • Create Callables and ensure that they respond to interruption, e.g. regularly call:
    
        if (Thread.currentThread().isInterrupted()) {
            throw new RuntimeException("The thread was interrupted, likely indicating failure in a sibling thread.");
        }
    
  • Pass the callables to the submit() method.
  • Call finishedSubmitting().
  • Iterate over this object (e.g. with a foreach loop) to get results from the callables. Each iteration will block waiting for the next result. If one of the callables throws an unhandled exception or the thread is interrupted during iteration then ExecutorService#shutdownNow() will be called resulting in all still running callables being interrupted, and a RuntimeException will be thrown

You can also call abort() to shut down the threads yourself.

Linear Supertypes
Iterable[V], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ExecutorServiceResultsHandler
  2. Iterable
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ExecutorServiceResultsHandler(executorService: ExecutorService)

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def abort(): Unit
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def awaitCompletion(): Unit

    Convenience method to wait for the callables to finish for when you don't care about the results.

  7. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  8. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. def finishedSubmitting(): Unit
  12. def forEach(arg0: Consumer[_ >: V]): Unit
    Definition Classes
    Iterable
  13. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  14. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  15. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  16. def iterator(): Iterator[V]
    Definition Classes
    ExecutorServiceResultsHandler → Iterable
  17. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  18. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  19. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  20. def spliterator(): Spliterator[V]
    Definition Classes
    Iterable
  21. def submit(task: Callable[V]): Unit
  22. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  23. def toString(): String
    Definition Classes
    AnyRef → Any
  24. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )

Inherited from Iterable[V]

Inherited from AnyRef

Inherited from Any

Ungrouped