CLD replication (WIP)
PATCH 1/1 CLD replication (WIP)
I just updated the current CLD replication code to the latest upstream cld.git code. It is now living on the "replica" branch ofgit://git.kernel.org/pub/scm/daemon/cld/cld.git
server/cld.h | 20 ++++ server/cldb.c | 69 +++++++++++-- server/cldb.h | 9 ++- server/cldbadm.c | 8 +- server/server.c | 287 ++++++++++++++++++++++++++++++++++++++++++++++++++--- test/pid-exists | 24 +++-- test/prep-db | 19 ++-- test/start-daemon | 24 ++++- test/stop-daemon | 18 ++-- 9 files changed, 419 insertions(+), 59 deletions(-)
Jeff Garzik (1):
cld replication work-in-progress.
server/cld.h +20 -0
@@ -94,6 +94,15 @@ struct msg_params {size_t msg_len; }; +enum st_cldb { +ST_CLDB_INIT , +ST_CLDB_OPEN , +ST_CLDB_ACTIVE , +ST_CLDB_MASTER , +ST_CLDB_SLAVE , +ST_CLDBNUM +}; +struct server_stats {unsigned long poll;/* num. polls */ unsigned long event;/* events dispatched */
@@ -115,6 +124,17 @@ struct server {char *port;/* bind port, NULL means auto */ char *port_file;/* Port file to write */ +unsigned short rep_port;/* db4 replication port */ + +char *myhost; +char *force_myhost; +GList *rep_remotes; + +unsigned int n_peers;/* total peers in cell */ + +int rep_pipe[2 ]; + +enum st_cldb state_cldb, state_cldb_new;struct cldb cldb;/* database info */
server/cldb.c +61 -8
119 lines not on this page · raw message
server/cldb.h +8 -1
@@ -108,6 +108,11 @@ enum db_event { CLDB_EV_NONE, CLDB_EV_CLIENT, CLDB_EV_MASTER, CLDB_EV_ELECTED }; +struct db_remote {/* remotes for cldb_init */ +char *host; +unsigned short port; +}; +struct cldb {bool is_master;bool keyed;/* using encryption? */
@@ -134,7 +139,9 @@ struct cldb {extern int cldb_init (struct cldb *cldb,const char *db_home,const char *db_password,unsigned int env_flags,const char *errpfx,bool do_syslog, -unsigned int flags,void (*cb)(enum db_event )); +GList *remotes,char *rep_host,unsigned short rep_port, +int n_peers,void (*cb)(enum db_event )); +extern int cldb_up (struct cldb *cldb,unsigned int flags);extern void cldb_down (struct cldb *cldb);extern void cldb_fini (struct cldb *cldb);
server/cldbadm.c +5 -3
@@ -78,7 +78,8 @@ int main(int argc, char *argv[]) }if (cldb_init (&cld_adm.cldb, cld_adm.data_dir,NULL , -DB_RECOVER ,"cldbadm" , false,0 ,NULL )) +DB_RECOVER ,"cldbadm" , false, +NULL ,NULL ,0 ,0 ,NULL )) goto err_dbopen;switch (cld_adm.mode) {
@@ -142,8 +143,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state)* Stubs for contents of cldb.c */ int cldb_init (struct cldb *cldb,const char *db_home,const char *db_password, -unsigned int env_flags,const char *errpfx,bool do_syslog, -unsigned int flags,void (*cb)(enum db_event )) +unsigned int env_flags,const char *errpfx,bool do_syslog, +GList *remotes,char *rep_host,unsigned short rep_port, +int n_peers,void (*cb)(enum db_event )) {return 0 ;
server/server.c +272 -15
404 lines not on this page · raw message
test/pid-exists +13 -11
@@ -1,15 +1,17 @@ #!/bin/sh -if [ ! -f cld.pid ] -then - echo "pid file not found." >&2 - exit 1 -fi - -if [ ! -f cld.port ] -then - echo "port file not found." >&2 - exit 1 -fi +for n in 1 2 3 +do + if [ ! -f cld$n.pid ] + then + echo "cld$n.pid not found." >&2 + exit 1 + fi + if [ ! -f cld$n.port ] + then + echo "cld$n.port file not found." >&2 + exit 1 + fi +done exit 0
test/prep-db +11 -8
@@ -2,13 +2,16 @@ DATADIR=data -mkdir -p $DATADIR - -if [ ! -d $DATADIR ] -then - rm -rf $DATADIR - echo "test database dir not found." - exit 1 -fi +for n in 1 2 3 +do + mkdir -p $DATADIR/n$n/data + + if [ ! -d $DATADIR/n$n/data ] + then + rm -rf $DATADIR + echo "test database dir for node $n not found." + exit 1 + fi +done exit 0
test/start-daemon +20 -4
@@ -1,16 +1,32 @@ #!/bin/sh -if [ -f cld.pid ] +if [ -f cld1.pid -o -f cld2.pid -o -f cld3.pid ] then - echo "pid file found. daemon still running?" + echo "pid file found. daemons still running?" exit 1 fi ## Static port # ../server/cld -P cld.pid -d "$PWD/data" -p 18181 --port-file=cld.port -E ## Dynamic port -../server/cld -P cld.pid -d "$PWD/data" -p auto --port-file=cld.port -E +../server/cld -P cld1.pid -d "$PWD/data/n1/data" -p auto --port-file=cld1.port \ + -E -D 2 -S 3 \ + -m localhost.localdomain \ + -R localhost.localdomain:19182 \ + -R localhost.localdomain:19183 +../server/cld -P cld2.pid -d "$PWD/data/n2/data" -p auto --port-file=cld2.port \ + -E -D 2 -S 3 \ + -m localhost.localdomain \ + -R localhost.localdomain:19181 \ + -R localhost.localdomain:19183 +../server/cld -P cld3.pid -d "$PWD/data/n3/data" -p auto --port-file=cld3.port \ + -E -D 2 -S 3 \ + -m localhost.localdomain \ + -R localhost.localdomain:19181 \ + -R localhost.localdomain:19182 +sleep 1 -sleep 3 +echo " start-daemon: Waiting 20s, for daemons to start up..." +sleep 20 exit 0
test/stop-daemon +9 -9
@@ -1,25 +1,25 @@ #!/bin/sh -rm -f cld.port +rm -f cld?.port -if [ ! -f cld.pid ] +if [ ! -f cld1.pid -o ! -f cld2.pid -o ! -f cld3.pid ] then - echo no daemon pid file found. + echo at least one daemon pid file missing. exit 1 fi -kill `cat cld.pid` +kill `cat cld*.pid` for n in 0 1 2 3 4 5 6 7 8 9 do - if [ ! -f cld.pid ] + if [ -f cld1.pid -o -f cld2.pid -o -f cld3.pid ] then + sleep 1 + else exit 0 fi - - sleep 1 done -echo "PID file not removed, after signal sent." -rm -f cld.pid +echo "PID file(s) not removed, after signal sent." +rm -f cld*.pid exit 1
Quoted 3 lines · Jeff Garzik
I just updated the current CLD replication code to the latest upstream cld.git code. It is now living on the "replica" branch of
git://git.kernel.org/pub/scm/daemon/cld/cld.git
It looks like an ok code to me. Why is it still on branch?
-- Pete
Quoted 7 lines · Pete Zaitcev
Quoted 3 lines · Jeff Garzik
I just updated the current CLD replication code to the latest upstream cld.git code. It is now living on the "replica" branch of
git://git.kernel.org/pub/scm/daemon/cld/cld.gitIt looks like an ok code to me. Why is it still on branch?
Because it does not work, libcldc at present only has a random chance of connecting to the right server, and there is no present method to synchronize per-client sequence ids.
Jeff