From: Serge Petrenko <sergepetrenko@tarantool.org> To: vdavydov.dev@gmail.com Cc: tarantool-patches@freelists.org, Serge Petrenko <sergepetrenko@tarantool.org> Subject: [PATCH] replication: downstream status reporting in box.info Date: Wed, 6 Feb 2019 13:47:17 +0300 [thread overview] Message-ID: <20190206104717.29583-1-sergepetrenko@tarantool.org> (raw) Start showing downstream status for relays in "follow" state. Also refactor lbox_pushrelay to unify code for different relay states. Closes #3904 --- https://github.com/tarantool/tarantool/issues/3904 https://github.com/tarantool/tarantool/tree/sp/gh-3904-downstream-status src/box/lua/info.c | 46 ++++++++++++++++++-------------- test/replication/status.result | 4 +++ test/replication/status.test.lua | 1 + 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/box/lua/info.c b/src/box/lua/info.c index f1950deeb..70672f271 100644 --- a/src/box/lua/info.c +++ b/src/box/lua/info.c @@ -115,9 +115,31 @@ static void lbox_pushrelay(lua_State *L, struct relay *relay) { lua_newtable(L); - lua_pushstring(L, "vclock"); - lbox_pushvclock(L, relay_vclock(relay)); - lua_settable(L, -3); + lua_pushstring(L, "status"); + + switch(relay_get_state(relay)) { + case RELAY_FOLLOW: + lua_pushstring(L, "follow"); + lua_settable(L, -3); + lua_pushstring(L, "vclock"); + lbox_pushvclock(L, relay_vclock(relay)); + lua_settable(L, -3); + break; + case RELAY_STOPPED: + { + lua_pushstring(L, "stopped"); + lua_settable(L, -3); + + struct error *e = diag_last_error(relay_get_diag(relay)); + if (e != NULL) { + lua_pushstring(L, "message"); + lua_pushstring(L, e->errmsg); + lua_settable(L, -3); + } + break; + } + default: unreachable(); + } } static void @@ -147,25 +169,9 @@ lbox_pushreplica(lua_State *L, struct replica *replica) lua_settable(L, -3); } - if (relay_get_state(relay) == RELAY_FOLLOW) { + if (relay_get_state(relay) != RELAY_OFF) { lua_pushstring(L, "downstream"); lbox_pushrelay(L, relay); - lua_settable(L, -3); - } else if (relay_get_state(relay) == RELAY_STOPPED) { - lua_pushstring(L, "downstream"); - - lua_newtable(L); - lua_pushstring(L, "status"); - lua_pushstring(L, "stopped"); - lua_settable(L, -3); - - struct error *e = diag_last_error(relay_get_diag(relay)); - if (e != NULL) { - lua_pushstring(L, "message"); - lua_pushstring(L, e->errmsg); - lua_settable(L, -3); - } - lua_settable(L, -3); } } diff --git a/test/replication/status.result b/test/replication/status.result index 9e69f2478..a408d7eb2 100644 --- a/test/replication/status.result +++ b/test/replication/status.result @@ -172,6 +172,10 @@ replica.upstream == nil --- - true ... +replica.downstream.status == 'follow' +--- +- true +... replica.downstream.vclock[master_id] == box.info.vclock[master_id] --- - true diff --git a/test/replication/status.test.lua b/test/replication/status.test.lua index cfdf6acdb..8a82fe9ae 100644 --- a/test/replication/status.test.lua +++ b/test/replication/status.test.lua @@ -64,6 +64,7 @@ replica.uuid == box.space._cluster:get(replica_id)[2] -- replica.lsn == box.info.vclock[replica_id] replica.lsn == 0 replica.upstream == nil +replica.downstream.status == 'follow' replica.downstream.vclock[master_id] == box.info.vclock[master_id] replica.downstream.vclock[replica_id] == box.info.vclock[replica_id] -- 2.17.2 (Apple Git-113)
next reply other threads:[~2019-02-06 10:47 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-02-06 10:47 Serge Petrenko [this message] 2019-02-06 12:42 ` Vladimir Davydov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190206104717.29583-1-sergepetrenko@tarantool.org \ --to=sergepetrenko@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=vdavydov.dev@gmail.com \ --subject='Re: [PATCH] replication: downstream status reporting in box.info' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox