Skip to content

MINOR: Refactor kafka.cluster.Replica#12081

Merged
dajac merged 3 commits into
apache:trunkfrom
dajac:KAFKA-13790-2
Apr 25, 2022
Merged

MINOR: Refactor kafka.cluster.Replica#12081
dajac merged 3 commits into
apache:trunkfrom
dajac:KAFKA-13790-2

Conversation

@dajac

@dajac dajac commented Apr 21, 2022

Copy link
Copy Markdown
Member

This patch refactors kafka.cluster.Replica, it usages and tests. This is part of the work in KAFKA-13790.

Committer Checklist (excluded from commit message)

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

@dajac dajac requested a review from hachikuji April 21, 2022 11:12
@@ -0,0 +1,132 @@
/*

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 have renamed this file. Those tests have nothing to do with the Replica. I have to check if they could be relocated to another place, perhaps in UnifiedLogTest. Do you mind if I do this as a follow up? I need this PR for the next one.

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'm ok with that, but it might not be as much work as you imagine: UnifiedLogTest has a pretty minimalistic setup.

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.

Yeah, you're right. I just did it and it was simpler than what I though.

@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, nice cleanup. Left a few minor comments.

@@ -0,0 +1,132 @@
/*

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'm ok with that, but it might not be as much work as you imagine: UnifiedLogTest has a pretty minimalistic setup.

* @return true if the HW was incremented, and false otherwise.
*/
private def maybeIncrementLeaderHW(leaderLog: UnifiedLog, curTime: Long = time.milliseconds): Boolean = {
private def maybeIncrementLeaderHW(leaderLog: UnifiedLog, currentTimeMs: Long = time.milliseconds): Boolean = {

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.

Do we need the default argument for currentTimeMs? Looks like we have already computed the time in makeLeader.

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.

We have a few other calls where currentTimeMs is not computed beforehand. I will update makeLeader to pass it directly.

): Unit = {
replicaState.updateAndGet { currentReplicaState =>
// When the leader is elected or re-elected, the follower's last caught up time
// is set to the current time if the follower is in the ISR, else to 0. The later

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.

nit: The latter?

@dajac dajac requested a review from hachikuji April 23, 2022 13:13
@dajac

dajac commented Apr 23, 2022

Copy link
Copy Markdown
Member Author

@hachikuji Thanks for your review. I have addressed your comments.

@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.

@dajac dajac merged commit a5f7c82 into apache:trunk Apr 25, 2022
@dajac dajac deleted the KAFKA-13790-2 branch April 25, 2022 20:43
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