Re: [PR] KAFKA-18883: Move TransactionLog to transaction-coordinator module [kafka]

2026-02-04 Thread via GitHub


DL1231 commented on code in PR #20456:
URL: https://github.com/apache/kafka/pull/20456#discussion_r2767441142


##
core/src/main/scala/kafka/coordinator/transaction/TransactionStateManager.scala:
##
@@ -495,19 +495,21 @@ class TransactionStateManager(brokerId: Int,
 memRecords.batches.forEach { batch =>
   for (record <- batch.asScala) {
 require(record.hasKey, "Transaction state log's key should not 
be null")
-TransactionLog.readTxnRecordKey(record.key) match {
-  case Left(version) =>
-warn(s"Unknown message key with version $version" +
-  s" while loading transaction state from $topicPartition. 
Ignoring it. " +
-  "It could be a left over from an aborted upgrade.")
-  case Right(transactionalId) =>
-// load transaction metadata along with transaction state
-TransactionLog.readTxnRecordValue(transactionalId, 
record.value) match {
-  case None =>
-loadedTransactions.remove(transactionalId)
-  case Some(txnMetadata) =>
-loadedTransactions.put(transactionalId, txnMetadata)
-}
+val transactionalId = try 
Some(TransactionLog.readTxnRecordKey(record.key))

Review Comment:
   Filed a PR to refactor this: https://github.com/apache/kafka/pull/21405



-- 
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]



Re: [PR] KAFKA-18883: Move TransactionLog to transaction-coordinator module [kafka]

2026-01-21 Thread via GitHub


jolshan commented on code in PR #20456:
URL: https://github.com/apache/kafka/pull/20456#discussion_r2713532930


##
core/src/main/scala/kafka/coordinator/transaction/TransactionStateManager.scala:
##
@@ -495,19 +495,21 @@ class TransactionStateManager(brokerId: Int,
 memRecords.batches.forEach { batch =>
   for (record <- batch.asScala) {
 require(record.hasKey, "Transaction state log's key should not 
be null")
-TransactionLog.readTxnRecordKey(record.key) match {
-  case Left(version) =>
-warn(s"Unknown message key with version $version" +
-  s" while loading transaction state from $topicPartition. 
Ignoring it. " +
-  "It could be a left over from an aborted upgrade.")
-  case Right(transactionalId) =>
-// load transaction metadata along with transaction state
-TransactionLog.readTxnRecordValue(transactionalId, 
record.value) match {
-  case None =>
-loadedTransactions.remove(transactionalId)
-  case Some(txnMetadata) =>
-loadedTransactions.put(transactionalId, txnMetadata)
-}
+val transactionalId = try 
Some(TransactionLog.readTxnRecordKey(record.key))

Review Comment:
   thanks!



-- 
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]



Re: [PR] KAFKA-18883: Move TransactionLog to transaction-coordinator module [kafka]

2026-01-20 Thread via GitHub


chia7712 commented on code in PR #20456:
URL: https://github.com/apache/kafka/pull/20456#discussion_r2711319410


##
transaction-coordinator/src/test/java/org/apache/kafka/coordinator/transaction/TransactionLogTest.java:
##
@@ -67,15 +66,12 @@ class TransactionLogTest {
 );
 
 private sealed interface TxnKeyResult {
-record UnknownVersion(short version) implements TxnKeyResult { }

Review Comment:
   yes that will be addressed by the refactoring proposed here: 
https://github.com/apache/kafka/pull/20456#discussion_r2711313661



-- 
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]



Re: [PR] KAFKA-18883: Move TransactionLog to transaction-coordinator module [kafka]

2026-01-20 Thread via GitHub


chia7712 commented on code in PR #20456:
URL: https://github.com/apache/kafka/pull/20456#discussion_r2711313661


##
core/src/main/scala/kafka/coordinator/transaction/TransactionStateManager.scala:
##
@@ -495,19 +495,21 @@ class TransactionStateManager(brokerId: Int,
 memRecords.batches.forEach { batch =>
   for (record <- batch.asScala) {
 require(record.hasKey, "Transaction state log's key should not 
be null")
-TransactionLog.readTxnRecordKey(record.key) match {
-  case Left(version) =>
-warn(s"Unknown message key with version $version" +
-  s" while loading transaction state from $topicPartition. 
Ignoring it. " +
-  "It could be a left over from an aborted upgrade.")
-  case Right(transactionalId) =>
-// load transaction metadata along with transaction state
-TransactionLog.readTxnRecordValue(transactionalId, 
record.value) match {
-  case None =>
-loadedTransactions.remove(transactionalId)
-  case Some(txnMetadata) =>
-loadedTransactions.put(transactionalId, txnMetadata)
-}
+val transactionalId = try 
Some(TransactionLog.readTxnRecordKey(record.key))

Review Comment:
   Sure, that works. we can use a sealed interface to avoid explicit error 
handling and match the result in Scala. For example:
   
   ```java
   public sealed interface ReadResult permits TxnRecord, TxnTombstone, 
UnknownVersion {
   }
   
   public record TxnRecord(String transactionId, TransactionMetadata 
metadata) implements ReadResult {}
   
   public record TxnTombstone(String transactionId) implements ReadResult {}
   
   public record UnknownVersion(int version) implements ReadResult {}
   
   public static ReadResult read(ByteBuffer keyBuffer, ByteBuffer 
valueBuffer) {
   ```
   
   ```scala
 for (record <- batch.asScala) {
   require(record.hasKey, "Transaction state log's key should 
not be null")
   TransactionLog.read(record.key(), record.value()) match {
 case v: TransactionLog.UnknownVersion =>
   warn(s"Unknown message key with version ${v.version()}" +
 s" while loading transaction state from 
$topicPartition. Ignoring it. " +
 "It could be a left over from an aborted upgrade.")
 case r: TransactionLog.TxnTombstone =>
   loadedTransactions.remove(r.transactionId())
 case r: TransactionLog.TxnRecord =>
   loadedTransactions.put(r.transactionId(), r.metadata())
   }
 }
   ```



-- 
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]



Re: [PR] KAFKA-18883: Move TransactionLog to transaction-coordinator module [kafka]

2026-01-20 Thread via GitHub


jolshan commented on code in PR #20456:
URL: https://github.com/apache/kafka/pull/20456#discussion_r2710064656


##
core/src/main/scala/kafka/coordinator/transaction/TransactionStateManager.scala:
##
@@ -495,19 +495,21 @@ class TransactionStateManager(brokerId: Int,
 memRecords.batches.forEach { batch =>
   for (record <- batch.asScala) {
 require(record.hasKey, "Transaction state log's key should not 
be null")
-TransactionLog.readTxnRecordKey(record.key) match {
-  case Left(version) =>
-warn(s"Unknown message key with version $version" +
-  s" while loading transaction state from $topicPartition. 
Ignoring it. " +
-  "It could be a left over from an aborted upgrade.")
-  case Right(transactionalId) =>
-// load transaction metadata along with transaction state
-TransactionLog.readTxnRecordValue(transactionalId, 
record.value) match {
-  case None =>
-loadedTransactions.remove(transactionalId)
-  case Some(txnMetadata) =>
-loadedTransactions.put(transactionalId, txnMetadata)
-}
+val transactionalId = try 
Some(TransactionLog.readTxnRecordKey(record.key))

Review Comment:
   I also had a question about this handling. It seems like we took something 
that was not handled as an error and not require throwing and catching the 
error across the classes. I'm wondering if we can improve this to not require 
this error handling. 



-- 
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]



Re: [PR] KAFKA-18883: Move TransactionLog to transaction-coordinator module [kafka]

2026-01-20 Thread via GitHub


jolshan commented on code in PR #20456:
URL: https://github.com/apache/kafka/pull/20456#discussion_r2710061235


##
transaction-coordinator/src/test/java/org/apache/kafka/coordinator/transaction/TransactionLogTest.java:
##
@@ -67,15 +66,12 @@ class TransactionLogTest {
 );
 
 private sealed interface TxnKeyResult {
-record UnknownVersion(short version) implements TxnKeyResult { }

Review Comment:
   Can we get rid of this interface for the test? it doesn't seem to do much. 



-- 
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]



Re: [PR] KAFKA-18883: Move TransactionLog to transaction-coordinator module [kafka]

2026-01-04 Thread via GitHub


chia7712 merged PR #20456:
URL: https://github.com/apache/kafka/pull/20456


-- 
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]



Re: [PR] KAFKA-18883: Move TransactionLog to transaction-coordinator module [kafka]

2026-01-04 Thread via GitHub


chia7712 commented on code in PR #20456:
URL: https://github.com/apache/kafka/pull/20456#discussion_r2660561291


##
core/src/main/scala/kafka/coordinator/transaction/TransactionStateManager.scala:
##
@@ -495,19 +495,21 @@ class TransactionStateManager(brokerId: Int,
 memRecords.batches.forEach { batch =>
   for (record <- batch.asScala) {
 require(record.hasKey, "Transaction state log's key should not 
be null")
-TransactionLog.readTxnRecordKey(record.key) match {
-  case Left(version) =>
-warn(s"Unknown message key with version $version" +
-  s" while loading transaction state from $topicPartition. 
Ignoring it. " +
-  "It could be a left over from an aborted upgrade.")
-  case Right(transactionalId) =>
-// load transaction metadata along with transaction state
-TransactionLog.readTxnRecordValue(transactionalId, 
record.value) match {
-  case None =>
-loadedTransactions.remove(transactionalId)
-  case Some(txnMetadata) =>
-loadedTransactions.put(transactionalId, txnMetadata)
-}
+val transactionalId = try 
Some(TransactionLog.readTxnRecordKey(record.key))

Review Comment:
   Would you mind adding a unit test for this case in a follow-up PR?



-- 
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]



Re: [PR] KAFKA-18883: Move TransactionLog to transaction-coordinator module [kafka]

2026-01-02 Thread via GitHub


chia7712 commented on code in PR #20456:
URL: https://github.com/apache/kafka/pull/20456#discussion_r2657538889


##
transaction-coordinator/src/test/java/org/apache/kafka/coordinator/transaction/TransactionLogTest.java:
##
@@ -268,16 +261,15 @@ void testDeserializeFutureTransactionLogValue() {
 }
 
 @Test
-void testReadTxnRecordKeyCanReadUnknownMessage() {
+void testReadTxnRecordKeyThrowsOnUnknownVersion() {
 var unknownRecord = 
MessageUtil.toVersionPrefixedBytes(Short.MAX_VALUE, new TransactionLogKey());
-var result = readTxnRecordKey(wrap(unknownRecord));
-
-var uv = assertInstanceOf(TxnKeyResult.UnknownVersion.class, result);
-assertEquals(Short.MAX_VALUE, uv.version());
+var exception = assertThrows(IllegalStateException.class,
+() -> TransactionLog.readTxnRecordKey(wrap(unknownRecord)));
+assertTrue(exception.getMessage().contains("Unknown version " + 
Short.MAX_VALUE));
 }

 @Test
-void shouldReturnEmptyWhenForTombstoneRecord() {
-assertTrue(TransactionLog.readTxnRecordValue("transaction-id", 
null).isEmpty());
+void shouldReturnNullForTombstoneRecord() {
+assertEquals(null, TransactionLog.readTxnRecordValue("transaction-id", 
null));

Review Comment:
   ```java
   assertNull(TransactionLog.readTxnRecordValue("transaction-id", null));
   ```



-- 
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]



Re: [PR] KAFKA-18883: Move TransactionLog to transaction-coordinator module [kafka]

2026-01-02 Thread via GitHub


chia7712 commented on code in PR #20456:
URL: https://github.com/apache/kafka/pull/20456#discussion_r2657538559


##
transaction-coordinator/src/test/java/org/apache/kafka/coordinator/transaction/TransactionLogTest.java:
##
@@ -253,11 +248,9 @@ void testDeserializeFutureTransactionLogValue() {
 
 // Read the buffer with readTxnRecordValue.
 buffer.rewind();
-var txnMetadata = TransactionLog.readTxnRecordValue("transaction-id", 
buffer);
-
-assertFalse(txnMetadata.isEmpty(), "Expected transaction metadata but 
got none");
+var metadata = TransactionLog.readTxnRecordValue("transaction-id", 
buffer);
 
-var metadata = txnMetadata.get();
+assertFalse(metadata == null, "Expected transaction metadata but got 
none");

Review Comment:
   ```java
   assertNotNull(metadata, "Expected transaction metadata but got none");
   ```



-- 
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]



Re: [PR] KAFKA-18883: Move TransactionLog to transaction-coordinator module [kafka]

2025-12-28 Thread via GitHub


chia7712 commented on code in PR #20456:
URL: https://github.com/apache/kafka/pull/20456#discussion_r2649653963


##
core/src/main/scala/kafka/coordinator/transaction/TransactionStateManager.scala:
##
@@ -495,19 +495,21 @@ class TransactionStateManager(brokerId: Int,
 memRecords.batches.forEach { batch =>
   for (record <- batch.asScala) {
 require(record.hasKey, "Transaction state log's key should not 
be null")
-try {
-  val transactionalId = 
TransactionLog.readTxnRecordKey(record.key).asInstanceOf[String]
+val transactionalId = try 
Some(TransactionLog.readTxnRecordKey(record.key))
+catch {
+  case e: IllegalStateException =>
+warn(s"Unknown message key version while loading 
transaction state from $topicPartition. " +
+  s"Ignoring it. It could be a left over from an aborted 
upgrade. Error: ${e.getMessage}")

Review Comment:
   ```scala
   warn(s"Unknown message key version while loading 
transaction state from $topicPartition. " +
 s"Ignoring it. It could be a left over from an aborted 
upgrade", e)
   ```



-- 
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]



Re: [PR] KAFKA-18883: Move TransactionLog to transaction-coordinator module [kafka]

2025-12-22 Thread via GitHub


chia7712 commented on code in PR #20456:
URL: https://github.com/apache/kafka/pull/20456#discussion_r2639444098


##
transaction-coordinator/src/main/java/org/apache/kafka/coordinator/transaction/TransactionLog.java:
##
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.coordinator.transaction;
+
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.compress.Compression;
+import org.apache.kafka.common.protocol.ByteBufferAccessor;
+import org.apache.kafka.common.protocol.MessageUtil;
+import org.apache.kafka.common.record.RecordBatch;
+import 
org.apache.kafka.coordinator.transaction.generated.CoordinatorRecordType;
+import org.apache.kafka.coordinator.transaction.generated.TransactionLogKey;
+import org.apache.kafka.coordinator.transaction.generated.TransactionLogValue;
+import org.apache.kafka.server.common.TransactionVersion;
+
+import java.nio.ByteBuffer;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Messages stored for the transaction topic represent the producer id and 
transactional status of the corresponding
+ * transactional id, which have versions for both the key and value fields. 
Key and value
+ * versions are used to evolve the message formats:
+ *
+ * key version 0:   [transactionalId]
+ *-> value version 0:   [producer_id, producer_epoch, 
expire_timestamp, status, [topic, [partition] ], timestamp]
+ */
+public class TransactionLog {
+
+// enforce always using
+//  1. cleanup policy = compact
+//  2. compression = none
+//  3. unclean leader election = disabled
+//  4. required acks = -1 when writing
+public static final Compression ENFORCED_COMPRESSION = Compression.NONE;
+public static final short ENFORCED_REQUIRED_ACKS = (short) -1;
+
+/**
+ * Generates the bytes for transaction log message key
+ *
+ * @return key bytes
+ */
+public static byte[] keyToBytes(String transactionalId) {
+return MessageUtil.toCoordinatorTypePrefixedBytes(
+new TransactionLogKey().setTransactionalId(transactionalId)
+);
+}
+
+/**
+ * Generates the payload bytes for transaction log message value
+ *
+ * @return value payload bytes
+ */
+public static byte[] valueToBytes(TxnTransitMetadata txnMetadata,
+  TransactionVersion 
transactionVersionLevel) {
+if (txnMetadata.txnState() == TransactionState.EMPTY && 
!txnMetadata.topicPartitions().isEmpty()) {
+throw new IllegalStateException("Transaction is not expected to 
have any partitions since its state is "
++ txnMetadata.txnState() + ": " + txnMetadata);
+}
+
+List transactionPartitions = 
null;
+
+if (txnMetadata.txnState() != TransactionState.EMPTY) {
+transactionPartitions = txnMetadata.topicPartitions().stream()
+.collect(Collectors.groupingBy(TopicPartition::topic))
+.entrySet().stream()
+.map(entry -> {
+TransactionLogValue.PartitionsSchema schema = new 
TransactionLogValue.PartitionsSchema();

Review Comment:
   ```java
   new TransactionLogValue.PartitionsSchema()
   .setTopic(entry.getKey())
   
.setPartitionIds(entry.getValue().stream().map(TopicPartition::partition).toList()
   )
   ```



-- 
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]



Re: [PR] KAFKA-18883: Move TransactionLog to transaction-coordinator module [kafka]

2025-12-22 Thread via GitHub


chia7712 commented on code in PR #20456:
URL: https://github.com/apache/kafka/pull/20456#discussion_r2639438335


##
core/src/main/scala/kafka/coordinator/transaction/TransactionStateManager.scala:
##
@@ -495,19 +495,19 @@ class TransactionStateManager(brokerId: Int,
 memRecords.batches.forEach { batch =>
   for (record <- batch.asScala) {
 require(record.hasKey, "Transaction state log's key should not 
be null")
-TransactionLog.readTxnRecordKey(record.key) match {
-  case Left(version) =>
-warn(s"Unknown message key with version $version" +
-  s" while loading transaction state from $topicPartition. 
Ignoring it. " +
-  "It could be a left over from an aborted upgrade.")
-  case Right(transactionalId) =>
-// load transaction metadata along with transaction state
-TransactionLog.readTxnRecordValue(transactionalId, 
record.value) match {
-  case None =>
-loadedTransactions.remove(transactionalId)
-  case Some(txnMetadata) =>
-loadedTransactions.put(transactionalId, txnMetadata)
-}
+try {
+  val transactionalId = 
TransactionLog.readTxnRecordKey(record.key).asInstanceOf[String]

Review Comment:
   ```scala
   val transactionalId = try 
Some(TransactionLog.readTxnRecordKey(record.key))
   catch {
 case e: IllegalStateException =>
   warn(s"Unknown message key version while loading 
transaction state from $topicPartition. " +
 s"Ignoring it. It could be a left over from an aborted 
upgrade. Error: ${e.getMessage}")
   None
   }
   transactionalId.foreach { txnId =>
 // load transaction metadata along with transaction state
 val txnMetadata = TransactionLog.readTxnRecordValue(txnId, 
record.value)
 if (txnMetadata == null) {
   loadedTransactions.remove(txnId)
 } else {
   loadedTransactions.put(txnId, txnMetadata)
 }
   }
   ```



-- 
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]



Re: [PR] KAFKA-18883: Move TransactionLog to transaction-coordinator module [kafka]

2025-12-22 Thread via GitHub


chia7712 commented on code in PR #20456:
URL: https://github.com/apache/kafka/pull/20456#discussion_r2639424870


##
transaction-coordinator/src/main/java/org/apache/kafka/coordinator/transaction/TransactionLog.java:
##
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.coordinator.transaction;
+
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.compress.Compression;
+import org.apache.kafka.common.protocol.ByteBufferAccessor;
+import org.apache.kafka.common.protocol.MessageUtil;
+import org.apache.kafka.common.record.RecordBatch;
+import 
org.apache.kafka.coordinator.transaction.generated.CoordinatorRecordType;
+import org.apache.kafka.coordinator.transaction.generated.TransactionLogKey;
+import org.apache.kafka.coordinator.transaction.generated.TransactionLogValue;
+import org.apache.kafka.server.common.TransactionVersion;
+
+import java.nio.ByteBuffer;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Messages stored for the transaction topic represent the producer id and 
transactional status of the corresponding
+ * transactional id, which have versions for both the key and value fields. 
Key and value
+ * versions are used to evolve the message formats:
+ *
+ * key version 0:   [transactionalId]
+ *-> value version 0:   [producer_id, producer_epoch, 
expire_timestamp, status, [topic, [partition] ], timestamp]
+ */
+public class TransactionLog {
+
+// enforce always using
+//  1. cleanup policy = compact
+//  2. compression = none
+//  3. unclean leader election = disabled
+//  4. required acks = -1 when writing
+public static final Compression ENFORCED_COMPRESSION = Compression.NONE;
+public static final short ENFORCED_REQUIRED_ACKS = (short) -1;
+
+/**
+ * Generates the bytes for transaction log message key
+ *
+ * @return key bytes
+ */
+public static byte[] keyToBytes(String transactionalId) {
+return MessageUtil.toCoordinatorTypePrefixedBytes(
+new TransactionLogKey().setTransactionalId(transactionalId)
+);
+}
+
+/**
+ * Generates the payload bytes for transaction log message value
+ *
+ * @return value payload bytes
+ */
+public static byte[] valueToBytes(TxnTransitMetadata txnMetadata,
+  TransactionVersion 
transactionVersionLevel) {
+if (txnMetadata.txnState() == TransactionState.EMPTY && 
!txnMetadata.topicPartitions().isEmpty()) {
+throw new IllegalStateException("Transaction is not expected to 
have any partitions since its state is "
++ txnMetadata.txnState() + ": " + txnMetadata);
+}
+
+List transactionPartitions = 
null;
+
+if (txnMetadata.txnState() != TransactionState.EMPTY) {
+transactionPartitions = txnMetadata.topicPartitions().stream()
+.collect(Collectors.groupingBy(TopicPartition::topic))
+.entrySet().stream()
+.map(entry -> {
+TransactionLogValue.PartitionsSchema schema = new 
TransactionLogValue.PartitionsSchema();
+schema.setTopic(entry.getKey());
+schema.setPartitionIds(
+entry.getValue().stream()
+.map(TopicPartition::partition)
+.toList()
+);
+return schema;
+}).toList();
+}
+
+return MessageUtil.toVersionPrefixedBytes(
+transactionVersionLevel.transactionLogValueVersion(),
+new TransactionLogValue()
+.setProducerId(txnMetadata.producerId())
+.setProducerEpoch(txnMetadata.producerEpoch())
+.setTransactionTimeoutMs(txnMetadata.txnTimeoutMs())
+.setTransactionStatus(txnMetadata.txnState().id())
+

Re: [PR] KAFKA-18883: Move TransactionLog to transaction-coordinator module [kafka]

2025-12-21 Thread via GitHub


TaiJuWu commented on code in PR #20456:
URL: https://github.com/apache/kafka/pull/20456#discussion_r2638715824


##
transaction-coordinator/src/main/java/org/apache/kafka/coordinator/transaction/TransactionLog.java:
##
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.coordinator.transaction;
+
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.compress.Compression;
+import org.apache.kafka.common.protocol.ByteBufferAccessor;
+import org.apache.kafka.common.protocol.MessageUtil;
+import org.apache.kafka.common.record.RecordBatch;
+import 
org.apache.kafka.coordinator.transaction.generated.CoordinatorRecordType;
+import org.apache.kafka.coordinator.transaction.generated.TransactionLogKey;
+import org.apache.kafka.coordinator.transaction.generated.TransactionLogValue;
+import org.apache.kafka.server.common.TransactionVersion;
+
+import java.nio.ByteBuffer;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Messages stored for the transaction topic represent the producer id and 
transactional status of the corresponding
+ * transactional id, which have versions for both the key and value fields. 
Key and value
+ * versions are used to evolve the message formats:
+ *
+ * key version 0:   [transactionalId]
+ *-> value version 0:   [producer_id, producer_epoch, 
expire_timestamp, status, [topic, [partition] ], timestamp]
+ */
+public class TransactionLog {
+
+// enforce always using
+//  1. cleanup policy = compact
+//  2. compression = none
+//  3. unclean leader election = disabled
+//  4. required acks = -1 when writing
+public static final Compression ENFORCED_COMPRESSION = Compression.NONE;
+public static final short ENFORCED_REQUIRED_ACKS = (short) -1;
+
+/**
+ * Generates the bytes for transaction log message key
+ *
+ * @return key bytes
+ */
+public static byte[] keyToBytes(String transactionalId) {
+return MessageUtil.toCoordinatorTypePrefixedBytes(
+new TransactionLogKey().setTransactionalId(transactionalId)
+);
+}
+
+/**
+ * Generates the payload bytes for transaction log message value
+ *
+ * @return value payload bytes
+ */
+public static byte[] valueToBytes(TxnTransitMetadata txnMetadata,
+  TransactionVersion 
transactionVersionLevel) {
+if (txnMetadata.txnState() == TransactionState.EMPTY && 
!txnMetadata.topicPartitions().isEmpty()) {
+throw new IllegalStateException("Transaction is not expected to 
have any partitions since its state is "
++ txnMetadata.txnState() + ": " + txnMetadata);
+}
+
+List transactionPartitions = 
null;
+
+if (txnMetadata.txnState() != TransactionState.EMPTY) {
+transactionPartitions = txnMetadata.topicPartitions().stream()
+.collect(Collectors.groupingBy(TopicPartition::topic))
+.entrySet().stream()
+.map(entry -> {
+TransactionLogValue.PartitionsSchema schema = new 
TransactionLogValue.PartitionsSchema();
+schema.setTopic(entry.getKey());
+schema.setPartitionIds(
+entry.getValue().stream()
+.map(TopicPartition::partition)
+.toList()
+);
+return schema;
+}).toList();
+}
+
+return MessageUtil.toVersionPrefixedBytes(
+transactionVersionLevel.transactionLogValueVersion(),
+new TransactionLogValue()
+.setProducerId(txnMetadata.producerId())
+.setProducerEpoch(txnMetadata.producerEpoch())
+.setTransactionTimeoutMs(txnMetadata.txnTimeoutMs())
+.setTransactionStatus(txnMetadata.txnState().id())
+

Re: [PR] KAFKA-18883: Move TransactionLog to transaction-coordinator module [kafka]

2025-12-21 Thread via GitHub


chia7712 commented on code in PR #20456:
URL: https://github.com/apache/kafka/pull/20456#discussion_r2638648672


##
transaction-coordinator/src/main/java/org/apache/kafka/coordinator/transaction/TransactionLog.java:
##
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.coordinator.transaction;
+
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.compress.Compression;
+import org.apache.kafka.common.protocol.ByteBufferAccessor;
+import org.apache.kafka.common.protocol.MessageUtil;
+import org.apache.kafka.common.record.RecordBatch;
+import 
org.apache.kafka.coordinator.transaction.generated.CoordinatorRecordType;
+import org.apache.kafka.coordinator.transaction.generated.TransactionLogKey;
+import org.apache.kafka.coordinator.transaction.generated.TransactionLogValue;
+import org.apache.kafka.server.common.TransactionVersion;
+
+import java.nio.ByteBuffer;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Messages stored for the transaction topic represent the producer id and 
transactional status of the corresponding
+ * transactional id, which have versions for both the key and value fields. 
Key and value
+ * versions are used to evolve the message formats:
+ *
+ * key version 0:   [transactionalId]
+ *-> value version 0:   [producer_id, producer_epoch, 
expire_timestamp, status, [topic, [partition] ], timestamp]
+ */
+public class TransactionLog {
+
+// enforce always using
+//  1. cleanup policy = compact
+//  2. compression = none
+//  3. unclean leader election = disabled
+//  4. required acks = -1 when writing
+public static final Compression ENFORCED_COMPRESSION = Compression.NONE;
+public static final short ENFORCED_REQUIRED_ACKS = (short) -1;
+
+/**
+ * Generates the bytes for transaction log message key
+ *
+ * @return key bytes
+ */
+public static byte[] keyToBytes(String transactionalId) {
+return MessageUtil.toCoordinatorTypePrefixedBytes(
+new TransactionLogKey().setTransactionalId(transactionalId)
+);
+}
+
+/**
+ * Generates the payload bytes for transaction log message value
+ *
+ * @return value payload bytes
+ */
+public static byte[] valueToBytes(TxnTransitMetadata txnMetadata,
+  TransactionVersion 
transactionVersionLevel) {
+if (txnMetadata.txnState() == TransactionState.EMPTY && 
!txnMetadata.topicPartitions().isEmpty()) {
+throw new IllegalStateException("Transaction is not expected to 
have any partitions since its state is "
++ txnMetadata.txnState() + ": " + txnMetadata);
+}
+
+List transactionPartitions = 
null;
+
+if (txnMetadata.txnState() != TransactionState.EMPTY) {
+transactionPartitions = txnMetadata.topicPartitions().stream()
+.collect(Collectors.groupingBy(TopicPartition::topic))
+.entrySet().stream()
+.map(entry -> {
+TransactionLogValue.PartitionsSchema schema = new 
TransactionLogValue.PartitionsSchema();
+schema.setTopic(entry.getKey());
+schema.setPartitionIds(
+entry.getValue().stream()
+.map(TopicPartition::partition)
+.toList()
+);
+return schema;
+}).toList();
+}
+
+return MessageUtil.toVersionPrefixedBytes(
+transactionVersionLevel.transactionLogValueVersion(),
+new TransactionLogValue()
+.setProducerId(txnMetadata.producerId())
+.setProducerEpoch(txnMetadata.producerEpoch())
+.setTransactionTimeoutMs(txnMetadata.txnTimeoutMs())
+.setTransactionStatus(txnMetadata.txnState().id())
+

Re: [PR] KAFKA-18883: Move TransactionLog to transaction-coordinator module [kafka]

2025-12-21 Thread via GitHub


chia7712 commented on code in PR #20456:
URL: https://github.com/apache/kafka/pull/20456#discussion_r2638650908


##
transaction-coordinator/src/main/java/org/apache/kafka/coordinator/transaction/TransactionLog.java:
##
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.coordinator.transaction;
+
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.compress.Compression;
+import org.apache.kafka.common.protocol.ByteBufferAccessor;
+import org.apache.kafka.common.protocol.MessageUtil;
+import org.apache.kafka.common.record.RecordBatch;
+import 
org.apache.kafka.coordinator.transaction.generated.CoordinatorRecordType;
+import org.apache.kafka.coordinator.transaction.generated.TransactionLogKey;
+import org.apache.kafka.coordinator.transaction.generated.TransactionLogValue;
+import org.apache.kafka.server.common.TransactionVersion;
+
+import java.nio.ByteBuffer;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Messages stored for the transaction topic represent the producer id and 
transactional status of the corresponding
+ * transactional id, which have versions for both the key and value fields. 
Key and value
+ * versions are used to evolve the message formats:
+ *
+ * key version 0:   [transactionalId]
+ *-> value version 0:   [producer_id, producer_epoch, 
expire_timestamp, status, [topic, [partition] ], timestamp]
+ */
+public class TransactionLog {
+
+// enforce always using
+//  1. cleanup policy = compact
+//  2. compression = none
+//  3. unclean leader election = disabled
+//  4. required acks = -1 when writing
+public static final Compression ENFORCED_COMPRESSION = Compression.NONE;
+public static final short ENFORCED_REQUIRED_ACKS = (short) -1;
+
+/**
+ * Generates the bytes for transaction log message key
+ *
+ * @return key bytes
+ */
+public static byte[] keyToBytes(String transactionalId) {
+return MessageUtil.toCoordinatorTypePrefixedBytes(
+new TransactionLogKey().setTransactionalId(transactionalId)
+);
+}
+
+/**
+ * Generates the payload bytes for transaction log message value
+ *
+ * @return value payload bytes
+ */
+public static byte[] valueToBytes(TxnTransitMetadata txnMetadata,
+  TransactionVersion 
transactionVersionLevel) {
+if (txnMetadata.txnState() == TransactionState.EMPTY && 
!txnMetadata.topicPartitions().isEmpty()) {
+throw new IllegalStateException("Transaction is not expected to 
have any partitions since its state is "
++ txnMetadata.txnState() + ": " + txnMetadata);
+}
+
+List transactionPartitions = 
null;
+
+if (txnMetadata.txnState() != TransactionState.EMPTY) {
+transactionPartitions = txnMetadata.topicPartitions().stream()
+.collect(Collectors.groupingBy(TopicPartition::topic))
+.entrySet().stream()
+.map(entry -> {
+TransactionLogValue.PartitionsSchema schema = new 
TransactionLogValue.PartitionsSchema();
+schema.setTopic(entry.getKey());
+schema.setPartitionIds(
+entry.getValue().stream()
+.map(TopicPartition::partition)
+.toList()
+);
+return schema;
+}).toList();
+}
+
+return MessageUtil.toVersionPrefixedBytes(
+transactionVersionLevel.transactionLogValueVersion(),
+new TransactionLogValue()
+.setProducerId(txnMetadata.producerId())
+.setProducerEpoch(txnMetadata.producerEpoch())
+.setTransactionTimeoutMs(txnMetadata.txnTimeoutMs())
+.setTransactionStatus(txnMetadata.txnState().id())
+

Re: [PR] KAFKA-18883: Move TransactionLog to transaction-coordinator module [kafka]

2025-12-21 Thread via GitHub


chia7712 commented on code in PR #20456:
URL: https://github.com/apache/kafka/pull/20456#discussion_r2638646906


##
transaction-coordinator/src/main/java/org/apache/kafka/coordinator/transaction/TransactionLog.java:
##
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.coordinator.transaction;
+
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.compress.Compression;
+import org.apache.kafka.common.protocol.ByteBufferAccessor;
+import org.apache.kafka.common.protocol.MessageUtil;
+import org.apache.kafka.common.record.RecordBatch;
+import 
org.apache.kafka.coordinator.transaction.generated.CoordinatorRecordType;
+import org.apache.kafka.coordinator.transaction.generated.TransactionLogKey;
+import org.apache.kafka.coordinator.transaction.generated.TransactionLogValue;
+import org.apache.kafka.server.common.TransactionVersion;
+
+import java.nio.ByteBuffer;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Messages stored for the transaction topic represent the producer id and 
transactional status of the corresponding
+ * transactional id, which have versions for both the key and value fields. 
Key and value
+ * versions are used to evolve the message formats:
+ *
+ * key version 0:   [transactionalId]
+ *-> value version 0:   [producer_id, producer_epoch, 
expire_timestamp, status, [topic, [partition] ], timestamp]
+ */
+public class TransactionLog {
+
+// enforce always using
+//  1. cleanup policy = compact
+//  2. compression = none
+//  3. unclean leader election = disabled
+//  4. required acks = -1 when writing
+public static final Compression ENFORCED_COMPRESSION = Compression.NONE;
+public static final short ENFORCED_REQUIRED_ACKS = (short) -1;
+
+/**
+ * Generates the bytes for transaction log message key
+ *
+ * @return key bytes
+ */
+public static byte[] keyToBytes(String transactionalId) {
+return MessageUtil.toCoordinatorTypePrefixedBytes(
+new TransactionLogKey().setTransactionalId(transactionalId)
+);
+}
+
+/**
+ * Generates the payload bytes for transaction log message value
+ *
+ * @return value payload bytes
+ */
+public static byte[] valueToBytes(TxnTransitMetadata txnMetadata,
+  TransactionVersion 
transactionVersionLevel) {
+if (txnMetadata.txnState() == TransactionState.EMPTY && 
!txnMetadata.topicPartitions().isEmpty()) {
+throw new IllegalStateException("Transaction is not expected to 
have any partitions since its state is "
++ txnMetadata.txnState() + ": " + txnMetadata);
+}
+
+List transactionPartitions = 
null;
+
+if (txnMetadata.txnState() != TransactionState.EMPTY) {
+transactionPartitions = txnMetadata.topicPartitions().stream()
+.collect(Collectors.groupingBy(TopicPartition::topic))
+.entrySet().stream()
+.map(entry -> {
+TransactionLogValue.PartitionsSchema schema = new 
TransactionLogValue.PartitionsSchema();
+schema.setTopic(entry.getKey());
+schema.setPartitionIds(
+entry.getValue().stream()
+.map(TopicPartition::partition)
+.toList()
+);
+return schema;
+}).toList();
+}
+
+return MessageUtil.toVersionPrefixedBytes(
+transactionVersionLevel.transactionLogValueVersion(),
+new TransactionLogValue()
+.setProducerId(txnMetadata.producerId())
+.setProducerEpoch(txnMetadata.producerEpoch())
+.setTransactionTimeoutMs(txnMetadata.txnTimeoutMs())
+.setTransactionStatus(txnMetadata.txnState().id())
+

Re: [PR] KAFKA-18883: Move TransactionLog to transaction-coordinator module [kafka]

2025-12-20 Thread via GitHub


chia7712 commented on code in PR #20456:
URL: https://github.com/apache/kafka/pull/20456#discussion_r2637087436


##
core/src/test/scala/unit/kafka/coordinator/transaction/TransactionLogTest.scala:
##
@@ -0,0 +1,249 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package kafka.coordinator.transaction
+
+import org.apache.kafka.common.TopicPartition
+import org.apache.kafka.common.compress.Compression
+import org.apache.kafka.common.protocol.{ByteBufferAccessor, MessageUtil}
+import org.apache.kafka.common.protocol.types.Field.TaggedFieldsSection
+import org.apache.kafka.common.protocol.types.{CompactArrayOf, Field, Schema, 
Struct, Type}
+import org.apache.kafka.common.record.{MemoryRecords, RecordBatch, 
SimpleRecord}
+import org.apache.kafka.coordinator.transaction.{TransactionMetadata, 
TransactionState, TxnTransitMetadata, TransactionLog}
+import org.apache.kafka.coordinator.transaction.generated.{TransactionLogKey, 
TransactionLogValue}
+import org.apache.kafka.server.common.TransactionVersion.{TV_0, TV_2}
+import org.junit.jupiter.api.Assertions.{assertEquals, assertThrows, 
assertTrue, fail}
+import org.junit.jupiter.api.Test
+
+import java.nio.ByteBuffer
+import java.util
+import scala.collection.Seq
+import scala.jdk.CollectionConverters._
+
+class TransactionLogTest {

Review Comment:
   Could you rewrite this by Java?



-- 
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]



Re: [PR] KAFKA-18883: Move TransactionLog to transaction-coordinator module [kafka]

2025-11-01 Thread via GitHub


TaiJuWu commented on code in PR #20456:
URL: https://github.com/apache/kafka/pull/20456#discussion_r2484044515


##
transaction-coordinator/src/main/java/org/apache/kafka/coordinator/transaction/TransactionLog.java:
##
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.coordinator.transaction;
+
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.compress.Compression;
+import org.apache.kafka.common.protocol.ByteBufferAccessor;
+import org.apache.kafka.common.protocol.MessageUtil;
+import org.apache.kafka.common.record.RecordBatch;
+import 
org.apache.kafka.coordinator.transaction.generated.CoordinatorRecordType;
+import org.apache.kafka.coordinator.transaction.generated.TransactionLogKey;
+import org.apache.kafka.coordinator.transaction.generated.TransactionLogValue;
+import org.apache.kafka.server.common.TransactionVersion;
+
+import java.nio.ByteBuffer;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Messages stored for the transaction topic represent the producer id and 
transactional status of the corresponding
+ * transactional id, which have versions for both the key and value fields. 
Key and value
+ * versions are used to evolve the message formats:
+ *
+ * key version 0:   [transactionalId]
+ *-> value version 0:   [producer_id, producer_epoch, 
expire_timestamp, status, [topic, [partition] ], timestamp]
+ */
+public class TransactionLog {

Review Comment:
   Thanks remind, remove it and merge trunk.



-- 
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]



Re: [PR] KAFKA-18883: Move TransactionLog to transaction-coordinator module [kafka]

2025-11-01 Thread via GitHub


chia7712 commented on code in PR #20456:
URL: https://github.com/apache/kafka/pull/20456#discussion_r2483883120


##
transaction-coordinator/src/main/java/org/apache/kafka/coordinator/transaction/TransactionLog.java:
##
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.coordinator.transaction;
+
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.compress.Compression;
+import org.apache.kafka.common.protocol.ByteBufferAccessor;
+import org.apache.kafka.common.protocol.MessageUtil;
+import org.apache.kafka.common.record.RecordBatch;
+import 
org.apache.kafka.coordinator.transaction.generated.CoordinatorRecordType;
+import org.apache.kafka.coordinator.transaction.generated.TransactionLogKey;
+import org.apache.kafka.coordinator.transaction.generated.TransactionLogValue;
+import org.apache.kafka.server.common.TransactionVersion;
+
+import java.nio.ByteBuffer;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Messages stored for the transaction topic represent the producer id and 
transactional status of the corresponding
+ * transactional id, which have versions for both the key and value fields. 
Key and value
+ * versions are used to evolve the message formats:
+ *
+ * key version 0:   [transactionalId]
+ *-> value version 0:   [producer_id, producer_epoch, 
expire_timestamp, status, [topic, [partition] ], timestamp]
+ */
+public class TransactionLog {

Review Comment:
   Should we remove `TransactionLog.scala`?



-- 
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]



Re: [PR] KAFKA-18883: Move TransactionLog to transaction-coordinator module [kafka]

2025-09-16 Thread via GitHub


github-actions[bot] commented on PR #20456:
URL: https://github.com/apache/kafka/pull/20456#issuecomment-3301103546

   A label of 'needs-attention' was automatically added to this PR in order to 
raise the
   attention of the committers. Once this issue has been triaged, the `triage` 
label
   should be removed to prevent this automation from happening again.


-- 
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]



Re: [PR] KAFKA-18883: Move TransactionLog to transaction-coordinator module [kafka]

2025-09-09 Thread via GitHub


github-actions[bot] commented on PR #20456:
URL: https://github.com/apache/kafka/pull/20456#issuecomment-3273055211

   A label of 'needs-attention' was automatically added to this PR in order to 
raise the
   attention of the committers. Once this issue has been triaged, the `triage` 
label
   should be removed to prevent this automation from happening again.


-- 
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]