Exemplo n.º 1
0
        private void OnModuleTerminated(TerminatedModule moduleTerminated)
        {
            Task.Run(() =>
            {
                _timer.Stop();
                if (_prepareTerminatedModule == moduleTerminated.Module)
                {
                    _modules.Dequeue();
                    _logger.Trace($"{_prepareTerminatedModule.ToString()} stopped.");
                }
                else
                {
                    throw new Exception("Termination error");
                }

                if (_modules.Count == 0)
                {
                    _logger.Trace("node will be closed after 5s...");
                    for (var i = 0; i < 5; i++)
                    {
                        _logger.Trace($"{5 - i}");
                        Thread.Sleep(1000);
                    }

                    _logger.Trace("node is closed.");
                    _closing.Set();
                }
                else
                {
                    PublishMessage();
                }
            });
        }
Exemplo n.º 2
0
        private void PublishMessage()
        {
            _prepareTerminatedModule = _modules.Peek();
            _logger.Trace($"begin stop {_prepareTerminatedModule.ToString()}...");
            MessageHub.Instance.Publish(new TerminationSignal(_prepareTerminatedModule));

            _timer.Start();
        }