Reputation: 95
I am creating a kafka topic using pykafka python library api using the following code.
from pykafka import KafkaClient
client = KafkaClient(hosts="127.0.0.1:9092")
topic = client.topics[topic_name]
producer = topic.get_producer(sync=True)
producer.produce('message'))
Here the topic is created with only 1 partition as default.How can i assign more than one partition to the topic using pykafka something like
topic.number_of_partitons=3
?
Upvotes: 2
Views: 1178
Reputation: 6217
You're noticing pykafka's support for topic autocreation. When accessing a topic that doesn't already exist through the client.topics
dict, the topic is automatically created with default settings defined in the broker configuration.
Pykafka also supports CLI integration with the topic creation and deletion APIs in Kafka 0.10.1. See the source code for information on how to use it. Here's an example:
python pykafka/cli/kafka_tools.py --broker_version 0.10.1 create_topic --num_partitions 3 --rpelication_factor 2 cli_testtopic
Upvotes: 0