@Internal public class BarrierBuffer extends Object implements CheckpointBarrierHandler
CheckpointBarrierHandler
that blocks inputs with barriers until
all inputs have received the barrier for a given checkpoint.
To avoid back-pressuring the input streams (which may cause distributed deadlocks), the BarrierBuffer continues receiving buffers from the blocked channels and stores them internally until the blocks are released.
Constructor and Description |
---|
BarrierBuffer(InputGate inputGate,
IOManager ioManager) |
Modifier and Type | Method and Description |
---|---|
void |
cleanup()
Cleans up all internally held resources.
|
long |
getCurrentCheckpointId()
Gets the ID defining the current pending, or just completed, checkpoint.
|
BufferOrEvent |
getNextNonBlocked()
Returns the next
BufferOrEvent that the operator may consume. |
boolean |
isEmpty()
Checks if the barrier handler has buffered any data internally.
|
void |
registerCheckpointEventHandler(EventListener<CheckpointBarrier> checkpointHandler)
Registers the given event handler to be notified on successful checkpoints.
|
String |
toString() |
public BarrierBuffer(InputGate inputGate, IOManager ioManager) throws IOException
inputGate
- The input gate to draw the buffers and events from.ioManager
- The I/O manager that gives access to the temp directories.IOException
- Thrown, when the spilling to temp files cannot be initialized.public BufferOrEvent getNextNonBlocked() throws IOException, InterruptedException
CheckpointBarrierHandler
BufferOrEvent
that the operator may consume.
This call blocks until the next BufferOrEvent is available, ir until the stream
has been determined to be finished.getNextNonBlocked
in interface CheckpointBarrierHandler
null
, if the stream is finished.IOException
- Thrown, if the network or local disk I/O fails.InterruptedException
- Thrown, if the thread is interrupted while blocking during
waiting for the next BufferOrEvent to become available.public void registerCheckpointEventHandler(EventListener<CheckpointBarrier> checkpointHandler)
CheckpointBarrierHandler
registerCheckpointEventHandler
in interface CheckpointBarrierHandler
checkpointHandler
- The handler to register.public boolean isEmpty()
CheckpointBarrierHandler
isEmpty
in interface CheckpointBarrierHandler
public void cleanup() throws IOException
CheckpointBarrierHandler
cleanup
in interface CheckpointBarrierHandler
IOException
- Thrown, if the cleanup of I/O resources failed.public long getCurrentCheckpointId()
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.