Class NewTopic


  • public class NewTopic
    extends Object
    A new topic to be created
    • Constructor Detail

      • NewTopic

        public NewTopic()
        Constructor
      • NewTopic

        public NewTopic​(String name,
                        int numPartitions,
                        short replicationFactor)
        Constructor
        Parameters:
        name - the topic name
        numPartitions - number of partitions
        replicationFactor - replication factor
      • NewTopic

        public NewTopic​(String name,
                        Map<Integer,​List<Integer>> replicasAssignments)
        Constructor
        Parameters:
        name - the topic name
        replicasAssignments - a map from partition id to replica ids
      • NewTopic

        public NewTopic​(JsonObject json)
        Constructor (from JSON representation)
        Parameters:
        json - JSON representation
    • Method Detail

      • getName

        public String getName()
        Returns:
        the name of the topic to be created
      • setName

        public NewTopic setName​(String name)
        Set the name of the topic to be created
        Parameters:
        name - the name of the topic to be created
        Returns:
        current instance of the class to be fluent
      • getNumPartitions

        public int getNumPartitions()
        Returns:
        the number of partitions for the new topic or -1 if a replica assignment has been specified
      • setNumPartitions

        public NewTopic setNumPartitions​(int numPartitions)
        Set the number of partitions for the new topic or -1 if a replica assignment has been specified
        Parameters:
        numPartitions - the number of partitions for the new topic or -1 if a replica assignment has been specified
        Returns:
        current instance of the class to be fluent
      • getReplicationFactor

        public short getReplicationFactor()
        Returns:
        the replication factor for the new topic or -1 if a replica assignment has been specified
      • setReplicationFactor

        public NewTopic setReplicationFactor​(short replicationFactor)
        Set the replication factor for the new topic or -1 if a replica assignment has been specified
        Parameters:
        replicationFactor - the replication factor for the new topic or -1 if a replica assignment has been specified
        Returns:
        current instance of the class to be fluent
      • getReplicasAssignments

        public Map<Integer,​List<Integer>> getReplicasAssignments()
        Returns:
        a map from partition id to replica ids
      • setReplicasAssignments

        public NewTopic setReplicasAssignments​(Map<Integer,​List<Integer>> replicasAssignments)
        Set a map from partition id to replica ids
        Parameters:
        replicasAssignments - a map from partition id to replica ids
        Returns:
        current instance of the class to be fluent
      • getConfig

        public Map<String,​String> getConfig()
        Returns:
        the configuration for the new topic or null if no configs ever specified
      • setConfig

        public NewTopic setConfig​(Map<String,​String> config)
        Set the configuration for the new topic or null if no configs ever specified
        Parameters:
        config - the configuration for the new topic or null if no configs ever specified
        Returns:
        current instance of the class to be fluent
      • toJson

        public JsonObject toJson()
        Convert object to JSON representation
        Returns:
        JSON representation