@After
  public void tearDown() throws Exception {
    if (restApp != null) {
      restApp.stop();
    }

    if (servers != null) {
      for (KafkaServer server : servers) {
        server.shutdown();
      }

      // Remove any persistent data
      for (KafkaServer server : servers) {
        for (String logDir : JavaConversions.asJavaCollection(server.config().logDirs())) {
          CoreUtils.rm(logDir);
        }
      }
    }

    if (zkUtils != null) {
      zkUtils.close();
    }

    if (zookeeper != null) {
      zookeeper.shutdown();
    }
  }
Esempio n. 2
0
 public void shutdown() throws Exception {
   log.info("Shutting down Kafka server");
   // https://issues.apache.org/jira/browse/KAFKA-1887
   server.kafkaController().shutdown();
   server.shutdown();
   server.awaitShutdown();
   final Seq<String> logDirs = server.config().logDirs();
   for (String f : JavaConversions.asJavaCollection(logDirs)) {
     try {
       deleteRecursively(new File(f));
     } catch (IOException e) {
       log.warn("Cannot delete file: " + f, e.getMessage());
     }
   }
   ;
   zookeeper.shutdown();
   awaitCond(aVoid -> !zookeeper.isRunning(), 2000, 100);
   log.info("ZooKeeper server shut down.");
   Thread.sleep(2000);
 }
 /**
  * This broker's `metadata.broker.list` value. Example: `127.0.0.1:9092`.
  *
  * <p>You can use this to tell Kafka producers and consumers how to connect to this instance.
  */
 public String brokerList() {
   return kafka.config().hostName() + ":" + kafka.boundPort(SecurityProtocol.PLAINTEXT);
 }