- Timestamp:
- 09/25/15 14:39:59 (9 years ago)
- Location:
- branches/gteufl
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gteufl
- Property svn:ignore
-
old new 8 8 FxCopResults.txt 9 9 Google.ProtocolBuffers-0.9.1.dll 10 Google.ProtocolBuffers-2.4.1.473.dll 10 11 HeuristicLab 3.3.5.1.ReSharper.user 11 12 HeuristicLab 3.3.6.0.ReSharper.user 12 13 HeuristicLab.4.5.resharper.user 13 14 HeuristicLab.ExtLibs.6.0.ReSharper.user 15 HeuristicLab.Scripting.Development 14 16 HeuristicLab.resharper.user 15 17 ProtoGen.exe … … 17 19 _ReSharper.HeuristicLab 18 20 _ReSharper.HeuristicLab 3.3 21 _ReSharper.HeuristicLab 3.3 Tests 19 22 _ReSharper.HeuristicLab.ExtLibs 20 23 bin 21 24 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll 25 obj
-
- Property svn:mergeinfo changed
-
Property
svn:global-ignores
set to
*.nuget
packages
- Property svn:ignore
-
branches/gteufl/HeuristicLab.Clients.Hive.Slave/3.3/Executor.cs
r9456 r12969 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 85 85 task.Start(); 86 86 if (!startTaskSem.WaitOne(Settings.Default.ExecutorSemTimeouts)) { 87 taskDataInvalid = true;88 87 throw new TimeoutException("Timeout when starting the task. TaskStarted event was not fired."); 89 88 } 90 89 } 91 90 catch (Exception e) { 92 this.CurrentException = e; 93 taskDataInvalid = true; 94 Task_TaskFailed(this, new EventArgs<Exception>(e)); 95 } finally { 91 HandleStartStopPauseError(e); 92 } 93 finally { 96 94 taskStartedSem.Set(); 97 95 } … … 103 101 taskStartedSem.WaitOne(Settings.Default.ExecutorSemTimeouts); 104 102 if (task == null) { 105 CurrentException = new Exception("Pausing task " + this.TaskId + ": Task is null"); 106 executorQueue.AddMessage(ExecutorMessageType.ExceptionOccured); 103 HandleStartStopPauseError(new Exception("Pausing task " + this.TaskId + ": Task is null")); 107 104 return; 108 105 } … … 112 109 task.Pause(); 113 110 //we need to block the pause... 114 pauseStopSem.WaitOne(); 111 if (!pauseStopSem.WaitOne(Settings.Default.ExecutorSemTimeouts)) { 112 throw new Exception("Pausing task " + this.TaskId + " timed out."); 113 } 115 114 } 116 115 catch (Exception ex) { 117 CurrentException = new Exception("Error pausing task " + this.TaskId + ": " + ex.ToString()); 118 executorQueue.AddMessage(ExecutorMessageType.ExceptionOccured); 116 HandleStartStopPauseError(ex); 119 117 } 120 118 } … … 125 123 // wait until task is started. if this does not happen, the Task is null an we give up 126 124 taskStartedSem.WaitOne(Settings.Default.ExecutorSemTimeouts); 127 if (task == null) {128 CurrentException = new Exception("Stopping task " + this.TaskId + ": Task is null");129 executorQueue.AddMessage(ExecutorMessageType.ExceptionOccured);130 }131 125 wasTaskAborted = true; 126 127 if (task == null) { 128 HandleStartStopPauseError(new Exception("Stopping task " + this.TaskId + ": Task is null")); 129 return; 130 } 132 131 133 132 if ((ExecutionState == ExecutionState.Started) || (ExecutionState == ExecutionState.Paused)) { 134 133 try { 135 134 task.Stop(); 136 pauseStopSem.WaitOne(); 135 if (!pauseStopSem.WaitOne(Settings.Default.ExecutorSemTimeouts)) { 136 throw new Exception("Stopping task " + this.TaskId + " timed out."); 137 } 137 138 } 138 139 catch (Exception ex) { 139 CurrentException = new Exception("Error stopping task " + this.TaskId + ": " + ex.ToString()); 140 executorQueue.AddMessage(ExecutorMessageType.ExceptionOccured); 140 HandleStartStopPauseError(ex); 141 141 } 142 142 } … … 185 185 #endregion 186 186 187 public Tuple<TaskData, DateTime> GetTaskDataSnapshot() { 188 if (taskDataInvalid) return null; 189 190 Tuple<TaskData, DateTime> snapshot = null; 191 if (task == null) { 192 if (CurrentException == null) { 193 CurrentException = new Exception("Task with id " + this.TaskId + " is null, sending empty task"); 194 } 195 } else { 196 var taskData = new TaskData(); 197 198 var pausedTrigger = new EventWaitHandle(false, EventResetMode.ManualReset); 199 EventHandler pausedHandler = null; 200 pausedHandler = (s, e) => { 201 task.TaskPaused -= pausedHandler; 202 task.TaskPaused += Task_TaskPaused; 203 pausedTrigger.Set(); 204 }; 205 206 task.TaskPaused -= Task_TaskPaused; 207 task.TaskPaused += pausedHandler; 208 task.Pause(); 209 pausedTrigger.WaitOne(); 210 211 taskData.Data = PersistenceUtil.Serialize(task); 212 var timestamp = DateTime.Now; 213 214 EventHandler startedHandler = null; 215 startedHandler = (s, e) => { 216 task.TaskStarted -= startedHandler; 217 task.TaskStarted += Task_TaskStarted; 218 }; 219 220 task.TaskStarted -= Task_TaskStarted; 221 task.TaskStarted += startedHandler; 222 task.Start(); 223 224 taskData.TaskId = TaskId; 225 snapshot = Tuple.Create(taskData, timestamp); 226 } 227 228 return snapshot; 229 } 230 187 231 public TaskData GetTaskData() { 188 232 if (taskDataInvalid) return null; … … 190 234 if (task != null && task.ExecutionState == ExecutionState.Started) { 191 235 throw new InvalidStateException("Task is still running"); 236 } 237 238 TaskData taskData = null; 239 if (task == null) { 240 if (CurrentException == null) { 241 CurrentException = new Exception("Task with id " + this.TaskId + " is null, sending empty task"); 242 } 192 243 } else { 193 TaskData taskData = new TaskData(); 194 if (task == null) { 195 //send empty task and save exception 196 taskData.Data = PersistenceUtil.Serialize(new TaskData()); 197 if (CurrentException == null) { 198 CurrentException = new Exception("Task with id " + this.TaskId + " is null, sending empty task"); 199 } 200 } else { 201 taskData.Data = PersistenceUtil.Serialize(task); 202 } 244 taskData = new TaskData(); 245 taskData.Data = PersistenceUtil.Serialize(task); 203 246 taskData.TaskId = TaskId; 204 return taskData;205 }247 } 248 return taskData; 206 249 } 207 250 … … 211 254 task = null; 212 255 } 256 257 private void HandleStartStopPauseError(Exception e) { 258 taskDataInvalid = true; 259 Task_TaskFailed(this, new EventArgs<Exception>(e)); 260 } 213 261 } 214 262 }
Note: See TracChangeset
for help on using the changeset viewer.