<commit_before>package com.DemandCube.KafkaSphere.kafka;


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

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


public class BrokerMetaData {
  public static HashMap<String, HashMap<String, String>> brokerDetails = new HashMap<>();

  public static void main(String[] args){
    List<kafka.javaapi.TopicMetadata> data = MetaDataDump();
    HashMap<String, String> topicDetails = new HashMap<>();
    String topic;

    for (kafka.javaapi.TopicMetadata item : data){
      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();
        }
        topicDetails.put("partition", String.valueOf(part.partitionId()) );
        topicDetails.put("leader", part.leader().host() );
        topicDetails.put("replicas", "[" + replicas + "]");
        topicDetails.put("isr", "[" + isr + "]");
      }

      brokerDetails.put(topic, topicDetails);
      System.out.println(brokerDetails);
    }
  }

  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> topics = new ArrayList<String>();
    TopicMetadataRequest req = new TopicMetadataRequest(topics);
    kafka.javaapi.TopicMetadataResponse res = consumer.send(req);
    return res.topicsMetadata();
  };
}<commit_msg>refactor - changed main to getDetails<commit_after>package com.DemandCube.KafkaSphere.kafka;


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

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


public class BrokerMetaData {

  public static HashMap<String, HashMap<String, String>> getDetails(){
    HashMap<String, HashMap<String, String>> brokerDetails = new HashMap<>();
    List<kafka.javaapi.TopicMetadata> data = MetaDataDump();
    HashMap<String, String> topicDetails = new HashMap<>();
    String topic;

    for (kafka.javaapi.TopicMetadata item : data){
      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();
        }
        topicDetails.put("partition", String.valueOf(part.partitionId()) );
        topicDetails.put("leader", part.leader().host() );
        topicDetails.put("replicas", "[" + replicas + "]");
        topicDetails.put("isr", "[" + isr + "]");
      }

      brokerDetails.put(topic, topicDetails);
    }
    return brokerDetails;
  }

  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> topics = new ArrayList<String>();
    TopicMetadataRequest req = new TopicMetadataRequest(topics);
    kafka.javaapi.TopicMetadataResponse res = consumer.send(req);
    return res.topicsMetadata();
  };
}
{'fraction_non_alphanumeric': 0.14109902690326273, 'fraction_numerical': 0.011448196908986834, 'mean_word_length': 3.5448634590377113, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2561327', 'n_tokens_mistral': 1088, 'n_tokens_neox': 1031, 'n_words': 206}