Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OaaS/HeuristicLab.Clients.Hive.Slave.AzureClient/3.3/WorkerRole.cs @ 8242

Last change on this file since 8242 was 8242, checked in by spimming, 12 years ago

#1888:

  • slave worker role initial commit
  • start client communication service optionally
  • make slave client communication interchangeable ('PipeCom', 'TraceCom')
File size: 2.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 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;
23using System.Net;
24using System.Threading;
25using HeuristicLab.Clients.Hive.SlaveCore;
26using Microsoft.WindowsAzure.Diagnostics;
27using Microsoft.WindowsAzure.ServiceRuntime;
28
29namespace HeuristicLab.Clients.Hive.Slave.AzureClient {
30  public class WorkerRole : RoleEntryPoint {
31    private Core core;
32    private Thread coreThread;
33
34    public override void Run() {
35      core = new Core(false);
36      coreThread = new Thread(core.Start);
37      coreThread.Start();
38
39      while (true) {
40        Thread.Sleep(10000);
41      }
42    }
43
44    public override bool OnStart() {
45      ServicePointManager.DefaultConnectionLimit = 12;
46      //core = new Core();
47      try {
48        if (!String.IsNullOrEmpty(RoleEnvironment.GetConfigurationSettingValue(Constants.DiagnosticsConnectionString))) {
49          DiagnosticMonitorConfiguration dmc = DiagnosticMonitor.GetDefaultInitialConfiguration();
50          dmc.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
51          dmc.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;
52          DiagnosticMonitor.Start(Constants.DiagnosticsConnectionString, dmc);
53        }
54      }
55      catch (RoleEnvironmentException ex) {
56        // diagnostics connection string not in configuration
57        // -> diagnostics disabled
58        // nothing more to do
59      }
60
61      return base.OnStart();
62    }
63
64    public override void OnStop() {
65      core.Shutdown();
66      base.OnStop();
67    }
68  }
69}
Note: See TracBrowser for help on using the repository browser.