use of org.apache.flink.runtime.io.network.api.EventAnnouncement 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);
}
use of org.apache.flink.runtime.io.network.api.EventAnnouncement 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();
}
Aggregations