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

@@ -203,18 +203,16 @@
 trics %7B%0A
-  
   public
@@ -245,18 +245,16 @@
  args)%7B%0A
-  
     List
@@ -306,26 +306,24 @@
 Dump();%0A    
-  
 for (kafka.j
@@ -359,26 +359,24 @@
 ata)%7B%0A      
- 
- 
 System.out.p
@@ -405,26 +405,24 @@
 m.topic());%0A
-  
       for (k
@@ -490,26 +490,24 @@
 ))%7B%0A        
-  
 String repli
@@ -512,26 +512,24 @@
 licas = %22%22;%0A
-  
         Stri
@@ -541,34 +541,32 @@
 r = %22%22;%0A        
-  
 for (kafka.clust
@@ -612,18 +612,16 @@
         
-  
 replicas
@@ -646,34 +646,32 @@
 host();%0A        
-  
 %7D%0A          for 
@@ -660,26 +660,24 @@
   %7D%0A        
- 
- 
 for (kafka.c
@@ -722,18 +722,16 @@
         
-  
 isr += %22
@@ -755,30 +755,26 @@
 ();%0A        
-  %7D%0A  
+%7D%0A
         Syst
@@ -829,34 +829,32 @@
 nId());%0A        
-  
 System.out.print
@@ -895,26 +895,24 @@
 ().host());%0A
-  
         Syst
@@ -968,26 +968,24 @@
 %22);%0A        
-  
 System.out.p
@@ -1034,22 +1034,18 @@
     
- 
- 
 %7D%0A
-  
     %7D%0A  
   %7D%0A
@@ -1044,15 +1044,11 @@
 %7D%0A  
- 
- 
 %7D%0A%0A
-  
   pu
@@ -1109,26 +1109,24 @@
 Dump()%7B%0A    
-  
 kafka.javaap
@@ -1230,26 +1230,24 @@
 data%22);%0A    
-  
 List%3CString%3E
@@ -1278,26 +1278,24 @@
 %3CString%3E();%0A
-  
     TopicMet
@@ -1352,18 +1352,16 @@
 2);%0A    
- 
- 
 kafka.ja
@@ -1414,18 +1414,16 @@
 d(req);%0A
-  
     List
@@ -1486,18 +1486,16 @@
 ();%0A    
- 
- 
 return d
@@ -1500,17 +1500,15 @@
  data3;%0A
-  
   %7D;%0A%7D%0A

refactor - consistent indentation