/// <summary>
        /// Utilization/ClusterUtilization.
        /// </summary>
        /// <param name="id">The unique identifier of the <see cref="Cluster"/>.</param>
        /// <returns>A <see cref="ViewResult"/> object of the <see cref="Cluster"/> with the specified id.</returns>
        public ActionResult ClusterUtilization(uint id)
        {
            var cluster = this.db.Clusters
                          .Include(c => c.Nodes)
                          .First(c => c.Id == id);

            if (cluster == null)
            {
                return(this.NotFound());
            }

            var result = new ClusterSummary()
            {
                Cluster       = cluster,
                NodeSummaries = new List <NodeSummary>(),
            };

            // Since Utilization and Power statistics are already indexed by Timestamp, retreiving
            // the most recent n-entries is very efficient. Scanning them in-memory to find the most
            // recent for each node ID is faster than taking round-trips the database.
            var searchDepth = cluster.Nodes.Count * 5;

            var recentPowerAll = this.db.PowerData
                                 .OrderByDescending(e => e.Timestamp)
                                 .Take(searchDepth)
                                 .ToList();

            var recentUtilizationAll = this.db.UtilizationData
                                       .OrderByDescending(e => e.TimeStamp)
                                       .Take(searchDepth)
                                       .ToList();

            foreach (var node in cluster.Nodes)
            {
                result.NodeSummaries.Add(new NodeSummary()
                {
                    Node              = node,
                    Id                = node.Id,
                    RecentPower       = recentPowerAll.First(e => e.GlobalNodeId == node.GlobalId),
                    RecentUtilization = recentUtilizationAll.First(e => e.GlobalNodeId == node.GlobalId),
                });
            }

            if (cluster.Nodes.Count() < 1)
            {
                return(this.RedirectToAction("Error", "Home"));
            }

            this.ViewData["ReportingInterval"] = (uint)cluster.RefreshRate.TotalSeconds;
            this.ViewData["LastUpdated"]       = DateTime.Now;

            return(this.View(result));
        }
Пример #2
0
 public void Read (TProtocol iprot)
 {
   TField field;
   iprot.ReadStructBegin();
   while (true)
   {
     field = iprot.ReadFieldBegin();
     if (field.Type == TType.Stop) { 
       break;
     }
     switch (field.ID)
     {
       case 0:
         if (field.Type == TType.Struct) {
           Success = new ClusterSummary();
           Success.Read(iprot);
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 1:
         if (field.Type == TType.Struct) {
           Aze = new AuthorizationException();
           Aze.Read(iprot);
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       default: 
         TProtocolUtil.Skip(iprot, field.Type);
         break;
     }
     iprot.ReadFieldEnd();
   }
   iprot.ReadStructEnd();
 }