MINOR: Make TopicPartitionBookkeeper and TopicPartitionEntry top level#12097
Merged
ijuma merged 4 commits intoMay 11, 2022
Conversation
Merged
3 tasks
72b2009 to
0c8e5d9
Compare
hachikuji
reviewed
May 11, 2022
Contributor
There was a problem hiding this comment.
I think basically we're providing a high level view into a map. How about TxnPartitionMap?
…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.
0c8e5d9 to
7f36f54
Compare
ijuma
commented
May 11, 2022
|
|
||
| final Map<TopicPartition, TxnPartitionEntry> topicPartitions = new HashMap<>(); | ||
|
|
||
| TxnPartitionEntry get(TopicPartition topicPartition) { |
Member
Author
There was a problem hiding this comment.
I removed the Partition suffix from this and getOrCreate.
Member
Author
|
Looking at the test results, every test passed for at least one JDK version. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the first step towards refactoring the
TransactionManagersothat it's easier to understand and test. The high level idea is to push
down behavior to
TopicPartitionEntryandTopicPartitionBookkeeperand 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
TopicPartitionBookkeeperandTopicPartitionEntrytop level and rename them and a coupleof 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)