dawidwys commented on a change in pull request #18665: URL: https://github.com/apache/flink/pull/18665#discussion_r802645032
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/source/coordinator/SourceCoordinator.java ########## @@ -101,16 +115,71 @@ Licensed to the Apache Software Foundation (ASF) under one public SourceCoordinator( String operatorName, - ExecutorService coordinatorExecutor, + ScheduledExecutorService coordinatorExecutor, Source<?, SplitT, EnumChkT> source, SourceCoordinatorContext<SplitT> context, CoordinatorStore coordinatorStore) { + this( + operatorName, + coordinatorExecutor, + source, + context, + coordinatorStore, + WATERMARK_ALIGNMENT_DISABLED); + } + + public SourceCoordinator( + String operatorName, + ScheduledExecutorService coordinatorExecutor, + Source<?, SplitT, EnumChkT> source, + SourceCoordinatorContext<SplitT> context, + CoordinatorStore coordinatorStore, + WatermarkAlignmentParams watermarkAlignmentParams) { this.operatorName = operatorName; this.coordinatorExecutor = coordinatorExecutor; this.source = source; this.enumCheckpointSerializer = source.getEnumeratorCheckpointSerializer(); this.context = context; this.coordinatorStore = coordinatorStore; + this.watermarkAlignmentParams = watermarkAlignmentParams; + + if (watermarkAlignmentParams.isEnabled()) { + coordinatorStore.putIfAbsent( + watermarkAlignmentParams.watermarkGroup, new WatermarkAggregator<>()); + coordinatorExecutor.scheduleAtFixedRate( + this::announceCombinedWatermark, + watermarkAlignmentParams.updateInterval, + watermarkAlignmentParams.updateInterval, + TimeUnit.MILLISECONDS); + } + } + + @VisibleForTesting + void announceCombinedWatermark() { + checkState(watermarkAlignmentParams != WATERMARK_ALIGNMENT_DISABLED); + + Watermark globalCombinedWatermark = + coordinatorStore.apply( + watermarkAlignmentParams.watermarkGroup, + (value) -> { + WatermarkAggregator aggregator = (WatermarkAggregator) value; + return new Watermark( + aggregator.getAggregatedWatermark().getTimestamp()); + }); + + // TODO: check if min actually changed Review comment: Yep ;) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org