Changeset 7171 for trunk/sources
- Timestamp:
- 12/11/11 16:37:05 (13 years ago)
- 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 47 47 private Semaphore waitShutdownSem = new Semaphore(0, 1); 48 48 private bool abortRequested; 49 private ISlaveCommunication clientCom;50 49 private ServiceHost slaveComm; 51 50 private WcfService wcfService; … … 77 76 slaveComm = new ServiceHost(typeof(SlaveCommunicationService)); 78 77 slaveComm.Open(); 79 clientCom = SlaveClientCom.Instance.ClientCom; 80 78 81 79 // delete all left over task directories 82 80 pluginManager.CleanPluginTemp(); 83 clientCom.LogMessage("Hive Slave started");81 SlaveClientCom.Instance.LogMessage("Hive Slave started"); 84 82 85 83 wcfService = WcfService.Instance; … … 93 91 EventLogManager.LogException(ex); 94 92 } 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, 96 94 //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)); 98 96 } 99 97 ShutdownCore(); … … 118 116 DetermineAction(container); 119 117 if (!abortRequested) { 120 clientCom.StatusChanged(configManager.GetStatusForClientConsole());118 SlaveClientCom.Instance.StatusChanged(configManager.GetStatusForClientConsole()); 121 119 } 122 120 } … … 134 132 135 133 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)); 137 135 } 138 136 139 137 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"); 141 139 } 142 140 … … 146 144 /// <param name="container">The container, containing the message</param> 147 145 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)); 149 147 150 148 switch (container.Message) { … … 195 193 .ContinueWith((t) => { 196 194 SlaveStatusInfo.IncrementExceptionOccured(); 197 clientCom.LogMessage(t.Exception.ToString());195 SlaveClientCom.Instance.LogMessage(t.Exception.ToString()); 198 196 }, TaskContinuationOptions.OnlyOnFaulted); 199 197 } … … 203 201 .ContinueWith((t) => { 204 202 SlaveStatusInfo.IncrementExceptionOccured(); 205 clientCom.LogMessage(t.Exception.ToString());203 SlaveClientCom.Instance.LogMessage(t.Exception.ToString()); 206 204 }, TaskContinuationOptions.OnlyOnFaulted); 207 205 } … … 211 209 .ContinueWith((t) => { 212 210 SlaveStatusInfo.IncrementExceptionOccured(); 213 clientCom.LogMessage(t.Exception.ToString());211 SlaveClientCom.Instance.LogMessage(t.Exception.ToString()); 214 212 }, TaskContinuationOptions.OnlyOnFaulted); 215 213 } … … 219 217 .ContinueWith((t) => { 220 218 SlaveStatusInfo.IncrementExceptionOccured(); 221 clientCom.LogMessage(t.Exception.ToString());219 SlaveClientCom.Instance.LogMessage(t.Exception.ToString()); 222 220 }, TaskContinuationOptions.OnlyOnFaulted); 223 221 } … … 337 335 } 338 336 catch (TaskNotFoundException ex) { 339 clientCom.LogMessage(ex.ToString());337 SlaveClientCom.Instance.LogMessage(ex.ToString()); 340 338 } 341 339 catch (Exception ex) { 342 clientCom.LogMessage(ex.ToString());340 SlaveClientCom.Instance.LogMessage(ex.ToString()); 343 341 } 344 342 } … … 355 353 } 356 354 catch (TaskNotFoundException ex) { 357 clientCom.LogMessage(ex.ToString());355 SlaveClientCom.Instance.LogMessage(ex.ToString()); 358 356 } 359 357 catch (Exception ex) { 360 clientCom.LogMessage(ex.ToString());358 SlaveClientCom.Instance.LogMessage(ex.ToString()); 361 359 } 362 360 } … … 378 376 wcfService.UpdateJobState(task.Id, TaskState.Failed, exception.ToString()); 379 377 } 380 clientCom.LogMessage(exception.Message);378 SlaveClientCom.Instance.LogMessage(exception.Message); 381 379 } 382 380 catch (TaskNotFoundException ex) { 383 381 SlaveStatusInfo.IncrementExceptionOccured(); 384 clientCom.LogMessage(ex.ToString());382 SlaveClientCom.Instance.LogMessage(ex.ToString()); 385 383 } 386 384 catch (Exception ex) { 387 385 SlaveStatusInfo.IncrementExceptionOccured(); 388 clientCom.LogMessage(ex.ToString());386 SlaveClientCom.Instance.LogMessage(ex.ToString()); 389 387 } 390 388 } … … 394 392 SlaveStatusInfo.IncrementExceptionOccured(); 395 393 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())); 397 395 wcfService.UpdateJobState(e.Value.TaskId, TaskState.Waiting, e.Value2.ToString()); 398 396 } … … 406 404 private void log_MessageAdded(object sender, EventArgs<string> e) { 407 405 try { 408 clientCom.LogMessage(e.Value.Split('\t')[1]);406 SlaveClientCom.Instance.LogMessage(e.Value.Split('\t')[1]); 409 407 } 410 408 catch { } … … 416 414 /// </summary> 417 415 private void DoAbortAll() { 418 clientCom.LogMessage("Aborting all jobs.");416 SlaveClientCom.Instance.LogMessage("Aborting all jobs."); 419 417 foreach (Guid taskId in taskManager.TaskIds) { 420 418 AbortTaskAsync(taskId); … … 426 424 /// </summary> 427 425 private void DoPauseAll() { 428 clientCom.LogMessage("Pausing all jobs.");426 SlaveClientCom.Instance.LogMessage("Pausing all jobs."); 429 427 foreach (Guid taskId in taskManager.TaskIds) { 430 428 PauseTaskAsync(taskId); … … 436 434 /// </summary> 437 435 private void DoStopAll() { 438 clientCom.LogMessage("Stopping all jobs.");436 SlaveClientCom.Instance.LogMessage("Stopping all jobs."); 439 437 foreach (Guid taskId in taskManager.TaskIds) { 440 438 StopTaskAsync(taskId); … … 456 454 /// </summary> 457 455 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"); 460 458 heartbeatManager.StopHeartBeat(); 461 459 abortRequested = true; … … 463 461 DoAbortAll(); 464 462 465 clientCom.LogMessage("Logging out");463 SlaveClientCom.Instance.LogMessage("Logging out"); 466 464 WcfService.Instance.Disconnect(); 467 clientCom.Shutdown();465 SlaveClientCom.Instance.ClientCom.Shutdown(); 468 466 SlaveClientCom.Close(); 469 467 … … 477 475 /// </summary> 478 476 private void DoStartSlave() { 479 clientCom.LogMessage("Restart received");477 SlaveClientCom.Instance.LogMessage("Restart received"); 480 478 configManager.Asleep = false; 481 479 } … … 486 484 /// </summary> 487 485 private void Sleep() { 488 clientCom.LogMessage("Sleep received - not accepting any new jobs");486 SlaveClientCom.Instance.LogMessage("Sleep received - not accepting any new jobs"); 489 487 configManager.Asleep = true; 490 488 DoPauseAll(); -
trunk/sources/HeuristicLab.Clients.Hive.Slave/3.3/Manager/ConfigManager.cs
r6983 r7171 125 125 } 126 126 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)); 128 128 } 129 129 return prog; -
trunk/sources/HeuristicLab.Clients.Hive.Slave/3.3/Manager/HeartbeatManager.cs
r7166 r7171 83 83 while (!threadStopped) { 84 84 try { 85 SlaveClientCom.Instance. ClientCom.StatusChanged(ConfigManager.Instance.GetStatusForClientConsole());85 SlaveClientCom.Instance.StatusChanged(ConfigManager.Instance.GetStatusForClientConsole()); 86 86 } 87 87 catch (Exception ex) { … … 109 109 }; 110 110 111 SlaveClientCom.Instance. ClientCom.LogMessage("Send HB: " + heartBeatData);111 SlaveClientCom.Instance.LogMessage("Send HB: " + heartBeatData); 112 112 List<MessageContainer> msgs = wcfService.SendHeartbeat(heartBeatData); 113 113 114 114 if (msgs == null) { 115 SlaveClientCom.Instance. ClientCom.LogMessage("Error getting response from HB");115 SlaveClientCom.Instance.LogMessage("Error getting response from HB"); 116 116 OnExceptionOccured(new Exception("Error getting response from HB")); 117 117 } 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())); 120 120 msgs.ForEach(mc => MessageQueue.GetInstance().AddMessage(mc)); 121 121 } … … 124 124 } 125 125 catch (Exception e) { 126 SlaveClientCom.Instance. ClientCom.LogMessage("Heartbeat thread failed: " + e.ToString());126 SlaveClientCom.Instance.LogMessage("Heartbeat thread failed: " + e.ToString()); 127 127 OnExceptionOccured(e); 128 128 } … … 130 130 } 131 131 waitHandle.Close(); 132 SlaveClientCom.Instance. ClientCom.LogMessage("Heartbeat thread stopped");132 SlaveClientCom.Instance.LogMessage("Heartbeat thread stopped"); 133 133 } 134 134 -
trunk/sources/HeuristicLab.Clients.Hive.Slave/3.3/SlaveClientCom.cs
r6983 r7171 23 23 using HeuristicLab.Clients.Hive.SlaveCore.Properties; 24 24 using HeuristicLab.Clients.Hive.SlaveCore.ServiceContracts; 25 using System; 25 26 26 27 namespace HeuristicLab.Clients.Hive.SlaveCore { … … 44 45 } 45 46 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()); 46 65 } 47 66 }
Note: See TracChangeset
for help on using the changeset viewer.