/** Stop the broker. */ public void stop() { log.debug( "Shutting down embedded Kafka broker at {} (with ZK ensemble at {}) ...", brokerList(), zookeeperConnect()); kafka.shutdown(); kafka.awaitShutdown(); log.debug("Removing logs.dir at {} ...", logDir); List<String> logDirs = Collections.singletonList(logDir.getAbsolutePath()); CoreUtils.delete(scala.collection.JavaConversions.asScalaBuffer(logDirs).seq()); tmpFolder.delete(); log.debug( "Shutdown of embedded Kafka broker at {} completed (with ZK ensemble at {}) ...", brokerList(), zookeeperConnect()); }
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); }
public void stopKafkaServer() { kserver.shutdown(); kserver.awaitShutdown(); Utils.rm(kafkalogdir); }