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 cancelling any pending
jobs.Constructor and Description |
---|
ComplexFutureAction(scala.Function1<JobSubmitter,scala.concurrent.Future<T>> run) |
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancels the execution of this action.
|
boolean |
isCancelled()
Returns whether the action has been cancelled.
|
boolean |
isCompleted()
Returns whether the action has already been completed with a value or an exception.
|
scala.collection.Seq<Object> |
jobIds()
Returns the job IDs run by the underlying async operation.
|
<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.
|
<S> scala.concurrent.Future<S> |
transform(scala.Function1<scala.util.Try<T>,scala.util.Try<S>> f,
scala.concurrent.ExecutionContext e) |
<S> scala.concurrent.Future<S> |
transformWith(scala.Function1<scala.util.Try<T>,scala.concurrent.Future<S>> f,
scala.concurrent.ExecutionContext e) |
scala.Option<scala.util.Try<T>> |
value()
The value of this Future.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
get
$init$, andThen, apply, collect, failed, fallbackTo, filter, find, find, firstCompletedOf, flatMap, flatten, fold, foldLeft, foreach, fromTry, map, mapTo, onFailure, onSuccess, recover, recoverWith, reduce, reduceLeft, sequence, successful, transform, traverse, unit, withFilter, zip, zipWith
public ComplexFutureAction(scala.Function1<JobSubmitter,scala.concurrent.Future<T>> run)
public void cancel()
FutureAction
cancel
in interface FutureAction<T>
public boolean isCancelled()
FutureAction
isCancelled
in interface FutureAction<T>
public boolean isCompleted()
FutureAction
isCompleted
in interface FutureAction<T>
isCompleted
in interface scala.concurrent.Future<T>
public scala.collection.Seq<Object> jobIds()
FutureAction
This returns the current snapshot of the job list. Certain operations may run multiple jobs, so multiple calls to this method may return different lists.
jobIds
in interface FutureAction<T>
public <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>
func
- (undocumented)executor
- (undocumented)public ComplexFutureAction<T> ready(scala.concurrent.duration.Duration atMost, scala.concurrent.CanAwait permit) throws InterruptedException, java.util.concurrent.TimeoutException
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 durationpermit
- (undocumented)InterruptedException
java.util.concurrent.TimeoutException
public T result(scala.concurrent.duration.Duration atMost, scala.concurrent.CanAwait permit) throws Exception
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 durationpermit
- (undocumented)Exception
- exception during action executionpublic <S> scala.concurrent.Future<S> transform(scala.Function1<scala.util.Try<T>,scala.util.Try<S>> f, scala.concurrent.ExecutionContext e)
transform
in interface scala.concurrent.Future<T>
public <S> scala.concurrent.Future<S> transformWith(scala.Function1<scala.util.Try<T>,scala.concurrent.Future<S>> f, scala.concurrent.ExecutionContext e)
transformWith
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>