コード例 #1
0
        private void RunHeartBeatThread()
        {
            while (!threadStopped)
            {
                try {
                    SlaveClientCom.Instance.StatusChanged(ConfigManager.Instance.GetStatusForClientConsole());
                }
                catch (Exception ex) {
                    EventLogManager.LogMessage("Couldn't sent status information to client ui. Exception is: " + Environment.NewLine + ex.ToString());
                }

                try {
                    lock (locker) {
                        if (wcfService.ConnState != NetworkEnum.WcfConnState.Connected)
                        {
                            // login happens automatically upon successfull connection
                            wcfService.Connect(ConfigManager.Instance.GetClientInfo());
                            SlaveStatusInfo.LoginTime = DateTime.Now;
                        }
                        if (wcfService.ConnState == NetworkEnum.WcfConnState.Connected)
                        {
                            Slave info = ConfigManager.Instance.GetClientInfo();

                            Heartbeat heartBeatData = new Heartbeat {
                                SlaveId        = info.Id,
                                FreeCores      = info.Cores.HasValue ? info.Cores.Value - SlaveStatusInfo.UsedCores : 0,
                                FreeMemory     = ConfigManager.Instance.GetFreeMemory(),
                                CpuUtilization = ConfigManager.Instance.GetCpuUtilization(),
                                JobProgress    = ConfigManager.Instance.GetExecutionTimeOfAllJobs(),
                                AssignJob      = !ConfigManager.Instance.Asleep,
                                HbInterval     = (int)interval.TotalSeconds
                            };

                            SlaveClientCom.Instance.LogMessage("Send HB: " + heartBeatData);
                            List <MessageContainer> msgs = wcfService.SendHeartbeat(heartBeatData);

                            if (msgs == null)
                            {
                                SlaveClientCom.Instance.LogMessage("Error getting response from HB");
                            }
                            else
                            {
                                SlaveClientCom.Instance.LogMessage("HB Response received (" + msgs.Count + "): ");
                                msgs.ForEach(mc => SlaveClientCom.Instance.LogMessage(mc.Message.ToString()));
                                msgs.ForEach(mc => MessageQueue.GetInstance().AddMessage(mc));
                            }
                        }
                    }
                }
                catch (Exception e) {
                    SlaveClientCom.Instance.LogMessage("Heartbeat thread failed: " + e.ToString());
                }
                waitHandle.WaitOne(this.interval);
            }
            SlaveClientCom.Instance.LogMessage("Heartbeat thread stopped");
        }
コード例 #2
0
        private void DispatchMessageQueue()
        {
            MessageQueue queue = MessageQueue.GetInstance();

            while (!abortRequested)
            {
                MessageContainer container = queue.GetMessage();
                DetermineAction(container);
                if (!abortRequested)
                {
                    SlaveClientCom.Instance.StatusChanged(configManager.GetStatusForClientConsole());
                }
            }
        }
コード例 #3
0
        public void Sleep()
        {
            MessageContainer mc = new MessageContainer(MessageContainer.MessageType.Sleep);

            MessageQueue.GetInstance().AddMessage(mc);
        }
コード例 #4
0
        public void AbortAll()
        {
            MessageContainer mc = new MessageContainer(MessageContainer.MessageType.AbortAll);

            MessageQueue.GetInstance().AddMessage(mc);
        }
コード例 #5
0
        public void Restart()
        {
            MessageContainer mc = new MessageContainer(MessageContainer.MessageType.Restart);

            MessageQueue.GetInstance().AddMessage(mc);
        }