Example #1
0
 private void GetNsqdInformation(ProducerInformation nsqdNode)
 {
     var httpUri = string.Format("http://{0}:{1}", nsqdNode.BroadcastAddress, nsqdNode.HttpPort);
     var client = new NsqdHttpClient(httpUri, TimeSpan.FromSeconds(10));
     var stats = client.GetStats();
     var topics = new List<TopicModel>(Topics);
     foreach (var topic in topics)
     {
         var nsqdTopic = stats.Topics.SingleOrDefault(p => p.TopicName == topic.Topic);
         //int? messageCount = nsqdTopic == null ? (int?)null : nsqdTopic.MessageCount;
         topic.SetNsqdStats(nsqdNode, nsqdTopic);
     }
 }
Example #2
0
            internal void SetNsqdStats(ProducerInformation nsqdNode, NsqdStatsTopic nsqdTopic)
            {
                if (nsqdNode == null)
                    throw new ArgumentNullException("nsqdNode");

                lock (_nsqdStatsLocker)
                {
                    string key = string.Format("{0}:{1}", nsqdNode.BroadcastAddress, nsqdNode.HttpPort);
                    _nsqdStats[key] = nsqdTopic;
                }

                CalculateStats();
            }