Example #1
0
 private void BroadcastServerUpdate()
 {
     _myNodeStatus = ConvetToMyEntity(m_CurrentNodeStatus);
     var message = string.Format("{0} {1}\r\n", "ManagementServer ", JsonConvert.SerializeObject(_myNodeStatus));
     int i = this.SessionCount;
     //Only push update to loged in sessions
     foreach (var s in this.GetSessions(s => s.Connected))
     {
         s.TrySend(message);
     }
 }
Example #2
0
        private MyNodeStatus ConvetToMyEntity(NodeStatus m_CurrentNodeStatus)
        {
            MyNodeStatus myNodeStatus = new MyNodeStatus();
            var bootstrapStatus = m_CurrentNodeStatus.BootstrapStatus;
            MyBootstrapStatus myBootstrapStatus = new MyBootstrapStatus();
            myBootstrapStatus.AvailableWorkingThreads = bootstrapStatus.Values["AvailableWorkingThreads"].ToString();
            myBootstrapStatus.AvailableCompletionPortThreads = bootstrapStatus.Values["AvailableCompletionPortThreads"].ToString();
            myBootstrapStatus.MaxCompletionPortThreads = bootstrapStatus.Values["MaxCompletionPortThreads"].ToString();
            myBootstrapStatus.MaxWorkingThreads = bootstrapStatus.Values["MaxWorkingThreads"].ToString();
            myBootstrapStatus.TotalThreadCount = bootstrapStatus.Values["TotalThreadCount"].ToString();
            myBootstrapStatus.CpuUsage = bootstrapStatus.Values["CpuUsage"].ToString();
            myBootstrapStatus.MemoryUsage = bootstrapStatus.Values["MemoryUsage"].ToString();
            myNodeStatus.MyBootstrapStatus = myBootstrapStatus;

            var instancesStatus = m_CurrentNodeStatus.InstancesStatus;
            myNodeStatus.MyInstancesStatus = new List<MyInstancesStatus>();
            foreach (var item in instancesStatus)
            {
                MyInstancesStatus InstancesStatus = new MyInstancesStatus();
                InstancesStatus.CollectedTime = item.CollectedTime.ToString();
                InstancesStatus.Name = item.Name;
                InstancesStatus.Tag = item.Tag;
                InstancesStatus.MaxConnectionNumber = item.Values["MaxConnectionNumber"].ToString();
                ListenerInfo[] ListenerInfos = item.Values["Listeners"] as ListenerInfo[];
                if (ListenerInfos == null || ListenerInfos.Length < 1)
                {
                    InstancesStatus.Listeners = "0.0.0.0";
                }
                else
                {
                    InstancesStatus.Listeners = ListenerInfos[0].EndPoint.ToString();
                }
                InstancesStatus.IsRunning = item.Values["IsRunning"].ToString();
                InstancesStatus.StartedTime = !item.Values.ContainsKey("StartedTime") || item.Values["StartedTime"] == null ? string.Empty : item.Values["StartedTime"].ToString();
                InstancesStatus.TotalConnections = item.Values["TotalConnections"].ToString();
                InstancesStatus.RequestHandlingSpeed = item.Values["RequestHandlingSpeed"].ToString();
                InstancesStatus.TotalHandledRequests = item.Values["TotalHandledRequests"].ToString();
                InstancesStatus.AvialableSendingQueueItems = item.Values["AvialableSendingQueueItems"].ToString();
                InstancesStatus.TotalSendingQueueItems = item.Values["TotalSendingQueueItems"].ToString();
                myNodeStatus.MyInstancesStatus.Add(InstancesStatus);
            }
            return myNodeStatus;
        }