From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp21.mail.ru (smtp21.mail.ru [94.100.179.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 79D4543040C for ; Fri, 4 Sep 2020 14:38:25 +0300 (MSK) References: <67ad0fd7ff4703527b66b3604c819413f6e7c466.1599173312.git.v.shpilevoy@tarantool.org> From: Serge Petrenko Message-ID: <15afcac4-bee4-c59c-33cd-60c4fd768a0d@tarantool.org> Date: Fri, 4 Sep 2020 14:38:23 +0300 MIME-Version: 1.0 In-Reply-To: <67ad0fd7ff4703527b66b3604c819413f6e7c466.1599173312.git.v.shpilevoy@tarantool.org> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [Tarantool-patches] [PATCH v2 10/10] raft: introduce box.info.raft List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy , tarantool-patches@dev.tarantool.org, gorcunov@gmail.com 04.09.2020 01:51, Vladislav Shpilevoy пишет: > Box.info.raft returns a table of form: > > { > state: , > term: , > vote: , > leader: > } > > The fields correspond to the same named Raft concepts one to one. > This info dump is supposed to help with the tests, first of all. > And with investigation of problems in a real cluster. > > Part of #1146 Thanks for the patch! Looks good to me. > --- > src/box/lua/info.c | 17 +++++++++++++++++ > test/box/info.result | 1 + > 2 files changed, 18 insertions(+) > > diff --git a/src/box/lua/info.c b/src/box/lua/info.c > index 1c131caec..8e1dbd497 100644 > --- a/src/box/lua/info.c > +++ b/src/box/lua/info.c > @@ -49,6 +49,7 @@ > #include "main.h" > #include "version.h" > #include "box/box.h" > +#include "box/raft.h" > #include "lua/utils.h" > #include "fiber.h" > #include "tt_static.h" > @@ -577,6 +578,21 @@ lbox_info_listen(struct lua_State *L) > return 1; > } > > +static int > +lbox_info_raft(struct lua_State *L) > +{ > + lua_createtable(L, 0, 4); > + lua_pushstring(L, raft_state_strs[raft.state]); > + lua_setfield(L, -2, "state"); > + luaL_pushuint64(L, raft.volatile_term); > + lua_setfield(L, -2, "term"); > + lua_pushinteger(L, raft.volatile_vote); > + lua_setfield(L, -2, "vote"); > + lua_pushinteger(L, raft.leader); > + lua_setfield(L, -2, "leader"); > + return 1; > +} > + > static const struct luaL_Reg lbox_info_dynamic_meta[] = { > {"id", lbox_info_id}, > {"uuid", lbox_info_uuid}, > @@ -595,6 +611,7 @@ static const struct luaL_Reg lbox_info_dynamic_meta[] = { > {"vinyl", lbox_info_vinyl}, > {"sql", lbox_info_sql}, > {"listen", lbox_info_listen}, > + {"raft", lbox_info_raft}, > {NULL, NULL} > }; > > diff --git a/test/box/info.result b/test/box/info.result > index 40eeae069..d0abb634a 100644 > --- a/test/box/info.result > +++ b/test/box/info.result > @@ -82,6 +82,7 @@ t > - memory > - package > - pid > + - raft > - replication > - replication_anon > - ro -- Serge Petrenko