kafka-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ewen Cheslack-Postava <e...@confluent.io>
Subject Re: Get replication and partition count of a topic
Date Mon, 12 Jan 2015 18:13:54 GMT
I think the closest thing to what you want is
ZkUtils.getPartitionsForTopics, which returns a list of partition IDs for
each topic you specify.

-Ewen

On Mon, Jan 12, 2015 at 12:55 AM, Manikumar Reddy <kumar@nmsworks.co.in>
wrote:

> Hi,
>
> kafka-topics.sh script can be used to retrieve topic information.
>
> Ex: sh kafka-topics.sh --zookeeper localhost:2181 --describe --topic TOPIC1
>
> You can look into TopicCommand.scala code
>
> https://git-wip-us.apache.org/repos/asf?p=kafka.git;a=blob;f=core/src/main/scala/kafka/admin/TopicCommand.scala;hb=HEAD
>
> On Mon, Jan 12, 2015 at 2:01 PM, Ankit Jain <ankitm.jain@impetus.co.in>
> wrote:
>
> > Hi All,
> >
> >
> > I want to get the replication and partition count of a topic. I tried the
> > following piece of code:
> >
> >
> >         java.util.Set<String> topics = new HashSet<String>();
> >         topics.add("topicName");
> >         Set<TopicMetadata> topicMetadatas =
> > AdminUtils.fetchTopicMetadataFromZk(JavaConversions.asScalaSet(topics),
> > zkClient);
> >         Iterator<TopicMetadata> topicMetadataIterator =
> > topicMetadatas.iterator();
> >
> >         while (topicMetadataIterator.hasNext()) {
> >             topicMetadataIterator.next();
> >             topicMetadataIterator.next().
> >             Iterator<PartitionMetadata> partitionMetadataIterator =
> > topicMetadataIterator.next().partitionsMetadata().iterator();
> >
> >         }
> >
> >
> > But, the above code returning me the metadata of each partition and also
> > replica details of each partition.
> >
> >
> > Is there any simple API available in kafka to get the partition and
> > replica count for a topic.
> >
> >
> > Thanks,
> >
> > Ankit
> >
> >
> > ________________________________
> >
> >
> >
> >
> >
> >
> > NOTE: This message may contain information that is confidential,
> > proprietary, privileged or otherwise protected by law. The message is
> > intended solely for the named addressee. If received in error, please
> > destroy and notify the sender. Any use of this email is prohibited when
> > received in error. Impetus does not represent, warrant and/or guarantee,
> > that the integrity of this communication has been maintained nor that the
> > communication is free of errors, virus, interception or interference.
> >
>



-- 
Thanks,
Ewen

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message