Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OaaS/HeuristicLab.Services.Hive.Scaler/Hive/HiveHelper.cs @ 15428

Last change on this file since 15428 was 9508, checked in by fschoepp, 12 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: 1.2 KB
RevLine 
[9508]1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Services.Hive;
6using DA = HeuristicLab.Services.Hive.DataAccess;
7using DT = HeuristicLab.Services.Hive.DataTransfer;
8
9namespace HeuristicLab.Services.Optimization.Scaler.Hive {
10  public static class HiveHelper {
11    public static double GetGlobalUsage() {
12      // from Status.aspx.cs of HeuristicLab.Services.Hive.WebRole
13      var dao = ServiceLocator.Instance.HiveDao;
14      var transactionManager = ServiceLocator.Instance.TransactionManager;
15      IEnumerable<DT.Slave> onlineSlaves = new List<DT.Slave>();
16      IEnumerable<Guid> resourceIds = new List<Guid>();
17
18      transactionManager.UseTransaction(() => {
19        resourceIds = dao.GetResources(x => true).Select(y => y.Id);
20      }, false, false);
21
22      transactionManager.UseTransaction(() => {
23        onlineSlaves = dao.GetSlaves(x => (x.SlaveState == DA.SlaveState.Calculating || x.SlaveState == DA.SlaveState.Idle) && resourceIds.Contains(x.ResourceId));
24      }, false, false);
25
26      return onlineSlaves.Count() > 0 ? onlineSlaves.Average(s => s.CpuUtilization) : 0.0d;
27    }
28  }
29}
Note: See TracBrowser for help on using the repository browser.