Refactor zookeeper driver

This patch tries to refactor zookeeper driver.

It have changed so much code that it's difficult to
explain how it work in detail.

There were several problems in the old zookeeper driver:
 1. Each zookeeper message contains whole member list,
    it make network become heavy and slow.
 2. Before sending each message, get_nodes function was call.
    We used this function to get the number of members by comparing
    each znode in /sheepdog/queue. This function will become
    more and more slower as znodes increasing in /sheepdog/queue.
 3. The processing method of LEAVE EVENT is too lengthy. When a sheep
    droped from the cluster, zookeeper will remove the corresponding
    znodes in /sheepdog/member automatically, and each sheep will be
    notified by the registered watcher fcuntion. Normally, sheep should
    process this leave event when it got it, but it didn't, it created
    a new leave event message and send it to /sheepdog/queue, untill all
    sheep received this new message again.
 4. There are so many unnecessary zookeeper locks. These locks greatly
    reduce zookeeper driver's performance.

This patch tries to fix all problems memtioned above:
 1. Reduce message size, remove member list from message content
    and save it in two places:
    a) In /sheepdog/member. When a sheep joins into cluster, it put it's
       information into /sheepdog/member/<node_to_str(myself)>, and get
       other sheep's information from there.
    b) In eache sheep's private memory. Each sheep will maintain an array
       to contain the newest member list so that it can access this content
       as much as quickly, and needn't to call get_nodes function when it send
       a new message.
 2. Optimize the processing method of LEAVE EVENT. Now, sheep will process
    leave event once it received it.
 3. Remove unncecessary zookeeper locks.

Signed-off-by: Yunkai Zhang <qiushu.zyk@taobao.com>
Optimize the size of buffer send to zookeeper

We send the whole buf[MAX_EVENT_BUF_SIZE] to zookeeper regardless the
real content is so small.

Now, we only send the real content in the buffer, not waste anymore.

Signed-off-by: Yunkai Zhang <qiushu.zyk@taobao.com>
try to recover previous zookeeper session when sheep start

Signed-off-by: Yunkai Zhang <qiushu.zyk@taobao.com>
retry again when zoo_* api return ZCONNECTIONLOSS/ZOPERATIONTIMEOUT error

Signed-off-by: Yunkai Zhang <qiushu.zyk@taobao.com>
Fix two bug:

 1. Change pthread lock in zk_dispatch/zk_block so that
    it will not block IO request between sheep.
 2. If one node pointed to by queue_pos was send by leaver,
    and it have blocked whole cluster, we should ignore it.

Signed-off-by: Yunkai Zhang <qiushu.zyk@taobao.com>
Use atomic builtins to replace pthread mutex locks

There were two pthread mutex locks in zookeeper dirver:
 1. pthread mutex lock in zk_dispatch/zk_lock, this lock was used to
    prevent zk_lock poping data before zk_dispatch have pushed it.
 2. pthread mutex lock in zk_queue_pop/add_event, this lock was used to
    protected leave event list.

This patch use GNU atomic builtins(__sync_xxx) to replace these two
pthread mutex locks. It makes zookeeper driver more lighter and
and faster.

Signed-off-by: Yunkai Zhang <qiushu.zyk@taobao.com>