同步探测-Redis
1 workflow
创建 workflow 时,生成需要测试的 key 的 slot 列表
(1) [source_set] 源集群生成测试 key,value 为 reqid
(2) [target_get] 目标集群检查 key 的 value
1> key 的 value 与源集群测试 key 的 value 一致 ----> OK
2> key 的 value 与源集群测试 key 的 value 不一致,且时间未到 10 分钟 ----> ERR_TASK_ING
3> key 的 value 与源集群测试 key 的 value 不一致,且时间已超过 10 分钟 ----> OK
(3) [source_del] 删除源集群测试 key
2 常见问题
2.1 如何使得不同的 task 获取到相同的测试 key
生成要测试的 key 的 slot
>>> import random
>>> slot_list = range(16384)
>>> random.seed(0)
>>> random.shuffle(slot_list)
>>> print slot_list[:10]
[5545, 6735, 3541, 3145, 12972, 6485, 14559, 10544, 9010, 15150]
# todo
经测,同 seed_num 的情况下,有时候返回的列表是不一样的,原因目前还未知
将测试 key 和 slot 存储到本地 cache
slot_key_list = _dc.Index("{data_dir}/slot_key".format(data_dir=config.LOCALDATA_DIR))
if len(slot_key_list) != 16384:
with open("./data/slot_key.md", "r") as f:
for line in f:
line_list = line.strip().split(" ")
key_index = int(line_list[0])
key_name = "{{{hash_tag}}}:{slot}".format(hash_tag=line_list[-1], slot=key_index)
slot_key_list[key_index] = key_name
2.2 时间判定问题
target_get 应该是以 source_set 写入的时间为准
即 source_set value 后,将 value 传递给 target_get
Last updated