From 4ec482eeebafffb9879de55829fc183c46c456d1 Mon Sep 17 00:00:00 2001 From: Chia-Ping Tsai Date: Sat, 25 Jul 2020 19:13:21 +0800 Subject: [PATCH] MINOR: remove NewTopic#NO_PARTITIONS and NewTopic#NO_REPLICATION_FACTOR as they are duplicate to CreateTopicsRequest#NO_NUM_PARTITIONS and CreateTopicsRequest#NO_REPLICATION_FACTOR --- .../org/apache/kafka/clients/admin/NewTopic.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/clients/src/main/java/org/apache/kafka/clients/admin/NewTopic.java b/clients/src/main/java/org/apache/kafka/clients/admin/NewTopic.java index 84e0e59a73124..2f335d02f2f2b 100644 --- a/clients/src/main/java/org/apache/kafka/clients/admin/NewTopic.java +++ b/clients/src/main/java/org/apache/kafka/clients/admin/NewTopic.java @@ -21,6 +21,7 @@ import org.apache.kafka.common.message.CreateTopicsRequestData.CreatableReplicaAssignment; import org.apache.kafka.common.message.CreateTopicsRequestData.CreatableTopic; import org.apache.kafka.common.message.CreateTopicsRequestData.CreateableTopicConfig; +import org.apache.kafka.common.requests.CreateTopicsRequest; import java.util.Collection; import java.util.Collections; @@ -34,9 +35,6 @@ */ public class NewTopic { - private static final int NO_PARTITIONS = -1; - private static final short NO_REPLICATION_FACTOR = -1; - private final String name; private final Optional numPartitions; private final Optional replicationFactor; @@ -87,14 +85,14 @@ public String name() { * The number of partitions for the new topic or -1 if a replica assignment has been specified. */ public int numPartitions() { - return numPartitions.orElse(NO_PARTITIONS); + return numPartitions.orElse(CreateTopicsRequest.NO_NUM_PARTITIONS); } /** * The replication factor for the new topic or -1 if a replica assignment has been specified. */ public short replicationFactor() { - return replicationFactor.orElse(NO_REPLICATION_FACTOR); + return replicationFactor.orElse(CreateTopicsRequest.NO_REPLICATION_FACTOR); } /** @@ -126,8 +124,8 @@ public Map configs() { CreatableTopic convertToCreatableTopic() { CreatableTopic creatableTopic = new CreatableTopic(). setName(name). - setNumPartitions(numPartitions.orElse(NO_PARTITIONS)). - setReplicationFactor(replicationFactor.orElse(NO_REPLICATION_FACTOR)); + setNumPartitions(numPartitions.orElse(CreateTopicsRequest.NO_NUM_PARTITIONS)). + setReplicationFactor(replicationFactor.orElse(CreateTopicsRequest.NO_REPLICATION_FACTOR)); if (replicasAssignments != null) { for (Entry> entry : replicasAssignments.entrySet()) { creatableTopic.assignments().add(