zookeeper: fixed concurrent startup error

Current implementation of zookeeper driver has a risk when multiple sheep
start up concurrently.

Consider the following situation:
1. There is a 3 node cluster: sheep1, sheep2, sheep3.
2. Both sheep2 and sheep3 leave cluster.
3. Both sheep2 and sheep3 start up after previous zookeeper session timeout.
4. Sheep1 leaves the cluster before sheep2 and sheep3 receiving join requests
   from zookeeper.
5. When sheep2 and sheep3 receive the join requests, both of them assume they
   are master due to zk_member_empty() returns true.

The new implementation is following the standard way that zookeeper sugguests.
At start up, each sheep creates a ephemeral sequencial node under MASTER_ZNODE.
The sheep who has the least number will be the master.

However, due to the join logic in zookeeper, there is a risk of hang during
join cluster.
This is because zk_compete_master and add_join_event are two seperate operations,
and there is no transection protection.
For example sheep1 got a less sequence number for master competition than sheep2,
but a larger sequence number for join request event.
So if the current master sheep3 quit before handling sheep2's join request,
sheep2 will hang on joining cluster.

To solve this problem, we force sheep send join request only when it can confirm
its a sheep with a less sequence number of master competition has joined.

Signed-off-by: Kai Zhang <kyle@zelin.io>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
tests/functional: add 067 for testing concurrent start up

Signed-off-by: Kai Zhang <kyle@zelin.io>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
sheep: rejoin cluster after a zookeeper session timeout

Add sd_reconnect_handler() to group.c to handle reconnect issue.

Signed-off-by: Kai Zhang <kyle@zelin.io>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
tools: add kill_zk_session

This is a useful tool for simulating zookeeper session timeout.

Usage:
./kill_zk_session [zk_path]

zk_path should contains the clientid_t content.

Signed-off-by: Kai Zhang <kyle@zelin.io>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
tests/functional: add 068 for testing rejoin cluster

Signed-off-by: Kai Zhang <kyle@zelin.io>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
zookeeper: handle session timeout for all zookeeper operations

The idea is: when a zk_* APIs returns ZK_INVALIDSTATE, it means the connection
and session to zookeeper have been lost.
At this point, callers of zk_* APIs should just do nothing but drop control as
soon as possible.
And another thread will responsable for cleaning memory state, re-connecting
to zookeeper and re-sending join request.

Signed-off-by: Kai Zhang <kyle@zelin.io>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
zookeeper: clean code by macro RETURN_IF_ERROR() and RETURN_VOID_IF_ERROR

Signed-off-by: Kai Zhang <kyle@zelin.io>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>