* [PATCH] replication: downstream status reporting in box.info
@ 2019-02-06 10:47 Serge Petrenko
2019-02-06 12:42 ` Vladimir Davydov
0 siblings, 1 reply; 2+ messages in thread
From: Serge Petrenko @ 2019-02-06 10:47 UTC (permalink / raw)
To: vdavydov.dev; +Cc: tarantool-patches, Serge Petrenko
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)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-02-06 12:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-06 10:47 [PATCH] replication: downstream status reporting in box.info Serge Petrenko
2019-02-06 12:42 ` Vladimir Davydov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox