Skip to content

MINOR: Move transaction coordinator leaf classes from Scala to Java#22576

Open
sjhajharia wants to merge 2 commits into
apache:trunkfrom
sjhajharia:move-txn-leaf-classes
Open

MINOR: Move transaction coordinator leaf classes from Scala to Java#22576
sjhajharia wants to merge 2 commits into
apache:trunkfrom
sjhajharia:move-txn-leaf-classes

Conversation

@sjhajharia

@sjhajharia sjhajharia commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Description

As part of the ongoing effort to migrate kafka.coordinator.transaction
from Scala (core) to Java (the transaction-coordinator module), this PR
moves the self-contained "leaf" classes - pure data holders and a
stateful helper with no ReplicaManager/KafkaConfig coupling. These can
move independently while the remaining Scala classes continue to compile
against them, since core depends on transaction-coordinator.

Changes

  • The three data classes become Java records. PendingCompleteTxn keeps a
    custom toString to preserve the original log output format.
  • TxnMarkerQueue becomes a plain Java class: kafka.utils.Logging →
    SLF4J, Scala getOrElseUpdate → computeIfAbsent, and Option → Optional on
    the public API.
  • Scala call sites updated
  • Import repointed in KafkaApis.scala and the affected test files.

Reviewers: Chia-Ping Tsai chia7712@gmail.com

@github-actions github-actions Bot added triage PRs from the community core Kafka Broker transactions Transactions and EOS labels Jun 15, 2026
TxnTransitMetadata newMetadata
) {

@Override

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about relying on the auto-generated code?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we can get rid of it I think. Done!


public void forEachTxnTopicPartition(BiConsumer<Integer, BlockingQueue<PendingCompleteTxnAndMarkerEntry>> f) {
markersPerTxnTopicPartition.forEach((partition, queue) -> {
if (!queue.isEmpty()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why we need this check. It seems we can safely remove it without letting the smoke out

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even I was considering the same, but wanted to ensure with a second eye. Done the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Kafka Broker transactions Transactions and EOS triage PRs from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants