public void Modify_should_not_modify_weight_when_whitelist_is_empty()
        {
            datacenters.GetActiveDatacenters().Returns(new HashSet <string>());

            modifier.Modify(new Uri("http://url.com/"), null, null, null, null, ref weight);
            weight.Should().Be(1.1);
        }
Example #2
0
        public void Modify(Uri replica, IList <Uri> allReplicas, IReplicaStorageProvider storageProvider, Request request, RequestParameters parameters, ref double weight)
        {
            var active = datacenters.GetActiveDatacenters();

            if (active.Count == 0)
            {
                return;
            }

            var replicaDatacenter = datacenters.GetDatacenterWeak(replica.Host);

            if (replicaDatacenter == null)
            {
                return;
            }

            if (active.Contains(replicaDatacenter))
            {
                return;
            }

            weight = 0;
        }
Example #3
0
        /// <summary>
        /// <para>Returns <c>true</c> if current local datacenter is among ones listed in result of <see cref="IDatacenters.GetActiveDatacenters"/>.</para>
        /// <para>Also returns <c>true</c> if local datacenter cannot be determined.</para>
        /// </summary>
        public static bool LocalDatacenterIsActive([NotNull] this IDatacenters datacenters)
        {
            var localDatacenter = datacenters.GetLocalDatacenter();

            return(localDatacenter == null || datacenters.GetActiveDatacenters().Contains(localDatacenter));
        }
 public IReadOnlyCollection <string> GetActiveDatacenters() =>
 baseDatacenters.GetActiveDatacenters();