Querying Zookeeper from Python

Install the prerequisites. Below works for Debian-based distros such as Ubuntu/Mint:

apt-get install libzookeeper-mt-dev

Install python libraries:

pip install zkpython pykeeper

Example code below shows making a connection, getting the names of some child nodes and pulling info from each of those child nodes:

import pykeeper
import json

client = pykeeper.ZooKeeper('')

coords = client.get_children('/druid/coordinator/_COORDINATOR')

list_of_coord_addresses = []

for coord in coords:
  zk_coord = client.get('/druid/coordinator/_COORDINATOR/%s' % coord )


Unfortunately I can’t get this installed on CentOS.



Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>