Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/01/15 14:59:47 (9 years ago)
Author:
ascheibe
Message:

#2394 merged r12428, r12429, r12430, r12435, r12442, r12443, r12445, r12514, r12517, r12519, r12520, r12521, r12523, r12532, r12542, r12546, r12552, r12553, r12556, r12557, r12559, r12561, r12146, r12457 into stable

Location:
stable
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Services.WebApp.Status/3.3/WebApi/DataController.cs

    r12428 r12563  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using System.Collections.Generic;
     24using System.Data.Linq;
    325using System.Linq;
    426using System.Web.Http;
     
    2547        FROM UserTasks ut;";
    2648
    27 
    2849    private class UserTaskStatus {
    2950      public Guid UserId { get; set; }
     
    4162        CalculatingTasks = uts.CalculatingTasks,
    4263        WaitingTasks = uts.WaitingTasks
    43       });
     64      }).OrderBy(x => x.User.Name);
    4465    }
    4566    // end temporary quickfix
     
    5071                            where slave.SlaveState == SlaveState.Calculating || slave.SlaveState == SlaveState.Idle
    5172                            select slave).ToList();
     73        var activeSlaves = onlineSlaves.Where(s => s.IsAllowedToCalculate).ToList();
     74        var calculatingSlaves = activeSlaves.Where(s => s.SlaveState == SlaveState.Calculating).ToList();
     75        int calculatingMemory = calculatingSlaves.Any() ? (int)calculatingSlaves.Sum(s => s.Memory) : 0;
     76        int freeCalculatingMemory = calculatingSlaves.Any() ? (int)calculatingSlaves.Sum(s => s.FreeMemory) : 0;
     77
    5278        return new DTO.Status {
    5379          CoreStatus = new DTO.CoreStatus {
    5480            TotalCores = onlineSlaves.Sum(s => s.Cores ?? 0),
    55             AvailableCores = onlineSlaves.Where(s => s.IsAllowedToCalculate).Sum(s => s.Cores ?? 0),
    56             FreeCores = onlineSlaves.Sum(s => s.FreeCores ?? 0)
     81            FreeCores = onlineSlaves.Sum(s => s.FreeCores ?? 0), // temporary for old chart data
     82            ActiveCores = activeSlaves.Sum(s => s.Cores ?? 0),
     83            CalculatingCores = calculatingSlaves.Sum(s => s.Cores ?? 0) - calculatingSlaves.Sum(s => s.FreeCores ?? 0)
    5784          },
    5885          CpuUtilizationStatus = new DTO.CpuUtilizationStatus {
     
    6087                                  ? Math.Round(onlineSlaves.Average(s => s.CpuUtilization), 2)
    6188                                  : 0.0,
    62             UsedCpuUtilization = onlineSlaves.Any(x => x.IsAllowedToCalculate)
    63                                  ? Math.Round(onlineSlaves.Where(x => x.IsAllowedToCalculate).Average(s => s.CpuUtilization), 2)
    64                                  : 0.0
     89            ActiveCpuUtilization = activeSlaves.Any()
     90                                   ? Math.Round(activeSlaves.Average(s => s.CpuUtilization), 2)
     91                                   : 0.0,
     92            CalculatingCpuUtilization = calculatingSlaves.Any()
     93                                        ? Math.Round(calculatingSlaves.Average(s => s.CpuUtilization), 2)
     94                                        : 0.0
    6595          },
    6696          MemoryStatus = new DTO.MemoryStatus {
    67             TotalMemory = onlineSlaves.Any() ? (int)onlineSlaves.Sum(s => s.Memory) / 1024 : 0,
    68             FreeMemory = onlineSlaves.Any() ? (int)onlineSlaves.Sum(s => s.FreeMemory) / 1024 : 0
     97            TotalMemory = onlineSlaves.Any() ? (int)onlineSlaves.Sum(s => s.Memory) : 0,
     98            FreeMemory = onlineSlaves.Any() ? (int)onlineSlaves.Sum(s => s.FreeMemory) : 0,
     99            ActiveMemory = activeSlaves.Any() ? (int)activeSlaves.Sum(s => s.Memory) : 0,
     100            UsedMemory = calculatingMemory - freeCalculatingMemory
    69101          },
    70102          TasksStatus = GetTaskStatus(db),
    71           SlavesCpuStatus = onlineSlaves.Select(x => new DTO.SlaveCpuStatus {
    72             CpuUtilization = Math.Round(x.CpuUtilization, 2),
     103          SlavesStatus = onlineSlaves.Select(x => new DTO.SlaveStatus {
    73104            Slave = new DTO.Slave {
    74105              Id = x.ResourceId.ToString(),
    75106              Name = x.Name
    76             }
    77           }),
     107            },
     108            CpuUtilization = x.CpuUtilization,
     109            Cores = x.Cores ?? 0,
     110            FreeCores = x.FreeCores ?? 0,
     111            Memory = x.Memory ?? 0,
     112            FreeMemory = x.FreeMemory ?? 0,
     113            IsAllowedToCalculate = x.IsAllowedToCalculate,
     114            State = x.SlaveState.ToString()
     115          }).OrderBy(x => x.Slave.Name),
    78116          Timestamp = JavascriptUtils.ToTimestamp(DateTime.Now)
    79117        };
     
    82120
    83121    public IEnumerable<DTO.Status> GetStatusHistory(DateTime start, DateTime end) {
     122      TimeSpan ts = end - start;
     123      int increment = 1;
     124      double totalMinutes = ts.TotalMinutes;
     125      while (totalMinutes > 5761) {
     126        totalMinutes -= 5761;
     127        increment += 5;
     128      }
    84129      using (var db = new HiveDataContext()) {
     130        DataLoadOptions loadOptions = new DataLoadOptions();
     131        loadOptions.LoadWith<Statistics>(o => o.SlaveStatistics);
     132        db.LoadOptions = loadOptions;
     133        db.DeferredLoadingEnabled = false;
    85134        var statistics = db.Statistics.Where(s => s.Timestamp >= start && s.Timestamp <= end)
    86                                       .OrderBy(x => x.Timestamp)
     135                                      .OrderBy(s => s.Timestamp)
    87136                                      .ToList();
     137        var status = new DTO.Status {
     138          CoreStatus = new DTO.CoreStatus(),
     139          CpuUtilizationStatus = new DTO.CpuUtilizationStatus(),
     140          MemoryStatus = new DTO.MemoryStatus()
     141        };
     142        int freeCores = 0;
     143        int freeMemory = 0;
     144        int i = 1;
    88145        foreach (var statistic in statistics) {
    89           yield return new DTO.Status {
    90             CoreStatus = new DTO.CoreStatus {
    91               TotalCores = statistic.SlaveStatistics.Sum(x => x.Cores),
    92               AvailableCores = 0,
    93               FreeCores = statistic.SlaveStatistics.Sum(x => x.FreeCores)
    94             },
    95             CpuUtilizationStatus = new DTO.CpuUtilizationStatus {
    96               TotalCpuUtilization = 0.0,
    97               UsedCpuUtilization = statistic.SlaveStatistics.Any() ? statistic.SlaveStatistics.Average(x => x.CpuUtilization) : 0.0
    98             },
    99             MemoryStatus = new DTO.MemoryStatus {
    100               TotalMemory = statistic.SlaveStatistics.Sum(x => x.Memory) / 1024,
    101               FreeMemory = statistic.SlaveStatistics.Sum(x => x.FreeMemory) / 1024
    102             },
    103             Timestamp = JavascriptUtils.ToTimestamp(statistic.Timestamp)
    104           };
     146          status.CoreStatus.TotalCores += statistic.SlaveStatistics.Sum(x => x.Cores);
     147          freeCores += statistic.SlaveStatistics.Sum(x => x.FreeCores);
     148          status.CpuUtilizationStatus.TotalCpuUtilization += statistic.SlaveStatistics.Any()
     149                                                             ? statistic.SlaveStatistics.Average(x => x.CpuUtilization)
     150                                                             : 0.0;
     151          status.MemoryStatus.TotalMemory += statistic.SlaveStatistics.Sum(x => x.Memory);
     152          freeMemory += statistic.SlaveStatistics.Sum(x => x.FreeMemory);
     153          if (i >= increment) {
     154            status.Timestamp = JavascriptUtils.ToTimestamp(statistic.Timestamp);
     155            status.CoreStatus.TotalCores /= i;
     156            freeCores /= i;
     157            status.CpuUtilizationStatus.TotalCpuUtilization /= i;
     158            status.MemoryStatus.TotalMemory /= i;
     159            freeMemory /= i;
     160            status.CoreStatus.ActiveCores = status.CoreStatus.TotalCores;
     161            status.MemoryStatus.ActiveMemory = status.MemoryStatus.TotalMemory;
     162            status.CpuUtilizationStatus.ActiveCpuUtilization = status.CpuUtilizationStatus.TotalCpuUtilization;
     163            status.CpuUtilizationStatus.CalculatingCpuUtilization = status.CpuUtilizationStatus.CalculatingCpuUtilization;
     164            status.CoreStatus.CalculatingCores = status.CoreStatus.TotalCores - freeCores;
     165            status.MemoryStatus.UsedMemory = status.MemoryStatus.TotalMemory - freeMemory;
     166            yield return status;
     167            status = new DTO.Status {
     168              CoreStatus = new DTO.CoreStatus(),
     169              CpuUtilizationStatus = new DTO.CpuUtilizationStatus(),
     170              MemoryStatus = new DTO.MemoryStatus()
     171            };
     172            freeCores = 0;
     173            freeMemory = 0;
     174            i = 1;
     175          } else {
     176            i++;
     177          }
    105178        }
    106179      }
  • stable/HeuristicLab.Services.WebApp.Status/3.3/WebApi/DataTransfer/Slave.cs

    r12428 r12563  
    1 namespace HeuristicLab.Services.WebApp.Status.WebApi.DataTransfer {
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22namespace HeuristicLab.Services.WebApp.Status.WebApi.DataTransfer {
    223  public class Slave {
    324    public string Id { get; set; } // currently unused
  • stable/HeuristicLab.Services.WebApp.Status/3.3/WebApi/DataTransfer/Status.cs

    r12428 r12563  
    1 using System.Collections.Generic;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System.Collections.Generic;
    223
    324namespace HeuristicLab.Services.WebApp.Status.WebApi.DataTransfer {
     
    526  public class CoreStatus {
    627    public int TotalCores { get; set; }
    7     public int AvailableCores { get; set; }
    8     public int FreeCores { get; set; }
     28    public int FreeCores { get; set; } // temporary quickfix for old chart data
     29    public int ActiveCores { get; set; }
     30    public int CalculatingCores { get; set; }
    931  }
    1032
    1133  public class CpuUtilizationStatus {
    1234    public double TotalCpuUtilization { get; set; }
    13     public double UsedCpuUtilization { get; set; }
     35    public double ActiveCpuUtilization { get; set; }
     36    public double CalculatingCpuUtilization { get; set; }
    1437  }
    1538
    1639  public class MemoryStatus {
    1740    public int TotalMemory { get; set; }
    18     public int FreeMemory { get; set; }
     41    public int FreeMemory { get; set; } // temporary quickfix for old chart data
     42    public int ActiveMemory { get; set; }
     43    public int UsedMemory { get; set; }
    1944  }
    2045
     
    2550  }
    2651
    27   public class SlaveCpuStatus {
     52  public class SlaveStatus {
    2853    public Slave Slave { get; set; }
    2954    public double CpuUtilization { get; set; }
     55    public int Cores { get; set; }
     56    public int FreeCores { get; set; }
     57    public int Memory { get; set; }
     58    public int FreeMemory { get; set; }
     59    public bool IsAllowedToCalculate { get; set; }
     60    public string State { get; set; }
    3061  }
    3162
     
    3566    public MemoryStatus MemoryStatus { get; set; }
    3667    public IEnumerable<TaskStatus> TasksStatus { get; set; }
    37     public IEnumerable<SlaveCpuStatus> SlavesCpuStatus { get; set; }
     68    public IEnumerable<SlaveStatus> SlavesStatus { get; set; }
    3869    public long Timestamp { get; set; }
    3970  }
  • stable/HeuristicLab.Services.WebApp.Status/3.3/WebApi/DataTransfer/User.cs

    r12428 r12563  
    1 
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
    222namespace HeuristicLab.Services.WebApp.Status.WebApi.DataTransfer {
    323  public class User {
  • stable/HeuristicLab.Services.WebApp.Status/3.3/WebApi/JavascriptUtils.cs

    r12428 r12563  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223
    324namespace HeuristicLab.Services.WebApp.Status.WebApi {
     
    627      var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
    728      var time = input.Subtract(new TimeSpan(epoch.Ticks));
    8       return (long)(time.Ticks / 10000);
     29      return time.Ticks / 10000;
    930    }
    1031  }
Note: See TracChangeset for help on using the changeset viewer.