[ 
https://issues.apache.org/jira/browse/KAFKA-5513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16943748#comment-16943748
 ] 

M. Manna commented on KAFKA-5513:
---------------------------------

Simply putting my thought here. The same doc says:


{noformat}
Otherwise, each rack will get at most one replica. In a perfect situation where 
the number of replicas is the same as the number of racks and each rack has the 
same number of brokers, it guarantees that the replica distribution is even 
across brokers and racks.{noformat}

For the exception, it says



{{}}
{noformat}
AdminOperationException If rack information is supplied but it is incomplete, 
or if it is not possible to assign each replica to a unique rack.{noformat}
And the code says:
{noformat}
if (brokerMetadatas.exists(_.rack.isEmpty)){noformat}

The document is clarifying that it will attempt for a uniform distribution. The 
exception will be thrown if that's not achievable for any of the racks. May be 
it's my mistake, but don't feel there is a contradiction here. 





 

 

> Contradicting scalaDoc for AdminUtils.assignReplicasToBrokers
> -------------------------------------------------------------
>
>                 Key: KAFKA-5513
>                 URL: https://issues.apache.org/jira/browse/KAFKA-5513
>             Project: Kafka
>          Issue Type: Improvement
>          Components: core
>            Reporter: Charly Molter
>            Priority: Trivial
>
> The documentation for AdminUtils.assignReplicasToBrokers seems to contradict 
> itself.
> I says in the description: "As the result, if the number of replicas is equal 
> to or greater than the number of racks, it will ensure that each rack will 
> get at least one replica."
> Which means that it is possible to get an assignment where there's multiple 
> replicas in a rack (if there's less racks than the replication factor).
> However, the throws clauses says: " @throws AdminOperationException If rack 
> information is supplied but it is incomplete, or if it is not possible to 
> assign each replica to a unique rack."
> Which seems to be contradicting the first claim.
> In practice it doesn't throw when RF < #racks so the point in the @throws 
> clause should probably be removed.
> https://github.com/apache/kafka/blob/trunk/core/src/main/scala/kafka/admin/AdminUtils.scala#L121-L130



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to