Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.Slave.AzureClient/WorkerRole.cs @ 7877

Last change on this file since 7877 was 7371, checked in by spimming, 13 years ago

#1680:

  • start diagnostic monitor only when a connection string is specified
  • constants file added
File size: 1.4 KB
Line 
1using System;
2using System.Net;
3using System.Threading;
4using HeuristicLab.Clients.Hive.SlaveCore;
5using Microsoft.WindowsAzure.Diagnostics;
6using Microsoft.WindowsAzure.ServiceRuntime;
7
8namespace HeuristicLab.Clients.Hive.Slave.AzureClient {
9  public class WorkerRole : RoleEntryPoint {
10    private Core core;
11    private Thread coreThread;
12
13    public override void Run() {
14      core = new Core(false);
15      coreThread = new Thread(core.Start);
16      coreThread.Start();
17
18      while (true) {
19        Thread.Sleep(10000);
20      }
21    }
22
23    public override bool OnStart() {
24      ServicePointManager.DefaultConnectionLimit = 12;
25      core = new Core();
26      try {
27        if (!String.IsNullOrEmpty(RoleEnvironment.GetConfigurationSettingValue(Constants.DiagnosticsConnectionString))) {
28          DiagnosticMonitorConfiguration dmc = DiagnosticMonitor.GetDefaultInitialConfiguration();
29          dmc.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
30          dmc.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;
31          DiagnosticMonitor.Start(Constants.DiagnosticsConnectionString, dmc);
32        }
33      }
34      catch (RoleEnvironmentException ex) {
35        //diagnostics connectio string not in configuration
36        //-> diagnostics disabled
37        //nothing more to do
38      }
39
40      return base.OnStart();
41    }
42
43    public override void OnStop() {
44      core.Shutdown();
45      base.OnStop();
46    }
47  }
48}
Note: See TracBrowser for help on using the repository browser.