dajac commented on code in PR #14047: URL: https://github.com/apache/kafka/pull/14047#discussion_r1268008967
########## group-coordinator/src/main/java/org/apache/kafka/coordinator/group/RecordHelpers.java: ########## @@ -467,6 +471,72 @@ public static Record newEmptyGroupMetadataRecord( ); } + /** + * Creates an OffsetCommit record. + * + * @param groupId The group id. + * @param topic The topic name. + * @param partitionId The partition id. + * @param offsetAndMetadata The offset and metadata. + * @param metadataVersion The metadata version. + * @return The record. + */ + public static Record newOffsetCommitRecord( + String groupId, + String topic, + int partitionId, + OffsetAndMetadata offsetAndMetadata, + MetadataVersion metadataVersion + ) { + short version = offsetAndMetadata.expireTimestampMs.isPresent() ? + (short) 1 : metadataVersion.offsetCommitValueVersion(); + + return new Record( + new ApiMessageAndVersion( + new OffsetCommitKey() + .setGroup(groupId) + .setTopic(topic) + .setPartition(partitionId), + (short) 1 + ), + new ApiMessageAndVersion( + new OffsetCommitValue() + .setOffset(offsetAndMetadata.offset) + .setLeaderEpoch(offsetAndMetadata.leaderEpoch.orElse(RecordBatch.NO_PARTITION_LEADER_EPOCH)) + .setMetadata(offsetAndMetadata.metadata) + .setCommitTimestamp(offsetAndMetadata.commitTimestampMs) + // Version 1 has a non-empty expireTimestamp field + .setExpireTimestamp(offsetAndMetadata.expireTimestampMs.orElse(OffsetCommitRequest.DEFAULT_TIMESTAMP)), Review Comment: This comes from [here](https://github.com/apache/kafka/blob/trunk/core/src/main/scala/kafka/coordinator/group/GroupMetadataManager.scala#L1094). -- 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