Package org.apache.spark.util
Class SparkThreadUtils
Object
org.apache.spark.util.SparkThreadUtils
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
awaitResult
(scala.concurrent.Awaitable<T> awaitable, scala.concurrent.duration.Duration atMost) Preferred alternative toAwait.result()
.static <T> T
awaitResultNoSparkExceptionConversion
(scala.concurrent.Awaitable<T> awaitable, scala.concurrent.duration.Duration atMost)
-
Constructor Details
-
SparkThreadUtils
public SparkThreadUtils()
-
-
Method Details
-
awaitResult
public static <T> T awaitResult(scala.concurrent.Awaitable<T> awaitable, scala.concurrent.duration.Duration atMost) throws SparkException Preferred alternative toAwait.result()
.This method wraps and re-throws any exceptions thrown by the underlying
Await
call, ensuring that this thread's stack trace appears in logs.In addition, it calls
Awaitable.result
directly to avoid usingForkJoinPool
'sBlockingContext
. Codes running in the user's thread may be in a thread of Scala ForkJoinPool. As concurrent executions in ForkJoinPool may see someThreadLocal
value unexpectedly, this method basically prevents ForkJoinPool from running other tasks in the current waiting thread. In general, we should use this method because many places in Spark useThreadLocal
and it's hard to debug whenThreadLocal
s leak to other tasks.- Parameters:
awaitable
- (undocumented)atMost
- (undocumented)- Returns:
- (undocumented)
- Throws:
SparkException
-
awaitResultNoSparkExceptionConversion
public static <T> T awaitResultNoSparkExceptionConversion(scala.concurrent.Awaitable<T> awaitable, scala.concurrent.duration.Duration atMost)
-