Beispiel #1
0
        public Task <TaskHealthResponse> Handle(TaskHealthRequest request)
        {
            Debug.WriteLine("Received message {0} from {1}", request, _envelope.ReplyUri);

            return(_controller.CheckStatusOfOwnedTasks().ContinueWith(t => {
                if (t.IsFaulted)
                {
                    return TaskHealthResponse.ErrorFor(request.Subjects);
                }

                var response = t.Result;
                response.AddMissingSubjects(request.Subjects);

                Debug.WriteLine("Responding with {0} on node {1} from health request from {2}", response, _graph.NodeId, _envelope.ReplyUri);

                return response;
            }));
        }
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);
            }));
        }