using System; using System.Net; using System.Threading; using HeuristicLab.Clients.Hive.SlaveCore; using Microsoft.WindowsAzure.Diagnostics; using Microsoft.WindowsAzure.ServiceRuntime; namespace HeuristicLab.Clients.Hive.Slave.AzureClient { public class WorkerRole : RoleEntryPoint { private Core core; private Thread coreThread; public override void Run() { core = new Core(false); coreThread = new Thread(core.Start); coreThread.Start(); while (true) { Thread.Sleep(10000); } } public override bool OnStart() { ServicePointManager.DefaultConnectionLimit = 12; core = new Core(); try { if (!String.IsNullOrEmpty(RoleEnvironment.GetConfigurationSettingValue(Constants.DiagnosticsConnectionString))) { DiagnosticMonitorConfiguration dmc = DiagnosticMonitor.GetDefaultInitialConfiguration(); dmc.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1); dmc.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose; DiagnosticMonitor.Start(Constants.DiagnosticsConnectionString, dmc); } } catch (RoleEnvironmentException ex) { //diagnostics connectio string not in configuration //-> diagnostics disabled //nothing more to do } return base.OnStart(); } public override void OnStop() { core.Shutdown(); base.OnStop(); } } }