public virtual void LogHeartbeat(string type, string name, string status, string nameValuePairs) { IHeartbeat heartbeat = NewHeartbeat(type, name); if (!string.IsNullOrEmpty(nameValuePairs)) { heartbeat.AddData(nameValuePairs); } heartbeat.Status = status; heartbeat.Complete(); }
public virtual void LogHeartbeat(String type, String name, String status, String nameValuePairs, string messageTreeId) { IHeartbeat heartbeat = NewHeartbeat(type, name, messageTreeId); if (!string.IsNullOrEmpty(nameValuePairs)) { heartbeat.AddData(nameValuePairs); } heartbeat.Status = status; heartbeat.Complete(CallContextManager.MessageTreeId); }
public void Run(object o) { while (true) { if (!m_nodeInfo.HaveAcessRight) { break; } m_nodeInfo.Refresh(); var messageTreeId = Jasmine.GetManager().GetMessageIdFactory().GetNextId(); ITransaction t = Jasmine.GetProducer().NewTransaction("System", "Status", messageTreeId); IHeartbeat h = Jasmine.GetProducer().NewHeartbeat("Heartbeat", domainInfo.Ip, messageTreeId); var xml = XmlHelper.XmlSerialize(m_nodeInfo, Encoding.UTF8); h.AddData(xml); h.Status = "0"; h.Complete(messageTreeId); t.Status = "0"; t.Complete(messageTreeId); Thread.Sleep(this.domainInfo.TickTime); } }
public void Run(object o) { try { // Get DLL versions collectComponentVersions(); Random random = new Random(); int initialSleep = random.Next(CatConstants.HEARTBEAT_MIN_INITIAL_SLEEP_MILLISECONDS, CatConstants.HEARTBEAT_MAX_INITIAL_SLEEP_MILLISECONDS); Console.WriteLine("Heartbeat initial sleep: " + initialSleep + " ms"); Thread.Sleep(initialSleep); } catch (Exception ex) { Cat.lastException = ex; return; } // In Java, try to avoid send heartbeat at 59-01 second, which is missing here in .NET // In Java, try to build class paths, which is a list of jar file names. try { ITransaction reboot = Cat.NewTransaction("System", "Reboot"); reboot.Status = CatConstants.SUCCESS; Cat.LogEvent("Reboot", NetworkInterfaceManager.HostIP, CatConstants.SUCCESS); reboot.Complete(); DateTime lastSendVersionsTimestamp = default(DateTime); while (true) { ITransaction t = Cat.NewTransaction("System", "Status"); t.AddData(CatConstants.DUMP_LOCKED, false); IHeartbeat h = Cat.NewHeartbeat("Heartbeat", NetworkInterfaceManager.HostIP); try { var now = DateTime.Now; bool isLongIntevalHeartbeat = false; if (default(DateTime) == lastSendVersionsTimestamp || now.Hour != lastSendVersionsTimestamp.Hour || (now - lastSendVersionsTimestamp >= TimeSpan.FromMinutes(LONG_INTERVAL_HEARBEAT_MINUTES))) { isLongIntevalHeartbeat = true; lastSendVersionsTimestamp = now; } h.AddData(BuildStatusData(isLongIntevalHeartbeat)); h.Status = CatConstants.SUCCESS; if (isLongIntevalHeartbeat) { string configHeartBeatMessage = config.GetConfigHeartbeatMessage(); if (!String.IsNullOrWhiteSpace(configHeartBeatMessage)) { Cat.LogEvent("Cat.Client.InconsistentAppId", configHeartBeatMessage); } } } catch (Exception ex) { Cat.lastException = ex; h.SetStatus(ex); Cat.LogError(ex); } finally { h.Complete(); } if (!String.IsNullOrEmpty(fileVersion)) { Cat.LogEvent("Cat.Client.Version", fileVersion); } t.Status = CatConstants.SUCCESS; t.Complete(); // Append Cat.lastException if not null if (null != Cat.lastException) { Exception ex = Cat.lastException; Cat.lastException = null; Cat.LogEvent("Cat.Client.LastException", ex.GetType().Name, CatConstants.SUCCESS, ex.ToString()); } // Append Cat.lastMessage if not null if (!String.IsNullOrWhiteSpace(Cat.lastMessage)) { Cat.LogEvent("Cat.Client.LastMessage", "msg", CatConstants.SUCCESS, "message=" + Cat.lastMessage); Cat.lastMessage = null; } // Sleep to the 30th second of the next minute, not to the 30th second of the current minute. var sleepInSeconds = 90 - DateTime.Now.Second; Thread.Sleep(sleepInSeconds * 1000); } } catch (Exception ex) { Cat.lastException = ex; } }