public PCNode this[string key] { get { return(key.Count(c => c == '.') == 3 ? KnownNodes.FirstOrDefault(c => c.IP == key) : KnownNodes.FirstOrDefault(c => c.MachineName == key || c.MacAddress == key)); } }
protected Nodes() { try { KnownNodes.Add((T)typeof(T).GetProperty("This").GetValue(null, null)); } catch (NullReferenceException) { throw new MissingMethodException($"{typeof(T).Name} class is missing a static get property named 'This' that returns a {typeof(T).Name} object.\n public static {typeof(T).Name} This{{ get {{...}}}}\n public static {typeof(T).Name} This => new {typeof(T).Name}();"); } NetworkComms.DefaultSendReceiveOptions = new SendReceiveOptions <ProtobufSerializer, LZMACompressor>(); }
/// <summary> /// Adds a node to the list of known nodes. /// </summary> /// <param name="node">The node to add.</param> /// <returns> /// The index of the node in the list of known nodes /// after the addition. /// </returns> public int AddToKnownNodes(NodeT node) { int i = KnownNodes.IndexOf(node); if (i < 0) { i = KnownNodes.Count; KnownNodes.Add(node); } return(i); }
protected override IEnumerable <MonitorStatus> GetMonitorStatus() { if (HealthStatus.Data?.Indexes != null) { yield return(HealthStatus.Data.Indexes.Values.GetWorstStatus()); } if (KnownNodes.All(n => n.LastException != null)) { yield return(MonitorStatus.Critical); } if (KnownNodes.Any(n => n.LastException != null)) { yield return(MonitorStatus.Warning); } yield return(DataPollers.GetWorstStatus()); }
public override void VisualiseAlgorithm(UUID to, Parameters parameters) { if (Equals(VisualisedNode)) { ResetAlgorithm(); _visualise = false; VisualisedNode = null; return; } else if (VisualisedNode != null) { VisualisedNode.Stop(); } IMNodeInternal target = KnownNodes.ContainsKey(to) ? KnownNodes[to] : null; _text = Dijkstra.AlwaysPrint || (Dijkstra.EverPrint && parameters != null && parameters.Get <bool>("Text")); VisualisedNode = this; RunAlgorithm("Visualise Dijkstra's Algorithm", target, true); }
private void SendFullCacheUpdate(IPAddress ip) { if (ip == null) { throw new ArgumentException("The specified IP address is not valid", "ip"); } if (!KnownNodes.Contains(ip)) { throw new ArgumentException("The ip address specified is not known.", "ip"); } // grab a copy of the cache CacheProvider <string, ClientResultMessage> temp = ResultCache; temp.ClearSubscribersNoNotify(); InterNodeCommunicationMessage msg = new InterNodeCommunicationMessage { Data = CacheSerialiser.Serialise(temp), IsLocalOnly = true, MessageType = InterNodeMessageType.FullCacheUpdateReceived }; SendToNode(ip, InterNodeCommunicationMessageSerialiser.Serialise(msg)); }