Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content
/ zk Public

simple zookeeper c++ bindings, zookeeper service monitor implemented via zookeeper c++ bindings.

Notifications You must be signed in to change notification settings

satanson/zk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple zookeeper c++ bindings, zookeeper service monitor implemented via zookeeper c++ bindings. https://github.com/satanson/zk

Zk is built on conditions as follows:

  1. zookeeper 3.4.3 and 3.4.8
  2. g++ 4.8.4 (c++11 option enabled)

I don't build zk on other versions of zookeeper and g++.

ZK can be grasped in fews steps!

  1. download zookeeper-3.4.8 and build c bindings of zookeeper

     $ wget  https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.8/zookeeper-3.4.8.tar.gz
     $ tar xzvf zookeeper-3.4.8.tar.gz
     $ cd zookeeper-3.4.8/src/c
     $ ./configure && make && sudo make install
    
  2. build zk demos

     $ ./build.sh
     $ ./zk_test -help
     $ ./zk_test 172.17.0.2:2181 /foobar
    
     $ ./build_zksm.sh
     $ ./zksm_test -help
     $ ./zksm_test 172.17.0.2:2181 /foobar
    

A standalone zookeeper instance or a zookeeper cluster should be started when trying zk_test and zksm_test. If you familiar with docker, image jplock/zookeeper can be played with for testing.

API manual You can learn how to use zk from demos(zk_test.cpp, zksm_test.cpp), which is quit easy!

  1. Zookeeper ctor: establish connection to Zookeeper cluster and create a session.
ZooKeeper(string const& connStr, int sessionTimeout,shared_ptr<Watcher> watcher)

override Watcher's virtual function void process(WatchedEvent &const)

  1. zk_create: create znode.
string zk_create(string const& path,string const& data,CreateMode createMode)
  1. zk_delete: delete znode.
void zk_delete(string const& path,int version)
  1. zk_exists: test if znode exists.
bool zk_exists(string const& path, bool watch)
  1. zk_getData: fetch data from znode.
string zk_getData(string const& path, bool watch)
  1. zk_setData: store data into znode.
void zk_setData(string const& path, string const& data, int version)
  1. zk_getChildren: get znode's children.
list<string> zk_getChildren(string const& path,bool watch)

About

simple zookeeper c++ bindings, zookeeper service monitor implemented via zookeeper c++ bindings.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published