Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KAFKA-16907: Fix RaftUtil's type complexity #16831

Open
wants to merge 30 commits into
base: trunk
Choose a base branch
from

Conversation

frankvicky
Copy link
Contributor

@frankvicky frankvicky commented Aug 8, 2024

JIRA: KAFKA-16907

This PR aims to fix the ClassDataAbstractionCoupling and ClassFanOutComplexity issues in RaftUtils.
RaftUtils will be split into several classes, each based on a specific RPC in the Raft consensus protocol.

Committer Checklist (excluded from commit message)

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

@frankvicky
Copy link
Contributor Author

Will fix conflicts after 3.9 RC

@frankvicky frankvicky requested a review from jsancio October 8, 2024 08:38
@frankvicky
Copy link
Contributor Author

Hi @jsancio,
Could you please take a look at this PR when you have some time?
Many thanks! 😺

@frankvicky
Copy link
Contributor Author

Hi @chia7712
Could you please take a look?
Many thanks 😺

}
}

public static AddRaftVoterRequestData addVoterRequest(
Copy link
Contributor

Choose a reason for hiding this comment

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

VoteRequest, VoteResponse should be part of the VoteRPCs, but not addVoter, removeVoter, updateVoter. Perhaps we want a DynamicReconfigRpc class for those

@@ -288,7 +290,7 @@ private ApiMessage buildTestRequest(ApiKeys key) {
return VoteRequest.singletonRequest(topicPartition, clusterId, leaderEpoch, leaderId, lastEpoch, 329);

case FETCH:
FetchRequestData request = RaftUtil.singletonFetchRequest(topicPartition, topicId, fetchPartition ->
FetchRequestData request = FetchRpc.singletonFetchRequest(topicPartition, topicId, fetchPartition ->
Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't be upset having both Fetch and FetchSnapshot in the same class. But I guess same argument could be made for Begin and End Quorum (and I see how naming might get more difficult)

Copy link
Contributor

@ahuang98 ahuang98 left a comment

Choose a reason for hiding this comment

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

Approach looks reasonable to me! Main request is that the dynamic reconfig related RPCs are broken out of VoteRPC

Comment on lines 110 to 119
data.topics().get(0).topicName().equals(topicPartition.topic()) &&
data.topics().get(0).partitions().size() == 1 &&
data.topics().get(0).partitions().get(0).partitionIndex() == topicPartition.partition();
}

public static boolean hasValidTopicPartition(BeginQuorumEpochResponseData data, TopicPartition topicPartition) {
return data.topics().size() == 1 &&
data.topics().get(0).topicName().equals(topicPartition.topic()) &&
data.topics().get(0).partitions().size() == 1 &&
data.topics().get(0).partitions().get(0).partitionIndex() == topicPartition.partition();
Copy link
Contributor

Choose a reason for hiding this comment

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

spacing looks off

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems like an issue of idea format config.
I have adjusted it.

TopicPartition topicPartition
) {
return new DescribeQuorumRequestData()
.setTopics(
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like these are all 8 vs 4 spaces

.setLeaderEpoch(leaderEpoch)
.setHighWatermark(highWatermark)
.setCurrentVoters(toReplicaStates(apiVersion, leaderId, voters, currentTimeMs))
.setObservers(toReplicaStates(apiVersion, leaderId, observers, currentTimeMs))))));
Copy link
Contributor

@ahuang98 ahuang98 Jan 31, 2025

Choose a reason for hiding this comment

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

style nit: I know this was carried over from the old code, but maybe better to have each closing parenthesis on its own new line

(there are a few other spots in the PR which could use this too)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will take a look 😺

Copy link
Contributor

@ahuang98 ahuang98 left a comment

Choose a reason for hiding this comment

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

other than style nit, looks good to me
@jsancio to help merge!

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

Successfully merging this pull request may close these issues.

2 participants