Upgraded kafka to 0.8.1.1 and zkclient to 0.4

This commit is contained in:
Graham Berks 2014-11-18 21:26:17 +00:00
parent 678caa5b2c
commit 1a695580a4
4 changed files with 34 additions and 28 deletions

2
.gitignore vendored
View file

@ -12,3 +12,5 @@ autodoc/**
/tmp
/logs
.nrepl-port
.idea
*.iml

View file

@ -5,9 +5,9 @@
[org.clojure/data.json "0.2.2"]
;; kafka and its related deps
[org.apache.kafka/kafka_2.10 "0.8.0"]
[org.apache.kafka/kafka_2.10 "0.8.1.1"]
[org.apache.zookeeper/zookeeper "3.3.4"]
[com.101tec/zkclient "0.3"]
[com.101tec/zkclient "0.4"]
[com.yammer.metrics/metrics-core "2.2.0"]
[org.scala-lang/scala-library "2.10.1"]
[net.sf.jopt-simple/jopt-simple "3.2"]]

View file

@ -1,12 +1,14 @@
(ns clj-kafka.test.utils
(:import [kafka.server KafkaConfig KafkaServer]
[kafka.admin CreateTopicCommand]
[kafka.common TopicAndPartition]
(:import
[kafka.admin AdminUtils]
[kafka.server KafkaConfig KafkaServer]
[java.net InetSocketAddress]
[org.apache.zookeeper.server ZooKeeperServer NIOServerCnxn$Factory]
[org.apache.commons.io FileUtils]
[org.I0Itec.zkclient ZkClient]
[org.I0Itec.zkclient.serialize ZkSerializer])
[org.I0Itec.zkclient.serialize ZkSerializer]
[kafka.utils Time]
(java.util Properties))
(:use [clojure.java.io :only (file)]
[clj-kafka.core :only (as-properties)]))
@ -14,7 +16,7 @@
[& parts]
(.getPath (apply file (System/getProperty "java.io.tmpdir") "clj-kafka" parts)))
(def system-time (proxy [kafka.utils.Time] []
(def system-time (proxy [Time] []
(milliseconds [] (System/currentTimeMillis))
(nanoseconds [] (System/nanoTime))
(sleep [ms] (Thread/sleep ms))))
@ -41,15 +43,16 @@
(.startup zk))))
(defn wait-until-initialised
[kafka-server topic]
(let [topic-and-partition (TopicAndPartition. topic 0)]
(while (not (.. kafka-server apis leaderCache keySet (contains topic-and-partition)))
[^KafkaServer kafka-server topic]
(let [apis (.apis kafka-server)
cache (.metadataCache apis)]
(while (not (.containsTopicAndPartition cache topic 0))
(Thread/sleep 500))))
(defn create-topic
[zk-client topic & {:keys [partitions replicas]
:or {partitions 1 replicas 1}}]
(CreateTopicCommand/createTopic zk-client topic partitions replicas ""))
(AdminUtils/createTopic zk-client topic partitions replicas (Properties.)))
(def string-serializer (proxy [ZkSerializer] []
(serialize [data] (.getBytes data "UTF-8"))

View file

@ -8,6 +8,7 @@
:topic "test"})
(def zk-connect {"zookeeper.connect" "127.0.0.1:2182"})
(given (with-test-broker config
(brokers zk-connect))
(expect count 1))