Package org.apache.kafka.clients.admin
Class NewTopic
- java.lang.Object
-
- org.apache.kafka.clients.admin.NewTopic
-
public class NewTopic extends Object
A new topic to be created viaAdmin.createTopics(Collection).
-
-
Constructor Summary
Constructors Constructor Description NewTopic(String name, int numPartitions, short replicationFactor)A new topic with the specified replication factor and number of partitions.NewTopic(String name, Map<Integer,List<Integer>> replicasAssignments)A new topic with the specified replica assignment configuration.NewTopic(String name, Optional<Integer> numPartitions, Optional<Short> replicationFactor)A new topic that optionally defaultsnumPartitionsandreplicationFactorto the broker configurations fornum.partitionsanddefault.replication.factorrespectively.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,String>configs()The configuration for the new topic or null if no configs ever specified.NewTopicconfigs(Map<String,String> configs)Set the configuration to use on the new topic.booleanequals(Object o)inthashCode()Stringname()The name of the topic to be created.intnumPartitions()The number of partitions for the new topic or -1 if a replica assignment has been specified.Map<Integer,List<Integer>>replicasAssignments()A map from partition id to replica ids (i.e.shortreplicationFactor()The replication factor for the new topic or -1 if a replica assignment has been specified.StringtoString()
-
-
-
Constructor Detail
-
NewTopic
public NewTopic(String name, int numPartitions, short replicationFactor)
A new topic with the specified replication factor and number of partitions.
-
NewTopic
public NewTopic(String name, Optional<Integer> numPartitions, Optional<Short> replicationFactor)
A new topic that optionally defaultsnumPartitionsandreplicationFactorto the broker configurations fornum.partitionsanddefault.replication.factorrespectively.
-
NewTopic
public NewTopic(String name, Map<Integer,List<Integer>> replicasAssignments)
A new topic with the specified replica assignment configuration.- Parameters:
name- the topic name.replicasAssignments- a map from partition id to replica ids (i.e. broker ids). Although not enforced, it is generally a good idea for all partitions to have the same number of replicas.
-
-
Method Detail
-
name
public String name()
The name of the topic to be created.
-
numPartitions
public int numPartitions()
The number of partitions for the new topic or -1 if a replica assignment has been specified.
-
replicationFactor
public short replicationFactor()
The replication factor for the new topic or -1 if a replica assignment has been specified.
-
replicasAssignments
public Map<Integer,List<Integer>> replicasAssignments()
A map from partition id to replica ids (i.e. broker ids) or null if the number of partitions and replication factor have been specified instead.
-
configs
public NewTopic configs(Map<String,String> configs)
Set the configuration to use on the new topic.- Parameters:
configs- The configuration map.- Returns:
- This NewTopic object.
-
configs
public Map<String,String> configs()
The configuration for the new topic or null if no configs ever specified.
-
-