コード例 #1
0
ファイル: ShardValueDetail.cs プロジェクト: waqashaneef/NosDB
        public override bool TryGetNodeDetail(out NodeDetail nodeDetail)
        {
            NodeDetail         thisNode       = new EndNodeDetail();
            List <string>      childernNaames = new List <string>();
            ShardConfiguration shardConfig    = (ShardConfiguration)Configuration;

            foreach (ServerNode node in shardConfig.Servers.Nodes.Values)
            {
                if (node.Name.Equals(PathChunks[0]))
                {
                    childernNaames.Add(node.Priority.ToString());
                    string[] childPathChunks = new string[this.PathChunks.Length - 1];
                    Array.Copy(this.PathChunks, 1, childPathChunks, 0, this.PathChunks.Length - 1);
                    ServerDetail s1 = new ServerDetail()
                    {
                        IPAddress = node.Name,
                        Priority  = node.Priority
                    };
                    thisNode = new ServerValueDetail(PathChunks[0], PathType.Server, s1, childPathChunks);
                }
            }
            if (PathChunks.Length == 1)
            {
                nodeDetail = thisNode;
                return(true);
            }

            return(thisNode.TryGetNodeDetail(out nodeDetail));
        }
コード例 #2
0
        public override bool TryGetNodeDetail(out NodeDetail nodeDetail)
        {
            NodeDetail    thisNode       = new EndNodeDetail();
            bool          sucess         = false;
            List <string> childernNaames = new List <string>();

            foreach (var node in ((ConfigClusterInfo)Configuration).Servers)
            {
                if (node.IPAddress.Equals(PathChunks[0]))
                {
                    childernNaames.Add(node.Priority.ToString());
                    string[] childPathChunks = new string[this.PathChunks.Length - 1];
                    Array.Copy(this.PathChunks, 1, childPathChunks, 0, this.PathChunks.Length - 1);

                    thisNode = new ServerValueDetail(PathChunks[0], PathType.ConfigurationNode, node, childPathChunks);
                    sucess   = true;
                }
            }
            if (PathChunks.Length == 1)
            {
                nodeDetail = thisNode;
                return(sucess);
            }
            return(thisNode.TryGetNodeDetail(out nodeDetail));
        }