KAFKA-18311: Enforcing copartitioned topics (4/N)#18397
KAFKA-18311: Enforcing copartitioned topics (4/N)#18397lucasbru merged 3 commits intoapache:trunkfrom
Conversation
|
PTAL @aliehsaeedii |
a3a1fc8 to
6d49d28
Compare
cadonna
left a comment
There was a problem hiding this comment.
Thanks for the PR!
Here my comment!
| * @throws TopicConfigurationException If source topics are missing, or there are topics in copartitionTopics that are not copartitioned | ||
| * according to topicPartitionCountProvider are not co-partitioned. |
There was a problem hiding this comment.
Something is wrong with this sentence. Should it be:
If source topics are missing, or there are topics in {@code copartitionTopics} that are not co-partitioned according to topicPartitionCountProvider.
?
| * Enforces the number of partitions for copartitioned topics. | ||
| * | ||
| * @param copartitionedTopics The set of copartitioned topics (external source topics and repartition topics). | ||
| * @param fixedRepartitionTopics The set of repartition topics whose partition count is fixed by the topology. |
There was a problem hiding this comment.
With by the topology you mean user-specifed, right? If yes, maybe you should mention that they are user-specified.
There was a problem hiding this comment.
I don't want too restrictive - the number of partitions is fixed in the topology, and on the broker we don't necessarily know why it was fixed. But I think right now you are right, this only happens when the user explicitly specifies it in repartition, so I updated it this way:
The set of repartition topics whose partition count is fixed by the topology sent by the client (in particular, when the user uses `repartition` in the DSL).
| if (topicPartitionCount.isEmpty()) { | ||
| final String str = String.format("Following topics are missing: [%s]", topic); | ||
| log.error(str); | ||
| throw TopicConfigurationException.missingSourceTopics(str); |
There was a problem hiding this comment.
Do you think, we are able to verify missing source topics in one location instead of spreading the verification between co-partition enforcer and repartition topic configuration?
There was a problem hiding this comment.
Since we always call RepartitionTopics before calling this class in practice, this can never happen. But that it cannot happen, depends on how this class is used. I think it is still good style for this "unit" to have well-defined behavior if it is used in a context where a source topic is missing. Would you propose that this class just implicitly depends on the validation happening somewhere else?
| assertEquals(Map.of(repartitionTopic, 2), result); | ||
| } | ||
|
|
||
|
|
| Utils.mkMap(Utils.mkEntry(repartitionTopic1, 10), | ||
| Utils.mkEntry(repartitionTopic2, 5)) |
There was a problem hiding this comment.
Could you also use Map.of() here?
| } | ||
|
|
||
| @Test | ||
| public void shouldNotThrowAnExceptionWhenTopicInfosWithEnforcedNumOfPartitionsAreValid() { |
There was a problem hiding this comment.
nit:
Could you try to formulate this in a positive way?
| } | ||
|
|
||
| @Test | ||
| public void shouldNotThrowAnExceptionWhenNumberOfPartitionsOfNonRepartitionTopicAndRepartitionTopicWithEnforcedNumOfPartitionsMatch() { |
There was a problem hiding this comment.
Also here could you please try to formulate this positively?
| final String firstSourceTopic = "first"; | ||
| final String secondSourceTopic = "second"; |
There was a problem hiding this comment.
nit:
If you specify all this variables in all tests as constants with sensible names, it would reduce a bit the noise within the tests.
There was a problem hiding this comment.
Interesting that you think this is better. Done
|
Ready for re-review @cadonna |
|
@cadonna As discussed offline, I can add a third validation for source topics in a different place and throw IllegalStateException here. I will do these changes as I rebase |
A simplified port of "CopartitionedTopicsEnforcer" from the client-side to the group coordinator. This class is responsible for enforcing the number of partitions in copartitioned topics. For each copartition group, it checks whether the number of partitions for all topics in the group is the same, and enforces the right number of partitions for repartition topics whose number of partitions is not enforced by the topology. Compared to the client-side version, the implementation uses immutable data structures, and returns the computed number of partitions instead of modifying mutable data structures and calling the admin client. Reviewers: Bruno Cadonna <cadonna@apache.org>
…emove-metadata-version-methods-for-versions-older-than-3.0 * apache-github/trunk: KAFKA-18340: Change Dockerfile to use log4j2 yaml instead log4j properties (apache#18378) MINOR: fix flaky RemoteLogManagerTest#testStopPartitionsWithDeletion (apache#18474) KAFKA-18311: Enforcing copartitioned topics (4/N) (apache#18397) KAFKA-18308; Update CoordinatorSerde (apache#18455) KAFKA-18440: Convert AuthorizationException to fatal error in AdminClient (apache#18435) KAFKA-17671: Create better documentation for transactions (apache#17454) KAFKA-18304; Introduce json converter generator (apache#18458) MINOR: Clean up classic group tests (apache#18473) KAFKA-18399 Remove ZooKeeper from KafkaApis (2/N): CONTROLLED_SHUTDOWN and ENVELOPE (apache#18422) MINOR: improve StreamThread periodic processing log (apache#18430)
A simplified port of "CopartitionedTopicsEnforcer" from the client-side to the group coordinator. This class is responsible for enforcing the number of partitions in copartitioned topics. For each copartition group, it checks whether the number of partitions for all topics in the group is the same, and enforces the right number of partitions for repartition topics whose number of partitions is not enforced by the topology. Compared to the client-side version, the implementation uses immutable data structures, and returns the computed number of partitions instead of modifying mutable data structures and calling the admin client. Reviewers: Bruno Cadonna <cadonna@apache.org>
A simplified port of "CopartitionedTopicsEnforcer" from the client-side to the group coordinator. This class is responsible for enforcing the number of partitions in copartitioned topics. For each copartition group, it checks whether the number of partitions for all topics in the group is the same, and enforces the right number of partitions for repartition topics whose number of partitions is not enforced by the topology. Compared to the client-side version, the implementation uses immutable data structures, and returns the computed number of partitions instead of modifying mutable data structures and calling the admin client. Reviewers: Bruno Cadonna <cadonna@apache.org>
A simplified port of "CopartitionedTopicsEnforcer" from the client-side to the group coordinator.
This class is responsible for enforcing the number of partitions in copartitioned topics. For each copartition group, it checks whether the number of partitions for all topics in the group is the same, and enforces the right number of partitions for repartition topics whose number of partitions is not enforced by the topology.
Compared to the client-side version, the implementation uses immutable data structures, and returns the computed number of partitions instead of modifying mutable data structures and calling the admin client.
Committer Checklist (excluded from commit message)