From: Serge Petrenko <sergepetrenko@tarantool.org>
To: sergos@tarantool.org, v.shpilevoy@tarantool.org
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH 1/3] vclock: add an ability to set individual clock components
Date: Fri, 31 Jan 2020 17:58:05 +0300 [thread overview]
Message-ID: <8c924da71c7c3253453f789c130d2dff5c319eff.1580482010.git.sergepetrenko@tarantool.org> (raw)
In-Reply-To: <cover.1580482010.git.sergepetrenko@tarantool.org>
This is needed to 'hide' 0-th vclock component in replication responses.
Follow-up #3186
---
src/box/vclock.c | 12 ++++++++++++
src/box/vclock.h | 11 +++++++++++
2 files changed, 23 insertions(+)
diff --git a/src/box/vclock.c b/src/box/vclock.c
index 90ae27591..90802308e 100644
--- a/src/box/vclock.c
+++ b/src/box/vclock.c
@@ -37,6 +37,17 @@
#include "diag.h"
#include "tt_static.h"
+void
+vclock_set(struct vclock *vclock, uint32_t replica_id, int64_t lsn)
+{
+ assert(lsn >= 0);
+ assert(replica_id < VCLOCK_MAX);
+ vclock->signature -= vclock_get(vclock, replica_id);
+ vclock->lsn[replica_id] = lsn;
+ vclock->map |= 1 << replica_id;
+ vclock->signature += lsn;
+}
+
int64_t
vclock_follow(struct vclock *vclock, uint32_t replica_id, int64_t lsn)
{
@@ -51,6 +62,7 @@ vclock_follow(struct vclock *vclock, uint32_t replica_id, int64_t lsn)
return prev_lsn;
}
+
static int
vclock_snprint(char *buf, int size, const struct vclock *vclock)
{
diff --git a/src/box/vclock.h b/src/box/vclock.h
index eb0fb5d8b..e54711bc1 100644
--- a/src/box/vclock.h
+++ b/src/box/vclock.h
@@ -209,6 +209,17 @@ vclock_calc_sum(const struct vclock *vclock)
return sum;
}
+/**
+ * Set vclock component represented by replica id to the desired
+ * value.
+ *
+ * @param vclock Vector clock.
+ * @param replica_id Replica identifier.
+ * @param lsn Lsn to set
+ */
+void
+vclock_set(struct vclock *vclock, uint32_t replica_id, int64_t lsn);
+
static inline int64_t
vclock_sum(const struct vclock *vclock)
{
--
2.21.0 (Apple Git-122)
next prev parent reply other threads:[~2020-01-31 14:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-31 14:58 [Tarantool-patches] [PATCH 0/3] replication: count local space requests separately Serge Petrenko
2020-01-31 14:58 ` Serge Petrenko [this message]
2020-01-31 14:58 ` [Tarantool-patches] [PATCH 2/3] replication: hide 0-th vclock components in replication responses Serge Petrenko
2020-01-31 14:58 ` [Tarantool-patches] [PATCH 3/3] box: start counting local space requests separately Serge Petrenko
2020-02-03 13:27 ` [Tarantool-patches] [PATCH 0/3] replication: count " Serge Petrenko
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=8c924da71c7c3253453f789c130d2dff5c319eff.1580482010.git.sergepetrenko@tarantool.org \
--to=sergepetrenko@tarantool.org \
--cc=sergos@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH 1/3] vclock: add an ability to set individual clock components' \
/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