You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: kafka-streams-AssignedStreamsTasks.adoc
+19-3
Original file line number
Diff line number
Diff line change
@@ -89,16 +89,32 @@ In the end, `maybeCommit` gives the number of running stream tasks that <<kafka-
89
89
90
90
NOTE: `maybeCommit` is used exclusively when `TaskManager` is requested to link:kafka-streams-internals-TaskManager.adoc#maybeCommitActiveTasks[maybeCommitActiveTasks].
91
91
92
-
=== [[punctuate]] `punctuate` Method
92
+
=== [[punctuate]] Punctuating Running Stream Tasks (by Stream and System Time) -- `punctuate` Method
93
93
94
94
[source, java]
95
95
----
96
96
int punctuate()
97
97
----
98
98
99
-
`punctuate`...FIXME
99
+
`punctuate` walks over the <<kafka-streams-internals-AssignedTasks.adoc#running, running stream tasks>> and requests them to <<kafka-streams-internals-StreamTask.adoc#maybePunctuateStreamTime, maybePunctuateStreamTime>> and <<kafka-streams-internals-StreamTask.adoc#maybePunctuateSystemTime, maybePunctuateSystemTime>>.
100
100
101
-
NOTE: `punctuate` is used exclusively when `TaskManager` is requested to link:kafka-streams-internals-TaskManager.adoc#punctuate[punctuate].
101
+
For every positive response (<<kafka-streams-internals-StreamTask.adoc#maybePunctuateStreamTime, maybePunctuateStreamTime>> or <<kafka-streams-internals-StreamTask.adoc#maybePunctuateSystemTime, maybePunctuateSystemTime>> returned `true`), an internal `punctuated` counter is incremented.
102
+
103
+
In the end, `punctuate` returns the internal `punctuated` counter.
104
+
105
+
In case of a `TaskMigratedException`, `punctuate` prints out the following INFO message to the logs, <<kafka-streams-internals-AssignedTasks.adoc#closeZombieTask, closes the zombie task>>, and possibly removes the task from the <<kafka-streams-internals-AssignedTasks.adoc#running, running stream tasks>>.
106
+
107
+
```
108
+
Failed to punctuate stream task [taskId] since it got migrated to another thread already. Closing it as zombie before triggering a new rebalance.
109
+
```
110
+
111
+
In case of a `KafkaException`, `punctuate` prints out the following ERROR message to the logs and re-throws the exception.
112
+
113
+
```
114
+
Failed to punctuate stream task [taskId] due to the following error:
115
+
```
116
+
117
+
NOTE: `punctuate` is used exclusively when `TaskManager` is requested to <<kafka-streams-internals-TaskManager.adoc#punctuate, punctuate stream tasks>>.
`PunctuationQueue` manages a https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/PriorityQueue.html[java.util.PriorityQueue] of <<kafka-streams-PunctuationSchedule.adoc#, PunctuationSchedules>>.
4
5
5
-
=== [[mayPunctuate]] `mayPunctuate` Method
6
+
=== [[mayPunctuate]] Attempting to Punctuate --`mayPunctuate` Method
6
7
7
8
[source, java]
8
9
----
9
10
boolean mayPunctuate(
10
-
final long timestamp,
11
-
final PunctuationType type,
12
-
final ProcessorNodePunctuator processorNodePunctuator)
11
+
long timestamp,
12
+
PunctuationType type,
13
+
ProcessorNodePunctuator processorNodePunctuator)
13
14
----
14
15
15
-
`mayPunctuate`...FIXME
16
+
`mayPunctuate` takes the <<kafka-streams-PunctuationSchedule.adoc#, PunctuationSchedules>> off the <<pq, PriorityQueue>> for which the <<kafka-streams-Stamped.adoc#timestamp, timestamp>> is older (_smaller_) than the given `timestamp`.
16
17
17
-
NOTE: `mayPunctuate` is used when `StreamTask` is requested to link:kafka-streams-internals-StreamTask.adoc#maybePunctuateStreamTime[maybePunctuateStreamTime] and link:kafka-streams-internals-StreamTask.adoc#maybePunctuateSystemTime[maybePunctuateSystemTime].
18
+
`mayPunctuate` then requests the given <<kafka-streams-ProcessorNodePunctuator.adoc#, ProcessorNodePunctuator>> to <<kafka-streams-ProcessorNodePunctuator.adoc#punctuate, punctuate>> (with the <<kafka-streams-PunctuationSchedule.adoc#node, node>> and the <<kafka-streams-PunctuationSchedule.adoc#punctuator, punctuator>> of every `PunctuationSchedule`, the given `timestamp` and the `PunctuationType`).
19
+
20
+
In the end, `mayPunctuate` returns whether a `PunctuationSchedule` was punctuated (`true`) or not (`false`).
21
+
22
+
NOTE: `mayPunctuate` is used when `StreamTask` is requested to attempt to punctuate by <<kafka-streams-internals-StreamTask.adoc#maybePunctuateStreamTime, stream>> and <<kafka-streams-internals-StreamTask.adoc#maybePunctuateSystemTime, system>> time.
=== [[maybePunctuateStreamTime]] Attempting to Punctuate by Stream Time -- `maybePunctuateStreamTime` Method
294
294
295
295
[source, java]
296
296
----
297
297
boolean maybePunctuateStreamTime()
298
298
----
299
299
300
-
`maybePunctuateStreamTime`...FIXME
300
+
`maybePunctuateStreamTime` requests the <<partitionGroup, PartitionGroup>> for the <<kafka-streams-internals-PartitionGroup.adoc#timestamp, minimum partition timestamp across all partitions>>.
301
301
302
-
NOTE: `maybePunctuateStreamTime` is used exclusively when `AssignedStreamsTasks` is requested to link:kafka-streams-AssignedStreamsTasks.adoc#punctuate[punctuate].
302
+
`maybePunctuateStreamTime` requests the <<streamTimePunctuationQueue, stream-time PunctuationQueue>> to <<kafka-streams-PunctuationQueue.adoc#mayPunctuate, mayPunctuate>> with the minimum timestamp.
In the end, `maybePunctuateStreamTime` returns whatever the stream-time `PunctuationQueue` returned.
305
+
306
+
If the minimum timestamp is <<kafka-streams-internals-RecordQueue.adoc#UNKNOWN, UNKNOWN>>, `maybePunctuateStreamTime` returns `false`.
307
+
308
+
NOTE: `maybePunctuateStreamTime` is used exclusively when `AssignedStreamsTasks` is requested to <<kafka-streams-AssignedStreamsTasks.adoc#punctuate, punctuate running stream tasks>>.
309
+
310
+
=== [[maybePunctuateSystemTime]] Attempting to Punctuate by System Time -- `maybePunctuateSystemTime` Method
NOTE: `maybePunctuateSystemTime` is used exclusively when `AssignedStreamsTasks` is requested to link:kafka-streams-AssignedStreamsTasks.adoc#punctuate[punctuate].
319
+
NOTE: `maybePunctuateSystemTime` is used exclusively when `AssignedStreamsTasks` is requested to <<kafka-streams-AssignedStreamsTasks.adoc#punctuate, punctuate running stream tasks>>.
Copy file name to clipboardexpand all lines: kafka-streams-internals-StreamThread.adoc
+20-12
Original file line number
Diff line number
Diff line change
@@ -520,17 +520,6 @@ In the end, `create` creates a <<creating-instance, StreamThread>>.
520
520
521
521
NOTE: `create` is used exclusively when `KafkaStreams` is <<kafka-streams-KafkaStreams.adoc#, created>>.
522
522
523
-
=== [[punctuate]] `punctuate` Internal Method
524
-
525
-
[source, java]
526
-
----
527
-
void punctuate()
528
-
----
529
-
530
-
`punctuate`...FIXME
531
-
532
-
NOTE: `punctuate` is used when `StreamThread` is requested to <<run, start>> (and <<runOnce, polls records once>> and <<processAndMaybeCommit, processes records (with optional commit)>>).
@@ -577,6 +566,21 @@ Committed all active tasks [activeTaskIds] and standby tasks [standbyTaskIds] in
577
566
578
567
NOTE: `maybeCommit` is used when `StreamThread` is requested to <<runOnce, poll records once>> (directly and indirectly in <<processAndMaybeCommit, processAndMaybeCommit>>).
`maybePunctuate` requests the <<taskManager, TaskManager>> to <<kafka-streams-internals-TaskManager.adoc#punctuate, punctuate>>.
577
+
578
+
If the punctuate returned a positive number (greater than `0`), `maybePunctuate` <<advanceNowAndComputeLatency, advanceNowAndComputeLatency>> and requests the <<streamsMetrics, StreamsMetricsThreadImpl>> for the <<kafka-streams-StreamsMetricsThreadImpl.adoc#punctuateTimeSensor, punctuateTimeSensor>> to record the punctuate time.
579
+
580
+
In the end, `maybePunctuate` returns whether the punctuate returned a positive number (`true`) or not (`false`).
581
+
582
+
NOTE: `maybePunctuate` is used exclusively when `StreamThread` is requested to <<runOnce, poll records once and add them to active stream tasks>>.
a| [[lastCommitMs]] Time of the last <<maybeCommit, commit>>
592
596
593
597
| numIterations
594
-
a| [[numIterations]]
598
+
a| [[numIterations]] Number of iterations when the <<taskManager, TaskManager>> is requested to <<kafka-streams-internals-TaskManager.adoc#process, process records by running stream tasks (one record per task)>> while `StreamThread` is <<runOnce, polling records once and adding them to active stream tasks>>
595
599
596
600
Default: `1`
597
601
602
+
Incremented while <<runOnce, polling records once and adding them to active stream tasks>>
603
+
604
+
Decremented by half while <<runOnce, polling records once and adding them to active stream tasks>>
605
+
598
606
| processStandbyRecords
599
607
a| [[processStandbyRecords]] Flag to control whether to <<maybeUpdateStandbyTasks, maybeUpdateStandbyTasks>> after <<maybeCommit, maybeCommit>> was executed
Copy file name to clipboardexpand all lines: kafka-streams-internals-TaskManager.adoc
+3-3
Original file line number
Diff line number
Diff line change
@@ -358,16 +358,16 @@ In the end, `maybeCommitActiveTasks` gives the number of running stream tasks th
358
358
359
359
NOTE: `maybeCommitActiveTasks` is used exclusively when `StreamThread` is requested to link:kafka-streams-internals-StreamThread.adoc#processAndMaybeCommit[processAndMaybeCommit].
`punctuate` simply requests <<active, AssignedStreamsTasks>> to link:kafka-streams-AssignedStreamsTasks.adoc#punctuate[punctuate].
368
+
`punctuate` simply requests the <<active, AssignedStreamsTasks>> to <<kafka-streams-AssignedStreamsTasks.adoc#punctuate, punctuate>>.
369
369
370
-
NOTE: `punctuate` is used exclusively when `StreamThread` is requested to link:kafka-streams-internals-StreamThread.adoc#punctuate[punctuate].
370
+
NOTE: `punctuate` is used exclusively when `StreamThread` is requested to <<kafka-streams-internals-StreamThread.adoc#maybePunctuate, attempt to punctuate>>.
371
371
372
372
=== [[commitAll]] Committing Active and Standby Tasks -- `commitAll` Method
0 commit comments