Changeset 6945


Ignore:
Timestamp:
11/02/11 18:42:44 (8 years ago)
Author:
ascheibe
Message:

#1233 slave: catch more errors and log them to the windows event log

Location:
branches/HeuristicLab.Hive-3.4/sources
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.ConsoleClient/3.3/Program.cs

    r6744 r6945  
    2121
    2222using System;
     23using System.Diagnostics;
    2324using System.Threading;
    2425
     
    2627  public class Program {
    2728    static void Main(string[] args) {
     29      EventLog eventLog = null;
     30      try {
     31        if (!System.Diagnostics.EventLog.SourceExists("HLHive")) {
     32          System.Diagnostics.EventLog.CreateEventSource("HLHive", "HiveSlave");
     33        }
     34        eventLog = new EventLog();
     35        eventLog.Source = "HLHive";
     36        eventLog.Log = "HiveSlave";
     37      }
     38      catch (Exception) { }
     39
    2840      //slave part
    2941      Core core = new Core();
     42      core.ServiceEventLog = eventLog;
    3043      Console.WriteLine("Starting core ...");
    3144      Thread coreThread = new Thread(core.Start);
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.TrayIcon/3.3/HeuristicLab.Clients.Hive.Slave.TrayIcon-3.3.csproj

    r6896 r6945  
    3737  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
    3838    <PlatformTarget>AnyCPU</PlatformTarget>
    39     <OutputPath>..\..\..\..\..\trunk\sources\bin\</OutputPath>
     39    <OutputPath>bin\Debug\</OutputPath>
    4040  </PropertyGroup>
    4141  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
     
    4646    <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    4747      <HintPath>..\..\..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
    48       <Private>False</Private>
     48      <Private>True</Private>
    4949    </Reference>
    5050    <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    5151      <HintPath>..\..\..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
    52       <Private>False</Private>
     52      <Private>True</Private>
    5353    </Reference>
    5454    <Reference Include="HeuristicLab.Core.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    5555      <HintPath>..\..\..\..\..\trunk\sources\bin\HeuristicLab.Core.Views-3.3.dll</HintPath>
    56       <Private>False</Private>
     56      <Private>True</Private>
    5757    </Reference>
    5858    <Reference Include="HeuristicLab.MainForm-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    5959      <HintPath>..\..\..\..\..\trunk\sources\bin\HeuristicLab.MainForm-3.3.dll</HintPath>
    60       <Private>False</Private>
     60      <Private>True</Private>
    6161    </Reference>
    6262    <Reference Include="HeuristicLab.MainForm.WindowsForms-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    6363      <HintPath>..\..\..\..\..\trunk\sources\bin\HeuristicLab.MainForm.WindowsForms-3.3.dll</HintPath>
    64       <Private>False</Private>
     64      <Private>True</Private>
    6565    </Reference>
    6666    <Reference Include="System" />
     
    112112      <Project>{8C0D9F39-397F-4DBE-856F-BC4DC0FE23F8}</Project>
    113113      <Name>HeuristicLab.Clients.Hive.Slave.Views-3.3</Name>
    114       <Private>False</Private>
     114      <Private>True</Private>
    115115    </ProjectReference>
    116116    <ProjectReference Include="..\..\HeuristicLab.Clients.Hive.Slave\3.3\HeuristicLab.Clients.Hive.Slave-3.3.csproj">
    117117      <Project>{989FE92B-484E-41EE-87E2-6A24AF0381D8}</Project>
    118118      <Name>HeuristicLab.Clients.Hive.Slave-3.3</Name>
    119       <Private>False</Private>
     119      <Private>True</Private>
    120120    </ProjectReference>
    121121  </ItemGroup>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Views/3.3/SlaveMainViewBase.cs

    r6823 r6945  
    6161    #region Register Content Events
    6262    protected override void DeregisterContentEvents() {
     63      Content.CoreConnectionChanged -= new EventHandler<Common.EventArgs<CoreConnection>>(Content_CoreConnectionChanged);
    6364      base.DeregisterContentEvents();
    6465    }
     
    6667    protected override void RegisterContentEvents() {
    6768      base.RegisterContentEvents();
     69      Content.CoreConnectionChanged += new EventHandler<Common.EventArgs<CoreConnection>>(Content_CoreConnectionChanged);
     70    }
     71
     72    void Content_CoreConnectionChanged(object sender, Common.EventArgs<CoreConnection> e) {
     73      if (e.Value == CoreConnection.Offline) {
     74        Connector();
     75      }
    6876    }
    6977    #endregion
     
    7785        Content.UserVisibleMessageFired += new System.EventHandler<Common.EventArgs<string>>(Content_UserVisibleMessageFired);
    7886        Task.Factory.StartNew(Connector);
     87      } else {
     88        Content.UserVisibleMessageFired -= new System.EventHandler<Common.EventArgs<string>>(Content_UserVisibleMessageFired);
    7989      }
    8090    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.WindowsService/3.3/ProjectInstaller.cs

    r6898 r6945  
    1515      base.OnAfterInstall(savedState);
    1616
     17      //try to create an event log     
     18      try {
     19        if (!System.Diagnostics.EventLog.SourceExists("HLHive")) {
     20          System.Diagnostics.EventLog.CreateEventSource("HLHive", "HiveSlave");
     21        }
     22      }
     23      catch { }
     24
    1725      //try to start the service after installation
    1826      using (var serviceController = new ServiceController(this.serviceInstaller1.ServiceName, Environment.MachineName)) {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Core.cs

    r6910 r6945  
    7171    public void Start() {
    7272      abortRequested = false;
     73      EventLogManager.ServiceEventLog = ServiceEventLog;
    7374
    7475      try {
     
    9091      catch (Exception ex) {
    9192        if (ServiceEventLog != null) {
    92           try {
    93             ServiceEventLog.WriteEntry(string.Format("Hive Slave threw exception: {0} with stack trace: {1}", ex.ToString(), ex.StackTrace), EventLogEntryType.Error);
    94           }
    95           catch (Exception) { }
     93          EventLogManager.LogException(ex);
    9694        } else {
    9795          //try to log with clientCom. if this works the user sees at least a message,
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/HeuristicLab.Clients.Hive.Slave-3.3.csproj

    r6896 r6945  
    118118    <Compile Include="ExecutorQueue.cs" />
    119119    <Compile Include="IPluginProvider.cs" />
     120    <Compile Include="Manager\EventLogManager.cs" />
    120121    <Compile Include="Manager\TaskManager.cs" />
    121122    <Compile Include="Exceptions\OutOfCoresException.cs" />
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/SlaveClientCom.cs

    r6456 r6945  
    5757      }
    5858      catch {
    59         pipeFactory = new DuplexChannelFactory<ISlaveCommunication>(dummy, new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/HeuristicLabSlaveCom"));
     59        EventLogManager.LogMessage("Couldn't create pipe for SlaveClientCom with config!");
     60
     61        try {
     62          pipeFactory = new DuplexChannelFactory<ISlaveCommunication>(dummy, new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/HeuristicLabSlaveCom"));
     63        }
     64        catch {
     65          EventLogManager.LogMessage("Couldn't create pipe for SlaveClientCom with fixed addresse!");
     66          return;
     67        }
    6068      }
     69      pipeFactory.Faulted += new System.EventHandler(pipeFactory_Faulted);
    6170
    6271      ISlaveCommunication pipeProxy = pipeFactory.CreateChannel();
     
    6473    }
    6574
     75    void pipeFactory_Faulted(object sender, System.EventArgs e) {
     76      EventLogManager.LogMessage("SlaveClientCom just faulted. Trying to repair it...");
     77
     78      try {
     79        pipeFactory.Faulted -= new System.EventHandler(pipeFactory_Faulted);
     80        SetupClientCom();
     81      }
     82      catch { }
     83    }
     84
    6685    public static void Close() {
    67       if (pipeFactory.State != CommunicationState.Closed)
     86      if (pipeFactory.State != CommunicationState.Closed && pipeFactory.State != CommunicationState.Faulted)
    6887        pipeFactory.Close();
    6988    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/SlaveCommunicationService.cs

    r6371 r6945  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.ServiceModel;
     
    5455
    5556    public void LogMessage(string message) {
    56       subscribers.ForEach(delegate(ISlaveCommunicationCallbacks callback) {
    57         if (((ICommunicationObject)callback).State == CommunicationState.Opened) {
    58           callback.OnMessageLogged(message);
    59         } else {
    60           subscribers.Remove(callback);
    61         }
    62       });
     57      try {
     58        subscribers.ForEach(delegate(ISlaveCommunicationCallbacks callback) {
     59          if (((ICommunicationObject)callback).State == CommunicationState.Opened) {
     60            callback.OnMessageLogged(message);
     61          } else {
     62            subscribers.Remove(callback);
     63          }
     64        });
     65      }
     66      catch (Exception ex) {
     67        EventLogManager.LogException(ex);
     68      }
    6369    }
    6470
    6571    public void StatusChanged(StatusCommons status) {
    66       subscribers.ForEach(delegate(ISlaveCommunicationCallbacks callback) {
    67         if (((ICommunicationObject)callback).State == CommunicationState.Opened) {
    68           callback.OnStatusChanged(status);
    69         } else {
    70           subscribers.Remove(callback);
    71         }
    72       });
     72      try {
     73        subscribers.ForEach(delegate(ISlaveCommunicationCallbacks callback) {
     74          if (((ICommunicationObject)callback).State == CommunicationState.Opened) {
     75            callback.OnStatusChanged(status);
     76          } else {
     77            subscribers.Remove(callback);
     78          }
     79        });
     80      }
     81      catch (Exception ex) {
     82        EventLogManager.LogException(ex);
     83      }
    7384    }
    7485
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/SlaveTask.cs

    r6725 r6945  
    5151
    5252    public TimeSpan ExecutionTime {
    53       get { return executor != null ? executor.ExecutionTime : TimeSpan.Zero; }
     53      get {
     54        try {
     55          return executor != null ? executor.ExecutionTime : TimeSpan.Zero;
     56        }
     57        catch (Exception ex) {
     58          EventLogManager.LogException(ex);
     59          return TimeSpan.Zero;
     60        }
     61      }
    5462    }
    5563
     
    122130
    123131      if (executor != null) {
    124         executor.Dispose();
     132        try {
     133          executor.Dispose();
     134        }
     135        catch (Exception ex) {
     136          EventLogManager.LogException(ex);
     137        }
    125138      }
    126139
     
    155168
    156169    public TaskData GetTaskData() {
    157       return executor.GetTaskData();
     170      TaskData data = null;
     171      try {
     172        data = executor.GetTaskData();
     173      }
     174      catch (Exception ex) {
     175        EventLogManager.LogException(ex);
     176      }
     177      return data;
    158178    }
    159179
Note: See TracChangeset for help on using the changeset viewer.