package com.DemandCube.KafkaSphere.kafka;


import kafka.javaapi.TopicMetadataRequest;
import kafka.javaapi.consumer.SimpleConsumer;

import java.util.ArrayList;
import java.util.List;


public class metrics {
    public static void main(String[] args){
      List<kafka.javaapi.TopicMetadata> data = MetaDataDump();
      for (kafka.javaapi.TopicMetadata item : data){
        System.out.println("topic: " + item.topic());
      }
    }

    public static List<kafka.javaapi.TopicMetadata> MetaDataDump(){
      kafka.javaapi.consumer.SimpleConsumer consumer = new SimpleConsumer("0.0.0.0", 9092, 100000, 64 * 1024, "metadata");
      List<String> topics2 = new ArrayList<String>();
      TopicMetadataRequest req = new TopicMetadataRequest(topics2);
      kafka.javaapi.TopicMetadataResponse res = consumer.send(req);
      List<kafka.javaapi.TopicMetadata> data3 = res.topicsMetadata();
      return data3;
    };
}

@@ -417,16 +417,667 @@
 pic());%0A
+        for (kafka.javaapi.PartitionMetadata part: item.partitionsMetadata())%7B%0A          String replicas = %22%22;%0A          String isr = %22%22;%0A          for (kafka.cluster.Broker replica: part.replicas())%7B%0A            replicas += %22 %22 + replica.host();%0A          %7D%0A          for (kafka.cluster.Broker replica: part.isr())%7B%0A            isr += %22 %22 + replica.host();%0A          %7D%0A          System.out.println(%22    Partition: %22 + part.partitionId());%0A          System.out.println(%22    Leader   : %22 + part.leader().host());%0A          System.out.println(%22    Replicas : %5B%22 + replicas + %22%5D%22);%0A          System.out.println(%22    ISR      : %5B%22 + isr + %22%5D%22);%0A        %7D%0A
       %7D%0A

add - broker topic and partition metadump