You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by srikannan <sr...@yahoo.com> on 2015/03/25 12:12:24 UTC

Re: Get replication and partition count of a topic

Ewen Cheslack-Postava <ew...@...> writes:

Im also searching the shortest way to find topic partition count, so that the 
initialization code in the thread pool can set up the right number of threads.

so far i found below is the shortest way. 


	public static void main(String[] args){
		
		int sessionTimeoutMs = 10000;
		int connectionTimeoutMs = 10000;
		ZkClient zkClient = new ZkClient("localhost:2181", 
sessionTimeoutMs, connectionTimeoutMs);

		TopicMetadata metaData =  
AdminUtils.fetchTopicMetadataFromZk("forthtopic",zkClient);
		System.out.println(metaData.partitionsMetadata().size());

	}

kindly reply if you find any other shortest way.