public class ComplexFutureAction<T> extends Object implements FutureAction<T>
FutureAction
for actions that could trigger multiple Spark jobs. Examples include take,
takeSample. Cancellation works by setting the cancelled flag to true and interrupting the
action thread if it is being blocked by a job.Constructor and Description |
---|
ComplexFutureAction() |
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancels the execution of this action.
|
boolean |
cancelled()
Returns whether the promise has been cancelled.
|
boolean |
isCompleted()
Returns whether the action has already been completed with a value or an exception.
|
<U> void |
onComplete(scala.Function1<scala.util.Try<T>,U> func,
scala.concurrent.ExecutionContext executor)
When this action is completed, either through an exception, or a value, applies the provided
function.
|
ComplexFutureAction<T> |
ready(scala.concurrent.duration.Duration atMost,
scala.concurrent.CanAwait permit)
Blocks until this action completes.
|
T |
result(scala.concurrent.duration.Duration atMost,
scala.concurrent.CanAwait permit)
Awaits and returns the result (of type T) of this action.
|
ComplexFutureAction<T> |
run(scala.Function0<T> func,
scala.concurrent.ExecutionContext executor)
Executes some action enclosed in the closure.
|
<T,U,R> void |
runJob(RDD<T> rdd,
scala.Function1<scala.collection.Iterator<T>,U> processPartition,
scala.collection.Seq<Object> partitions,
scala.Function2<Object,U,scala.runtime.BoxedUnit> resultHandler,
scala.Function0<R> resultFunc)
Runs a Spark job.
|
scala.Option<scala.util.Try<T>> |
value()
The value of this Future.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
get
public void cancel()
FutureAction
cancel
in interface FutureAction<T>
public ComplexFutureAction<T> run(scala.Function0<T> func, scala.concurrent.ExecutionContext executor)
public <T,U,R> void runJob(RDD<T> rdd, scala.Function1<scala.collection.Iterator<T>,U> processPartition, scala.collection.Seq<Object> partitions, scala.Function2<Object,U,scala.runtime.BoxedUnit> resultHandler, scala.Function0<R> resultFunc)
public boolean cancelled()
public ComplexFutureAction<T> ready(scala.concurrent.duration.Duration atMost, scala.concurrent.CanAwait permit)
FutureAction
ready
in interface FutureAction<T>
ready
in interface scala.concurrent.Awaitable<T>
atMost
- maximum wait time, which may be negative (no waiting is done), Duration.Inf
for unbounded waiting, or a finite positive durationpublic T result(scala.concurrent.duration.Duration atMost, scala.concurrent.CanAwait permit)
FutureAction
result
in interface FutureAction<T>
result
in interface scala.concurrent.Awaitable<T>
atMost
- maximum wait time, which may be negative (no waiting is done), Duration.Inf
for unbounded waiting, or a finite positive durationpublic <U> void onComplete(scala.Function1<scala.util.Try<T>,U> func, scala.concurrent.ExecutionContext executor)
FutureAction
onComplete
in interface FutureAction<T>
onComplete
in interface scala.concurrent.Future<T>
public boolean isCompleted()
FutureAction
isCompleted
in interface FutureAction<T>
isCompleted
in interface scala.concurrent.Future<T>
public scala.Option<scala.util.Try<T>> value()
FutureAction
If the future is not completed the returned value will be None. If the future is completed the value will be Some(Success(t)) if it contains a valid result, or Some(Failure(error)) if it contains an exception.
value
in interface FutureAction<T>
value
in interface scala.concurrent.Future<T>