tests/002: add correct output file

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Revert "sheep: let all sheeps with smaller epoch added into delayed_nodes list"

This reverts commit 98241c50d23d99047c37a606a845f5f0bccbbf50.

We cannot pass test 002 after the commit and it looks difficult to fix
the problem.  The benefit of the commit is not mandatory, so let's
revert it for now and fix it in future.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
corosync: handle network partition

This patch adds support for network partition detection again with
more efficient way.

Even when many nodes go down at the same time, corosync dispatches
leave messages one by one.  It makes it difficult to detect a network
partition.  To determine whether there are succeeding leave events or
not, this patch uses a cpg file descriptor, which is used to check
notified corosync messages.  If the descriptor is ready for read,
sheep skip processing events and tries to receive the next events.  If
more than half numbers of nodes go down at the same time, sheep
determine that a network partition has occurred and stop serving.

With this patch, sheep can also detect NIC failure and avoid updating
epoch wrongly.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
tests: avoid false detection of network partion

If more than half nodes go down at the same time, sheep wrongly
detects a network partition failure.  This add one second sleep to
avoid the problem.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
collie: add helper function to read vdi objects

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
collie: add vdi backup support

This enables us to create an incremental backup between two snapshots.

  $ collie vdi backup
  Usage: collie vdi backup [-s snapshot] [-F from] [-a address] [-p port] [-h] <vdiname> <backup>
  Options:
    -s, --snapshot          specify a snapshot id or tag name
    -F, --from              create a differential backup from the snapshot
    -a, --address           specify the daemon address (default: localhost)
    -p, --port              specify the daemon port
    -h, --help              display this help and exit

The created backup file contains differential data for each data
objects.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
collie: vdi restore support

This enables us to restore vdi images with backup files created by
'vdi backup' command.

  $ collie vdi restore
  Usage: collie vdi restore [-s snapshot] [-a address] [-p port] [-h] <vdiname> <backup>
  Options:
    -s, --snapshot          specify a snapshot id or tag name
    -a, --address           specify the daemon address (default: localhost)
    -p, --port              specify the daemon port
    -h, --help              display this help and exit

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
tests: add test to check vdi backup and restore

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
test: fix simulate_machine_down helper

use $1 instead of mad $i

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
collie: don't show cluster creation time when collie fails to get it

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: remove tempoary objects only when sheep starts up

It is not safe to remove temporary objects while sheep is running.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
collie: handle snapshot name correctly in fix get_oid

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
tests: add option to exit immediately on test failure

This add '-e' option to stop check script immediately on test failure.
This is useful when we want to check sheep.log or dumped core files of
the failure.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
sheep: set response data size to zero by default

We tend to forget to set rsp->data_length to 0 when we don't need to
send any data, so it looks better not to initialize the value with
req->data_length.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
gateway: clean up wait_forward_request()

We only process POLLIN events, then we can simplify processing with goto
and remove the never-reach code.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
ops: refactor read_copy_from_replica()

This function does competely the same as gateway_read_obj(), so we'd better
directly call gateway_read_obj() by faking a request.

We didn't call it in the old code because a nasty nested requests problem over
the same FD. Now with short thread and sockfd, we don't have this kind of
problem.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
collie: fix buffer overflow of size_to_str()

We might end up with i == ARRAY_SIZE(units), which will cross array boundry.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep: correct join_message->nr_nodes type

In send_join_request() we use -1 to check if the epoch read error happens.
So we should change uint16_t to int16_t.

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Revert "collie: add cluster recover info command"

With the new manual recovery design, we need to increment epoch even
when object recovery is disabled, so the command "cluster recover
info" is no longer required.

This reverts commit d652f24f00bef5045233083ff704b252a54beffe.

Conflicts:

	include/internal_proto.h
	sheep/ops.c

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
Revert "sheep: do the real work of dsiable/enable recovery"

It requires quite big changes to extend this patch to handle leave
nodes.  The next patch will implements manual recovery with much
simpler approach.

This reverts commit a9186fd8f0e133ba7065a579da1062650991e89a.

Conflicts:

	sheep/group.c
	sheep/sheep_priv.h

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>