Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5778


Ignore:
Timestamp:
03/21/11 14:16:01 (13 years ago)
Author:
ascheibe
Message:

#1233

  • log uncaught exceptions to an eventlog if available
  • fixed job pause bug
Location:
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Core.cs

    r5721 r5778  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Diagnostics;
    2425using System.IO;
    2526using System.Runtime.CompilerServices;
     
    4243    public static Core TheCore;
    4344
     45    public EventLog ServiceEventLog { get; set; }
     46
    4447    public static bool abortRequested { get; set; }
    4548    private Semaphore waitShutdownSem = new Semaphore(0, 1);
     
    7679      abortRequested = false;
    7780
    78       //start the client communication service (pipe between slave and slave gui)
    79       slaveComm = new ServiceHost(typeof(SlaveCommunicationService));
    80       slaveComm.Open();
    81 
    82       ClientCom = SlaveClientCom.Instance.ClientCom;
    83       ClientCom.LogMessage("Hive Slave started");
    84 
    85       ConfigManager manager = ConfigManager.Instance;
    86       manager.Core = this;
    87 
    88       wcfService = WcfService.Instance;
    89       RegisterServiceEvents();
    90 
    91       StartHeartbeats(); // Start heartbeats thread
    92       DispatchMessageQueue(); // dispatch messages until abortRequested
    93 
    94       DeRegisterServiceEvents();
    95       waitShutdownSem.Release();
     81      try {
     82        //start the client communication service (pipe between slave and slave gui)
     83        slaveComm = new ServiceHost(typeof(SlaveCommunicationService));
     84        slaveComm.Open();
     85
     86        ClientCom = SlaveClientCom.Instance.ClientCom;
     87        ClientCom.LogMessage("Hive Slave started");
     88
     89        ConfigManager manager = ConfigManager.Instance;
     90        manager.Core = this;
     91
     92        wcfService = WcfService.Instance;
     93        RegisterServiceEvents();
     94
     95        StartHeartbeats(); // Start heartbeats thread
     96        DispatchMessageQueue(); // dispatch messages until abortRequested
     97      }
     98      catch (Exception ex) {
     99        if (ServiceEventLog != null) {
     100          try {
     101            ServiceEventLog.WriteEntry("Hive Slave threw exception: " + ex.ToString() + " with stack trace: " + ex.StackTrace);
     102          }
     103          catch (Exception) { }
     104        } else {
     105          throw ex;
     106        }
     107      }
     108      finally {
     109        DeRegisterServiceEvents();
     110        waitShutdownSem.Release();
     111      }
    96112    }
    97113
    98114    private void StartHeartbeats() {
    99       //Initialize the heartbeat     
    100       heartbeatManager = new HeartbeatManager { Interval = new TimeSpan(0, 0, 10) };
    101       heartbeatManager.StartHeartbeat();
     115      //Initialize the heartbeat     
     116      if (heartbeatManager != null) {
     117        heartbeatManager = new HeartbeatManager { Interval = new TimeSpan(0, 0, 10) };
     118        heartbeatManager.StartHeartbeat();
     119      }
    102120    }
    103121
     
    194212      if (job != null) {
    195213        engines[job.Id].Pause();
    196         JobData sJob = engines[job.Id].GetFinishedJob();
     214        JobData sJob = engines[job.Id].GetPausedJob();
    197215        // job.Exception = engines[job.Id].CurrentException; // can there be an exception if a job is paused
    198216        job.ExecutionTime = engines[job.Id].ExecutionTime;
     
    339357      ClientCom.LogMessage("Sleep received");
    340358      heartbeatManager.StopHeartBeat();
     359      heartbeatManager = null;
    341360      DoStopAll();
    342361      WcfService.Instance.Disconnect();
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Executor.cs

    r5718 r5778  
    175175      }
    176176
     177      return GetJob();
     178    }
     179
     180    public JobData GetPausedJob() {
     181      if (Job == null) {
     182        throw new InvalidStateException("Job is null");
     183      }
     184
     185      if (Job.ExecutionState == HeuristicLab.Core.ExecutionState.Started) {
     186        try { Job.Pause(); }
     187        catch { }
     188      }
     189
     190      return GetJob();
     191    }
     192
     193    private JobData GetJob() {
    177194      if (Job.ExecutionState == HeuristicLab.Core.ExecutionState.Started) {
    178195        throw new InvalidStateException("Job is still running");
Note: See TracChangeset for help on using the changeset viewer.