guozhangwang commented on a change in pull request #8964:
URL: https://github.com/apache/kafka/pull/8964#discussion_r460599173
##########
File path:
streams/src/main/java/org/apache/kafka/streams/processor/internals/AbstractTask.java
##########
@@ -49,6 +61,31 @@
this.stateDirectory = stateDirectory;
}
+ protected void initializeCheckpoint() {
+ // we will delete the local checkpoint file after registering the
state stores and loading them into the
+ // state manager, therefore we should initialize the snapshot as empty
to indicate over-write checkpoint needed
+ offsetSnapshotSinceLastFlush = Collections.emptyMap();
+ }
+
+ /**
+ * The following exceptions maybe thrown from the state manager flushing
call
+ *
+ * @throws TaskMigratedException recoverable error sending changelog
records that would cause the task to be removed
+ * @throws StreamsException fatal error when flushing the state store, for
example sending changelog records failed
+ * or flushing state store get IO errors; such
error should cause the thread to die
+ */
+ protected void maybeWriteCheckpoint(final boolean enforceCheckpoint) {
+ final Map<TopicPartition, Long> offsetSnapshot =
stateMgr.changelogOffsets();
+ if (StateManagerUtil.checkpointNeeded(enforceCheckpoint,
offsetSnapshotSinceLastFlush, offsetSnapshot)) {
+ // since there's no written offsets we can checkpoint with empty
map,
+ // and the state's current offset would be used to checkpoint
+ stateMgr.flush();
+ stateMgr.checkpoint(Collections.emptyMap());
Review comment:
I see what did you mean now. Will do.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]