Ejemplo n.º 1
0
        public LoadBalancer(ILoadDistributor distributor, IEnumerable <ServerNode> nodePool, string clusterId)
        {
            Distributor = distributor;
            NodePool    = nodePool;

            _persistedDictionary = new PersistentDictionary <int>(clusterId);
        }
        private static string _resolveLoadBalancer(ClusterModel cluster)
        {
            if (cluster == null)
            {
                return(null);
            }

            var nodePool = IoC.Resolve <ServerNodeRepository>()
                           .FindAll()
                           .InPool(cluserId: cluster.Id)
                           .ToList();

            ILoadDistributor loadDistributer = cluster.MapTypeToDistrubtor();

            using (var lb = new LoadBalancer(loadDistributer, nodePool, cluster.Id))
            {
                return(lb.SelectInstanceFromPool());
            }
        }