zk/controller to get leader node
This commit is contained in:
parent
c46c916ca0
commit
27ba361517
2 changed files with 19 additions and 3 deletions
|
@ -13,3 +13,13 @@
|
|||
:data
|
||||
#(zk/data z (str "/brokers/ids/" %)))
|
||||
(zk/children z "/brokers/ids")))))
|
||||
|
||||
(defn controller
|
||||
"Get leader node"
|
||||
[m]
|
||||
(with-resource [z (zk/connect (get m "zookeeper.connect"))]
|
||||
zk/close
|
||||
(-> (zk/data z "/controller")
|
||||
:data
|
||||
String.
|
||||
Integer/valueOf)))
|
||||
|
|
|
@ -3,9 +3,15 @@
|
|||
clj-kafka.zk
|
||||
[clj-kafka.test.utils :only (with-test-broker)]))
|
||||
|
||||
(given (with-test-broker {:zookeeper-port 2182
|
||||
(def config {:zookeeper-port 2182
|
||||
:kafka-port 9999
|
||||
:topic "test"}
|
||||
:topic "test"})
|
||||
|
||||
(given (with-test-broker config
|
||||
(brokers {"zookeeper.connect" "127.0.0.1:2182"}))
|
||||
(expect count 1
|
||||
first {:host "localhost", :jmx_port -1, :port 9999, :version 1}))
|
||||
|
||||
(given (with-test-broker config
|
||||
(controller {"zookeeper.connect" "127.0.0.1:2182"}))
|
||||
(expect identity 0))
|
||||
|
|
Loading…
Reference in a new issue