From d0ab88c1bda7a3950f379adf3ef22dc9e5e8df2a Mon Sep 17 00:00:00 2001
From: Roman Tsisyk <roman@tsisyk.com>
Date: Thu, 21 Apr 2016 15:56:20 +0300
Subject: [PATCH] Rename SERVER_ID -> SERVER_UUID, CLUSTER_ID -> CLUSTER_UUID

Fix server_id vs server_uuid mess.
---
 src/box/alter.cc        |  2 +-
 src/box/applier.cc      |  4 ++--
 src/box/box.cc          | 11 ++++++-----
 src/box/cluster.cc      |  6 +++---
 src/box/cluster.h       |  4 ++--
 src/box/iproto.cc       |  2 +-
 src/box/lua/info.c      |  4 ++--
 src/box/memtx_engine.cc | 10 +++++-----
 src/box/recovery.cc     |  4 ++--
 9 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/src/box/alter.cc b/src/box/alter.cc
index 9c082fbe0d..223c873102 100644
--- a/src/box/alter.cc
+++ b/src/box/alter.cc
@@ -1962,7 +1962,7 @@ on_replace_dd_schema(struct trigger * /* trigger */, void *event)
 		if (new_tuple == NULL)
 			tnt_raise(ClientError, ER_CLUSTER_ID_IS_RO);
 		tt_uuid uu = tuple_field_uuid(new_tuple, 1);
-		CLUSTER_ID = uu;
+		CLUSTER_UUID = uu;
 	}
 }
 
diff --git a/src/box/applier.cc b/src/box/applier.cc
index 1bbffdab00..cdbd2762cd 100644
--- a/src/box/applier.cc
+++ b/src/box/applier.cc
@@ -163,7 +163,7 @@ applier_join(struct applier *applier)
 	struct ev_io *coio = &applier->io;
 	struct iobuf *iobuf = applier->iobuf;
 	struct xrow_header row;
-	xrow_encode_join(&row, &SERVER_ID);
+	xrow_encode_join(&row, &SERVER_UUID);
 	coio_write_xrow(coio, &row);
 
 	/* Decode JOIN response */
@@ -242,7 +242,7 @@ applier_subscribe(struct applier *applier)
 
 	/* TODO: don't use struct recovery here */
 	struct recovery *r = ::recovery;
-	xrow_encode_subscribe(&row, &CLUSTER_ID, &SERVER_ID, &r->vclock);
+	xrow_encode_subscribe(&row, &CLUSTER_UUID, &SERVER_UUID, &r->vclock);
 	coio_write_xrow(coio, &row);
 	applier_set_state(applier, APPLIER_FOLLOW);
 	/* Re-enable warnings after successful execution of SUBSCRIBE */
diff --git a/src/box/box.cc b/src/box/box.cc
index c09569adac..c31b1230c1 100644
--- a/src/box/box.cc
+++ b/src/box/box.cc
@@ -1088,10 +1088,10 @@ box_process_subscribe(struct ev_io *io, struct xrow_header *header)
 	 * replica connect, and refuse a connection from a replica
 	 * which belongs to a different cluster.
 	 */
-	if (!tt_uuid_is_equal(&cluster_uuid, &CLUSTER_ID)) {
+	if (!tt_uuid_is_equal(&cluster_uuid, &CLUSTER_UUID)) {
 		tnt_raise(ClientError, ER_CLUSTER_ID_MISMATCH,
 			  tt_uuid_str(&cluster_uuid),
-			  tt_uuid_str(&CLUSTER_ID));
+			  tt_uuid_str(&CLUSTER_UUID));
 	}
 
 	/* Check server uuid */
@@ -1144,8 +1144,9 @@ box_set_server_uuid()
 	boxk(IPROTO_DELETE, BOX_CLUSTER_ID, "%u", 1);
 
 	/* Register local server */
-	tt_uuid_create(&SERVER_ID);
-	boxk(IPROTO_INSERT, BOX_CLUSTER_ID, "%u%s", 1, tt_uuid_str(&SERVER_ID));
+	tt_uuid_create(&SERVER_UUID);
+	boxk(IPROTO_INSERT, BOX_CLUSTER_ID, "%u%s", 1,
+	     tt_uuid_str(&SERVER_UUID));
 	assert(r->server_id == 1);
 
 	/* Ugly hack: bootstrap always starts from scratch */
@@ -1251,7 +1252,7 @@ bootstrap_from_master(struct server *master)
 	 */
 
 	/* Generate Server-UUID */
-	tt_uuid_create(&SERVER_ID);
+	tt_uuid_create(&SERVER_UUID);
 	applier_resume_to_state(applier, APPLIER_INITIAL_JOIN, TIMEOUT_INFINITY);
 
 	/*
diff --git a/src/box/cluster.cc b/src/box/cluster.cc
index 6419f96886..a83e330ac7 100644
--- a/src/box/cluster.cc
+++ b/src/box/cluster.cc
@@ -44,11 +44,11 @@
  * Globally unique identifier of this cluster.
  * A cluster is a set of connected appliers.
  */
-struct tt_uuid CLUSTER_ID;
+struct tt_uuid CLUSTER_UUID;
 /**
  * Globally unique identifier of this server.
  */
-struct tt_uuid SERVER_ID;
+struct tt_uuid SERVER_UUID;
 
 typedef rb_tree(struct server) serverset_t;
 rb_proto(, serverset_, serverset_t, struct server)
@@ -163,7 +163,7 @@ server_set_id(struct server *server, uint32_t server_id)
 	if (!vclock_has(&r->vclock, server_id))
 		vclock_add_server_nothrow(&r->vclock, server_id);
 
-	if (tt_uuid_is_equal(&SERVER_ID, &server->uuid)) {
+	if (tt_uuid_is_equal(&SERVER_UUID, &server->uuid)) {
 		/* Assign local server id */
 		assert(r->server_id == SERVER_ID_NIL);
 		r->server_id = server_id;
diff --git a/src/box/cluster.h b/src/box/cluster.h
index 0879e0d4d1..45b68e4fe5 100644
--- a/src/box/cluster.h
+++ b/src/box/cluster.h
@@ -95,9 +95,9 @@ cluster_free(void);
 /** {{{ Global cluster identifier API **/
 
 /** UUID of the cluster. */
-extern struct tt_uuid CLUSTER_ID;
+extern struct tt_uuid CLUSTER_UUID;
 /** UUID of the instance. */
-extern struct tt_uuid SERVER_ID;
+extern struct tt_uuid SERVER_UUID;
 
 struct vclock *
 cluster_clock();
diff --git a/src/box/iproto.cc b/src/box/iproto.cc
index 6c96c483ed..3d051dcd7a 100644
--- a/src/box/iproto.cc
+++ b/src/box/iproto.cc
@@ -925,7 +925,7 @@ tx_process_connect(struct cmsg *m)
 		con->session = session_create(con->input.fd);
 		static __thread char greeting[IPROTO_GREETING_SIZE];
 		/* TODO: dirty read from tx thread */
-		struct tt_uuid uuid = SERVER_ID;
+		struct tt_uuid uuid = SERVER_UUID;
 		greeting_encode(greeting, tarantool_version_id(),
 				&uuid, con->session->salt, SESSION_SEED_SIZE);
 		obuf_dup_xc(out, greeting, IPROTO_GREETING_SIZE);
diff --git a/src/box/lua/info.c b/src/box/lua/info.c
index aaefab8816..42a7067498 100644
--- a/src/box/lua/info.c
+++ b/src/box/lua/info.c
@@ -135,7 +135,7 @@ lbox_info_server(struct lua_State *L)
 	lua_pushinteger(L, recovery->server_id);
 	lua_settable(L, -3);
 	lua_pushliteral(L, "uuid");
-	lua_pushlstring(L, tt_uuid_str(&SERVER_ID), UUID_STR_LEN);
+	lua_pushlstring(L, tt_uuid_str(&SERVER_UUID), UUID_STR_LEN);
 	lua_settable(L, -3);
 	lua_pushliteral(L, "lsn");
 	luaL_pushint64(L, vclock_get(&recovery->vclock, recovery->server_id));
@@ -180,7 +180,7 @@ lbox_info_cluster(struct lua_State *L)
 {
 	lua_createtable(L, 0, 2);
 	lua_pushliteral(L, "uuid");
-	lua_pushlstring(L, tt_uuid_str(&CLUSTER_ID), UUID_STR_LEN);
+	lua_pushlstring(L, tt_uuid_str(&CLUSTER_UUID), UUID_STR_LEN);
 	lua_settable(L, -3);
 
 	return 1;
diff --git a/src/box/memtx_engine.cc b/src/box/memtx_engine.cc
index f53e2ab114..16ae1df7f5 100644
--- a/src/box/memtx_engine.cc
+++ b/src/box/memtx_engine.cc
@@ -609,7 +609,7 @@ MemtxEngine::MemtxEngine(const char *snap_dirname, bool panic_on_snap_error,
 	m_panic_on_wal_error(panic_on_wal_error)
 {
 	flags = ENGINE_CAN_BE_TEMPORARY;
-	xdir_create(&m_snap_dir, snap_dirname, SNAP, &SERVER_ID);
+	xdir_create(&m_snap_dir, snap_dirname, SNAP, &SERVER_UUID);
 	m_snap_dir.panic_if_error = panic_on_snap_error;
 	xdir_scan_xc(&m_snap_dir);
 	struct vclock *vclock = vclockset_last(&m_snap_dir.index);
@@ -681,7 +681,7 @@ MemtxEngine::recoverToCheckpoint(int64_t lsn)
 	struct xlog *snap = xlog_open_xc(&m_snap_dir, lsn);
 	auto guard = make_scoped_guard([=]{ xlog_close(snap); });
 	/* Save server UUID */
-	SERVER_ID = snap->server_uuid;
+	SERVER_UUID = snap->server_uuid;
 
 	say_info("recovering from `%s'", snap->filename);
 	struct xlog_cursor cursor;
@@ -1129,7 +1129,7 @@ checkpoint_init(struct checkpoint *ckpt, const char *snap_dirname,
 {
 	ckpt->entries = RLIST_HEAD_INITIALIZER(ckpt->entries);
 	ckpt->waiting_for_snap_thread = false;
-	xdir_create(&ckpt->dir, snap_dirname, SNAP, &SERVER_ID);
+	xdir_create(&ckpt->dir, snap_dirname, SNAP, &SERVER_UUID);
 	ckpt->snap_io_rate_limit = snap_io_rate_limit;
 	/* May be used in abortCheckpoint() */
 	vclock_create(&ckpt->vclock);
@@ -1305,10 +1305,10 @@ MemtxEngine::join(struct xstream *stream)
 	struct xdir dir;
 	struct xlog *snap = NULL;
 	/*
-	 * snap_dirname and SERVER_ID don't change after start,
+	 * snap_dirname and SERVER_UUID don't change after start,
 	 * safe to use in another thread.
 	 */
-	xdir_create(&dir, m_snap_dir.dirname, SNAP, &SERVER_ID);
+	xdir_create(&dir, m_snap_dir.dirname, SNAP, &SERVER_UUID);
 
 	auto guard = make_scoped_guard([&]{
 		xdir_destroy(&dir);
diff --git a/src/box/recovery.cc b/src/box/recovery.cc
index c18fa211db..f5faba506f 100644
--- a/src/box/recovery.cc
+++ b/src/box/recovery.cc
@@ -141,7 +141,7 @@ recovery_new(const char *wal_dirname, bool panic_on_wal_error,
 		free(r);
 	});
 
-	xdir_create(&r->wal_dir, wal_dirname, XLOG, &SERVER_ID);
+	xdir_create(&r->wal_dir, wal_dirname, XLOG, &SERVER_UUID);
 	r->wal_dir.panic_if_error = panic_on_wal_error;
 
 	vclock_copy(&r->vclock, vclock);
@@ -386,7 +386,7 @@ recovery_finalize(struct recovery *r, struct xstream *stream,
 	}
 	if (wal_mode != WAL_NONE) {
 		wal_writer_start(wal_mode, r->wal_dir.dirname,
-				 &SERVER_ID, &r->vclock, rows_per_wal);
+				 &SERVER_UUID, &r->vclock, rows_per_wal);
 	}
 }
 
-- 
GitLab