public Agent(string NodeId, string AgentId, string AgentPath, Illuminate.Communication.Communicator Com) { _com = Com; _nodeId = NodeId; _agentId = _nodeId + "_" + AgentId; _agentPath = AgentPath; _sectionName = AgentId; #region Get Agent Filename string tempPath = _agentPath; tempPath = tempPath.Replace("\\", "/"); string[] pathParts = tempPath.Split('/'); _agentType = pathParts[pathParts.Length - 1]; #endregion #region Get Log Name if (_agentId.Contains("Monitor") || _agentId.Contains("Manager")) { LOGNAME = _agentId; } else { LOGNAME = _agentId + "_" + _agentType; } #endregion }
public static string GetStatus(string nodeId, Illuminate.Core.Node.AgentCollection agentCollection) { System.Reflection.Assembly ass = System.Reflection.Assembly.GetExecutingAssembly(); StringBuilder output = new StringBuilder(); output.Append("Illuminate Agent Status\n"); output.Append("--------------------\n"); output.Append("\n"); output.Append("Node Identifier: " + nodeId); output.Append("\n\n"); output.Append(Tools.Tools.GetString("#", 3) + Tools.Tools.GetString("Agent Type", 40) + Tools.Tools.GetString("Id", 21) + Tools.Tools.GetString("Cnt", 6) + Tools.Tools.GetString("Status", 8) + "\n"); output.Append(Tools.Tools.GetUnderline(36 + 7 + 25 + 11) + "\n"); output.Append("\n"); for (int i = 0; i < agentCollection.Count; i++) { output.Append(Tools.Tools.GetString(i.ToString(), 3) + Tools.Tools.GetString(agentCollection[i].AgentType, 39) + " " + Tools.Tools.GetString(agentCollection[i].AgentId, 20) + " "); output.Append(Tools.Tools.GetString(agentCollection[i].RunCount.ToString(), 6)); output.Append(Tools.Tools.GetString(agentCollection[i].Status.ToString(), 15)); output.Append("\n"); } return output.ToString(); }
public new void InitializeAgent(Illuminate.Contexts.AgentContext context) { _dataService = context.NodeDataService; base.InitializeAgent(context); _currentManagerNodeName = _context.NodeId; _context.NodeId = Illuminate.Communication.Communicator.MANAGERNAME; Logger.WriteLine("Getting AgentManagerInterval...", Logger.Severity.Debug, LOGNAME); int agentManagerInterval = 0; if (!int.TryParse(_dataService.Monitor.GetSetting(Illuminate.Node.Managers.Settings.AgentManagerInterval), out agentManagerInterval)) throw new Illuminate.Exceptions.ErrorException("AgentManagerInterval either not defined or invalid."); _context.Interval = agentManagerInterval; Logger.WriteLine("AgentManagerInterval: " + _context.Interval.ToString() + "...", Logger.Severity.Debug, LOGNAME); Logger.WriteLine("Getting EnableLoadBalancing...", Logger.Severity.Debug, LOGNAME); _enableLoadBalancing = false; if (_dataService.Monitor.GetSetting(Illuminate.Node.Managers.Settings.EnableLoadBalancing) == "True") { _enableLoadBalancing = true; _loadBalancer = new LoadBalancer(context, LOGNAME); } else { Logger.WriteLine("LoadBalancing is disabled.", Logger.Severity.Information, LOGNAME); } Logger.WriteLine("EnableLoadBalancing: " + _enableLoadBalancing.ToString() + "...", Logger.Severity.Debug, LOGNAME); _context.Communicator.OnDataIn += new Illuminate.Communication.Communicator.OnDataInDelegate(com_OnDataIn); _dataService.Monitor.NotifyNewManagerStarted(_currentManagerNodeName); }
public LoadBalancer(Illuminate.Contexts.AgentContext context, string logName) { _dataService = context.NodeDataService; LOGNAME = logName; _sentWarningMessages = new Dictionary<string, List<LoadBalancingWarning.WarningTypeEnum>>(); _systemLoads = new Dictionary<string, Illuminate.Node.Entities.ISystemLoad>(); _nodeAgentManagement = new NodeAgentManagement(_dataService, LOGNAME); _nodeAgentManagement.OnSendWarning += new NodeAgentManagement.OnSendWarningDelegate(QueueWarningEmail); _warningMessages = new List<LoadBalancingWarning>(); _nodeWarningSendTime = new Dictionary<string, DateTime>(); string warningDisplayName = _dataService.Monitor.GetSetting(Illuminate.Node.Managers.Settings.LoadBalancerDisplayName); if (!string.IsNullOrEmpty(warningDisplayName)) _warningDisplayName = warningDisplayName; Logger.WriteLine("LoadBalancerDisplayName: " + _warningDisplayName, Logger.Severity.Debug, LOGNAME); _warningFromAddress = _dataService.Monitor.GetSetting(Illuminate.Node.Managers.Settings.LoadBalancerFromAddress); if (string.IsNullOrEmpty(_warningFromAddress)) throw new Illuminate.Exceptions.ErrorException("LoadBalancerFromAddress either not defined or invalid."); Logger.WriteLine("LoadBalancerFromAddress: " + _warningFromAddress, Logger.Severity.Debug, LOGNAME); _warningToAddress = _dataService.Monitor.GetSetting(Illuminate.Node.Managers.Settings.LoadBalancerWarningDest); if (string.IsNullOrEmpty(_warningToAddress)) throw new Illuminate.Exceptions.ErrorException("LoadBalancerWarningTo either not defined or invalid."); Logger.WriteLine("LoadBalancerWarningTo: " + _warningToAddress, Logger.Severity.Debug, LOGNAME); if (!int.TryParse(_dataService.Monitor.GetSetting(Illuminate.Node.Managers.Settings.MaxWaitBeforeDead), out _maxWaitBeforeDead)) throw new Illuminate.Exceptions.ErrorException("MaxWaitBeforeDead either not defined or invalid."); Logger.WriteLine("MaxWaitBeforeDead: " + _maxWaitBeforeDead.ToString(), Logger.Severity.Debug, LOGNAME); if (!double.TryParse(_dataService.Monitor.GetSetting(Illuminate.Node.Managers.Settings.OptimalSystemLoad), out _optimalSystemLoad)) throw new Illuminate.Exceptions.ErrorException("OptimalSystemLoad either not defined or invalid."); Logger.WriteLine("OptimalSystemLoad: " + _optimalSystemLoad.ToString(), Logger.Severity.Debug, LOGNAME); if (!double.TryParse(_dataService.Monitor.GetSetting(Illuminate.Node.Managers.Settings.OptimalLoadWindowSize), out _optimalLoadWindowSize)) throw new Illuminate.Exceptions.ErrorException("OptimalLoadWindowSize either not defined or invalid."); Logger.WriteLine("OptimalLoadWindowSize: " + _optimalLoadWindowSize.ToString(), Logger.Severity.Debug, LOGNAME); _optimalSystemLoadLowerBound = _optimalSystemLoad - _optimalLoadWindowSize; _optimalSystemLoadUpperBound = _optimalSystemLoad + _optimalLoadWindowSize; string extendedLoadBalancer = _dataService.Monitor.GetSetting(Illuminate.Node.Managers.Settings.ExtendedLoadBalancer); if (!string.IsNullOrEmpty(extendedLoadBalancer)) { Logger.WriteLine("ExtendedLoadBalancer: " + extendedLoadBalancer, Logger.Severity.Information, LOGNAME); try { Invoker inv = new Invoker(); _extendedLoadBalancer = (ILoadBalancer)inv.Invoke(context.AgentPath + extendedLoadBalancer, typeof(ILoadBalancer)); _extendedLoadBalancer.InitializePlugin(_dataService, LOGNAME); } catch (Exception ex) { Logger.WriteLine("Unable to load extended load balancer: " + ex.Message, Logger.Severity.Error, LOGNAME); _extendedLoadBalancer = null; } } //load initial data UpdateSystemLoadCache(); }
public Node(int EntryId, string NodeName, string Status, DateTime StatusDate, Illuminate.Node.Service GS) { _entryId = EntryId; _nodeName = NodeName; _status = Status; _statusDate = StatusDate; this.GS = GS; }
public new void InitializeAgent(Illuminate.Contexts.AgentContext context) { base.InitializeAgent(context); Logger.WriteLine("Initializing Test Agent...", Logger.Severity.Debug, LOGNAME); StreamWriter sw = new StreamWriter("test.txt"); sw.WriteLine("222"); sw.Close(); }
public SystemLoad(string nodeName, DateTime lastUpdated, double load1Min, double load5Min, double load15Min, long freeMemory, int processorCount, Illuminate.Node.Service GS) { _nodeName = nodeName; _lastUpdated = lastUpdated; _load1Min = load1Min; _load5Min = load5Min; _load15Min = load15Min; _freeMemory = freeMemory; _processorCount = processorCount; this.GS = GS; }
private void Start() { sceneRandomizer = FindObjectOfType <SceneRandomizer>(); levelCounter.text = levelCounterPrefix + 1; illuminate = GetComponent <Illuminate>(); ResetCollectiblesRemaining(GameObject.FindGameObjectsWithTag("Collectible").Length); GetPlayer(); PlaySound(startSound); swordIcon.enabled = false; swordBrokenIcon.enabled = false; armorIcon.enabled = false; }
/// <summary> /// Binds a datatable to a collection of entities /// </summary> /// <param name="Dt">The datatable to bind</param> /// <param name="GS">Reference to the Illuminate Service</param> /// <returns>Collection of Entities</returns> public static Collections.Setting Bind(DataTable Dt, Illuminate.Node.Service GS) { Collections.Setting settings = new Collections.Setting(); for (int i = 0; i < Dt.Rows.Count; i++) { DataRow Dr = Dt.Rows[i]; Setting setting = Bind(Dr, GS); settings.Add(setting); } return settings; }
public NodeAgentManagement(Illuminate.Node.Service dataService, string logName) { _dataService = dataService; LOGNAME = logName; _nodeAgents = new Dictionary<string, Node.Collections.IAgent>(); _nodeAgentTypeCount = new Dictionary<string, Dictionary<string, int>>(); _agentNodes = new Dictionary<string, List<string>>(); _nodeAgentsToAdd = new Dictionary<string, List<string>>(); _nodeAgentsToRemove = new Dictionary<string, List<string>>(); _minimumTotalAgentLimits = _dataService.Monitor.GetTotalAgentLimits("MIN"); _maximumTotalAgentLimits = _dataService.Monitor.GetTotalAgentLimits("MAX"); _minimumNodeAgentLimits = _dataService.Monitor.GetNodeAgentLimits("MIN"); _maximumNodeAgentLimits = _dataService.Monitor.GetNodeAgentLimits("MAX"); }
public void RunCommand(Illuminate.Communication.Command Command) { for (int i = 0; i < Count; i++) { if (Command.Destination == this[i].AgentId) { this[i].Communicator.RaiseDataIn(Command); } } }
/// <summary> /// Constructor /// </summary> /// <param name="Service">Reference to the Service object</param> public SystemLoadManager(Illuminate.Node.Service service) { GS = service; }
public void InitializeAgent(Illuminate.Contexts.AgentContext context) { _context = context; LOGNAME = context.LogName; }
/// <summary> /// Constructor /// </summary> /// <param name="Service">Reference to the Service object</param> public LinuxSystemLoadManager(Illuminate.Node.Service parentService) : base(parentService) { }
/// <summary> /// Binds a datatable to a collection of entities /// </summary> /// <param name="Dt">The datatable to bind</param> /// <param name="GS">Reference to the Illuminate Service</param> /// <returns>Collection of Entities</returns> public static Collections.Node Bind(DataTable Dt, Illuminate.Node.Service GS) { Collections.Node Nodes = new Collections.Node(); for (int i = 0; i < Dt.Rows.Count; i++) { DataRow Dr = Dt.Rows[i]; Node Node = Bind(Dr, GS); Nodes.Add(Node); } return Nodes; }
/// <summary> /// Binds a datarow to an entity /// </summary> /// <param name="Dr">The datarow you want to bind</param> /// <param name="GS">Reference to the Illuminate Service</param> /// <returns>A binded entity</returns> public static SystemLoad Bind(DataRow Dr, Illuminate.Node.Service GS) { string nodeName = string.Empty; DateTime lastUpdated = DateTime.MinValue; double load1Min = 0; double load5Min = 0; double load15Min = 0; long freeMemory = 0; int processorCount = 0; if (Dr.Table.Columns.Contains("NodeName")) nodeName = Dr["NodeName"].ToString(); if (Dr.Table.Columns.Contains("LastUpdated")) DateTime.TryParse(Dr["LastUpdated"].ToString(), out lastUpdated); if (Dr.Table.Columns.Contains("Load1Min")) double.TryParse(Dr["Load1Min"].ToString(), out load1Min); if (Dr.Table.Columns.Contains("Load5Min")) double.TryParse(Dr["Load5Min"].ToString(), out load5Min); if (Dr.Table.Columns.Contains("Load15Min")) double.TryParse(Dr["Load15Min"].ToString(), out load15Min); if (Dr.Table.Columns.Contains("FreeMemory")) long.TryParse(Dr["FreeMemory"].ToString(), out freeMemory); if (Dr.Table.Columns.Contains("ProcessorCount")) int.TryParse(Dr["ProcessorCount"].ToString(), out processorCount); return new SystemLoad(nodeName, lastUpdated, load1Min, load5Min, load15Min, freeMemory, processorCount, GS); }
public static void ShowStatus(string Cmd, Illuminate.Core.Node.AgentCollection agentCollection) { Console.Clear(); try { string[] command = Cmd.Split(' '); if (command.Length == 2) { int agentNumber = int.Parse(command[1]); if (agentNumber < 0 || agentNumber >= agentCollection.Count) { Console.WriteLine("*** The agent you are trying to show the status for does not exists"); return; } Console.WriteLine("Detailed Status"); Console.WriteLine("---------------"); Console.WriteLine(""); Console.WriteLine(Tools.Tools.GetString("#:", 25) + agentNumber); Console.WriteLine(Tools.Tools.GetString("Agent Id:", 25) + agentCollection[agentNumber].AgentId); Console.WriteLine(Tools.Tools.GetString("Agent Type:", 25) + agentCollection[agentNumber].AgentType); Console.WriteLine(Tools.Tools.GetString("Log Name:", 25) + agentCollection[agentNumber].LogName); Console.WriteLine(Tools.Tools.GetString("Run Count:", 25) + agentCollection[agentNumber].RunCount); Console.WriteLine(Tools.Tools.GetString("Last Execution Time:", 25) + agentCollection[agentNumber].LastExecutionTime); if (agentCollection[agentNumber].Status == Illuminate.Core.Node.Agent.AgentStatus.Executing) { Console.WriteLine(Tools.Tools.GetString("Start Execution Time:", 25) + agentCollection[agentNumber].StartExecutionTime); TimeSpan sp = DateTime.Now.Subtract(agentCollection[agentNumber].StartExecutionTime); Console.WriteLine(Tools.Tools.GetString("Elapsed time:", 25) + sp.TotalSeconds.ToString()); } else { Console.WriteLine(Tools.Tools.GetString("Next Execution Time:", 25) + agentCollection[agentNumber].NextExecutionTime); TimeSpan sp = DateTime.Now.Subtract(agentCollection[agentNumber].StartExecutionTime); Console.WriteLine(Tools.Tools.GetString("Seconds to Execution:", 25) + sp.TotalSeconds.ToString()); } Console.WriteLine(Tools.Tools.GetString("Status:", 25) + agentCollection[agentNumber].Status.ToString()); Console.WriteLine(""); Console.WriteLine("Internal Status"); Console.WriteLine("---------------"); Console.WriteLine(""); Console.WriteLine(agentCollection[agentNumber].InternalStatus); Console.WriteLine(""); } } catch (Exception e) { Console.WriteLine("Error trying to retreive log: " + e.Message); } }
void com_OnDataIn(Illuminate.Communication.Command Command) { }
public ConsoleStatus(Illuminate.Core.Node.AgentCollection agents) { _agents = agents; }
public void ExecuteJob(string logName, Illuminate.Contexts.AgentContext context) { LOGNAME = logName; Logger.WriteLine("QueueRunner is executing", Logger.Severity.Debug, LOGNAME); IQueueEntity queueEntry = Illuminate.ActiveJob.Queue.Instance.GetActiveJobQueueEntryRuntimeNow(); if (queueEntry != null) { Illuminate.ActiveJob.Queue.Instance.UpdateAgentId(queueEntry.JobId, queueEntry.Status, "Running", queueEntry.NextRunTime, context.AgentId); //get it again to make sure we are the agent registered in the databases queueEntry = Illuminate.ActiveJob.Queue.Instance.GetActiveJobQueueEntry(queueEntry.JobId, context.AgentId); if (queueEntry != null) { //run it Logger.WriteLine("Invoking agent...: " + queueEntry.Name, Logger.Severity.Information, LOGNAME); IAgent job = InvokeJob(queueEntry.DLL); Illuminate.Contexts.AgentContext jobContext = new Illuminate.Contexts.AgentContext(context.NodeId, context.SectionName, LOGNAME, context.Communicator, context.Agent); jobContext.Parameters = queueEntry.Parameters; jobContext.LogName = LOGNAME; if (job != null) { DateTime startTime = DateTime.Now; try { Logger.WriteLine("Starting Job: " + jobContext.AgentId, Logger.Severity.Debug, LOGNAME); Logger.WriteLine("Initialize Job: " + jobContext.AgentId, Logger.Severity.Debug, LOGNAME); job.InitializeAgent(jobContext); Logger.WriteLine("Executing Job: " + jobContext.AgentId, Logger.Severity.Debug, LOGNAME); job.Run(); Logger.WriteLine("Cleanup Job: " + jobContext.AgentId, Logger.Severity.Debug, LOGNAME); job.Cleanup(); } catch (Illuminate.Exceptions.CriticalException ce) { string body = "There was a critical error running job: " + jobContext.AgentId + ". " + ce.Message + " - " + ce.StackTrace.ToString(); //Illuminate.EmailQueue.Queue.Instance.Push(DateTime.Now, "*****@*****.**", "*****@*****.**", "Critical Error on Active Job", body); Logger.WriteLine(body, Logger.Severity.Fatal, LOGNAME); } catch (Illuminate.Exceptions.ErrorException ee) { string body = "There was a serious error running job: " + jobContext.AgentId + ". " + ee.Message + " - " + ee.StackTrace.ToString(); //Illuminate.EmailQueue.Queue.Instance.Push(DateTime.Now, "*****@*****.**", "*****@*****.**", "Serious Error on Active Job", body); Logger.WriteLine(body, Logger.Severity.Error, LOGNAME); } catch (Exception e) { string body = "There was a unknown error running job: " + jobContext.AgentId + ". " + e.Message + " - " + e.StackTrace.ToString(); //Illuminate.EmailQueue.Queue.Instance.Push(DateTime.Now, "*****@*****.**", "*****@*****.**", "Serious Error on Active Job", body); Logger.WriteLine(body, Logger.Severity.Error, LOGNAME); } finally { DateTime nextRunTime = startTime.AddSeconds(queueEntry.Interval); if (nextRunTime < DateTime.Now) nextRunTime = DateTime.Now; Logger.WriteLine("Resetting next execution time on Job: " + jobContext.AgentId + "Date/Time: " + nextRunTime.ToString(), Logger.Severity.Information, LOGNAME); //process done Illuminate.ActiveJob.Queue.Instance.UpdateAgentId(queueEntry.JobId, "Running", "Idle", nextRunTime, null); } } //End job != null else { Logger.WriteLine("Invoked Agent is NULL...", Logger.Severity.Debug, LOGNAME); //process error Illuminate.ActiveJob.Queue.Instance.UpdateAgentId(queueEntry.JobId, "Running", "Idle", queueEntry.NextRunTime, null); } } //Second End QueueEntry != null } //First End QueueEntry != null CheckExpiredAgent(); }
/// <summary> /// Binds a datarow to an entity /// </summary> /// <param name="Dr">The datarow you want to bind</param> /// <param name="GS">Reference to the Illuminate Service</param> /// <returns>A binded entity</returns> public static Setting Bind(DataRow Dr, Illuminate.Node.Service GS) { string settingName = string.Empty; string settingValue = string.Empty; if (Dr.Table.Columns.Contains("SettingName")) settingName = Dr["SettingName"].ToString(); if (Dr.Table.Columns.Contains("SettingValue")) settingValue = Dr["SettingValue"].ToString(); return new Setting(settingName, settingValue, GS); }
public Setting(string settingName, string settingValue, Illuminate.Node.Service GS) { _settingName = settingName; _settingValue = settingValue; this.GS = GS; }
public new void InitializeAgent(Illuminate.Contexts.AgentContext context) { Logger.WriteLine("Initializing QueueRunner...", Logger.Severity.Debug, LOGNAME); }
/// <summary> /// Binds a datatable to a collection of entities /// </summary> /// <param name="Dt">The datatable to bind</param> /// <param name="GS">Reference to the Illuminate Service</param> /// <returns>Collection of Entities</returns> public static Collections.SystemLoad Bind(DataTable Dt, Illuminate.Node.Service GS) { Collections.SystemLoad systemLoads = new Collections.SystemLoad(); for (int i = 0; i < Dt.Rows.Count; i++) { DataRow Dr = Dt.Rows[i]; SystemLoad systemLoad = Bind(Dr, GS); systemLoads.Add(systemLoad); } return systemLoads; }
public static void WriteStatus(string nodeId, Illuminate.Core.Node.AgentCollection agentCollection) { Commands.ClearLogs(); Console.Clear(); ConsoleStatus status = new ConsoleStatus(agentCollection); status.ShowConsole(); }
public static void ShowLog(string Cmd, Illuminate.Core.Node.AgentCollection agentCollection) { Console.Clear(); try { string[] logCommand = Cmd.Split(' '); if (logCommand.Length == 2) { if (logCommand[1] == "all") { Illuminate.Tools.Logger.LogNameToTrace = "all"; } else { int agentNumber = int.Parse(logCommand[1]); if (agentNumber < 0 || agentNumber >= agentCollection.Count) { Console.WriteLine("*** The agent you are trying to show the logs for does not exists"); return; } Illuminate.Tools.Logger.LogNameToTrace = agentCollection[agentNumber].LogName; } } } catch (Exception e) { Console.WriteLine("Error trying to retreive log: " + e.Message); } }
/// <summary> /// Binds a datarow to an entity /// </summary> /// <param name="Dr">The datarow you want to bind</param> /// <param name="GS">Reference to the Illuminate Service</param> /// <returns>A binded entity</returns> public static Node Bind(DataRow Dr, Illuminate.Node.Service GS) { int EntryId = 0; string NodeName = string.Empty; string Status = string.Empty; DateTime StatusDate = new DateTime(); if (Dr.Table.Columns.Contains("EntryId")) EntryId = int.Parse(Dr["EntryId"].ToString()); if (Dr.Table.Columns.Contains("NodeName")) NodeName = Dr["NodeName"].ToString(); if (Dr.Table.Columns.Contains("Status")) Status = Dr["Status"].ToString(); if (Dr.Table.Columns.Contains("StatusDate")) DateTime.TryParse(Dr["StatusDate"].ToString(), out StatusDate); return new Node(EntryId, NodeName, Status, StatusDate, GS); }