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

MINOR: Move Raft io thread implementation to Java #15119

Merged
merged 12 commits into from
Jan 5, 2024

Conversation

hachikuji
Copy link
Contributor

This patch moves the RaftIOThread implementation into Java. I changed the name to KafkaRaftClientDriver since the main thing it does is drive the calls to poll(). There shouldn't be any changes to the logic.

Committer Checklist (excluded from commit message)

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

@jsancio jsancio added the kraft label Jan 4, 2024
@jsancio jsancio self-assigned this Jan 4, 2024
Copy link
Member

@jsancio jsancio left a comment

Choose a reason for hiding this comment

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

Thanks for the changes.

try {
super.shutdown();
} finally {
client.close();
Copy link
Member

Choose a reason for hiding this comment

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

Should this type close the KafkaRaftClient? In the raft module we generally establish close/shutdown ownership based on if the type created the object or if it is was passed in through a function/constructor.

Take a look at KafkaRaftClient for an example. KafkaRaftClient doesn't close ReplicatedLog, NetworkChannel, etc because they were passed through the constructor. In the other hand KafkaRaftClient does close kafkaRaftMetrics and memoryPool because they were created by KafkaRaftClient.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I debated it. It is nice to have the driver own shutdown since it is in control of the poll loop. Given that, it seemed safer for it to also close the client once it knows that shutdown is complete.

In a future patch, my thought was to have the driver own creation of the client as well. We can replace RaftManager with a builder which constructs the client in the context of the driver. That would establish clear ownership and resolve the issue.

Copy link
Member

Choose a reason for hiding this comment

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

Okay. How about documenting this decision in the type's Java Doc and the private field KafkaRaftClient? That way future readers understand that this is the exception and not the rule.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good.

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 added some comments in the latest commit. Let me know if they address the comment.

checkstyle/import-control.xml Outdated Show resolved Hide resolved
Copy link
Member

@jsancio jsancio left a comment

Choose a reason for hiding this comment

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

LGTM

@hachikuji hachikuji merged commit 599e22b into apache:trunk Jan 5, 2024
1 check failed
yyu1993 pushed a commit to yyu1993/kafka that referenced this pull request Feb 15, 2024
This patch moves the `RaftIOThread` implementation into Java. I changed the name to `KafkaRaftClientDriver` since the main thing it does is drive the calls to `poll()`. There shouldn't be any changes to the logic.

Reviewers: José Armando García Sancio <[email protected]>
AnatolyPopov pushed a commit to aiven/kafka that referenced this pull request Feb 16, 2024
This patch moves the `RaftIOThread` implementation into Java. I changed the name to `KafkaRaftClientDriver` since the main thing it does is drive the calls to `poll()`. There shouldn't be any changes to the logic.

Reviewers: José Armando García Sancio <[email protected]>
clolov pushed a commit to clolov/kafka that referenced this pull request Apr 5, 2024
This patch moves the `RaftIOThread` implementation into Java. I changed the name to `KafkaRaftClientDriver` since the main thing it does is drive the calls to `poll()`. There shouldn't be any changes to the logic.

Reviewers: José Armando García Sancio <[email protected]>
Phuc-Hong-Tran pushed a commit to Phuc-Hong-Tran/kafka that referenced this pull request Jun 6, 2024
This patch moves the `RaftIOThread` implementation into Java. I changed the name to `KafkaRaftClientDriver` since the main thing it does is drive the calls to `poll()`. There shouldn't be any changes to the logic.

Reviewers: José Armando García Sancio <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants