Exemple #1
0
        public async Task <StoreGroupMember> ChooseMember(StoreGroup group, params string[] keys)
        {
            //需要在HashGroup中存在名称为StoreFroup-{group.Name}的哈希组
            string hashGroupName = $"StoreFroup-{group.Name}";
            var    hashGroup     = await _hashGroupRepositoryCacheProxy.QueryByName(hashGroupName);

            if (group == null)
            {
                var fragment = new TextFragment()
                {
                    Code = TextCodes.NotFoundHashGroupByName,
                    DefaultFormatting = "没有找到名称为{0}的一致性哈希组",
                    ReplaceParameters = new List <object>()
                    {
                        hashGroupName
                    }
                };

                throw new UtilityException((int)Errors.NotFoundHashGroupByName, fragment);
            }
            //从哈希组获取实际节点信息,节点信息为MemberName
            var memberName = await hashGroup.GetHashNodeKey(string.Join(".", keys), 1, 2, 3);

            var member = await getMember(group.ID, memberName);

            if (member == null)
            {
                var fragment = new TextFragment()
                {
                    Code = TextCodes.NotFounStoreGroupMemberByName,
                    DefaultFormatting = "在id为{0}的存储组中找不到名称为{1}的组成员",
                    ReplaceParameters = new List <object>()
                    {
                        group.ID.ToString(), memberName
                    }
                };

                throw new UtilityException((int)Errors.NotFounStoreGroupMemberByName, fragment);
            }
            return(member);
        }
Exemple #2
0
        public async Task <StoreGroupMember> GetMember(StoreGroup group, string memberName)
        {
            var member = await getMember(group.ID, memberName);

            return(member);
        }