Ejemplo n.º 1
0
 /// <summary>
 /// Adds an <see cref="AdaptiveHealthModifier{T}"/> with <see cref="AdaptiveHealthWithoutDecay"/> and given <paramref name="tuningPolicy"/>.
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="tuningPolicy">A health tuning policy. See <see cref="IAdaptiveHealthTuningPolicy"/> and <see cref="TuningPolicies"/> for details.</param>
 /// <param name="upMultiplier">A multiplier used to increase health. See <see cref="AdaptiveHealthWithoutDecay"/> for details.</param>
 /// <param name="downMultiplier">A multiplier used to decrease health. See <see cref="AdaptiveHealthWithoutDecay"/> for details.</param>
 /// <param name="minimumHealthValue">A minimum possible health value. See <see cref="AdaptiveHealthWithoutDecay"/> for details.</param>
 public static void AddAdaptiveHealthModifierWithoutDecay(
     this IWeighedReplicaOrderingBuilder builder,
     IAdaptiveHealthTuningPolicy tuningPolicy,
     double upMultiplier       = ClusterClientDefaults.AdaptiveHealthUpMultiplier,
     double downMultiplier     = ClusterClientDefaults.AdaptiveHealthDownMultiplier,
     double minimumHealthValue = ClusterClientDefaults.AdaptiveHealthMinimumValue) =>
 builder.AddModifier(new AdaptiveHealthModifier <double>(new AdaptiveHealthWithoutDecay(upMultiplier, downMultiplier, minimumHealthValue), tuningPolicy, builder.Log));
Ejemplo n.º 2
0
 /// <summary>
 /// Adds an <see cref="AdaptiveHealthModifier{T}"/> with <see cref="AdaptiveHealthWithLinearDecay"/> and given <paramref name="tuningPolicy"/>.
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="tuningPolicy">A health tuning policy. See <see cref="IAdaptiveHealthTuningPolicy"/> and <see cref="TuningPolicies"/> for details.</param>
 /// <param name="decayDuration">A duration of full health damage decay. See <see cref="AdaptiveHealthWithLinearDecay"/> for details.</param>
 /// <param name="upMultiplier">A multiplier used to increase health. See <see cref="AdaptiveHealthWithLinearDecay"/> for details.</param>
 /// <param name="downMultiplier">A multiplier used to decrease health. See <see cref="AdaptiveHealthWithLinearDecay"/> for details.</param>
 /// <param name="minimumHealthValue">A minimum possible health value. See <see cref="AdaptiveHealthWithLinearDecay"/> for details.</param>
 public static void AddAdaptiveHealthModifierWithLinearDecay(
     this IWeighedReplicaOrderingBuilder builder,
     IAdaptiveHealthTuningPolicy tuningPolicy,
     TimeSpan decayDuration,
     double upMultiplier       = ClusterClientDefaults.AdaptiveHealthUpMultiplier,
     double downMultiplier     = ClusterClientDefaults.AdaptiveHealthDownMultiplier,
     double minimumHealthValue = ClusterClientDefaults.AdaptiveHealthMinimumValue) =>
 builder.AddModifier(new AdaptiveHealthModifier <HealthWithDecay>(new AdaptiveHealthWithLinearDecay(() => DateTime.UtcNow, decayDuration, upMultiplier, downMultiplier, minimumHealthValue), tuningPolicy, builder.Log));
Ejemplo n.º 3
0
 /// <summary>
 /// Adds a <see cref="SnitchWeightModifier"/> that will apply external weights stored in Service Discovery nodes for given <paramref name="application"/> from given <paramref name="environment"/>.
 /// </summary>
 public static void SetupSnitchWeightModifier(
     [NotNull] this IWeighedReplicaOrderingBuilder self,
     [NotNull] IServiceLocator serviceLocator,
     [NotNull] string environment,
     [NotNull] string application)
 {
     self.AddModifier(new SnitchWeightModifier(serviceLocator, environment, application, self.Log));
 }
 /// <summary>
 /// Adds a <see cref="BoostLocalDatacentersModifier"/> that will increase weight of replicas in local datacenter.
 /// </summary>
 public static void SetupBoostLocalDatacentersWeightModifier(
     [NotNull] this IWeighedReplicaOrderingBuilder self,
     [NotNull] IDatacenters datacenters,
     [NotNull] Func <double> boostMultiplierProvider,
     [NotNull] Func <double> minimumWeightForBoostingProvider)
 {
     self.AddModifier(new BoostLocalDatacentersModifier(datacenters, boostMultiplierProvider, minimumWeightForBoostingProvider));
 }
 /// <summary>
 /// Adds a <see cref="BoostLocalDatacentersModifier"/> that will increase weight of replicas in local datacenter.
 /// </summary>
 public static void SetupBoostLocalDatacentersWeightModifier(
     [NotNull] this IWeighedReplicaOrderingBuilder self,
     [NotNull] IDatacenters datacenters,
     double boostMultiplier          = Constants.DefaultBoostMultiplier,
     double minimumWeightForBoosting = Constants.DefaultMinimumWeightForBoosting)
 {
     self.AddModifier(new BoostLocalDatacentersModifier(datacenters, boostMultiplier, minimumWeightForBoosting));
 }
Ejemplo n.º 6
0
 /// <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));
Ejemplo n.º 7
0
 /// <summary>
 /// Adds a <see cref="GrayListModifier"/> with given fixed <paramref name="grayPeriod"/> to the chain.
 /// </summary>
 public static void AddGrayListModifier(this IWeighedReplicaOrderingBuilder builder, TimeSpan grayPeriod) =>
 builder.AddModifier(new GrayListModifier(new FixedGrayPeriodProvider(grayPeriod), builder.Log));
Ejemplo n.º 8
0
 /// <summary>
 /// Adds a <see cref="GrayListModifier"/> with given <paramref name="grayPeriodProvider"/> to the chain.
 /// </summary>
 public static void AddGrayListModifier(this IWeighedReplicaOrderingBuilder builder, IGrayPeriodProvider grayPeriodProvider) =>
 builder.AddModifier(new GrayListModifier(grayPeriodProvider, builder.Log));
Ejemplo n.º 9
0
 /// <summary>
 /// Adds a <see cref="LeadershipWeightModifier"/> with given <paramref name="leaderResultDetector"/> to the chain.
 /// </summary>
 public static void AddLeadershipModifier(this IWeighedReplicaOrderingBuilder builder, ILeaderResultDetector leaderResultDetector) =>
 builder.AddModifier(new LeadershipWeightModifier(leaderResultDetector, builder.Log));
 /// <summary>
 /// Adds a <see cref="AvoidInactiveDatacentersModifier"/> that will apply zero weights for non-active datacenters.
 /// </summary>
 public static void SetupAvoidInactiveDatacentersWeightModifier(
     [NotNull] this IWeighedReplicaOrderingBuilder self,
     [NotNull] IDatacenters datacenters)
 {
     self.AddModifier(new AvoidInactiveDatacentersModifier(datacenters));
 }