Esempio n. 1
0
        public Dictionary <int, Management.ClientConfiguration.Dom.CacheServer> BringLocalServerToFirstPriority(string localNode, Dictionary <int, Management.ClientConfiguration.Dom.CacheServer> serversPriorityList)
        {
            Dictionary <int, Management.ClientConfiguration.Dom.CacheServer> tempList = new Dictionary <int, Management.ClientConfiguration.Dom.CacheServer>();
            int  localServerPriority = 0;
            bool localServerFound    = false;

            NCache.ServerName = localNode;
            ICacheServer sw            = NCache.GetCacheServer(new TimeSpan(0, 0, 0, 30));
            string       nodeName      = localNode;
            Hashtable    temp          = sw.GetNodeInfo().Map;
            string       server        = temp[Alachisoft.NCache.Management.CacheServer.Channel.SocketServer] as string;
            IPAddress    serverAddress = null;

            if (IPAddress.TryParse(server, out serverAddress))
            {
                nodeName = server;
            }

            foreach (KeyValuePair <int, Management.ClientConfiguration.Dom.CacheServer> pair in serversPriorityList)
            {
                string serverName = pair.Value.ServerName.ToLower();
                if (serverName.CompareTo(nodeName.ToLower()) == 0)
                {
                    localServerFound    = true;
                    localServerPriority = pair.Key;
                    break;
                }
            }

            if (localServerFound)
            {
                tempList.Add(0, serversPriorityList[localServerPriority]);

                int priority = 1;
                foreach (KeyValuePair <int, Management.ClientConfiguration.Dom.CacheServer> pair in serversPriorityList)
                {
                    if (pair.Key != localServerPriority)
                    {
                        tempList.Add(priority++, pair.Value);
                    }
                }

                serversPriorityList = tempList;
            }

            return(serversPriorityList);
        }