Exemple #1
0
        private static IEnumerable <NodeHistory> NodesFromInstanceSetHistory(
            IEnumerable <InstanceHistory> instanceHistories,
            Tenancies tenancies)
        {
            var placementsByServer = instanceHistories
                                     .Where(i => i.Placements != null)
                                     .SelectMany(i => i.Placements.Select(p => new
            {
                Instance = i,
                p.ServerId,
                p.From,
                p.To,
                p.Tenancy
            }))
                                     .Where(p => tenancies.HasFlag(p.Tenancy))
                                     .GroupBy(p => p.ServerId);

            foreach (var server in placementsByServer)
            {
                var peakInstanceCount = (uint)TimeseriesUtil.HighWatermark(
                    server.Select(p => p.From),
                    server.Select(p => p.To));

                yield return(new NodeHistory(
                                 server.Key,
                                 server.Select(p => p.From).Min(),
                                 server.Select(p => p.To).Max(),
                                 peakInstanceCount,
                                 server.Select(p => new NodePlacement(p.From, p.To, p.Instance))));
            }
        }
Exemple #2
0
 /// <summary>
 /// Create time series indicating the maximum number of parallel
 /// physical cores for each day of this set's existence.
 /// </summary>
 public IEnumerable <DataPoint> MaxPhysicalCoresByDay(Func <NodeTypeLocator, int> resolveCoreCount) =>
 this.Nodes == null
         ? Enumerable.Empty <DataPoint>()
         : TimeseriesUtil.DailyHistogram(
     this.Nodes.Select(p => new DataPoint(p.FirstUse, resolveCoreCount(p.NodeType))),
     this.Nodes.Select(p => new DataPoint(p.LastUse, resolveCoreCount(p.NodeType))));