// Path: hadoop-mini-clusters-kafka/src/main/java/com/github/sakserv/minicluster/systemtime/LocalSystemTime.java
// public class LocalSystemTime implements Time {
// 
//     @Override
//     public long milliseconds() {
//         return System.currentTimeMillis();
//     }
// 
//     @Override
//     public long nanoseconds() {
//         return System.nanoTime();
//     }
// 
//     @Override
//     public void sleep(long ms) {
//         try {
//             Thread.sleep(ms);
//         } catch (InterruptedException e) {
//             // no stress
//         }
//     }
// 
//     @Override
//     public long hiResClockMs() {
//         return System.currentTimeMillis();
//     }
// 
// }
// 
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
// 
//     // Logger
//     private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
// 
//     public static void deleteFolder(String directory, boolean quietly) {
//         try {
//             Path directoryPath = Paths.get(directory).toAbsolutePath();
//             if (!quietly) {
//                 LOG.info("FILEUTILS: Deleting contents of directory: {}",
//                         directoryPath.toAbsolutePath().toString());
//             }
//             Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
//                 @Override
//                 public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
//                         throws IOException {
//                     Files.delete(file);
//                     if (!quietly) {
//                         LOG.info("Removing file: {}", file.toAbsolutePath().toString());
//                     }
//                     return FileVisitResult.CONTINUE;
//                 }
// 
//                 @Override
//                 public FileVisitResult postVisitDirectory(Path dir, IOException exc)
//                         throws IOException {
//                     Files.delete(dir);
//                     if (!quietly) {
//                         LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
//                     }
//                     return FileVisitResult.CONTINUE;
//                 }
//             });
//         } catch (IOException e) {
//             LOG.error("FILEUTILS: Unable to remove {}", directory);
//         }
//     }
// 
//     public static void deleteFolder(String directory) {
//         deleteFolder(directory, false);
//     }
// 
//     @Override
//     public String toString() {
//         return "FileUtils";
//     }
// }


import scala.collection.Seq;
import java.lang.reflect.Constructor;
import java.util.Properties;
import kafka.metrics.KafkaMetricsReporter;
import kafka.metrics.KafkaMetricsReporter$;
import kafka.utils.VerifiableProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.systemtime.LocalSystemTime;
import com.github.sakserv.minicluster.util.FileUtils;
import kafka.server.KafkaConfig;
import kafka.server.KafkaServer;
import scala.Option;
    }

    @Override
    public void stop() throws Exception {
        stop(true);
    }

    @Override
    public void stop(boolean cleanUp) throws Exception {
        LOG.info("KAFKA: Stopping Kafka on port: {}", kafkaPort);
        kafkaServer.shutdown();

        if (cleanUp) {
            cleanUp();
        }
    }

    @Override
    public void configure() throws Exception {
        kafkaProperties.put("advertised.host.name", kafkaHostname);
        kafkaProperties.put("port", kafkaPort+"");
        kafkaProperties.put("broker.id", kafkaBrokerId+"");
        kafkaProperties.put("log.dir", kafkaTempDir);
        kafkaProperties.put("enable.zookeeper", "true");
        kafkaProperties.put("zookeeper.connect", zookeeperConnectionString);
        kafkaConfig = KafkaConfig.fromProps(kafkaProperties);
    }

    @Override
    public void cleanUp() throws Exception {
// Path: hadoop-mini-clusters-kafka/src/main/java/com/github/sakserv/minicluster/systemtime/LocalSystemTime.java
// public class LocalSystemTime implements Time {
// 
//     @Override
//     public long milliseconds() {
//         return System.currentTimeMillis();
//     }
// 
//     @Override
//     public long nanoseconds() {
//         return System.nanoTime();
//     }
// 
//     @Override
//     public void sleep(long ms) {
//         try {
//             Thread.sleep(ms);
//         } catch (InterruptedException e) {
//             // no stress
//         }
//     }
// 
//     @Override
//     public long hiResClockMs() {
//         return System.currentTimeMillis();
//     }
// 
// }
// 
// Path: hadoop-mini-clusters-common/src/main/java/com/github/sakserv/minicluster/util/FileUtils.java
// public final class FileUtils {
// 
//     // Logger
//     private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(FileUtils.class);
// 
//     public static void deleteFolder(String directory, boolean quietly) {
//         try {
//             Path directoryPath = Paths.get(directory).toAbsolutePath();
//             if (!quietly) {
//                 LOG.info("FILEUTILS: Deleting contents of directory: {}",
//                         directoryPath.toAbsolutePath().toString());
//             }
//             Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {
//                 @Override
//                 public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
//                         throws IOException {
//                     Files.delete(file);
//                     if (!quietly) {
//                         LOG.info("Removing file: {}", file.toAbsolutePath().toString());
//                     }
//                     return FileVisitResult.CONTINUE;
//                 }
// 
//                 @Override
//                 public FileVisitResult postVisitDirectory(Path dir, IOException exc)
//                         throws IOException {
//                     Files.delete(dir);
//                     if (!quietly) {
//                         LOG.info("Removing directory: {}", dir.toAbsolutePath().toString());
//                     }
//                     return FileVisitResult.CONTINUE;
//                 }
//             });
//         } catch (IOException e) {
//             LOG.error("FILEUTILS: Unable to remove {}", directory);
//         }
//     }
// 
//     public static void deleteFolder(String directory) {
//         deleteFolder(directory, false);
//     }
// 
//     @Override
//     public String toString() {
//         return "FileUtils";
//     }
// }


// Path: hadoop-mini-clusters-kafka/src/main/java/com/github/sakserv/minicluster/impl/KafkaLocalBroker.java
import scala.collection.Seq;
import java.lang.reflect.Constructor;
import java.util.Properties;
import kafka.metrics.KafkaMetricsReporter;
import kafka.metrics.KafkaMetricsReporter$;
import kafka.utils.VerifiableProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.sakserv.minicluster.MiniCluster;
import com.github.sakserv.minicluster.systemtime.LocalSystemTime;
import com.github.sakserv.minicluster.util.FileUtils;
import kafka.server.KafkaConfig;
import kafka.server.KafkaServer;
import scala.Option;

    }

    @Override
    public void stop() throws Exception {
        stop(true);
    }

    @Override
    public void stop(boolean cleanUp) throws Exception {
        LOG.info("KAFKA: Stopping Kafka on port: {}", kafkaPort);
        kafkaServer.shutdown();

        if (cleanUp) {
            cleanUp();
        }
    }

    @Override
    public void configure() throws Exception {
        kafkaProperties.put("advertised.host.name", kafkaHostname);
        kafkaProperties.put("port", kafkaPort+"");
        kafkaProperties.put("broker.id", kafkaBrokerId+"");
        kafkaProperties.put("log.dir", kafkaTempDir);
        kafkaProperties.put("enable.zookeeper", "true");
        kafkaProperties.put("zookeeper.connect", zookeeperConnectionString);
        kafkaConfig = KafkaConfig.fromProps(kafkaProperties);
    }

    @Override
    public void cleanUp() throws Exception {
        FileUtils.deleteFolder(kafkaTempDir);