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 <ku...@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.j...@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

Reply via email to