Exemplo n.º 1
0
        public ISolrClusterReplica Balance(ISolrClusterReplicas replicas, bool leader)
        {
            if (leader)
            {
                return(replicas.Leader.IsActive
                    ? replicas.Leader
                    : null);
            }
            var probes = new HashSet <int>();

            while (probes.Count < replicas.Count)
            {
                var index = GetNextIndex(replicas.Count) % replicas.Count;
                if (!probes.Add(index))
                {
                    continue;
                }
                var replica = replicas[index];
                if (replica.IsActive)
                {
                    return(replica);
                }
            }
            return(null);
        }
 public ISolrClusterReplica Balance(ISolrClusterReplicas replicas, bool leader)
 {
     if (leader)
         return replicas.Leader.IsActive
             ? replicas.Leader
             : null;
     var probes = new HashSet<int>();
     while (probes.Count < replicas.Count)
     {
         var index = GetNextIndex(replicas.Count) % replicas.Count;
         if (!probes.Add(index))
             continue;
         var replica = replicas[index];
         if (replica.IsActive)
             return replica;
     }
     return null;
 }
Exemplo n.º 3
0
 public SolrClusterOperationsProxy(ISolrClusterBalancer clusterBalancer, SolrClusterExceptionHandlers exceptionHandlers, int maxAttempts, ISolrOperationsProvider operationsProvider, ISolrClusterReplicas usableReplicas)
 {
     this.clusterBalancer    = clusterBalancer;
     this.exceptionHandlers  = exceptionHandlers;
     this.maxAttempts        = maxAttempts;
     this.operationsProvider = operationsProvider;
     this.usableReplicas     = usableReplicas;
 }