Package org.apache.kafka.clients.admin
Class NewTopic
- java.lang.Object
-
- org.apache.kafka.clients.admin.NewTopic
-
public class NewTopic extends java.lang.Object
A new topic to be created viaAdmin.createTopics(Collection)
.
-
-
Constructor Summary
Constructors Constructor Description NewTopic(java.lang.String name, int numPartitions, short replicationFactor)
A new topic with the specified replication factor and number of partitions.NewTopic(java.lang.String name, java.util.Map<java.lang.Integer,java.util.List<java.lang.Integer>> replicasAssignments)
A new topic with the specified replica assignment configuration.NewTopic(java.lang.String name, java.util.Optional<java.lang.Integer> numPartitions, java.util.Optional<java.lang.Short> replicationFactor)
A new topic that optionally defaultsnumPartitions
andreplicationFactor
to the broker configurations fornum.partitions
anddefault.replication.factor
respectively.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.lang.String>
configs()
The configuration for the new topic or null if no configs ever specified.NewTopic
configs(java.util.Map<java.lang.String,java.lang.String> configs)
Set the configuration to use on the new topic.boolean
equals(java.lang.Object o)
int
hashCode()
java.lang.String
name()
The name of the topic to be created.int
numPartitions()
The number of partitions for the new topic or -1 if a replica assignment has been specified.java.util.Map<java.lang.Integer,java.util.List<java.lang.Integer>>
replicasAssignments()
A map from partition id to replica ids (i.e.short
replicationFactor()
The replication factor for the new topic or -1 if a replica assignment has been specified.java.lang.String
toString()
-
-
-
Constructor Detail
-
NewTopic
public NewTopic(java.lang.String name, int numPartitions, short replicationFactor)
A new topic with the specified replication factor and number of partitions.
-
NewTopic
public NewTopic(java.lang.String name, java.util.Optional<java.lang.Integer> numPartitions, java.util.Optional<java.lang.Short> replicationFactor)
A new topic that optionally defaultsnumPartitions
andreplicationFactor
to the broker configurations fornum.partitions
anddefault.replication.factor
respectively.
-
NewTopic
public NewTopic(java.lang.String name, java.util.Map<java.lang.Integer,java.util.List<java.lang.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 java.lang.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 java.util.Map<java.lang.Integer,java.util.List<java.lang.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(java.util.Map<java.lang.String,java.lang.String> configs)
Set the configuration to use on the new topic.- Parameters:
configs
- The configuration map.- Returns:
- This NewTopic object.
-
configs
public java.util.Map<java.lang.String,java.lang.String> configs()
The configuration for the new topic or null if no configs ever specified.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-