public static void Enqueue <T>(this ISchedule <T> schedule, IEnumerable <T> tasks) { foreach (var task in tasks) { schedule.Enqueue(task); } }
public FingerTable(IOptions <DhtSettings> options, ISchedule scheduler) { _numDHT = options.Value.MaxNumberOfNodes; _numberOfFingerTableEntries = (uint)Math.Ceiling(Math.Log(_numDHT - 1) / Math.Log(2)); FingerTableEntries = new FingerTableEntry[_numberOfFingerTableEntries]; scheduler.Enqueue(new Timer(TimeSpan.FromSeconds(options.Value.FixFingersCallInSeconds).TotalMilliseconds), FixFingers); }
public void Schedule(IEnumerable <TestCase> testCases, int workerCount) { _logger.LogTrace("Scheduling tests"); if (_customTestSessions != null) { foreach (var session in _customTestSessions) { session.OnSessionStart(Options); } } _schedule.Enqueue(testCases); for (int i = 0; i < workerCount; ++i) { _tasks.Add(Task.Factory.StartNew(() => WorkerAction(this, _schedule), _cancellationToken)); } }
public NodeCheckingPredecessor(IDhtActions dhtActions, INetworkAdapter networkAdapter, IOptions <DhtSettings> options, ITimeOutScheduler timeOutScheduler, ISchedule scheduler) { _dhtActions = dhtActions; _timeOutScheduler = timeOutScheduler; _scheduler = scheduler; networkAdapter.CheckPredecessorHandler += CheckPredecessorHandler; networkAdapter.CheckPredecessorResponseHandler += CheckPredecessorResponseHandler; var dhtSettings = options.Value; double timeOut = TimeSpan.FromSeconds(dhtSettings.TimeToLiveInSeconds).TotalMilliseconds; _timeOutScheduler.AddTimeOutTimer(OriginPredecessor, dhtSettings.MaxRetryAttempts, timeOut, CheckPredecessor, TimeOutCheckPredecessorHandler); scheduler.Enqueue( new Timer(TimeSpan.FromSeconds(dhtSettings.CheckPredecessorCallInSeconds).TotalMilliseconds), CheckPredecessor); }
public NodeStabilizing(INetworkAdapter networkAdapter, IOptions <DhtSettings> options, IDhtActions dhtActions, ITimeOutScheduler timeOutScheduler, ISchedule scheduler) { _options = options; _dhtActions = dhtActions; _timeOutScheduler = timeOutScheduler; networkAdapter.StabilizeHandler += StabilizeHandler; networkAdapter.StabilizeResponseHandler += StabilizeResponseHandler; var dhtSettings = _options.Value; double timeOut = TimeSpan.FromSeconds(dhtSettings.TimeToLiveInSeconds).TotalMilliseconds; _timeOutScheduler.AddTimeOutTimer(OriginSuccessor, dhtSettings.MaxRetryAttempts + 1, timeOut, Stabilize, OnTimeOutStabilizeHandler); scheduler.Enqueue(new Timer(TimeSpan.FromSeconds(dhtSettings.StabilizeCallInSeconds).TotalMilliseconds), Stabilize); }