package com.DemandCube.KafkaSphere.kafka;


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

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


public class BrokerMetaData {
  public static void main(String[] args){
    List<kafka.javaapi.TopicMetadata> data = MetaDataDump();
    for (kafka.javaapi.TopicMetadata item : data){
      System.out.println("topic: " + item.topic());
      for (kafka.javaapi.PartitionMetadata part: item.partitionsMetadata()){
        String replicas = "";
        String isr = "";
        for (kafka.cluster.Broker replica: part.replicas()){
          replicas += " " + replica.host();
        }
        for (kafka.cluster.Broker replica: part.isr()){
          isr += " " + replica.host();
        }
        System.out.println("    Partition: " + part.partitionId());
        System.out.println("    Leader   : " + part.leader().host());
        System.out.println("    Replicas : [" + replicas + "]");
        System.out.println("    ISR      : [" + isr + "]");
      }
    }
  }

  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;
  };
}

@@ -180,16 +180,17 @@
 List;%0A%0A%0A
+%0A
 public c
@@ -211,16 +211,17 @@
 aData %7B%0A
+%0A
   public
@@ -1262,17 +1262,16 @@
 %3E topics
-2
  = new A
@@ -1352,17 +1352,16 @@
 t(topics
-2
 );%0A    k
@@ -1429,49 +1429,14 @@
     
-List%3Ckafka.javaapi.TopicMetadata%3E data3 =
+return
  res
@@ -1458,26 +1458,8 @@
 ();%0A
-    return data3;%0A
   %7D;

rename - vars