continue; int replicationFactor = newTopic.replicationFactor(); List<Node> replicas = new ArrayList<>(replicationFactor); for (int i = 0; i < replicationFactor; ++i) {
/** * Add topics to the existing broker(s). * The broker(s) must be running. * @param topics the topics. * @since 2.2 */ public void addTopics(NewTopic... topics) { Assert.notNull(this.zookeeper, "Broker must be started before this method can be called"); for (NewTopic topic : topics) { Assert.isTrue(this.topics.add(topic.name()), () -> "topic already exists: " + topic); Assert.isTrue(topic.replicationFactor() <= this.count && (topic.replicasAssignments() == null || topic.replicasAssignments().size() <= this.count), () -> "Embedded kafka does not support the requested replication factor: " + topic); } doWithAdmin(admin -> createTopics(admin, Arrays.asList(topics))); }
/** * Add topics to the existing broker(s). * The broker(s) must be running. * @param topics the topics. * @since 2.2 */ public void addTopics(NewTopic... topics) { Assert.notNull(this.zookeeper, "Broker must be started before this method can be called"); for (NewTopic topic : topics) { Assert.isTrue(this.topics.add(topic.name()), () -> "topic already exists: " + topic); Assert.isTrue(topic.replicationFactor() <= this.count && (topic.replicasAssignments() == null || topic.replicasAssignments().size() <= this.count), () -> "Embedded kafka does not support the requested replication factor: " + topic); } doWithAdmin(admin -> createTopics(admin, Arrays.asList(topics))); }