public DefaultServerWeightAccumulater(IServerStatusCollector collector, int serverWeightTaskTimerInterval = 30 * 1000)
 {
     _collector    = collector ?? throw new ArgumentNullException(nameof(collector));
     _weightsLock  = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion);
     _timeoutTimer = new HashedWheelEvictionTimer(Utils.Timer);
     _timeoutTimer.Schedule(Accumulate, TimeSpan.FromMilliseconds(serverWeightTaskTimerInterval));
     Accumulate();
 }
Beispiel #2
0
 public BaseLoadBalancer(int pingInterval, string name, IRule rule, IPing ping, IPingStrategy pingStrategy, ILoggerFactory factory)
 {
     _name = name;
     _rule = rule;
     _ping = ping;
     if (_ping == null)
     {
         throw new ArgumentNullException(nameof(ping));
     }
     _logger        = factory?.CreateLogger(typeof(BaseLoadBalancer)) ?? NullLogger.Instance;
     _pingStrategy  = pingStrategy ?? new SerialPingStrategy();
     _allServerLock = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion);
     _upServerLock  = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion);
     _counter       = new Counter();
     _timeoutTimer  = new HashedWheelEvictionTimer(Utils.Timer);
     _timeoutTimer.Schedule(this.RunPing, TimeSpan.FromMilliseconds(pingInterval));
     RunPing();
 }