hermanjakobsen commented on code in PR #19937:
URL: https://github.com/apache/kafka/pull/19937#discussion_r2140731755
##########
streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamTaskTest.java:
##########
@@ -1680,6 +1747,35 @@ public void shouldPunctuateOnceSystemTimeAfterGap() {
processorSystemTime.mockProcessor.checkAndClearPunctuateResult(PunctuationType.WALL_CLOCK_TIME,
now + 100, now + 110, now + 122, now + 130, now + 235, now + 240);
}
+ @Test
+ public void
shouldPunctuateUsingAnchoredSystemStartTimeWithStartTimeBeforeNow() {
+ when(stateManager.taskId()).thenReturn(taskId);
+ when(stateManager.taskType()).thenReturn(TaskType.ACTIVE);
+
+ final long now = time.milliseconds();
+ final long testStartTime = now + (10L - (now % 10L)); // Used to
make test deterministic
+ time.setCurrentTimeMs(testStartTime);
+ final MockProcessorNode<Integer, Integer, ?, ?>
anchoredProcessorSystemTime = new
MockProcessorNode<>(Instant.ofEpochMilli(testStartTime - 10), 10L,
PunctuationType.WALL_CLOCK_TIME);
+ task = createStatelessTaskWithAnchoredPunctuation(createConfig("100"),
anchoredProcessorSystemTime);
+ task.initializeIfNeeded();
+ task.completeRestoration(noOpResetter -> { });
+
+ // now is after startTime -> initial punctuation
+ assertTrue(task.canPunctuateSystemTime());
+ assertTrue(task.maybePunctuateSystemTime());
Review Comment:
Note that this contradicts what was agreed upon in the KIP
> If the startTime is defined as a point in time that is before the current
time, the implementation will just skip forward and calculate the next trigger
time.
If we have startTime at t=90, the current time is t=101, and the interval is
10s, the next trigger time will be t=110.
This behaviour is a result of how the first `PunctuationSchedule` is
registered in the `StreamTask` in `schedule()`. Any thoughts on this?
For my use case (i.e. reason I'm implementing this feature), it would be
desirable to have the behaviour following what was stated in the KIP as the
initial punctuation will be out of sync with the desired punctuation times.
However, that would require to add a flag(?) symbolising whether to initially
register the original `PunctuationSchedule` or the `PunctuationSchedule.next()`
(this will solve the KIP behaviour, I think) and thus increasing the scope of
the implementation?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]