Skip to content

MINOR: Make TopicPartitionBookkeeper and TopicPartitionEntry top level#12097

Merged
ijuma merged 4 commits into
apache:trunkfrom
ijuma:txn-manager-better-encapsulation-part-1
May 11, 2022
Merged

MINOR: Make TopicPartitionBookkeeper and TopicPartitionEntry top level#12097
ijuma merged 4 commits into
apache:trunkfrom
ijuma:txn-manager-better-encapsulation-part-1

Conversation

@ijuma

@ijuma ijuma commented Apr 26, 2022

Copy link
Copy Markdown
Member

This is the first step towards refactoring the TransactionManager so
that it's easier to understand and test. The high level idea is to push
down behavior to TopicPartitionEntry and TopicPartitionBookkeeper
and to encapsulate the state so that the mutations can only be done via
the appropriate methods.

Inner classes have no mechanism to limit access from the outer class,
which presents a challenge when mutability is widespread (like we do
here).

As a first step, we make TopicPartitionBookkeeper and
TopicPartitionEntry top level and rename them and a couple
of methods to make the intended usage clear and avoid
redundancy.

To make the review easier, we don't change anything else
except access changes required for the code to compile.
The next PR will contain the rest of the refactoring.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think basically we're providing a high level view into a map. How about TxnPartitionMap?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sounds good, will rename.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

ijuma added 3 commits May 10, 2022 20:33
…onsManager (round 3)

Conceptually, the ordering is defined by the producer id, producer epoch
and the sequence number. A given `TopicPartitionEntry` has a single
producer id and hence we only need to compare the other two.
This is the first step towards refactoring the `TransactionManager` so
that it's easier to understand and test. The high level idea is to push
down behavior to `TopicPartitionEntry` and `TopicPartitionBookkeeper`
and to encapsulate the state so that the mutations can only be done via
the appropriate methods.

Inner classes have no mechanism to limit access from the outer class,
which presents a challenge when mutability is widespread, like it is the
case here.

As a first step, we make `TopicPartitionBookkeeper` and
`TopicPartitionEntry` top level and rename them to make their intended
usage clear. To make the review easier, we don't change anything else
except access changes required for the code to compile.

The next PR will contain the rest of the refactoring.
@ijuma ijuma force-pushed the txn-manager-better-encapsulation-part-1 branch from 0c8e5d9 to 7f36f54 Compare May 11, 2022 03:35

final Map<TopicPartition, TxnPartitionEntry> topicPartitions = new HashMap<>();

TxnPartitionEntry get(TopicPartition topicPartition) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I removed the Partition suffix from this and getOrCreate.

@hachikuji hachikuji left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, LGTM

@ijuma

ijuma commented May 11, 2022

Copy link
Copy Markdown
Member Author

Looking at the test results, every test passed for at least one JDK version.

@ijuma ijuma merged commit 3ea7b41 into apache:trunk May 11, 2022
@ijuma ijuma deleted the txn-manager-better-encapsulation-part-1 branch October 19, 2023 04:38
mumrah added a commit to confluentinc/kafka that referenced this pull request Nov 30, 2023
)

This is a partial backport of KAFKA-13270 which sets the `JUTE_MAXBUFFER`
configuration to 4MB unless otherwise specified.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants