无法使用Sarama库更新Kafka中的分区

huangapple go评论125阅读模式
英文:

Unable to Update partitions in kafka using Sarama Library

问题

我已经尝试使用Sarama Go库来更新Kafka中的分区,有人可以建议这个库是否支持这个功能吗?

  1. func UpdateTopic_part(topicDetails *TopicInfo, con kafka.ClusterAdmin) {
  2. fmt.Println("update Partitions")
  3. topicAssignment := make([][]int32, 0, 2)
  4. err := con.AlterPartitionReassignments(topicDetails.Topic_name, topicAssignment)
  5. if err != nil {
  6. log.Error(err)
  7. }
  8. }

我可以帮你翻译这段代码,但请注意,我只会翻译代码部分,不会回答关于翻译的问题。

英文:

I have tried to use the Sarama Go library to update the partitions in kafka, Can anybody suggest whether this library support this feature?

  1. func UpdateTopic_part(topicDetails *TopicInfo, con kafka.ClusterAdmin) {
  2. fmt.Println("update Partitions")
  3. topicAssignment := make([][]int32, 0, 2)
  4. err := con.AlterPartitionReassignments(topicDetails.Topic_name, topicAssignment)
  5. if err != nil {
  6. log.Error(err)
  7. }
  8. }

答案1

得分: 1

如果你想要“更新分区”(注意:Kafka中的分区无法减少)现有主题,你可以使用CreatePartitions

AlterPartitionReassignments主要用于移动现有的分区。

英文:

You want CreatePartitions if you want to "update partitions" (note: partitions cannot be reduced in Kafka) of an existing topic.

AlterPartitionReassignments is primarily to be used for moving existing partitions around.

huangapple
  • 本文由 发表于 2022年9月21日 01:08:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/73790310.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定