Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OaaS/HeuristicLab.Services.Hive.Scaler/PerformanceCounter.cs @ 12055

Last change on this file since 12055 was 9508, checked in by fschoepp, 11 years ago

#1888:
HL:

  • Web projects requires different users to interact with hive. The singleton HiveServiceLocator.Instance doesn't allow different users at the same time, resulting in serialization during access of HiveClient methods.

The following changes have been introduced in favor of a parallel use of the HL libs:

  • HiveClient, TaskDownloader and ConcurrentTaskDownloader may now use a different IHiveServiceLocator than HiveServiceLocator.Instance (all methods have appropriate overloads now).
  • The default instance is still HiveServiceLocator.Instance.

Automated Scaling of Instances:

  • Added Scaler project to solution which represents a WorkerRole that scales the slave instances based on the global cpu utilization of all slaves.
  • Scaler is based on WASABi, rules can be adjusted in rulesstore.xml. Basic rule is: if < 45% global cpu utilization => remove an instance; if > 65% cpu => add an instance. Minimum boundary is 1 and maximum boundary is 8 slave instances.
  • Adjusted Slave project to automatically register itself to a SlaveGroup during WebRole startup (can be adjusted in service configuration).

Web-Frontend:

  • Added basic error messages to the dialogs when an ajax call fails.
  • Removed Styling.js from scripts.
File size: 2.3 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Diagnostics;
6
7namespace HeuristicLab.Services.Optimization.Scaler {
8  public static class PerformanceCounterHelper {
9    public const string HiveCounterCategory = "Hive";
10    public const string HiveCounterGlobalUsageName = "% Global Usage";
11    public const string HiveCounterGlobalUsage = @"\" + HiveCounterCategory + @"\" + HiveCounterGlobalUsageName;   
12
13    public class PerformanceCounterEntry {
14      public string Name { get; set; }
15      public string HelpText { get; set; }
16      public PerformanceCounterType Type { get; set; }
17    }
18
19    private static void InitializePerformanceCounters(string category, string categoryHelpText, params PerformanceCounterEntry[] entries) {
20     
21      if (PerformanceCounterCategory.Exists(category))
22        PerformanceCounterCategory.Delete(category);
23
24      var counterCollection = new CounterCreationDataCollection();
25      foreach (var entry in entries) {
26        var creationData = new CounterCreationData() {
27          CounterName = entry.Name,
28          CounterHelp = entry.HelpText,
29          CounterType = entry.Type
30        };
31        counterCollection.Add(creationData);
32      }
33      PerformanceCounterCategory.Create(
34        category,
35        categoryHelpText,
36        PerformanceCounterCategoryType.SingleInstance,
37        counterCollection);
38
39      Trace.WriteLine(string.Format("Category {0} created.", category));     
40    }
41
42    public static void InitializePerformanceCounters() {
43      InitializePerformanceCounters(HiveCounterCategory, "Hive performance counters",
44        new PerformanceCounterEntry() {
45          Name = HiveCounterGlobalUsageName,
46          Type = PerformanceCounterType.NumberOfItems32,
47          HelpText = "The current usage in % over all hive slaves in the system"
48        }
49      );
50    }
51
52    private static PerformanceCounter hiveGlovalUsage;
53    public static PerformanceCounter HiveGlobalUsage {
54      get {
55        if (hiveGlovalUsage == null) {
56          hiveGlovalUsage = new PerformanceCounter(
57            PerformanceCounterHelper.HiveCounterCategory,
58            PerformanceCounterHelper.HiveCounterGlobalUsageName,
59            string.Empty,
60            false);
61        }
62        return hiveGlovalUsage;
63      }
64    }
65  }
66}
Note: See TracBrowser for help on using the repository browser.