public static Map < String , List < String > > getConsumersPerTopic ( ZkClient zkClient , String group ) { ZkGroupDirs dirs = new ZkGroupDirs ( group ) ; List < String > consumers = getChildrenParentMayNotExist ( zkClient , dirs . consumerRegistryDir ) ; // Map < String , List < String > > consumersPerTopicMap = new HashMap < String , List < String > > ( ) ; for ( String consumer : consumers ) { TopicCount topicCount = getTopicCount ( zkClient , group , consumer ) ; for ( Map . Entry < String , Set < String > > e : topicCount . getConsumerThreadIdsPerTopic ( ) . entrySet ( ) ) { final String topic = e . getKey ( ) ; for ( String consumerThreadId : e . getValue ( ) ) { List < String > list = consumersPerTopicMap . get ( topic ) ; if ( list == null ) { list = new ArrayList < String > ( ) ; consumersPerTopicMap . put ( topic , list ) ; } // list . add ( consumerThreadId ) ; } } } // for ( Map . Entry < String , List < String > > e : consumersPerTopicMap . entrySet ( ) ) { Collections . sort ( e . getValue ( ) ) ; } return consumersPerTopicMap ; }
get all consumers for the group