kafka 1.0中的adminutils.addpartition调用似乎已将签名从2版本-0.10.2.0更改为1.0.0,如下所示
Kafka0.10.2.0
/**
* Add partitions to existing topic with optional replica assignment
*
* @param zkUtils Zookeeper utilities
* @param topic Topic for adding partitions to
* @param numPartitions Number of partitions to be set
* @param replicaAssignmentStr Manual replica assignment
* @param checkBrokerAvailable Ignore checking if assigned replica broker is available. Only used for testing
*/
def addPartitions(zkUtils: ZkUtils,
topic: String,
numPartitions: Int = 1,
replicaAssignmentStr: String = "",
checkBrokerAvailable: Boolean = true,
rackAwareMode: RackAwareMode = RackAwareMode.Enforced)
==========================
Kafka1.0.0
/**
* Add partitions to existing topic with optional replica assignment
*
* @param zkUtils Zookeeper utilities
* @param topic Topic for adding partitions to
* @param existingAssignment A map from partition id to its assigned replicas
* @param allBrokers All brokers in the cluster
* @param numPartitions Number of partitions to be set
* @param replicaAssignment Manual replica assignment, or none
* @param validateOnly If true, validate the parameters without actually adding the partitions
* @return the updated replica assignment
*/
def addPartitions(zkUtils: ZkUtils,
topic: String,
existingAssignment: Map[Int, Seq[Int]],
allBrokers: Seq[BrokerMetadata],
numPartitions: Int = 1,
replicaAssignment: Option[Map[Int, Seq[Int]]] = None,
validateOnly: Boolean = false): Map[Int, Seq[Int]] =
关于如何在java中轻松使用新的addpartitions调用而不必指定现有和新的副本分配,有什么想法吗?
3条答案
按热度按时间70gysomp1#
试试这个,对我有用
wn9m85ua2#
@穆尼什-谢谢你的回复。这是对我有用的代码。
bvhaajcl3#
从1.0.0开始,您可以改用kafka客户机库
在java代码中,它看起来像: