Saturday, September 06, 2014

Clojure and Zookeeper

Add [zookeeper-clj "0.9.1"] to dependencies

lein repl
(require '[zookeeper :as zk])
(.getChildren client "/" false) ;; watcher=false
#<ArrayList [hbase-unsecure, storm, zookeeper]>

(def ZK_HOSTS "127.0.0.1:2181,node1,node2,node3)
(def ZK_ROOT "/twitter-demo")(def client (zk/connect ZOOKEEPER_HOSTS :watcher (fn [event] (println event))))
(zk/create client ZK_ROOT :persistent? false)
(def version (:version (zk/exists client ZK_ROOT)))
(zk/create client ZK_ROOT :data (.getBytes "123143kdjkds") :persistent? false)


No comments: