jsancio commented on code in PR #12414: URL: https://github.com/apache/kafka/pull/12414#discussion_r959867602
########## core/src/main/scala/kafka/server/metadata/BrokerMetadataListener.scala: ########## @@ -119,16 +120,29 @@ class BrokerMetadataListener( } _bytesSinceLastSnapshot = _bytesSinceLastSnapshot + results.numBytes - if (shouldSnapshot()) { - maybeStartSnapshot() + + val shouldTakeSnapshot: Set[SnapshotReason] = shouldSnapshot() + if (shouldTakeSnapshot.nonEmpty) { + maybeStartSnapshot(shouldTakeSnapshot) } _publisher.foreach(publish) } } - private def shouldSnapshot(): Boolean = { - (_bytesSinceLastSnapshot >= maxBytesBetweenSnapshots) || metadataVersionChanged() + private def shouldSnapshot(): Set[SnapshotReason] = { + val metadataVersionHasChanged: Boolean = metadataVersionChanged() + val maxBytesHaveExceeded: Boolean = (_bytesSinceLastSnapshot >= maxBytesBetweenSnapshots) Review Comment: Minor but we tend not to declare the type for private variables with simple expressions. ########## core/src/main/scala/kafka/server/metadata/MetadataSnapshotter.scala: ########## @@ -31,5 +32,5 @@ trait MetadataSnapshotter { * * @return True if we will write out a new snapshot; false otherwise. */ - def maybeStartSnapshot(lastContainedLogTime: Long, image: MetadataImage): Boolean + def maybeStartSnapshot(lastContainedLogTime: Long, image: MetadataImage, reason: Set[SnapshotReason]): Boolean Review Comment: Let's add the new parameter to the documentation above. ########## core/src/main/scala/kafka/server/metadata/BrokerMetadataSnapshotter.scala: ########## @@ -59,11 +60,11 @@ class BrokerMetadataSnapshotter( val writer = writerBuilder.build( image.highestOffsetAndEpoch().offset, image.highestOffsetAndEpoch().epoch, - lastContainedLogTime - ) + lastContainedLogTime) Review Comment: Minor but you can revert this change. It is okay to have the closing delimiter in a new line. -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org