Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org
Cc: kostja@tarantool.org
Subject: [tarantool-patches] [PATCH v2 2/6] swim: make members array decoder be a separate function
Date: Tue,  9 Apr 2019 14:46:33 +0300	[thread overview]
Message-ID: <0b70490be1c6d5a666178f38f1c9534e84dbf10d.1554809200.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1554809200.git.v.shpilevoy@tarantool.org>
In-Reply-To: <cover.1554809200.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)

  parent reply	other threads:[~2019-04-09 11:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-09 11:46 [tarantool-patches] [PATCH v2 0/6] swim dissemination Vladislav Shpilevoy
2019-04-09 11:46 ` [tarantool-patches] [PATCH v2 1/6] swim: encapsulate member bin info into a 'passport' Vladislav Shpilevoy
2019-04-09 11:46 ` Vladislav Shpilevoy [this message]
2019-04-09 11:46 ` [tarantool-patches] [PATCH v2 3/6] test: rename some swim test methods and macros Vladislav Shpilevoy
2019-04-09 11:46 ` [tarantool-patches] [PATCH v2 4/6] test: speed up swim big cluster failure detection Vladislav Shpilevoy
2019-04-09 11:46 ` [tarantool-patches] [PATCH v2 5/6] test: set packet drop rate instead of flag in swim tests Vladislav Shpilevoy
2019-04-09 11:46 ` [tarantool-patches] [PATCH v2 6/6] swim: introduce dissemination component Vladislav Shpilevoy
2019-04-09 13:47   ` [tarantool-patches] " Konstantin Osipov

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.1554809200.git.v.shpilevoy@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH v2 2/6] 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