Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7171


Ignore:
Timestamp:
12/11/11 16:37:05 (13 years ago)
Author:
ascheibe
Message:

#1672 communication with ui should be more stable now

Location:
trunk/sources/HeuristicLab.Clients.Hive.Slave/3.3
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Clients.Hive.Slave/3.3/Core.cs

    r7166 r7171  
    4747    private Semaphore waitShutdownSem = new Semaphore(0, 1);
    4848    private bool abortRequested;
    49     private ISlaveCommunication clientCom;
    5049    private ServiceHost slaveComm;
    5150    private WcfService wcfService;
     
    7776        slaveComm = new ServiceHost(typeof(SlaveCommunicationService));
    7877        slaveComm.Open();
    79         clientCom = SlaveClientCom.Instance.ClientCom;
    80 
     78       
    8179        // delete all left over task directories
    8280        pluginManager.CleanPluginTemp();
    83         clientCom.LogMessage("Hive Slave started");
     81        SlaveClientCom.Instance.LogMessage("Hive Slave started");
    8482
    8583        wcfService = WcfService.Instance;
     
    9391          EventLogManager.LogException(ex);
    9492        } else {
    95           //try to log with clientCom. if this works the user sees at least a message,
     93          //try to log with SlaveClientCom.Instance. if this works the user sees at least a message,
    9694          //else an exception will be thrown anyways.
    97           clientCom.LogMessage(string.Format("Uncaught exception: {0} {1} Core is going to shutdown.", ex.ToString(), Environment.NewLine));
     95          SlaveClientCom.Instance.LogMessage(string.Format("Uncaught exception: {0} {1} Core is going to shutdown.", ex.ToString(), Environment.NewLine));
    9896        }
    9997        ShutdownCore();
     
    118116        DetermineAction(container);
    119117        if (!abortRequested) {
    120           clientCom.StatusChanged(configManager.GetStatusForClientConsole());
     118          SlaveClientCom.Instance.StatusChanged(configManager.GetStatusForClientConsole());
    121119        }
    122120      }
     
    134132
    135133    private void WcfService_ExceptionOccured(object sender, EventArgs<Exception> e) {
    136       clientCom.LogMessage(string.Format("Connection to server interruped with exception: {0}", e.Value.Message));
     134      SlaveClientCom.Instance.LogMessage(string.Format("Connection to server interruped with exception: {0}", e.Value.Message));
    137135    }
    138136
    139137    private void WcfService_Connected(object sender, EventArgs e) {
    140       clientCom.LogMessage("Connected successfully to Hive server");
     138      SlaveClientCom.Instance.LogMessage("Connected successfully to Hive server");
    141139    }
    142140
     
    146144    /// <param name="container">The container, containing the message</param>
    147145    private void DetermineAction(MessageContainer container) {
    148       clientCom.LogMessage(string.Format("Message: {0} for task: {1} ", container.Message.ToString(), container.TaskId));
     146      SlaveClientCom.Instance.LogMessage(string.Format("Message: {0} for task: {1} ", container.Message.ToString(), container.TaskId));
    149147
    150148      switch (container.Message) {
     
    195193      .ContinueWith((t) => {
    196194        SlaveStatusInfo.IncrementExceptionOccured();
    197         clientCom.LogMessage(t.Exception.ToString());
     195        SlaveClientCom.Instance.LogMessage(t.Exception.ToString());
    198196      }, TaskContinuationOptions.OnlyOnFaulted);
    199197    }
     
    203201       .ContinueWith((t) => {
    204202         SlaveStatusInfo.IncrementExceptionOccured();
    205          clientCom.LogMessage(t.Exception.ToString());
     203         SlaveClientCom.Instance.LogMessage(t.Exception.ToString());
    206204       }, TaskContinuationOptions.OnlyOnFaulted);
    207205    }
     
    211209       .ContinueWith((t) => {
    212210         SlaveStatusInfo.IncrementExceptionOccured();
    213          clientCom.LogMessage(t.Exception.ToString());
     211         SlaveClientCom.Instance.LogMessage(t.Exception.ToString());
    214212       }, TaskContinuationOptions.OnlyOnFaulted);
    215213    }
     
    219217       .ContinueWith((t) => {
    220218         SlaveStatusInfo.IncrementExceptionOccured();
    221          clientCom.LogMessage(t.Exception.ToString());
     219         SlaveClientCom.Instance.LogMessage(t.Exception.ToString());
    222220       }, TaskContinuationOptions.OnlyOnFaulted);
    223221    }
     
    337335      }
    338336      catch (TaskNotFoundException ex) {
    339         clientCom.LogMessage(ex.ToString());
     337        SlaveClientCom.Instance.LogMessage(ex.ToString());
    340338      }
    341339      catch (Exception ex) {
    342         clientCom.LogMessage(ex.ToString());
     340        SlaveClientCom.Instance.LogMessage(ex.ToString());
    343341      }
    344342    }
     
    355353      }
    356354      catch (TaskNotFoundException ex) {
    357         clientCom.LogMessage(ex.ToString());
     355        SlaveClientCom.Instance.LogMessage(ex.ToString());
    358356      }
    359357      catch (Exception ex) {
    360         clientCom.LogMessage(ex.ToString());
     358        SlaveClientCom.Instance.LogMessage(ex.ToString());
    361359      }
    362360    }
     
    378376          wcfService.UpdateJobState(task.Id, TaskState.Failed, exception.ToString());
    379377        }
    380         clientCom.LogMessage(exception.Message);
     378        SlaveClientCom.Instance.LogMessage(exception.Message);
    381379      }
    382380      catch (TaskNotFoundException ex) {
    383381        SlaveStatusInfo.IncrementExceptionOccured();
    384         clientCom.LogMessage(ex.ToString());
     382        SlaveClientCom.Instance.LogMessage(ex.ToString());
    385383      }
    386384      catch (Exception ex) {
    387385        SlaveStatusInfo.IncrementExceptionOccured();
    388         clientCom.LogMessage(ex.ToString());
     386        SlaveClientCom.Instance.LogMessage(ex.ToString());
    389387      }
    390388    }
     
    394392      SlaveStatusInfo.IncrementExceptionOccured();
    395393      heartbeatManager.AwakeHeartBeatThread();
    396       clientCom.LogMessage(string.Format("Exception occured for task {0}: {1}", e.Value.TaskId, e.Value2.ToString()));
     394      SlaveClientCom.Instance.LogMessage(string.Format("Exception occured for task {0}: {1}", e.Value.TaskId, e.Value2.ToString()));
    397395      wcfService.UpdateJobState(e.Value.TaskId, TaskState.Waiting, e.Value2.ToString());
    398396    }
     
    406404    private void log_MessageAdded(object sender, EventArgs<string> e) {
    407405      try {
    408         clientCom.LogMessage(e.Value.Split('\t')[1]);
     406        SlaveClientCom.Instance.LogMessage(e.Value.Split('\t')[1]);
    409407      }
    410408      catch { }
     
    416414    /// </summary>
    417415    private void DoAbortAll() {
    418       clientCom.LogMessage("Aborting all jobs.");
     416      SlaveClientCom.Instance.LogMessage("Aborting all jobs.");
    419417      foreach (Guid taskId in taskManager.TaskIds) {
    420418        AbortTaskAsync(taskId);
     
    426424    /// </summary>
    427425    private void DoPauseAll() {
    428       clientCom.LogMessage("Pausing all jobs.");
     426      SlaveClientCom.Instance.LogMessage("Pausing all jobs.");
    429427      foreach (Guid taskId in taskManager.TaskIds) {
    430428        PauseTaskAsync(taskId);
     
    436434    /// </summary>
    437435    private void DoStopAll() {
    438       clientCom.LogMessage("Stopping all jobs.");
     436      SlaveClientCom.Instance.LogMessage("Stopping all jobs.");
    439437      foreach (Guid taskId in taskManager.TaskIds) {
    440438        StopTaskAsync(taskId);
     
    456454    /// </summary>
    457455    private void ShutdownCore() {
    458       clientCom.LogMessage("Shutdown signal received");
    459       clientCom.LogMessage("Stopping heartbeat");
     456      SlaveClientCom.Instance.LogMessage("Shutdown signal received");
     457      SlaveClientCom.Instance.LogMessage("Stopping heartbeat");
    460458      heartbeatManager.StopHeartBeat();
    461459      abortRequested = true;
     
    463461      DoAbortAll();
    464462
    465       clientCom.LogMessage("Logging out");
     463      SlaveClientCom.Instance.LogMessage("Logging out");
    466464      WcfService.Instance.Disconnect();
    467       clientCom.Shutdown();
     465      SlaveClientCom.Instance.ClientCom.Shutdown();
    468466      SlaveClientCom.Close();
    469467
     
    477475    /// </summary> 
    478476    private void DoStartSlave() {
    479       clientCom.LogMessage("Restart received");
     477      SlaveClientCom.Instance.LogMessage("Restart received");
    480478      configManager.Asleep = false;
    481479    }
     
    486484    /// </summary>   
    487485    private void Sleep() {
    488       clientCom.LogMessage("Sleep received - not accepting any new jobs");
     486      SlaveClientCom.Instance.LogMessage("Sleep received - not accepting any new jobs");
    489487      configManager.Asleep = true;
    490488      DoPauseAll();
  • trunk/sources/HeuristicLab.Clients.Hive.Slave/3.3/Manager/ConfigManager.cs

    r6983 r7171  
    125125      }
    126126      catch (Exception ex) {
    127         SlaveClientCom.Instance.ClientCom.LogMessage(string.Format("Exception was thrown while trying to get execution times: {0}", ex.Message));
     127        SlaveClientCom.Instance.LogMessage(string.Format("Exception was thrown while trying to get execution times: {0}", ex.Message));
    128128      }
    129129      return prog;
  • trunk/sources/HeuristicLab.Clients.Hive.Slave/3.3/Manager/HeartbeatManager.cs

    r7166 r7171  
    8383      while (!threadStopped) {
    8484        try {
    85           SlaveClientCom.Instance.ClientCom.StatusChanged(ConfigManager.Instance.GetStatusForClientConsole());
     85          SlaveClientCom.Instance.StatusChanged(ConfigManager.Instance.GetStatusForClientConsole());
    8686        }
    8787        catch (Exception ex) {
     
    109109              };
    110110
    111               SlaveClientCom.Instance.ClientCom.LogMessage("Send HB: " + heartBeatData);
     111              SlaveClientCom.Instance.LogMessage("Send HB: " + heartBeatData);
    112112              List<MessageContainer> msgs = wcfService.SendHeartbeat(heartBeatData);
    113113
    114114              if (msgs == null) {
    115                 SlaveClientCom.Instance.ClientCom.LogMessage("Error getting response from HB");
     115                SlaveClientCom.Instance.LogMessage("Error getting response from HB");
    116116                OnExceptionOccured(new Exception("Error getting response from HB"));
    117117              } else {
    118                 SlaveClientCom.Instance.ClientCom.LogMessage("HB Response received (" + msgs.Count + "): ");
    119                 msgs.ForEach(mc => SlaveClientCom.Instance.ClientCom.LogMessage(mc.Message.ToString()));
     118                SlaveClientCom.Instance.LogMessage("HB Response received (" + msgs.Count + "): ");
     119                msgs.ForEach(mc => SlaveClientCom.Instance.LogMessage(mc.Message.ToString()));
    120120                msgs.ForEach(mc => MessageQueue.GetInstance().AddMessage(mc));
    121121              }
     
    124124        }
    125125        catch (Exception e) {
    126           SlaveClientCom.Instance.ClientCom.LogMessage("Heartbeat thread failed: " + e.ToString());
     126          SlaveClientCom.Instance.LogMessage("Heartbeat thread failed: " + e.ToString());
    127127          OnExceptionOccured(e);
    128128        }
     
    130130      }
    131131      waitHandle.Close();
    132       SlaveClientCom.Instance.ClientCom.LogMessage("Heartbeat thread stopped");
     132      SlaveClientCom.Instance.LogMessage("Heartbeat thread stopped");
    133133    }
    134134
  • trunk/sources/HeuristicLab.Clients.Hive.Slave/3.3/SlaveClientCom.cs

    r6983 r7171  
    2323using HeuristicLab.Clients.Hive.SlaveCore.Properties;
    2424using HeuristicLab.Clients.Hive.SlaveCore.ServiceContracts;
     25using System;
    2526
    2627namespace HeuristicLab.Clients.Hive.SlaveCore {
     
    4445        }
    4546        return instance;
     47      }
     48    }
     49
     50    public void LogMessage(string message) {
     51      try {
     52        ClientCom.LogMessage(message);
     53      }
     54      catch (Exception ex) {
     55        EventLogManager.LogMessage("Exception on LogMessage: " + ex.ToString() + Environment.NewLine + "Orginal message was: " + message);
     56      }
     57    }
     58
     59    public void StatusChanged(StatusCommons status) {
     60      try {
     61        ClientCom.StatusChanged(status);
     62      }
     63      catch (Exception ex) {
     64        EventLogManager.LogMessage("Exception on StatusChanged: " + ex.ToString());
    4665      }
    4766    }
Note: See TracChangeset for help on using the changeset viewer.