At Tue, 18 Oct 2011 16:58:58 +0800, Liu Yuan wrote: > > From: Liu Yuan <tailai.ly at taobao.com> > > We use SD_STATUS_HALT to identify the cluster state when it should not serve > IO requests. > > This is optional, users might risk themselves to turn off this HALT status. As > the below command: > > $ collie cluster format -H > or > $ collie cluster format --nohalt > > By default, this is enabled. > > [Test Case] > > [1] > steps: > > for i in 0 1 2 3; do ./sheep/sheep -d /store/$i -z $i -p 700$i; sleep 1; done > ./collie/collie cluster format --copies=3; > for i in 0 1; do pkill -f "sheep -d /store/$i"; sleep 1; done > for i in 2 3; do ./collie/collie cluster info -p 700$i; done > for i in 0 1; do ./sheep/sheep -d /store/$i -z $i -p 700$i; sleep 1; done > for i in 0 1 2 3; do ./collie/collie cluster info -p 700$i; done > > output: > > Cluster status: The sheepdog is stopped doing IO, short of living nodes > > Creation time Epoch Nodes > 2011-10-11 16:26:02 3 [192.168.0.1:7002, 192.168.0.1:7003] > 2011-10-11 16:26:02 2 [192.168.0.1:7001, 192.168.0.1:7002, 192.168.0.1:7003] > 2011-10-11 16:26:02 1 [192.168.0.1:7000, 192.168.0.1:7001, 192.168.0.1:7002, 192.168.0.1:7003] > Cluster status: The sheepdog is stopped doing IO, short of living nodes > > Creation time Epoch Nodes > 2011-10-11 16:26:02 3 [192.168.0.1:7002, 192.168.0.1:7003] > 2011-10-11 16:26:02 2 [192.168.0.1:7001, 192.168.0.1:7002, 192.168.0.1:7003] > 2011-10-11 16:26:02 1 [192.168.0.1:7000, 192.168.0.1:7001, 192.168.0.1:7002, 192.168.0.1:7003] > Cluster status: running > > Creation time Epoch Nodes > 2011-10-11 16:26:02 5 [192.168.0.1:7000, 192.168.0.1:7001, 192.168.0.1:7002, 192.168.0.1:7003] > 2011-10-11 16:26:02 4 [192.168.0.1:7000, 192.168.0.1:7002, 192.168.0.1:7003] > 2011-10-11 16:26:02 3 [192.168.0.1:7002, 192.168.0.1:7003] > 2011-10-11 16:26:02 2 [192.168.0.1:7001, 192.168.0.1:7002, 192.168.0.1:7003] > 2011-10-11 16:26:02 1 [192.168.0.1:7000, 192.168.0.1:7001, 192.168.0.1:7002, 192.168.0.1:7003] > > ... > > [2] > steps: > for i in 0 1; do sheep/sheep -d /store/$i -z $i -p 700$i;sleep 1;done > collie/collie cluster format > for i in 0 1; do collie/collie cluster info -p 700$i;done > for i in 0; do pkill -f "sheep/sheep -d /store/$i"; sleep 1; done > for i in 2; do sheep/sheep -d /store/$i -z $i -p 700$i;sleep 1;done > for i in 1 2; do pkill -f "sheep/sheep -d /store/$i"; sleep 1; done > for i in 0 1 2; do sheep/sheep -d /store/$i -z $i -p 700$i;sleep 1;done > for i in 0 1 2; do sheep/sheep -d /store/$i -z $i -p 700$i;sleep 1;done > for i in 0 1 2; do collie/collie cluster info -p 700$i;done > > output: > Cluster status: The sheepdog is stopped doing IO, short of living nodes > > Creation time Epoch Nodes > 2011-10-16 18:11:07 1 [192.168.0.1:7000, 192.168.0.1:7001] > Cluster status: The sheepdog is stopped doing IO, short of living nodes > > Creation time Epoch Nodes > 2011-10-16 18:11:07 1 [192.168.0.1:7000, 192.168.0.1:7001] > Cluster status: running > > Creation time Epoch Nodes > 2011-10-16 18:11:07 6 [192.168.0.1:7000, 192.168.0.1:7001, 192.168.0.1:7002] > 2011-10-16 18:11:07 5 [192.168.0.1:7000, 192.168.0.1:7002] > 2011-10-16 18:11:07 4 [192.168.0.1:7002] > 2011-10-16 18:11:07 3 [192.168.0.1:7001, 192.168.0.1:7002] > 2011-10-16 18:11:07 2 [192.168.0.1:7001] > 2011-10-16 18:11:07 1 [192.168.0.1:7000, 192.168.0.1:7001] > > ... > > Signed-off-by: Liu Yuan <tailai.ly at taobao.com> > --- > collie/cluster.c | 14 +++++++++++++- > collie/collie.c | 1 + > sheep/group.c | 45 ++++++++++++++++++++++++++++++++++++++++----- > sheep/sheep_priv.h | 5 +++++ > 4 files changed, 59 insertions(+), 6 deletions(-) > > diff --git a/collie/cluster.c b/collie/cluster.c > index e0ab37f..fd40f6e 100644 > --- a/collie/cluster.c > +++ b/collie/cluster.c > @@ -16,8 +16,15 @@ > > struct cluster_cmd_data { > int copies; > + int nohalt; > } cluster_cmd_data; > > +static void set_nohalt(uint32_t *p) > +{ > + if (p) > + *p |= 1; > +} > + Use #define instead of a magic number. Thanks, Kazutaka |