Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/17/13 10:49:49 (11 years ago)
Author:
fschoepp
Message:

#1888:

  • WorkerRole of Slave now logs all exceptions during startup to the blobstore (slavelog).
  • The PluginManager throws an exception during CheckWorkingDirectories() (Save method) which will be caught now, preventing crashes in Windows Azure.
  • "db.DeferredLocal = false" has been removed to prevent loading bugs.
  • HiveScenarioManager doesn't crash anymore, if he can't find an algorithm within a job during retrieval of the run results.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/OaaS/HeuristicLab.Clients.Hive.Slave.AzureClient/3.3/WorkerRole.cs

    r8251 r9365  
    2626using Microsoft.WindowsAzure.Diagnostics;
    2727using Microsoft.WindowsAzure.ServiceRuntime;
     28using Microsoft.WindowsAzure;
     29using Microsoft.WindowsAzure.StorageClient;
     30using System.Text;
    2831
    2932namespace HeuristicLab.Clients.Hive.Slave.AzureClient {
     33
     34
    3035  public class WorkerRole : RoleEntryPoint {
    3136    private Core core;
     
    3641
    3742    public override void Run() {
    38       core = new Core(false);
     43      try {
     44        LogError(new Exception("Starting Run()..."));
     45        core = new Core(false);
    3946
    40       string hiveServerAddress = RoleEnvironment.GetConfigurationSettingValue(HiveServerAddressSetting);
    41       string hiveServerCertificate = RoleEnvironment.GetConfigurationSettingValue(HiveServerCertificateSetting);
     47        string hiveServerAddress = RoleEnvironment.GetConfigurationSettingValue(HiveServerAddressSetting);
     48        string hiveServerCertificate = RoleEnvironment.GetConfigurationSettingValue(HiveServerCertificateSetting);
    4249
    43       // values are empty, settings from app.config are used
    44       if (!string.IsNullOrEmpty(hiveServerAddress) && !string.IsNullOrEmpty(hiveServerCertificate)) {
    45         core.SetNewHiveServer(hiveServerAddress, hiveServerCertificate);
     50        // values are empty, settings from app.config are used
     51        if (!string.IsNullOrEmpty(hiveServerAddress) && !string.IsNullOrEmpty(hiveServerCertificate)) {
     52          core.SetNewHiveServer(hiveServerAddress, hiveServerCertificate);
     53        }
     54
     55        coreThread = new Thread(core.Start);
     56        coreThread.Start();
     57
     58        LogError(new Exception("Run(): Core started successfullly"));
     59        while (true) {
     60          Thread.Sleep(10000);
     61        }
    4662      }
    47 
    48       coreThread = new Thread(core.Start);
    49       coreThread.Start();
    50 
    51       while (true) {
    52         Thread.Sleep(10000);
     63      catch (Exception e) {
     64        LogError(e);
     65    throw e;
    5366      }
    5467    }
    5568
    5669    public override bool OnStart() {
    57       ServicePointManager.DefaultConnectionLimit = 12;
    58       //core = new Core();
    5970      try {
    60         if (!String.IsNullOrEmpty(RoleEnvironment.GetConfigurationSettingValue(Constants.DiagnosticsConnectionString))) {
    61           DiagnosticMonitorConfiguration dmc = DiagnosticMonitor.GetDefaultInitialConfiguration();
    62           dmc.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
    63           dmc.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;
    64           DiagnosticMonitor.Start(Constants.DiagnosticsConnectionString, dmc);
     71        ServicePointManager.DefaultConnectionLimit = 12;
     72        //core = new Core();
     73        LogError(new Exception("Running OnStart()"));
     74        try {
     75          if (!String.IsNullOrEmpty(RoleEnvironment.GetConfigurationSettingValue(Constants.DiagnosticsConnectionString))) {
     76            DiagnosticMonitorConfiguration dmc = DiagnosticMonitor.GetDefaultInitialConfiguration();
     77            dmc.Logs.ScheduledTransferPeriod = TimeSpan.FromSeconds(5);
     78            dmc.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;
     79            DiagnosticMonitor.Start(Constants.DiagnosticsConnectionString, dmc);
     80          }
    6581        }
     82        catch (RoleEnvironmentException ex) {
     83          // diagnostics connection string not in configuration
     84          // -> diagnostics disabled
     85          // nothing more to do
     86          LogError(ex);
     87        }
     88
     89        RoleEnvironment.Changed += RoleEnvironmentChanged;
     90        LogError(new Exception("Finished OnStart() successfullly"));
    6691      }
    67       catch (RoleEnvironmentException ex) {
    68         // diagnostics connection string not in configuration
    69         // -> diagnostics disabled
    70         // nothing more to do
     92      catch (Exception ex) {
     93        LogError(ex);
     94    throw ex;
    7195      }
     96      return base.OnStart();
     97    }
    7298
    73       RoleEnvironment.Changed += RoleEnvironmentChanged;
    74 
    75       return base.OnStart();
     99    private void LogError(Exception e) {
     100      var storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=optimizationstorage1;AccountKey=n7Leom8ZFWkof/VQ2a4aRSvwOlX+Gwr3uojQF9CFJw1osmGCV0WwaNC8s7nkZ+qteLduAgW2l75WFpbXrkvG4Q==");
     101      var blobClient = storageAccount.CreateCloudBlobClient();
     102      var container = blobClient.GetContainerReference("slavelog");
     103      container.CreateIfNotExist();
     104      var guid = Guid.NewGuid();
     105      var blob = container.GetBlobReference(guid.ToString());
     106      var builder = new StringBuilder();
     107      builder.Append("ToString: ").Append(e.ToString()).Append("\n");
     108      builder.Append("Message: ").Append(e.Message).Append("\n");
     109      blob.UploadText(builder.ToString());
    76110    }
    77111
Note: See TracChangeset for help on using the changeset viewer.