Skip to content

KAFKA-14386: Return TopicAssignment from the ReplicaPlacer#12892

Merged
jsancio merged 12 commits intoapache:trunkfrom
andrewgrantcflt:KAFKA-14386
Dec 6, 2022
Merged

KAFKA-14386: Return TopicAssignment from the ReplicaPlacer#12892
jsancio merged 12 commits intoapache:trunkfrom
andrewgrantcflt:KAFKA-14386

Conversation

@andrewgrantcflt
Copy link
Contributor

JIRA

https://issues.apache.org/jira/browse/KAFKA-14386

Summary

This changes the ReplicaPlacer interface to return a class instead of a list of list of integers. There are two reasons for the suggestion. First, as mentioned in the JIRA, it will make the interface, arguably, a bit more readable and understandable by explicitly modeling the idea of topic and partition. Second and more importantly, it makes the interface more extendable in the future. Right now it would be challenging to add more metadata to the response. By having classes, we can easily add fields to them without breaking/changing the interface. For example, in the CreatePartitions RPC we are adding partitions to an existing topic and we might want to add some metadata to response making it clear which partition the assignment starts at which could look something like:

Committer Checklist (excluded from commit message)

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

@andrewgrantcflt andrewgrantcflt changed the title KAFKA-14386: Change ReplicaPlacer place method to return a class instead of list of list of integers KAFKA-14386: Change ReplicaPlacer place method to return a class instead of a list of list of integers Nov 23, 2022
@andrewgrantcflt andrewgrantcflt force-pushed the KAFKA-14386 branch 3 times, most recently from 15927cf to 2356f14 Compare November 28, 2022 21:52
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 @andymg3 .

Should we also improve the PartitionRegistration type to use a PartitionAssignment instead of int[] replicas?

@andrewgrantcflt
Copy link
Contributor Author

andrewgrantcflt commented Dec 1, 2022

Thanks for the changes @andymg3 .

Should we also improve the PartitionRegistration type to use a PartitionAssignment instead of int[] replicas?

Thanks for the review @jsancio. As of now I dont see much benefit in changing that type. In PartitionRegistration we also have []int isr, int[] removingReplicas, and int[] addingReplicas. I'm inclined to leave replicas as is for consistency - I think it reads a bit better when they're all the same type. They're often processed at the same time as well, so having to deal with both types may be a bit cumbersome. There are quite a few places in the codebase that use the replicas field and in practice if we were to use PartitionAssignment all callers would mostly just call PartitionAssignment.replicas() anyways. So overall I don't see much benefit in introducing the type.

What do you think?

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.

There are quite a few places in the codebase that use the replicas field and in practice if we were to use PartitionAssignment all callers would mostly just call PartitionAssignment.replicas() anyways. So overall I don't see much benefit in introducing the type.

Sounds good.

@andrewgrantcflt andrewgrantcflt changed the title KAFKA-14386: Change ReplicaPlacer place method to return a class instead of a list of list of integers KAFKA-14386: Return TopicAssignments from the ReplicaPlacer Dec 1, 2022
@andrewgrantcflt andrewgrantcflt changed the title KAFKA-14386: Return TopicAssignments from the ReplicaPlacer KAFKA-14386: Return TopicAssignment from the ReplicaPlacer Dec 1, 2022
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

@jsancio jsancio merged commit e96e42e into apache:trunk Dec 6, 2022
guozhangwang pushed a commit to guozhangwang/kafka that referenced this pull request Jan 25, 2023
)

This changes the ReplicaPlacer interface to return a class instead of a list of list of integers. There are two reasons for the suggestion. First, as mentioned in the JIRA, it will make the interface, arguably, a bit more readable and understandable by explicitly modeling the idea of topic and partition. Second and more importantly, it makes the interface more extendable in the future. Right now it would be challenging to add more metadata to the response.

Reviewers: José Armando García Sancio <jsancio@apache.org>
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

Comments