public void SetUp() { settings = new RelativeWeightSettings() { WeightUpdatePeriod = 200.Milliseconds(), PenaltyMultiplier = 100, InitialWeight = 1, StatisticSmoothingConstant = 100.Milliseconds(), WeightsDownSmoothingConstant = 100.Milliseconds(), WeightsRaiseSmoothingConstant = 100.Milliseconds(), WeightsTTL = 5.Minutes(), MinWeight = 0.005, Sensitivity = 3 }; clusterState = new ClusterState( timeProvider: Substitute.For <ITimeProvider>(), rawClusterStatistic: Substitute.For <IRawClusterStatistic>(), statisticHistory: Substitute.For <IStatisticHistory>(), relativeWeightCalculator: Substitute.For <IRelativeWeightCalculator>(), weightsNormalizer: Substitute.For <IWeightsNormalizer>(), weights: Substitute.For <IWeights>()); replicaStorageProvider = Substitute.For <IReplicaStorageProvider>(); storageProvider = Substitute.For <IGlobalStorageProvider>(); storageProvider.ObtainGlobalValue(Arg.Any <string>(), Arg.Any <Func <ClusterState> >()) .Returns(info => clusterState); relativeWeightModifier = new RelativeWeightModifier(settings, "srv", "env", 0, 1, storageProvider); }
public void SetUp() { settings = new RelativeWeightSettings() { WeightsTTL = 1.Hours() }; weights = new Weights(); }
public void Setup() { settings = new RelativeWeightSettings() { WeightUpdatePeriod = 200.Milliseconds(), PenaltyMultiplier = 100, InitialWeight = 1, StatisticSmoothingConstant = 100.Milliseconds(), WeightsDownSmoothingConstant = 100.Milliseconds(), WeightsRaiseSmoothingConstant = 100.Milliseconds(), WeightsTTL = 5.Minutes(), MinWeight = 0.005, Sensitivity = 3 }; relativeWeightCalculator = new RelativeWeightCalculator(); }
/// <summary> /// Adds an <see cref="RelativeWeightModifier"/> with given <see cref="RelativeWeightSettings"/> to the chain. /// </summary> /// <param name="builder"></param> /// <param name="settings">A relative weight settings.</param> /// <param name="globalStorageProvider">Global storage.</param> public static void AddRelativeWeightModifier(this IWeighedReplicaOrderingBuilder builder, RelativeWeightSettings settings, IGlobalStorageProvider globalStorageProvider = null) => builder.AddModifier(new RelativeWeightModifier(settings, builder.ServiceName, builder.Environment, builder.MinimumWeight, builder.MaximumWeight, globalStorageProvider, builder.Log));