Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9646


Ignore:
Timestamp:
06/19/13 15:29:37 (9 years ago)
Author:
pfleck
Message:

#2063:
Changed year in headers from 2012 to 2013.
Minor reformattings in chart helpers.
Refactored and simplified some statistics generator methods.

Location:
branches/HiveStatistics/sources
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveStatistics/sources/HeuristicLab.Clients.Hive/3.3/HiveClient.cs

    r9461 r9646  
    438438
    439439        refreshableJob.Progress.Status = "Downloading tasks...";
    440         downloader = new TaskDownloader(allTasks.Select(x => x.Id), refreshableJob.Log);
     440        downloader = new TaskDownloader(allTasks.Select(x => x.Id));
    441441        downloader.StartAsync();
    442442
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.Statistics/3.3/App_Code/ChartHelper.cshtml

    r9644 r9646  
    11@* HeuristicLab
    2  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     2 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    33 *
    44 * This file is part of HeuristicLab.
     
    3535}
    3636
    37 @helper LineChartTime(string destinationTag, string url, string title = "",
    38     double? minY = null, double? maxY = null, string axisYFormat = null) {
    39        
     37@helper LineChartTime(string destinationTag, string url, string title = "", double? minY = null, double? maxY = null, string axisYFormat = null) {
    4038    <script>
    4139        var @(destinationTag)Plot = $.jqplot("@destinationTag", "@url", {
     
    4644            },
    4745            seriesDefaults: {
    48                 markerOptions: { show: false },
    49                 //fill: true
     46                markerOptions: { show: false }
    5047            },
    5148            dataRenderer: ajaxDataRenderer,
     
    9794
    9895@helper RefreshChart(string destinationTag, string url, string startDateVar, string endDateVar) {
    99     @:$.ajax({url: "@(new HtmlString(url))?start=" + @startDateVar + "&end=" + @endDateVar, datatype: "json", success: function(result) {
    100     @:    for (var i = 0; i < result.length; i++) {
    101     @:        @(destinationTag)Plot.series[i].data = result[i];
    102     @:    }
    103     @:    @(destinationTag)Plot.replot({ resetAxes: true })
    104     @:}});
     96    <text>
     97    $.ajax({url: "@(new HtmlString(url))?start=" + @startDateVar + "&end=" + @endDateVar, datatype: "json", success: function(result) {
     98        for (var i = 0; i < result.length; i++) {
     99            @(destinationTag)Plot.series[i].data = result[i];
     100        }
     101        @(destinationTag)Plot.replot({ resetAxes: true })
     102    }});
     103    </text>
    105104}
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.Statistics/3.3/App_Start/BundleConfig.cs

    r9625 r9646  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.Statistics/3.3/App_Start/FilterConfig.cs

    r9625 r9646  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.Statistics/3.3/App_Start/RouteConfig.cs

    r9625 r9646  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.Statistics/3.3/Content/Site.css

    r9625 r9646  
    7575
    7676#login a:hover {
    77   color: #333;
     77  color: gray;
    7878}
    7979
     
    163163  margin: 1em 0;
    164164  padding: 1em;
     165  padding-top: 0;
    165166  border: 1px solid #CCC;
    166167}
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.Statistics/3.3/Controllers/AccountController.cs

    r9604 r9646  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.Statistics/3.3/Controllers/ChartDataController.cs

    r9644 r9646  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.Statistics/3.3/Controllers/HomeController.cs

    r9628 r9646  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.Statistics/3.3/Global.asax.cs

    r9604 r9646  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.Statistics/3.3/Helper/HtmMenulHelper.cs

    r9604 r9646  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.Statistics/3.3/Models/AccountModels.cs

    r9604 r9646  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.Statistics/3.3/Properties/AssemblyInfo.cs.frame

    r9604 r9646  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3232[assembly: AssemblyCompany("")]
    3333[assembly: AssemblyProduct("HeuristicLab")]
    34 [assembly: AssemblyCopyright("(c) 2002-2012 HEAL")]
     34[assembly: AssemblyCopyright("(c) 2002-2013 HEAL")]
    3535[assembly: AssemblyTrademark("")]
    3636[assembly: AssemblyCulture("")]
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.Statistics/3.3/Views/Home/Index.cshtml

    r9643 r9646  
    111111            var startDate = $('#Start').val();
    112112            var endDate = $('#End').val();
    113            
    114                         @*
    115             var url = "@Url.Action("AverageCpuUtilization", "ChartData")?start=" + startDate + "&end" + endDate;
    116            
    117             @ChartHelper.LineChartTime(
    118                 "AverageCpuUtilization",
    119                 "url",
    120                 title: "Avg. CPU Utilization History of all Slaves",
    121                 axisYFormat: "%.2f%%",
    122                 minY: 0, maxY: 100)
    123             *@
    124113
    125114            @ChartHelper.RefreshChart("AverageCpuUtilization", Url.Action("AverageCpuUtilization", "ChartData"), "startDate", "endDate")
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/HiveStatisticsGenerator.cs

    r9578 r9646  
    11using System;
    22using System.Collections.Generic;
     3using System.Data.Linq;
    34using System.Linq;
    45using System.Transactions;
     
    89namespace HeuristicLab.Services.Hive {
    910  public class HiveStatisticsGenerator : IStatisticsGenerator {
    10 
    1111    private IUserManager userManager { get { return ServiceLocator.Instance.UserManager; } }
    1212
     
    2222        if (newTime != null) {
    2323          UpdateFactTables(newTime, db);
    24           db.SubmitChanges();
     24          try {
     25            db.SubmitChanges();
     26          }
     27          catch (DuplicateKeyException) {
     28            // Propable change from summertime to wintertime, resulting in overlapping times
     29            // On wintertime to summertime change, slave timeouts and a fact gap will occur
     30          }
    2531        }
    2632
     
    3137    private DimTime UpdateDimensionTables(HiveDataContext db) {
    3238      var newTime = UpdateTime(db);
    33       // Update other tables out of sync with time dimension?
     39
    3440      UpdateUsers(db);
    3541      UpdateJobs(db);
     
    155161
    156162    private void UpdateClientInfoFacts(DimTime newTime, HiveDataContext db) {
     163      var time = newTime.Time;
     164
    157165      var lastFacts =
    158166        from cf in db.FactClientInfos
     
    178186      var clientFacts =
    179187        from s in slaves.ToList()
     188        let duration = s.LastFact != null ? (time - s.LastFact.Time).TotalMinutes : SmallestTimeSpan.TotalMinutes
    180189        select new FactClientInfo {
    181190          DimClient = s.Client,
    182191          DimTime = newTime,
    183192          UserId = s.Slave.OwnerUserId ?? Guid.Empty,
    184           NumUsedCores =
    185             s.Slave.Cores != null && s.Slave.FreeCores != null
    186               ? s.Slave.Cores.Value - s.Slave.FreeCores.Value
    187               : 0,
     193          NumUsedCores = s.Slave.Cores != null && s.Slave.FreeCores != null
     194                         ? s.Slave.Cores.Value - s.Slave.FreeCores.Value : 0,
    188195          NumTotalCores = s.Slave.Cores ?? 0,
    189           UsedMemory =
    190             s.Slave.Memory != null && s.Slave.FreeMemory != null
    191               ? s.Slave.Memory.Value - s.Slave.FreeMemory.Value
    192               : 0,
     196          UsedMemory = s.Slave.Memory != null && s.Slave.FreeMemory != null
     197                       ? s.Slave.Memory.Value - s.Slave.FreeMemory.Value : 0,
    193198          TotalMemory = s.Slave.Memory ?? 0,
    194199          CpuUtilization = s.Slave.CpuUtilization,
    195200          TrafficIn = 0,
    196201          TrafficOut = 0,
    197           TotalTimeIdle = CalcNewTotalTime(s.LastFact, newTime.Time,
    198                                            x => x.TotalTimeIdle,
    199                                            () => s.Slave.SlaveState == SlaveState.Idle && s.Slave.IsAllowedToCalculate),
    200           TotalTimeCalculating = CalcNewTotalTime(s.LastFact, newTime.Time,
    201                                                   x => x.TotalTimeCalculating,
    202                                                   () => s.Slave.SlaveState == SlaveState.Calculating),
     202          TotalTimeIdle = s.Slave.SlaveState == SlaveState.Idle && s.Slave.IsAllowedToCalculate
     203                                  ? duration : 0.0,
     204          TotalTimeCalculating = s.Slave.SlaveState == SlaveState.Calculating
     205                                  ? duration : 0.0,
    203206          TotalTimeTransferring = 0.0,
    204           TotalTimeUnavailable = CalcNewTotalTime(s.LastFact, newTime.Time,
    205                                                   x => x.TotalTimeUnavailable,
    206                                                   () => s.Slave.SlaveState == SlaveState.Idle && !s.Slave.IsAllowedToCalculate),
    207           TotalTimeOffline = CalcNewTotalTime(s.LastFact, newTime.Time,
    208                                               x => x.TotalTimeOffline,
    209                                               () => s.Slave.SlaveState == SlaveState.Offline)
     207          TotalTimeUnavailable = s.Slave.SlaveState == SlaveState.Idle && !s.Slave.IsAllowedToCalculate
     208                                  ? duration : 0.0,
     209          TotalTimeOffline = s.Slave.SlaveState == SlaveState.Offline
     210                                  ? duration : 0.0
    210211        };
    211212
    212213      db.FactClientInfos.InsertAllOnSubmit(clientFacts);
    213     }
    214 
    215     private double CalcNewTotalTime(FactClientInfo lastFact, DateTime newTime, Func<FactClientInfo, double> selector, Func<bool> condition) {
    216       if (lastFact == null) {
    217         return 0.0;
    218       }
    219       return condition()
    220                ? selector(lastFact) + (newTime - lastFact.Time).TotalMinutes
    221                : selector(lastFact);
    222214    }
    223215
     
    262254          TaskSize = t.LastFact == null ? t.TaskDataSize : t.LastFact.TaskSize,
    263255          ResultSize = t.Task.State == TaskState.Finished ? t.TaskDataSize : default(long?),
    264           NumCalculationRuns = stateLogsLinkedList.EnumerateNodes()
    265             .Count(sl => sl.Value.State == TaskState.Calculating && sl.NextIs(nsl => nsl.State == TaskState.Transferring)),
    266           NumRetries = stateLogsLinkedList.EnumerateNodes()
    267             .Count(sl => sl.Value.State == TaskState.Calculating && sl.Next != null && sl.NextIs(nsl => nsl.State != TaskState.Transferring)),
    268           TotalWaitingTime = SumTotalTime(stateLogsLinkedList, stateLog => stateLog.Value.State == TaskState.Waiting),
    269           TotalRuntime = SumTotalTime(stateLogsLinkedList, stateLog => stateLog.Value.State == TaskState.Calculating && stateLog.NextIs(x => x.State == TaskState.Transferring)),
    270           TotalTransferTime = SumTotalTime(stateLogsLinkedList, stateLog => stateLog.Value.State == TaskState.Transferring),
     256          NumCalculationRuns = stateLogsLinkedList.CountCalculationRuns(),
     257          NumRetries = stateLogsLinkedList.CountRetries(),
     258          TotalWaitingTime = stateLogsLinkedList.SumTotalTimeWhere(stateLog => stateLog.Value.State == TaskState.Waiting),
     259          TotalRuntime = stateLogsLinkedList.SumTotalTimeWhere(stateLog => stateLog.Value.State == TaskState.Calculating && stateLog.NextIs(x => x.State == TaskState.Transferring)),
     260          TotalTransferTime = stateLogsLinkedList.SumTotalTimeWhere(stateLog => stateLog.Value.State == TaskState.Transferring),
    271261          TaskState = t.Task.State
    272262        };
     
    275265      db.FactTasks.InsertAllOnSubmit(newTaskFacts);
    276266    }
    277 
    278     private double SumTotalTime(LinkedList<StateLog> stateLogs, Predicate<LinkedListNode<StateLog>> predicate) {
     267  }
     268
     269  public static class StateLogLinkedListExtensions {
     270    public static int CountCalculationRuns(this LinkedList<StateLog> stateLogs) {
    279271      return stateLogs.EnumerateNodes()
    280                       .Where(sl => predicate(sl))
    281                       .Sum(stateLog => stateLog.Next != null ? (stateLog.Next.Value.DateTime - stateLog.Value.DateTime).TotalMinutes : 0);
     272                      .Count(sl => sl.Value.State == TaskState.Calculating && sl.NextIs(nsl => nsl.State == TaskState.Transferring));
     273    }
     274
     275    public static int CountRetries(this LinkedList<StateLog> stateLogs) {
     276      return stateLogs.EnumerateNodes()
     277                      .Count(sl => sl.Value.State == TaskState.Calculating && sl.Next != null && sl.NextIs(nsl => nsl.State != TaskState.Transferring));
     278    }
     279
     280    public static double SumTotalTimeWhere(this LinkedList<StateLog> stateLogs, Predicate<LinkedListNode<StateLog>> predicate) {
     281      return stateLogs.EnumerateNodes()
     282                      .Where(stateLog => predicate(stateLog))
     283                      .Sum(stateLog => stateLog.Next != null ? (stateLog.Next.Value.DateTime - stateLog.Value.DateTime).TotalMinutes : 0.0);
    282284    }
    283285  }
    284286
    285   public static class LinkedListNodeExtensions {
     287  public static class LinkedListExtensions {
    286288    public static IEnumerable<LinkedListNode<T>> EnumerateNodes<T>(this LinkedList<T> list) {
    287289      var node = list.First;
Note: See TracChangeset for help on using the changeset viewer.