@Internal public class CheckpointedInputGate extends Object implements AsyncDataInput<BufferOrEvent>
CheckpointedInputGate
uses CheckpointBarrierHandler
to handle incoming
CheckpointBarrier
from the InputGate
.AVAILABLE
Constructor and Description |
---|
CheckpointedInputGate(InputGate inputGate,
BufferStorage bufferStorage,
CheckpointBarrierHandler barrierHandler) |
CheckpointedInputGate(InputGate inputGate,
BufferStorage bufferStorage,
CheckpointBarrierHandler barrierHandler,
int channelIndexOffset)
Creates a new checkpoint stream aligner.
|
CheckpointedInputGate(InputGate inputGate,
BufferStorage bufferStorage,
String taskName,
AbstractInvokable toNotifyOnCheckpoint) |
Modifier and Type | Method and Description |
---|---|
void |
cleanup()
Cleans up all internally held resources.
|
long |
getAlignmentDurationNanos()
Gets the time that the latest alignment took, in nanoseconds.
|
long |
getLatestCheckpointId()
Gets the ID defining the current pending, or just completed, checkpoint.
|
int |
getNumberOfInputChannels() |
CompletableFuture<?> |
isAvailable()
Check if this instance is available for further processing.
|
boolean |
isEmpty()
Checks if the barrier handler has buffered any data internally.
|
boolean |
isFinished() |
Optional<BufferOrEvent> |
pollNext()
Poll the next element.
|
String |
toString() |
public CheckpointedInputGate(InputGate inputGate, BufferStorage bufferStorage, String taskName, @Nullable AbstractInvokable toNotifyOnCheckpoint)
public CheckpointedInputGate(InputGate inputGate, BufferStorage bufferStorage, CheckpointBarrierHandler barrierHandler)
public CheckpointedInputGate(InputGate inputGate, BufferStorage bufferStorage, CheckpointBarrierHandler barrierHandler, int channelIndexOffset)
The aligner will allow only alignments that buffer up to the given number of bytes. When that number is exceeded, it will stop the alignment and notify the task that the checkpoint has been cancelled.
inputGate
- The input gate to draw the buffers and events from.bufferStorage
- The storage to hold the buffers and events for blocked channels.barrierHandler
- Handler that controls which channels are blocked.channelIndexOffset
- Optional offset added to channelIndex returned from the inputGate
before passing it to the barrierHandler.public CompletableFuture<?> isAvailable()
AvailabilityListener
When hot looping to avoid volatile access in CompletableFuture.isDone()
user of
this method should do the following check:
AvailabilityListener input = ...;
if (input.isAvailable() == AvailabilityListener.AVAILABLE || input.isAvailable().isDone()) {
// do something;
}
isAvailable
in interface AvailabilityListener
AvailabilityListener.AVAILABLE
should be returned. Previously returned
not completed futures should become completed once there is more input available or if
the input AvailabilityListener.isFinished()
.public Optional<BufferOrEvent> pollNext() throws Exception
AsyncDataInput
pollNext
in interface AsyncDataInput<BufferOrEvent>
Optional.empty()
will be returned if there is no data to return or
if AvailabilityListener.isFinished()
returns true. Otherwise Optional.of(element)
.Exception
public boolean isEmpty()
True
, if no data is buffered internally, false
otherwise.public boolean isFinished()
isFinished
in interface AvailabilityListener
public void cleanup() throws IOException
IOException
- Thrown if the cleanup of I/O resources failed.public long getLatestCheckpointId()
public long getAlignmentDurationNanos()
public int getNumberOfInputChannels()
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.