Beispiel #1
0
        public Task <TaskHealthResponse> CheckStatusOfOwnedTasks()
        {
            var subjects = CurrentlyOwnedSubjects();

            if (!subjects.Any())
            {
                return(TaskHealthResponse.Empty().ToCompletionTask());
            }

            var checks = subjects
                         .Select(subject => CheckStatus(subject).ContinueWith(t => new PersistentTaskStatus(subject, t.Result)))
                         .ToArray();

            return(Task.Factory.ContinueWhenAll(checks, tasks => new TaskHealthResponse
            {
                Tasks = tasks.Select(x => x.Result).ToArray()
            }));
        }
Beispiel #2
0
        public Task <TaskHealthResponse> CheckStatusOfOwnedTasks()
        {
            var subjects = CurrentlyOwnedSubjects().ToArray();

            if (!subjects.Any())
            {
                return(Task.FromResult(TaskHealthResponse.Empty()));
            }

            var request = new TaskHealthRequest
            {
                Subjects = subjects
            };

            return(_serviceBus.Request <TaskHealthResponse>(request, new RequestOptions
            {
                Destination = ControlChannel,
                Timeout = _settings.HealthCheckMessageTimeout
            }).ContinueWith(t => {
                if (t.IsFaulted)
                {
                    _logger.Error(NodeId, "Could not retrieve persistent status checks", t.Exception);

                    t.Exception.Handle(e => true);

                    return TaskHealthResponse.ErrorFor(subjects);
                }

                if (t.IsCompleted)
                {
                    var response = t.Result;
                    response.AddMissingSubjects(subjects);

                    return response;
                }

                _logger.Info(() => "Persistent task health status timedout for node " + NodeId);
                return TaskHealthResponse.ErrorFor(subjects);
            }));
        }