From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: tarantool-patches@freelists.org Cc: kostja@tarantool.org Subject: [tarantool-patches] [PATCH 2/5] swim: make members array decoder be a separate function Date: Fri, 5 Apr 2019 14:57:28 +0300 [thread overview] Message-ID: <0b70490be1c6d5a666178f38f1c9534e84dbf10d.1554465150.git.v.shpilevoy@tarantool.org> (raw) In-Reply-To: <cover.1554465150.git.v.shpilevoy@tarantool.org> In-Reply-To: <cover.1554465150.git.v.shpilevoy@tarantool.org> At this moment SWIM protocol stores array of members only in one place: inside the anti-entropy component. Its decoding is a simple loop taking the member definitions one by one and upserting them into the member table. But the dissemination also has something kinda like members array: an array of events. The trick is that an event is basically the same as a member +/- a couple of optional fields. Events are also decoded into the member definition structure. It means that anti-entropy decoder can be easily reused. Part of #3234 --- src/lib/swim/swim.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/lib/swim/swim.c b/src/lib/swim/swim.c index f65fb60a3..a30a83886 100644 --- a/src/lib/swim/swim.c +++ b/src/lib/swim/swim.c @@ -1019,12 +1019,14 @@ skip: return 0; } -/** Decode an anti-entropy message, update member table. */ +/** + * Decode a bunch of members encoded as a MessagePack array. Each + * correctly decoded member is upserted into the member table. + */ static int -swim_process_anti_entropy(struct swim *swim, const char **pos, const char *end) +swim_process_members(struct swim *swim, const char *prefix, + const char **pos, const char *end) { - say_verbose("SWIM %d: process anti-entropy", swim_fd(swim)); - const char *prefix = "invalid anti-entropy message:"; uint32_t size; if (swim_decode_array(pos, end, &size, prefix, "root") != 0) return -1; @@ -1044,6 +1046,15 @@ swim_process_anti_entropy(struct swim *swim, const char **pos, const char *end) return 0; } +/** Decode an anti-entropy message, update member table. */ +static int +swim_process_anti_entropy(struct swim *swim, const char **pos, const char *end) +{ + say_verbose("SWIM %d: process anti-entropy", swim_fd(swim)); + const char *prefix = "invalid anti-entropy message:"; + return swim_process_members(swim, prefix, pos, end); +} + /** * Decode a failure detection message. Schedule acks, process * acks. -- 2.17.2 (Apple Git-113)
next prev parent reply other threads:[~2019-04-05 11:57 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-04-05 11:57 [tarantool-patches] [PATCH 0/5] swim dissemination component Vladislav Shpilevoy 2019-04-05 11:57 ` [tarantool-patches] [PATCH 1/5] swim: encapsulate member bin info into a 'passport' Vladislav Shpilevoy 2019-04-05 11:57 ` Vladislav Shpilevoy [this message] 2019-04-05 11:57 ` [tarantool-patches] [PATCH 3/5] test: speed up swim big cluster failure detection Vladislav Shpilevoy 2019-04-09 8:43 ` [tarantool-patches] " Konstantin Osipov 2019-04-09 11:47 ` Vladislav Shpilevoy 2019-04-05 11:57 ` [tarantool-patches] [PATCH 4/5] test: set packet drop rate instead of flag in swim tests Vladislav Shpilevoy 2019-04-05 11:57 ` [tarantool-patches] [PATCH 5/5] swim: introduce dissemination component Vladislav Shpilevoy 2019-04-08 20:13 ` [tarantool-patches] " Vladislav Shpilevoy 2019-04-09 9:58 ` Konstantin Osipov 2019-04-09 11:47 ` Vladislav Shpilevoy 2019-04-09 12:25 ` [tarantool-patches] Re: [PATCH 0/5] swim " Vladislav Shpilevoy
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=0b70490be1c6d5a666178f38f1c9534e84dbf10d.1554465150.git.v.shpilevoy@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [tarantool-patches] [PATCH 2/5] swim: make members array decoder be a separate function' \ /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