Esempio n. 1
0
        public Dictionary <int, Management.ClientConfiguration.Dom.CacheServer> GetPrioritizedServerListForClient(string clientNode, string clusterId, ArrayList _nodeList)
        {
            int    priority         = 0;
            string ClientServerName = "";
            Dictionary <int, Management.ClientConfiguration.Dom.CacheServer> serversPriorityList = new Dictionary <int, Management.ClientConfiguration.Dom.CacheServer>();

            foreach (ServerNode serverNode in _nodeList)
            {
                Management.ClientConfiguration.Dom.CacheServer server = new Management.ClientConfiguration.Dom.CacheServer();


                try
                {
                    NCache.ServerName = serverNode.IP;
                    ICacheServer _cacheServer = NCache.GetCacheServer(new TimeSpan(0, 0, 0, 30));
                    Hashtable    bindedIps    = _cacheServer.BindedIp().Map;
                    if (bindedIps.Contains(Alachisoft.NCache.Management.Channel.SocketServer))
                    {
                        ClientServerName = bindedIps[Alachisoft.NCache.Management.Channel.SocketServer].ToString();
                    }

                    if (!string.IsNullOrEmpty(ClientServerName))
                    {
                        server.ServerName = ClientServerName;
                    }
                    else
                    {
                        server.ServerName = serverNode.IP;
                    }
                }
                catch (Exception ex)
                {
                    ClientServerName  = serverNode.IP;
                    server.ServerName = serverNode.IP;
                }

                server.Priority = priority;
                serversPriorityList[priority++] = server;
            }

            serversPriorityList = BringLocalServerToFirstPriority(clientNode, serversPriorityList);
            return(serversPriorityList);
        }