Exemplo n.º 1
0
        public SubscriberStats GetStats(bool withSystemStats = false)
        {
            string currentEndPoint;
            string topic;
            string type;

            lock (_statSync)
            {
                currentEndPoint = _currentEndPoint;
                topic           = _statTopic;
                type            = _statType;
            }

            long count     = 0;
            long beatCount = 0;
            long totalCount;

            lock (_clientSync)
            {
                if (_client != null)
                {
                    count     = _client.GetMessageCount();
                    beatCount = _client.GetBeatCount();
                }

                if (count < _lastCount)
                {
                    _lastCount = 0;
                }

                _totalCount += count - _lastCount;

                _lastCount = count;

                totalCount = _totalCount;
            }

            var statsBuilder = new SystemStatsBuilder();

            if (withSystemStats)
            {
                statsBuilder.ReadInFromCurrentProcess();
            }

            return(new SubscriberStats(Interlocked.CompareExchange(ref _connected, 0, 0) == 1,
                                       Interlocked.CompareExchange(ref _reconnect, 0, 0),
                                       Interlocked.CompareExchange(ref _beatFailover, 0, 0),
                                       count, beatCount, totalCount, currentEndPoint, _statEndPoints, topic, type, _name, statsBuilder.Build()));
        }
Exemplo n.º 2
0
        public PublisherStats GetStats(bool withSystemStats = false)
        {
            var clients = _store.Subscriptions
                          .Select(client => new PublisherClientStats(
                                      client.Name,
                                      client.MessageLoss,
                                      client.Backlog,
                                      client.EndPoint,
                                      client.Topic,
                                      client.Type,
                                      client.MessageCount,
                                      client.BeatCount))
                          .ToList();

            var statsBuilder = new SystemStatsBuilder();

            if (withSystemStats)
            {
                statsBuilder.ReadInFromCurrentProcess();
            }

            return(new PublisherStats(clients, statsBuilder.Build()));
        }