Exemplo n.º 1
0
        public async Task EnsureTasksHaveOwnership()
        {
            var healthChecks = AllPeers().Select(async x =>
            {
                var status = await x.CheckStatusOfOwnedTasks().ConfigureAwait(false);
                return(new { Peer = x, Response = status });
            }).ToArray();

            var checks = await Task.WhenAll(healthChecks).ConfigureAwait(false);


            var planner = new TaskHealthAssignmentPlanner(_permanentTasks);

            foreach (var check in checks)
            {
                planner.Add(check.Peer, check.Response);
            }


            var corrections = planner.ToCorrectionTasks(this);

            await Task.WhenAll(corrections).ConfigureAwait(false);

            _logger.Info(() => "Finished running task health monitoring on node " + NodeId);
        }
Exemplo n.º 2
0
        public Task EnsureTasksHaveOwnership()
        {
            var healthChecks = allPeers().Select(x => x.CheckStatusOfOwnedTasks().ContinueWith(_ => {
                return(new { Peer = x, Response = _.Result });
            }));

            return(Task.WhenAll(healthChecks).ContinueWith(checks => {
                var planner = new TaskHealthAssignmentPlanner(_permanentTasks);
                checks.Result.Each(_ => planner.Add(_.Peer, _.Response));

                var corrections = planner.ToCorrectionTasks(this);

                return Task.WhenAll(corrections).ContinueWith(_ => {
                    _logger.Info(() => "Finished running task health monitoring on node " + NodeId);
                }, TaskContinuationOptions.AttachedToParent);
            }, TaskContinuationOptions.AttachedToParent));
        }
        public Task EnsureTasksHaveOwnership()
        {
            var healthChecks = allPeers().Select(x => x.CheckStatusOfOwnedTasks().ContinueWith(_ => {
                return new {Peer = x, Response = _.Result};
            }));

            return Task.WhenAll(healthChecks).ContinueWith(checks => {
                var planner = new TaskHealthAssignmentPlanner(_permanentTasks);
                checks.Result.Each(_ => planner.Add(_.Peer, _.Response));

                var corrections = planner.ToCorrectionTasks(this);

                return Task.WhenAll(corrections).ContinueWith(_ => {

                    _logger.Info(() => "Finished running task health monitoring on node " + NodeId);

                }, TaskContinuationOptions.AttachedToParent);
            }, TaskContinuationOptions.AttachedToParent);
        }
        public async Task EnsureTasksHaveOwnership()
        {
            var healthChecks = AllPeers().Select(async x =>
            {
                var status = await x.CheckStatusOfOwnedTasks().ConfigureAwait(false);
                return new { Peer = x, Response = status };
            }).ToArray();

            var checks = await Task.WhenAll(healthChecks).ConfigureAwait(false);


            var planner = new TaskHealthAssignmentPlanner(_permanentTasks);
            foreach (var check in checks)
            {
                planner.Add(check.Peer, check.Response);
            }


            var corrections = planner.ToCorrectionTasks(this);

            await Task.WhenAll(corrections).ConfigureAwait(false);

            _logger.Info(() => "Finished running task health monitoring on node " + NodeId);
        }