[Tarantool-patches] [PATCH vshard 3/6] storage: introduce vshard.storage._call('info')

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Fri Jul 2 01:09:33 MSK 2021


Internal info function returns data needed by the routers. Now it
is only is_master flag. This is required for master discovery.

In future the function is supposed to get more attributes. For instance,
instance's own part of its config, bucket generation or bucket sequence number.

Needed for #75
---
 test/storage/storage.result   | 14 ++++++++++++++
 test/storage/storage.test.lua |  7 +++++++
 test/upgrade/upgrade.result   |  1 +
 vshard/storage/init.lua       |  7 +++++++
 4 files changed, 29 insertions(+)

diff --git a/test/storage/storage.result b/test/storage/storage.result
index 5372059..acae98f 100644
--- a/test/storage/storage.result
+++ b/test/storage/storage.result
@@ -938,6 +938,20 @@ assert(lstorage.bucket_are_all_rw())
 vshard.storage.internal.errinj.ERRINJ_NO_RECOVERY = false
 ---
 ...
+--
+-- Internal info function.
+--
+vshard.storage._call('info')
+---
+- is_master: true
+...
+_ = test_run:switch('storage_1_b')
+---
+...
+vshard.storage._call('info')
+---
+- is_master: false
+...
 _ = test_run:switch("default")
 ---
 ...
diff --git a/test/storage/storage.test.lua b/test/storage/storage.test.lua
index d1f3f50..99ef2c4 100644
--- a/test/storage/storage.test.lua
+++ b/test/storage/storage.test.lua
@@ -292,6 +292,13 @@ box.space._bucket:update(10, {{'=', 2, vshard.consts.BUCKET.ACTIVE}})
 assert(lstorage.bucket_are_all_rw())
 vshard.storage.internal.errinj.ERRINJ_NO_RECOVERY = false
 
+--
+-- Internal info function.
+--
+vshard.storage._call('info')
+_ = test_run:switch('storage_1_b')
+vshard.storage._call('info')
+
 _ = test_run:switch("default")
 test_run:drop_cluster(REPLICASET_2)
 test_run:drop_cluster(REPLICASET_1)
diff --git a/test/upgrade/upgrade.result b/test/upgrade/upgrade.result
index 8280e5b..8e59807 100644
--- a/test/upgrade/upgrade.result
+++ b/test/upgrade/upgrade.result
@@ -162,6 +162,7 @@ vshard.storage._call ~= nil
 vshard.storage._call('test_api', 1, 2, 3)
  | ---
  | - - bucket_recv
+ |   - info
  |   - rebalancer_apply_routes
  |   - rebalancer_request_state
  |   - storage_map
diff --git a/vshard/storage/init.lua b/vshard/storage/init.lua
index e13a24e..465abc5 100644
--- a/vshard/storage/init.lua
+++ b/vshard/storage/init.lua
@@ -2549,6 +2549,12 @@ local function storage_map(rid, name, args)
     return true, res
 end
 
+local function storage_service_info()
+    return {
+        is_master = this_is_master(),
+    }
+end
+
 local service_call_api
 
 local function service_call_test_api(...)
@@ -2562,6 +2568,7 @@ service_call_api = setmetatable({
     storage_ref = storage_ref,
     storage_unref = storage_unref,
     storage_map = storage_map,
+    info = storage_service_info,
     test_api = service_call_test_api,
 }, {__serialize = function(api)
     local res = {}
-- 
2.24.3 (Apple Git-128)



More information about the Tarantool-patches mailing list