def desc_topic(client, args):
"""Print detailed information about a topic.
:param client: KafkaClient connected to the cluster.
:type client: :class:`pykafka.KafkaClient`
:param topic: Name of the topic.
:type topic: :class:`str`
"""
# Don't auto-create topics.
if args.topic not in client.topics:
raise ValueError('Topic {} does not exist.'.format(args.topic))
topic = client.topics[args.topic]
print('Topic: {}'.format(topic.name))
print('Partitions: {}'.format(len(topic.partitions)))
print('Replicas: {}'.format(len(topic.partitions.values()[0].replicas)))
print(tabulate.tabulate(
[(p.id, p.leader.id, [r.id for r in p.replicas], [r.id for r in p.isr])
for p in topic.partitions.values()],
headers=['Partition', 'Leader', 'Replicas', 'ISR'],
numalign='center',
))
评论列表
文章目录