private ImmutableDictionary <UniqueAddress, IPruningState> PruningFromProto(RepeatedField <Proto.Msg.DataEnvelope.Types.PruningEntry> pruning) { if (pruning.Count == 0) { return(ImmutableDictionary <UniqueAddress, IPruningState> .Empty); } else { var builder = ImmutableDictionary <UniqueAddress, IPruningState> .Empty.ToBuilder(); foreach (var entry in pruning) { var removed = _ser.UniqueAddressFromProto(entry.RemovedAddress); if (entry.Performed) { builder.Add(removed, new PruningPerformed(new DateTime(entry.ObsoleteTime))); } else { var seen = new Actor.Address[entry.Seen.Count]; var i = 0; foreach (var s in entry.Seen) { seen[i] = _ser.AddressFromProto(s); i++; } builder.Add(removed, new PruningInitialized(_ser.UniqueAddressFromProto(entry.OwnerAddress), seen)); } } return(builder.ToImmutable()); } }
/// <summary> /// Creates new instance of <see cref="NodeMetrics"/> /// </summary> /// <param name="address">Address of the node the metrics are gathered at</param> /// <param name="timestamp">the time of sampling, in milliseconds since midnight, January 1, 1970 UTC</param> /// <param name="metrics">The set of sampled <see cref="Types.Metric"/></param> public NodeMetrics(Actor.Address address, long timestamp, IEnumerable <Types.Metric> metrics) { Address = address; timestamp_ = timestamp; metrics_ = new RepeatedField <Types.Metric>(); metrics_.AddRange(metrics); }
/// <summary> /// Converts Akka.NET type into Protobuf serializable message /// </summary> private AddressData AddressToProto(Actor.Address address) { return(new AddressData() { Hostname = address.Host, Protocol = address.Protocol, Port = (uint)(address.Port ?? 0), System = address.System, }); }
public WeightedRoutees(ImmutableArray <Routee> routees, Actor.Address selfAddress, IImmutableDictionary <Actor.Address, int> weights) { _routees = routees; _selfAddress = selfAddress; _weights = weights; // fill an array of same size as the refs with accumulated weights, // binarySearch is used to pick the right bucket from a requested value // from 1 to the total sum of the used weights. _buckets = InitBuckets(); }
/// <summary> /// Creates new instance of <see cref="Cpu"/> /// </summary> /// <param name="address">Address of the node the metrics are gathered at</param> /// <param name="timestamp">The time of sampling, in milliseconds since midnight, January 1, 1970 UTC</param> /// <param name="cpuProcessUsage">CPU usage by current process in percentage (in [0, 1] range)</param> /// <param name="cpuTotalUsage">CPU usage by all processes in percentage (in [0, 1] range)</param> /// <param name="processorsNumber">The number of available processors</param> public Cpu(Actor.Address address, long timestamp, double cpuProcessUsage, double cpuTotalUsage, int processorsNumber) { if (cpuProcessUsage < 0 || cpuProcessUsage > 1) throw new ArgumentException(nameof(cpuProcessUsage), $"{nameof(cpuProcessUsage)} must be between [0.0 - 1.0], was {cpuProcessUsage}" ); if (cpuTotalUsage < 0 || cpuTotalUsage > 1) throw new ArgumentException(nameof(cpuTotalUsage), $"{nameof(cpuTotalUsage)} must be between [0.0 - 1.0], was {cpuTotalUsage}" ); Address = address; Timestamp = timestamp; ProcessUsage = cpuProcessUsage; TotalUsage = cpuTotalUsage; ProcessorsNumber = processorsNumber; }
/// <summary> /// Creates instance of <see cref="StandardMetrics.Memory"/> /// </summary> /// <param name="address">Address index of the node the metrics are gathered at</param> /// <param name="timestamp">The time of sampling, in milliseconds since midnight, January 1, 1970 UTC</param> /// <param name="used">Total memory allocated to the currently running process (in bytes)</param> /// <param name="available">Memory available for current process (in bytes)</param> /// <param name="max">Max memory recommended for process (in bytes)</param> public Memory(Actor.Address address, long timestamp, double used, double available, Option<double> max) { if (used <= 0) throw new ArgumentException(nameof(used), $"{used} expected to be > 0 bytes"); if (available <= 0) throw new ArgumentException(nameof(used), $"{available} expected to be > 0 bytes"); if (max.HasValue && max.Value < 0) throw new ArgumentException(nameof(max), $"{max.Value} expected to be > 0 bytes"); Address = address; Timestamp = timestamp; Used = used; Available = available; MaxRecommended = max; }
/// <summary> /// Gets node metrics for given node address /// </summary> public Option <NodeMetrics> NodeMetricsFor(Actor.Address address) { var node = Nodes.FirstOrDefault(m => m.Address.Equals(address)); return(node ?? Option <NodeMetrics> .None); }
/// <summary> /// Removes nodes if their correlating node ring members are not <see cref="MemberStatus"/> `Up`. /// </summary> public MetricsGossip Remove(Actor.Address node) { return(new MetricsGossip(Nodes.Where(n => !n.Address.Equals(node)).ToImmutableHashSet())); }
/// <summary> /// Creates new instance of <see cref="MetricsGossipEnvelope"/> /// </summary> public MetricsGossipEnvelope(Actor.Address fromAddress, MetricsGossip gossip, bool reply) { FromAddress = fromAddress; Gossip = gossip; Reply = reply; }