Search in sources :

Example 61 with CheckpointBarrier

use of org.apache.flink.runtime.io.network.api.CheckpointBarrier in project flink by apache.

the class RemoteInputChannel method announce.

private SequenceBuffer announce(SequenceBuffer sequenceBuffer) throws IOException {
    checkState(!sequenceBuffer.buffer.isBuffer(), "Only a CheckpointBarrier can be announced but found %s", sequenceBuffer.buffer);
    checkAnnouncedOnlyOnce(sequenceBuffer);
    AbstractEvent event = EventSerializer.fromBuffer(sequenceBuffer.buffer, getClass().getClassLoader());
    checkState(event instanceof CheckpointBarrier, "Only a CheckpointBarrier can be announced but found %s", sequenceBuffer.buffer);
    CheckpointBarrier barrier = (CheckpointBarrier) event;
    return new SequenceBuffer(EventSerializer.toBuffer(new EventAnnouncement(barrier, sequenceBuffer.sequenceNumber), true), sequenceBuffer.sequenceNumber);
}
Also used : CheckpointBarrier(org.apache.flink.runtime.io.network.api.CheckpointBarrier) EventAnnouncement(org.apache.flink.runtime.io.network.api.EventAnnouncement) AbstractEvent(org.apache.flink.runtime.event.AbstractEvent)

Example 62 with CheckpointBarrier

use of org.apache.flink.runtime.io.network.api.CheckpointBarrier in project flink by apache.

the class ChannelStatePersister method checkForBarrier.

protected OptionalLong checkForBarrier(Buffer buffer) throws IOException {
    AbstractEvent event = parseEvent(buffer);
    if (event instanceof CheckpointBarrier) {
        long barrierId = ((CheckpointBarrier) event).getId();
        long expectedBarrierId = checkpointStatus == CheckpointStatus.COMPLETED ? lastSeenBarrier + 1 : lastSeenBarrier;
        if (barrierId >= expectedBarrierId) {
            logEvent("found barrier", barrierId);
            checkpointStatus = CheckpointStatus.BARRIER_RECEIVED;
            lastSeenBarrier = barrierId;
            return OptionalLong.of(lastSeenBarrier);
        } else {
            logEvent("ignoring barrier", barrierId);
        }
    }
    if (event instanceof EventAnnouncement) {
        // NOTE: only remote channels
        EventAnnouncement announcement = (EventAnnouncement) event;
        if (announcement.getAnnouncedEvent() instanceof CheckpointBarrier) {
            long barrierId = ((CheckpointBarrier) announcement.getAnnouncedEvent()).getId();
            logEvent("found announcement for barrier", barrierId);
            return OptionalLong.of(barrierId);
        }
    }
    return OptionalLong.empty();
}
Also used : CheckpointBarrier(org.apache.flink.runtime.io.network.api.CheckpointBarrier) EventAnnouncement(org.apache.flink.runtime.io.network.api.EventAnnouncement) AbstractEvent(org.apache.flink.runtime.event.AbstractEvent)

Aggregations

CheckpointBarrier (org.apache.flink.runtime.io.network.api.CheckpointBarrier)62 Test (org.junit.Test)43 CheckpointOptions (org.apache.flink.runtime.checkpoint.CheckpointOptions)14 ArrayDeque (java.util.ArrayDeque)8 InputChannelInfo (org.apache.flink.runtime.checkpoint.channel.InputChannelInfo)8 Buffer (org.apache.flink.runtime.io.network.buffer.Buffer)8 ArrayList (java.util.ArrayList)7 CancelCheckpointMarker (org.apache.flink.runtime.io.network.api.CancelCheckpointMarker)7 OperatorID (org.apache.flink.runtime.jobgraph.OperatorID)7 StreamConfig (org.apache.flink.streaming.api.graph.StreamConfig)7 IOException (java.io.IOException)6 AbstractEvent (org.apache.flink.runtime.event.AbstractEvent)6 BufferConsumer (org.apache.flink.runtime.io.network.buffer.BufferConsumer)6 CheckpointStorageLocationReference (org.apache.flink.runtime.state.CheckpointStorageLocationReference)6 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)5 EventAnnouncement (org.apache.flink.runtime.io.network.api.EventAnnouncement)5 InputChannelTestUtils.createSingleInputGate (org.apache.flink.runtime.io.network.partition.InputChannelTestUtils.createSingleInputGate)5 TestInputChannel (org.apache.flink.runtime.io.network.partition.consumer.TestInputChannel)5 ByteBuffer (java.nio.ByteBuffer)4 RecordingChannelStateWriter (org.apache.flink.runtime.checkpoint.channel.RecordingChannelStateWriter)4