Package org.apache.flink.runtime.io
Interface PullingAsyncDataInput<T>
-
- All Superinterfaces:
AvailabilityProvider
- All Known Implementing Classes:
CheckpointedInputGate
,IndexedInputGate
,InputGate
,InputGateWithMetrics
,SingleInputGate
,UnionInputGate
@Internal public interface PullingAsyncDataInput<T> extends AvailabilityProvider
Interface defining couple of essential methods for asynchronous and non blocking data polling.For the most efficient usage, user of this class is supposed to call
pollNext()
until it returns that no more elements are available. If that happens, he should check if inputisFinished()
. If not, he should wait forAvailabilityProvider.getAvailableFuture()
CompletableFuture
to be completed. For example:AsyncDataInput<T> input = ...; while (!input.isFinished()) { Optional<T> next; while (true) { next = input.pollNext(); if (!next.isPresent()) { break; } // do something with next } input.getAvailableFuture().get(); }
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
PullingAsyncDataInput.EndOfDataStatus
Status for describing if we have reached the end of data.-
Nested classes/interfaces inherited from interface org.apache.flink.runtime.io.AvailabilityProvider
AvailabilityProvider.AvailabilityHelper
-
-
Field Summary
-
Fields inherited from interface org.apache.flink.runtime.io.AvailabilityProvider
AVAILABLE
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description PullingAsyncDataInput.EndOfDataStatus
hasReceivedEndOfData()
Tells if we consumed all available data.boolean
isFinished()
Optional<T>
pollNext()
Poll the next element.-
Methods inherited from interface org.apache.flink.runtime.io.AvailabilityProvider
getAvailableFuture, isApproximatelyAvailable, isAvailable
-
-
-
-
Method Detail
-
pollNext
Optional<T> pollNext() throws Exception
Poll the next element. This method should be non blocking.- Returns:
Optional.empty()
will be returned if there is no data to return or ifisFinished()
returns true. OtherwiseOptional.of(element)
.- Throws:
Exception
-
isFinished
boolean isFinished()
- Returns:
- true if is finished and for example end of input was reached, false otherwise.
-
hasReceivedEndOfData
PullingAsyncDataInput.EndOfDataStatus hasReceivedEndOfData()
Tells if we consumed all available data.Moreover it tells us the reason why there is no more data incoming. If any of the upstream subtasks finished because of the stop-with-savepoint --no-drain, we should not drain the input. See also
StopMode
.
-
-