use of org.apache.flink.runtime.source.event.ReportedWatermarkEvent in project flink by apache.
the class SourceCoordinator method handleEventFromOperator.
@Override
public void handleEventFromOperator(int subtask, OperatorEvent event) {
runInEventLoop(() -> {
if (event instanceof RequestSplitEvent) {
LOG.info("Source {} received split request from parallel task {}", operatorName, subtask);
enumerator.handleSplitRequest(subtask, ((RequestSplitEvent) event).hostName());
} else if (event instanceof SourceEventWrapper) {
final SourceEvent sourceEvent = ((SourceEventWrapper) event).getSourceEvent();
LOG.debug("Source {} received custom event from parallel task {}: {}", operatorName, subtask, sourceEvent);
enumerator.handleSourceEvent(subtask, sourceEvent);
} else if (event instanceof ReaderRegistrationEvent) {
final ReaderRegistrationEvent registrationEvent = (ReaderRegistrationEvent) event;
LOG.info("Source {} registering reader for parallel task {} @ {}", operatorName, subtask, registrationEvent.location());
handleReaderRegistrationEvent(registrationEvent);
} else if (event instanceof ReportedWatermarkEvent) {
handleReportedWatermark(subtask, new Watermark(((ReportedWatermarkEvent) event).getWatermark()));
} else {
throw new FlinkException("Unrecognized Operator Event: " + event);
}
}, "handling operator event %s from subtask %d", event, subtask);
}
use of org.apache.flink.runtime.source.event.ReportedWatermarkEvent in project flink by apache.
the class SourceCoordinatorAlignmentTest method reportWatermarkEvent.
private void reportWatermarkEvent(SourceCoordinator<?, ?> sourceCoordinator1, int subtask, long watermark) {
sourceCoordinator1.handleEventFromOperator(subtask, new ReportedWatermarkEvent(watermark));
waitForCoordinatorToProcessActions();
sourceCoordinator1.announceCombinedWatermark();
}
use of org.apache.flink.runtime.source.event.ReportedWatermarkEvent in project flink by apache.
the class SourceOperator method emitLatestWatermark.
private void emitLatestWatermark(long time) {
checkState(currentMainOutput != null);
operatorEventGateway.sendEventToCoordinator(new ReportedWatermarkEvent(lastEmittedWatermark));
}
use of org.apache.flink.runtime.source.event.ReportedWatermarkEvent in project flink by apache.
the class SourceOperatorAlignmentTest method assertLatestReportedWatermarkEvent.
private void assertLatestReportedWatermarkEvent(SourceOperatorTestContext context, long expectedWatermark) {
List<OperatorEvent> events = context.getGateway().getEventsSent().stream().filter(event -> event instanceof ReportedWatermarkEvent).collect(Collectors.toList());
assertFalse(events.isEmpty());
assertEquals(new ReportedWatermarkEvent(expectedWatermark), events.get(events.size() - 1));
}
Aggregations