- Timestamp:
- 09/08/11 16:38:28 (13 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3
- Files:
-
- 10 edited
- 9 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Core.cs
r6721 r6725 50 50 private ServiceHost slaveComm; 51 51 private WcfService wcfService; 52 private JobManager jobManager;52 private TaskManager taskManager; 53 53 private ConfigManager configManager; 54 54 private PluginManager pluginManager; … … 57 57 var log = new ThreadSafeLog(new Log(Settings.Default.MaxLogCount)); 58 58 this.pluginManager = new PluginManager(WcfService.Instance, log); 59 this. jobManager = new JobManager(pluginManager, log);59 this.taskManager = new TaskManager(pluginManager, log); 60 60 log.MessageAdded += new EventHandler<EventArgs<string>>(log_MessageAdded); 61 61 62 Register JobManagerEvents();63 64 this.configManager = new ConfigManager( jobManager);62 RegisterTaskManagerEvents(); 63 64 this.configManager = new ConfigManager(taskManager); 65 65 ConfigManager.Instance = this.configManager; 66 66 } … … 78 78 clientCom = SlaveClientCom.Instance.ClientCom; 79 79 80 // delete all left over jobdirectories80 // delete all left over task directories 81 81 pluginManager.CleanPluginTemp(); 82 82 clientCom.LogMessage("Hive Slave started"); … … 149 149 /// <param name="container">The container, containing the message</param> 150 150 private void DetermineAction(MessageContainer container) { 151 clientCom.LogMessage(string.Format("Message: {0} for job: {1} ", container.Message.ToString(), container.TaskId));151 clientCom.LogMessage(string.Format("Message: {0} for task: {1} ", container.Message.ToString(), container.TaskId)); 152 152 153 153 if (container is ExecutorMessageContainer<Guid>) { … … 156 156 } else if (container is MessageContainer) { 157 157 switch (container.Message) { 158 case MessageContainer.MessageType.Calculate Job:159 Calculate JobAsync(container.TaskId);160 break; 161 case MessageContainer.MessageType.Abort Job:162 Abort JobAsync(container.TaskId);163 break; 164 case MessageContainer.MessageType.Stop Job:165 Stop JobAsync(container.TaskId);166 break; 167 case MessageContainer.MessageType.Pause Job:168 Pause JobAsync(container.TaskId);158 case MessageContainer.MessageType.CalculateTask: 159 CalculateTaskAsync(container.TaskId); 160 break; 161 case MessageContainer.MessageType.AbortTask: 162 AbortTaskAsync(container.TaskId); 163 break; 164 case MessageContainer.MessageType.StopTask: 165 StopTaskAsync(container.TaskId); 166 break; 167 case MessageContainer.MessageType.PauseTask: 168 PauseTaskAsync(container.TaskId); 169 169 break; 170 170 case MessageContainer.MessageType.StopAll: … … 195 195 } 196 196 197 private void Calculate JobAsync(Guid jobId) {198 TS.Task.Factory.StartNew(HandleCalculate Job, jobId)197 private void CalculateTaskAsync(Guid jobId) { 198 TS.Task.Factory.StartNew(HandleCalculateTask, jobId) 199 199 .ContinueWith((t) => { 200 200 SlaveStatusInfo.IncrementExceptionOccured(); … … 203 203 } 204 204 205 private void Stop JobAsync(Guid jobId) {206 TS.Task.Factory.StartNew(HandleStop Job, jobId)205 private void StopTaskAsync(Guid jobId) { 206 TS.Task.Factory.StartNew(HandleStopTask, jobId) 207 207 .ContinueWith((t) => { 208 208 SlaveStatusInfo.IncrementExceptionOccured(); … … 211 211 } 212 212 213 private void Pause JobAsync(Guid jobId) {214 TS.Task.Factory.StartNew(HandlePause Job, jobId)213 private void PauseTaskAsync(Guid jobId) { 214 TS.Task.Factory.StartNew(HandlePauseTask, jobId) 215 215 .ContinueWith((t) => { 216 216 SlaveStatusInfo.IncrementExceptionOccured(); … … 219 219 } 220 220 221 private void Abort JobAsync(Guid jobId) {222 TS.Task.Factory.StartNew(HandleAbort Job, jobId)221 private void AbortTaskAsync(Guid jobId) { 222 TS.Task.Factory.StartNew(HandleAbortTask, jobId) 223 223 .ContinueWith((t) => { 224 224 SlaveStatusInfo.IncrementExceptionOccured(); … … 227 227 } 228 228 229 private void HandleCalculate Job(object jobIdObj) {230 Guid jobId = (Guid)jobIdObj;231 Task job= null;229 private void HandleCalculateTask(object taskIdObj) { 230 Guid taskId = (Guid)taskIdObj; 231 Task task = null; 232 232 int usedCores = 0; 233 233 try { 234 job = wcfService.GetJob(jobId);235 if ( job == null) throw new JobNotFoundException(jobId);236 if (ConfigManager.Instance.GetFreeCores() < job.CoresNeeded) throw new OutOfCoresException();237 if (ConfigManager.GetFreeMemory() < job.MemoryNeeded) throw new OutOfMemoryException();238 SlaveStatusInfo.IncrementUsedCores( job.CoresNeeded); usedCores = job.CoresNeeded;239 TaskData jobData = wcfService.GetJobData(jobId);240 if ( jobData == null) throw new JobDataNotFoundException(jobId);241 job = wcfService.UpdateJobState(jobId, TaskState.Calculating, null);242 if ( job == null) throw new JobNotFoundException(jobId);243 jobManager.StartJobAsync(job, jobData);244 } 245 catch ( JobNotFoundException) {234 task = wcfService.GetJob(taskId); 235 if (task == null) throw new TaskNotFoundException(taskId); 236 if (ConfigManager.Instance.GetFreeCores() < task.CoresNeeded) throw new OutOfCoresException(); 237 if (ConfigManager.GetFreeMemory() < task.MemoryNeeded) throw new OutOfMemoryException(); 238 SlaveStatusInfo.IncrementUsedCores(task.CoresNeeded); usedCores = task.CoresNeeded; 239 TaskData taskData = wcfService.GetJobData(taskId); 240 if (taskData == null) throw new TaskDataNotFoundException(taskId); 241 task = wcfService.UpdateJobState(taskId, TaskState.Calculating, null); 242 if (task == null) throw new TaskNotFoundException(taskId); 243 taskManager.StartTaskAsync(task, taskData); 244 } 245 catch (TaskNotFoundException) { 246 246 SlaveStatusInfo.DecrementUsedCores(usedCores); 247 247 throw; 248 248 } 249 catch ( JobDataNotFoundException) {249 catch (TaskDataNotFoundException) { 250 250 SlaveStatusInfo.DecrementUsedCores(usedCores); 251 251 throw; 252 252 } 253 catch ( JobAlreadyRunningException) {253 catch (TaskAlreadyRunningException) { 254 254 SlaveStatusInfo.DecrementUsedCores(usedCores); 255 255 throw; 256 256 } 257 257 catch (OutOfCoresException) { 258 wcfService.UpdateJobState( jobId, TaskState.Waiting, "No more cores available");258 wcfService.UpdateJobState(taskId, TaskState.Waiting, "No more cores available"); 259 259 throw; 260 260 } 261 261 catch (OutOfMemoryException) { 262 wcfService.UpdateJobState( jobId, TaskState.Waiting, "No more memory available");262 wcfService.UpdateJobState(taskId, TaskState.Waiting, "No more memory available"); 263 263 throw; 264 264 } 265 265 catch (Exception e) { 266 266 SlaveStatusInfo.DecrementUsedCores(usedCores); 267 wcfService.UpdateJobState( jobId, TaskState.Waiting, e.ToString()); // unknown internal error - report and set waiting again268 throw; 269 } 270 } 271 272 private void HandleStop Job(object jobIdObj) {273 Guid jobId = (Guid)jobIdObj;274 try { 275 Task job = wcfService.GetJob(jobId);276 if ( job == null) throw new JobNotFoundException(jobId);277 jobManager.StopJobAsync(jobId);278 } 279 catch ( JobNotFoundException) {280 throw; 281 } 282 catch ( JobNotRunningException) {267 wcfService.UpdateJobState(taskId, TaskState.Waiting, e.ToString()); // unknown internal error - report and set waiting again 268 throw; 269 } 270 } 271 272 private void HandleStopTask(object taskIdObj) { 273 Guid taskId = (Guid)taskIdObj; 274 try { 275 Task task = wcfService.GetJob(taskId); 276 if (task == null) throw new TaskNotFoundException(taskId); 277 taskManager.StopTaskAsync(taskId); 278 } 279 catch (TaskNotFoundException) { 280 throw; 281 } 282 catch (TaskNotRunningException) { 283 283 throw; 284 284 } … … 288 288 } 289 289 290 private void HandlePause Job(object jobIdObj) {291 Guid jobId = (Guid)jobIdObj;292 try { 293 Task job = wcfService.GetJob(jobId);294 if ( job == null) throw new JobNotFoundException(jobId);295 jobManager.PauseJobAsync(jobId);296 } 297 catch ( JobNotFoundException) {298 throw; 299 } 300 catch ( JobNotRunningException) {290 private void HandlePauseTask(object taskIdObj) { 291 Guid taskId = (Guid)taskIdObj; 292 try { 293 Task task = wcfService.GetJob(taskId); 294 if (task == null) throw new TaskNotFoundException(taskId); 295 taskManager.PauseTaskAsync(taskId); 296 } 297 catch (TaskNotFoundException) { 298 throw; 299 } 300 catch (TaskNotRunningException) { 301 301 throw; 302 302 } … … 306 306 } 307 307 308 private void HandleAbort Job(object jobIdObj) {309 Guid jobId = (Guid)jobIdObj;310 try { 311 jobManager.AbortJob(jobId);312 } 313 catch ( JobNotFoundException) {314 throw; 315 } 316 } 317 318 #region JobManager Events319 private void Register JobManagerEvents() {320 this. jobManager.JobStarted += new EventHandler<EventArgs<SlaveJob>>(jobManager_JobStarted);321 this. jobManager.JobPaused += new EventHandler<EventArgs<SlaveJob, TaskData>>(jobManager_JobPaused);322 this. jobManager.JobStopped += new EventHandler<EventArgs<SlaveJob, TaskData>>(jobManager_JobStopped);323 this. jobManager.JobFailed += new EventHandler<EventArgs<Tuple<SlaveJob, TaskData, Exception>>>(jobManager_JobFailed);324 this. jobManager.ExceptionOccured += new EventHandler<EventArgs<SlaveJob, Exception>>(jobManager_ExceptionOccured);325 this. jobManager.JobAborted += new EventHandler<EventArgs<SlaveJob>>(jobManager_JobAborted);326 } 327 328 private void jobManager_JobStarted(object sender, EventArgs<SlaveJob> e) {308 private void HandleAbortTask(object taskIdObj) { 309 Guid taskId = (Guid)taskIdObj; 310 try { 311 taskManager.AbortTask(taskId); 312 } 313 catch (TaskNotFoundException) { 314 throw; 315 } 316 } 317 318 #region TaskManager Events 319 private void RegisterTaskManagerEvents() { 320 this.taskManager.TaskStarted += new EventHandler<EventArgs<SlaveTask>>(taskManager_TaskStarted); 321 this.taskManager.TaskPaused += new EventHandler<EventArgs<SlaveTask, TaskData>>(taskManager_TaskPaused); 322 this.taskManager.TaskStopped += new EventHandler<EventArgs<SlaveTask, TaskData>>(taskManager_TaskStopped); 323 this.taskManager.TaskFailed += new EventHandler<EventArgs<Tuple<SlaveTask, TaskData, Exception>>>(taskManager_TaskFailed); 324 this.taskManager.ExceptionOccured += new EventHandler<EventArgs<SlaveTask, Exception>>(taskManager_ExceptionOccured); 325 this.taskManager.TaskAborted += new EventHandler<EventArgs<SlaveTask>>(taskManager_TaskAborted); 326 } 327 328 private void taskManager_TaskStarted(object sender, EventArgs<SlaveTask> e) { 329 329 // successfully started, everything is good 330 330 } 331 331 332 private void jobManager_JobPaused(object sender, EventArgs<SlaveJob, TaskData> e) {332 private void taskManager_TaskPaused(object sender, EventArgs<SlaveTask, TaskData> e) { 333 333 try { 334 334 SlaveStatusInfo.DecrementUsedCores(e.Value.CoresNeeded); 335 335 heartbeatManager.AwakeHeartBeatThread(); 336 Task job = wcfService.GetJob(e.Value.JobId);337 if ( job == null) throw new JobNotFoundException(e.Value.JobId);338 job.ExecutionTime = e.Value.ExecutionTime;339 TaskData jobData = e.Value.GetJobData();340 wcfService.UpdateJobData( job, jobData, configManager.GetClientInfo().Id, TaskState.Paused);341 } 342 catch ( JobNotFoundException ex) {336 Task task = wcfService.GetJob(e.Value.TaskId); 337 if (task == null) throw new TaskNotFoundException(e.Value.TaskId); 338 task.ExecutionTime = e.Value.ExecutionTime; 339 TaskData taskData = e.Value.GetTaskData(); 340 wcfService.UpdateJobData(task, taskData, configManager.GetClientInfo().Id, TaskState.Paused); 341 } 342 catch (TaskNotFoundException ex) { 343 343 clientCom.LogMessage(ex.ToString()); 344 344 } … … 348 348 } 349 349 350 private void jobManager_JobStopped(object sender, EventArgs<SlaveJob, TaskData> e) {350 private void taskManager_TaskStopped(object sender, EventArgs<SlaveTask, TaskData> e) { 351 351 try { 352 352 SlaveStatusInfo.DecrementUsedCores(e.Value.CoresNeeded); 353 353 heartbeatManager.AwakeHeartBeatThread(); 354 Task job = wcfService.GetJob(e.Value.JobId);355 if ( job == null) throw new JobNotFoundException(e.Value.JobId);356 job.ExecutionTime = e.Value.ExecutionTime;357 TaskData jobData = e.Value.GetJobData();358 wcfService.UpdateJobData( job, jobData, configManager.GetClientInfo().Id, TaskState.Finished);359 } 360 catch ( JobNotFoundException ex) {354 Task task = wcfService.GetJob(e.Value.TaskId); 355 if (task == null) throw new TaskNotFoundException(e.Value.TaskId); 356 task.ExecutionTime = e.Value.ExecutionTime; 357 TaskData taskData = e.Value.GetTaskData(); 358 wcfService.UpdateJobData(task, taskData, configManager.GetClientInfo().Id, TaskState.Finished); 359 } 360 catch (TaskNotFoundException ex) { 361 361 clientCom.LogMessage(ex.ToString()); 362 362 } … … 366 366 } 367 367 368 private void jobManager_JobFailed(object sender, EventArgs<Tuple<SlaveJob, TaskData, Exception>> e) {368 private void taskManager_TaskFailed(object sender, EventArgs<Tuple<SlaveTask, TaskData, Exception>> e) { 369 369 try { 370 370 SlaveStatusInfo.DecrementUsedCores(e.Value.Item1.CoresNeeded); 371 371 heartbeatManager.AwakeHeartBeatThread(); 372 Slave Job slaveJob= e.Value.Item1;373 TaskData jobData = e.Value.Item2;372 SlaveTask slaveTask = e.Value.Item1; 373 TaskData taskData = e.Value.Item2; 374 374 Exception exception = e.Value.Item3; 375 375 376 Task job = wcfService.GetJob(slaveJob.JobId);377 if ( job == null) throw new JobNotFoundException(slaveJob.JobId);378 job.ExecutionTime = slaveJob.ExecutionTime;379 if ( jobData != null) {380 wcfService.UpdateJobData( job, jobData, configManager.GetClientInfo().Id, TaskState.Failed, exception.ToString());376 Task task = wcfService.GetJob(slaveTask.TaskId); 377 if (task == null) throw new TaskNotFoundException(slaveTask.TaskId); 378 task.ExecutionTime = slaveTask.ExecutionTime; 379 if (taskData != null) { 380 wcfService.UpdateJobData(task, taskData, configManager.GetClientInfo().Id, TaskState.Failed, exception.ToString()); 381 381 } else { 382 wcfService.UpdateJobState( job.Id, TaskState.Failed, exception.ToString());382 wcfService.UpdateJobState(task.Id, TaskState.Failed, exception.ToString()); 383 383 } 384 384 clientCom.LogMessage(exception.Message); 385 385 } 386 catch ( JobNotFoundException ex) {386 catch (TaskNotFoundException ex) { 387 387 SlaveStatusInfo.IncrementExceptionOccured(); 388 388 clientCom.LogMessage(ex.ToString()); … … 394 394 } 395 395 396 private void jobManager_ExceptionOccured(object sender, EventArgs<SlaveJob, Exception> e) {396 private void taskManager_ExceptionOccured(object sender, EventArgs<SlaveTask, Exception> e) { 397 397 SlaveStatusInfo.DecrementUsedCores(e.Value.CoresNeeded); 398 398 SlaveStatusInfo.IncrementExceptionOccured(); 399 399 heartbeatManager.AwakeHeartBeatThread(); 400 clientCom.LogMessage(string.Format("Exception occured for job {0}: {1}", e.Value.JobId, e.Value2.ToString()));401 wcfService.UpdateJobState(e.Value. JobId, TaskState.Waiting, e.Value2.ToString());402 } 403 404 private void jobManager_JobAborted(object sender, EventArgs<SlaveJob> e) {400 clientCom.LogMessage(string.Format("Exception occured for task {0}: {1}", e.Value.TaskId, e.Value2.ToString())); 401 wcfService.UpdateJobState(e.Value.TaskId, TaskState.Waiting, e.Value2.ToString()); 402 } 403 404 private void taskManager_TaskAborted(object sender, EventArgs<SlaveTask> e) { 405 405 SlaveStatusInfo.DecrementUsedCores(e.Value.CoresNeeded); 406 406 } … … 418 418 private void DoAbortAll() { 419 419 clientCom.LogMessage("Aborting all jobs."); 420 foreach (Guid jobId in jobManager.JobIds) {421 Abort JobAsync(jobId);420 foreach (Guid taskId in taskManager.TaskIds) { 421 AbortTaskAsync(taskId); 422 422 } 423 423 } … … 428 428 private void DoPauseAll() { 429 429 clientCom.LogMessage("Pausing all jobs."); 430 foreach (Guid jobId in jobManager.JobIds) {431 Pause JobAsync(jobId);430 foreach (Guid taskId in taskManager.TaskIds) { 431 PauseTaskAsync(taskId); 432 432 } 433 433 } … … 438 438 private void DoStopAll() { 439 439 clientCom.LogMessage("Stopping all jobs."); 440 foreach (Guid jobId in jobManager.JobIds) {441 Stop JobAsync(jobId);440 foreach (Guid taskId in taskManager.TaskIds) { 441 StopTaskAsync(taskId); 442 442 } 443 443 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Exceptions/SerializationException.cs
r6357 r6725 24 24 namespace HeuristicLab.Clients.Hive.SlaveCore { 25 25 public class SerializationException : Exception { 26 public SerializationException() : base("Serializing jobfailed.") { }26 public SerializationException() : base("Serializing task failed.") { } 27 27 } 28 28 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Exceptions/TaskAlreadyRunningException.cs
r6721 r6725 23 23 24 24 namespace HeuristicLab.Clients.Hive.SlaveCore { 25 public class JobAlreadyRunningException : Exception {26 public JobAlreadyRunningException(Guid jobId) : base(string.Format("Task with Id {0} is already running.", jobId)) { }25 public class TaskAlreadyRunningException : Exception { 26 public TaskAlreadyRunningException(Guid jobId) : base(string.Format("Task with Id {0} is already running.", jobId)) { } 27 27 } 28 28 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Exceptions/TaskFailedException.cs
r6721 r6725 23 23 24 24 namespace HeuristicLab.Clients.Hive.SlaveCore { 25 public class JobFailedException : Exception {26 public JobFailedException(string reason) : base(string.Format("Task failed with reason: {0}", reason)) { }25 public class TaskFailedException : Exception { 26 public TaskFailedException(string reason) : base(string.Format("Task failed with reason: {0}", reason)) { } 27 27 } 28 28 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Exceptions/TaskNotDataFoundException.cs
r6721 r6725 23 23 24 24 namespace HeuristicLab.Clients.Hive.SlaveCore { 25 public class JobDataNotFoundException : Exception {26 public JobDataNotFoundException(Guid jobId) : base(string.Format("TaskData with TaskId {0} was not found on server.", jobId)) { }25 public class TaskDataNotFoundException : Exception { 26 public TaskDataNotFoundException(Guid jobId) : base(string.Format("TaskData with TaskId {0} was not found on server.", jobId)) { } 27 27 } 28 28 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Exceptions/TaskNotFoundException.cs
r6721 r6725 23 23 24 24 namespace HeuristicLab.Clients.Hive.SlaveCore { 25 public class JobNotFoundException : Exception {26 public JobNotFoundException(Guid jobId) : base (string.Format("Task with Id {0} was not found on server.", jobId)) { }25 public class TaskNotFoundException : Exception { 26 public TaskNotFoundException(Guid jobId) : base (string.Format("Task with Id {0} was not found on server.", jobId)) { } 27 27 } 28 28 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Exceptions/TaskNotRunningException.cs
r6721 r6725 23 23 24 24 namespace HeuristicLab.Clients.Hive.SlaveCore { 25 public class JobNotRunningException : Exception {26 public JobNotRunningException(Guid jobId) : base(string.Format("Task with Id {0} is not running.", jobId)) { }25 public class TaskNotRunningException : Exception { 26 public TaskNotRunningException(Guid jobId) : base(string.Format("Task with Id {0} is not running.", jobId)) { } 27 27 } 28 28 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Executor.cs
r6721 r6725 29 29 namespace HeuristicLab.Clients.Hive.SlaveCore { 30 30 /// <summary> 31 /// The executor runs in the appdomain and handles the execution of an Hive job.31 /// The executor runs in the appdomain and handles the execution of an Hive task. 32 32 /// </summary> 33 33 public class Executor : MarshalByRefObject, IDisposable { 34 private bool was JobAborted = false;34 private bool wasTaskAborted = false; 35 35 private AutoResetEvent pauseStopSem = new AutoResetEvent(false); 36 private AutoResetEvent start JobSem = new AutoResetEvent(false); // block start method call37 private AutoResetEvent jobStartedSem = new AutoResetEvent(false); // make pause or stop wait until start is finished36 private AutoResetEvent startTaskSem = new AutoResetEvent(false); // block start method call 37 private AutoResetEvent taskStartedSem = new AutoResetEvent(false); // make pause or stop wait until start is finished 38 38 private ExecutorQueue executorQueue; 39 private bool jobDataInvalid = false; // if true, the jobdata is not sent when the jobis failed40 private I Job job;39 private bool taskDataInvalid = false; // if true, the jobdata is not sent when the task is failed 40 private ITask task; 41 41 private DateTime creationTime; 42 42 43 public Guid JobId { get; set; }43 public Guid TaskId { get; set; } 44 44 public int CoresNeeded { get; set; } 45 45 public int MemoryNeeded { get; set; } … … 63 63 64 64 private ExecutionState ExecutionState { 65 get { return job != null ? job.ExecutionState : HeuristicLab.Core.ExecutionState.Stopped; }65 get { return task != null ? task.ExecutionState : HeuristicLab.Core.ExecutionState.Stopped; } 66 66 } 67 67 68 68 public TimeSpan ExecutionTime { 69 get { return job != null ? job.ExecutionTime : new TimeSpan(0, 0, 0); }69 get { return task != null ? task.ExecutionTime : new TimeSpan(0, 0, 0); } 70 70 } 71 71 … … 79 79 try { 80 80 creationTime = DateTime.Now; 81 job = PersistenceUtil.Deserialize<IJob>(serializedJob);81 task = PersistenceUtil.Deserialize<ITask>(serializedJob); 82 82 83 83 RegisterJobEvents(); 84 84 85 job.Start();86 if (!start JobSem.WaitOne(Settings.Default.ExecutorSemTimeouts)) {87 jobDataInvalid = true;88 throw new TimeoutException("Timeout when starting the job. JobStarted event was not fired.");85 task.Start(); 86 if (!startTaskSem.WaitOne(Settings.Default.ExecutorSemTimeouts)) { 87 taskDataInvalid = true; 88 throw new TimeoutException("Timeout when starting the task. TaskStarted event was not fired."); 89 89 } 90 90 } 91 91 catch (Exception e) { 92 92 this.CurrentException = e; 93 Job_JobFailed(this, new EventArgs<Exception>(e));93 Task_TaskFailed(this, new EventArgs<Exception>(e)); 94 94 } 95 95 finally { 96 jobStartedSem.Set();96 taskStartedSem.Set(); 97 97 } 98 98 } … … 100 100 public void Pause() { 101 101 IsPausing = true; 102 // wait until jobis started. if this does not happen, the Task is null an we give up103 jobStartedSem.WaitOne(Settings.Default.ExecutorSemTimeouts);104 if ( job== null) {105 CurrentException = new Exception("Pausing job " + this.JobId + ": Task is null");102 // wait until task is started. if this does not happen, the Task is null an we give up 103 taskStartedSem.WaitOne(Settings.Default.ExecutorSemTimeouts); 104 if (task == null) { 105 CurrentException = new Exception("Pausing task " + this.TaskId + ": Task is null"); 106 106 executorQueue.AddMessage(ExecutorMessageType.ExceptionOccured); 107 107 return; 108 108 } 109 109 110 if ( job.ExecutionState == ExecutionState.Started) {110 if (task.ExecutionState == ExecutionState.Started) { 111 111 try { 112 job.Pause();112 task.Pause(); 113 113 //we need to block the pause... 114 114 pauseStopSem.WaitOne(); 115 115 } 116 116 catch (Exception ex) { 117 CurrentException = new Exception("Error pausing job " + this.JobId + ": " + ex.ToString());117 CurrentException = new Exception("Error pausing task " + this.TaskId + ": " + ex.ToString()); 118 118 executorQueue.AddMessage(ExecutorMessageType.ExceptionOccured); 119 119 } … … 123 123 public void Stop() { 124 124 IsStopping = true; 125 // wait until jobis started. if this does not happen, the Task is null an we give up126 jobStartedSem.WaitOne(Settings.Default.ExecutorSemTimeouts);127 if ( job== null) {128 CurrentException = new Exception("Stopping job " + this.JobId + ": Task is null");125 // wait until task is started. if this does not happen, the Task is null an we give up 126 taskStartedSem.WaitOne(Settings.Default.ExecutorSemTimeouts); 127 if (task == null) { 128 CurrentException = new Exception("Stopping task " + this.TaskId + ": Task is null"); 129 129 executorQueue.AddMessage(ExecutorMessageType.ExceptionOccured); 130 130 } 131 was JobAborted = true;131 wasTaskAborted = true; 132 132 133 133 if ((ExecutionState == ExecutionState.Started) || (ExecutionState == ExecutionState.Paused)) { 134 134 try { 135 job.Stop();135 task.Stop(); 136 136 pauseStopSem.WaitOne(); 137 137 } 138 138 catch (Exception ex) { 139 CurrentException = new Exception("Error stopping job " + this.JobId + ": " + ex.ToString());139 CurrentException = new Exception("Error stopping task " + this.TaskId + ": " + ex.ToString()); 140 140 executorQueue.AddMessage(ExecutorMessageType.ExceptionOccured); 141 141 } … … 144 144 145 145 private void RegisterJobEvents() { 146 job.JobStopped += new EventHandler(Job_JobStopped);147 job.JobFailed += new EventHandler(Job_JobFailed);148 job.JobPaused += new EventHandler(Job_JobPaused);149 job.JobStarted += new EventHandler(Job_JobStarted);146 task.TaskStopped += new EventHandler(Task_TaskStopped); 147 task.TaskFailed += new EventHandler(Task_TaskFailed); 148 task.TaskPaused += new EventHandler(Task_TaskPaused); 149 task.TaskStarted += new EventHandler(Task_TaskStarted); 150 150 } 151 151 152 152 private void DeregisterJobEvents() { 153 job.JobStopped -= new EventHandler(Job_JobStopped);154 job.JobFailed -= new EventHandler(Job_JobFailed);155 job.JobPaused -= new EventHandler(Job_JobPaused);156 job.JobStarted -= new EventHandler(Job_JobStarted);153 task.TaskStopped -= new EventHandler(Task_TaskStopped); 154 task.TaskFailed -= new EventHandler(Task_TaskFailed); 155 task.TaskPaused -= new EventHandler(Task_TaskPaused); 156 task.TaskStarted -= new EventHandler(Task_TaskStarted); 157 157 } 158 158 159 159 #region Task Events 160 private void Job_JobFailed(object sender, EventArgs e) {160 private void Task_TaskFailed(object sender, EventArgs e) { 161 161 IsStopping = true; 162 162 EventArgs<Exception> ex = (EventArgs<Exception>)e; 163 163 CurrentException = ex.Value; 164 executorQueue.AddMessage(ExecutorMessageType. JobFailed);165 } 166 167 private void Job_JobStopped(object sender, EventArgs e) {164 executorQueue.AddMessage(ExecutorMessageType.TaskFailed); 165 } 166 167 private void Task_TaskStopped(object sender, EventArgs e) { 168 168 IsStopping = true; 169 if (was JobAborted) {169 if (wasTaskAborted) { 170 170 pauseStopSem.Set(); 171 171 } 172 executorQueue.AddMessage(ExecutorMessageType. JobStopped);173 } 174 175 private void Job_JobPaused(object sender, EventArgs e) {172 executorQueue.AddMessage(ExecutorMessageType.TaskStopped); 173 } 174 175 private void Task_TaskPaused(object sender, EventArgs e) { 176 176 IsPausing = true; 177 177 pauseStopSem.Set(); 178 executorQueue.AddMessage(ExecutorMessageType. JobPaused);179 } 180 181 private void Job_JobStarted(object sender, EventArgs e) {182 start JobSem.Set();183 executorQueue.AddMessage(ExecutorMessageType. JobStarted);178 executorQueue.AddMessage(ExecutorMessageType.TaskPaused); 179 } 180 181 private void Task_TaskStarted(object sender, EventArgs e) { 182 startTaskSem.Set(); 183 executorQueue.AddMessage(ExecutorMessageType.TaskStarted); 184 184 } 185 185 #endregion 186 186 187 public TaskData Get JobData() {188 if ( jobDataInvalid) return null;189 190 if ( job.ExecutionState == ExecutionState.Started) {187 public TaskData GetTaskData() { 188 if (taskDataInvalid) return null; 189 190 if (task.ExecutionState == ExecutionState.Started) { 191 191 throw new InvalidStateException("Task is still running"); 192 192 } else { 193 TaskData jobData = new TaskData();194 if ( job== null) {195 //send empty joband save exception196 jobData.Data = PersistenceUtil.Serialize(new TaskData());193 TaskData taskData = new TaskData(); 194 if (task == null) { 195 //send empty task and save exception 196 taskData.Data = PersistenceUtil.Serialize(new TaskData()); 197 197 if (CurrentException == null) { 198 CurrentException = new Exception("Task with id " + this. JobId + " is null, sending empty job");198 CurrentException = new Exception("Task with id " + this.TaskId + " is null, sending empty task"); 199 199 } 200 200 } else { 201 jobData.Data = PersistenceUtil.Serialize(job);202 } 203 jobData.TaskId = JobId;204 return jobData;201 taskData.Data = PersistenceUtil.Serialize(task); 202 } 203 taskData.TaskId = TaskId; 204 return taskData; 205 205 } 206 206 } 207 207 208 208 public void Dispose() { 209 if ( job!= null)209 if (task != null) 210 210 DeregisterJobEvents(); 211 job= null;211 task = null; 212 212 } 213 213 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/ExecutorMessage.cs
r6464 r6725 26 26 [Serializable] 27 27 public enum ExecutorMessageType { 28 JobStarted,29 JobPaused,30 JobStopped,31 JobFailed,28 TaskStarted, 29 TaskPaused, 30 TaskStopped, 31 TaskFailed, 32 32 StopExecutorMonitoringThread, 33 33 ExceptionOccured -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/HeuristicLab.Clients.Hive.Slave-3.3.csproj
r6701 r6725 101 101 </ItemGroup> 102 102 <ItemGroup> 103 <Compile Include="Exceptions\ JobFailedException.cs" />103 <Compile Include="Exceptions\TaskFailedException.cs" /> 104 104 <Compile Include="Manager\ConfigManager.cs" /> 105 105 <Compile Include="Exceptions\SerializationException.cs" /> 106 106 <Compile Include="Exceptions\OutOfMemoryException.cs" /> 107 <Compile Include="Exceptions\ JobNotRunningException.cs" />108 <Compile Include="Exceptions\ JobAlreadyRunningException.cs" />109 <Compile Include="Exceptions\ JobNotFoundException.cs" />110 <Compile Include="Exceptions\ JobNotDataFoundException.cs" />107 <Compile Include="Exceptions\TaskNotRunningException.cs" /> 108 <Compile Include="Exceptions\TaskAlreadyRunningException.cs" /> 109 <Compile Include="Exceptions\TaskNotFoundException.cs" /> 110 <Compile Include="Exceptions\TaskNotDataFoundException.cs" /> 111 111 <Compile Include="ExecutorMessage.cs" /> 112 112 <Compile Include="ExecutorQueue.cs" /> 113 113 <Compile Include="IPluginProvider.cs" /> 114 <Compile Include="Manager\ JobManager.cs" />114 <Compile Include="Manager\TaskManager.cs" /> 115 115 <Compile Include="Exceptions\OutOfCoresException.cs" /> 116 <Compile Include="Exceptions\ JobNotStartedException.cs" />116 <Compile Include="Exceptions\AppDomainNotCreatedException.cs" /> 117 117 <Compile Include="SlaveClientCom.cs" /> 118 118 <Compile Include="Core.cs" /> … … 121 121 <Compile Include="Manager\HeartbeatManager.cs" /> 122 122 <Compile Include="Exceptions\InvalidStateException.cs" /> 123 <Compile Include=" JobStatus.cs" />123 <Compile Include="TaskStatus.cs" /> 124 124 <Compile Include="MessageQueue.cs" /> 125 125 <Compile Include="NetworkEnum.cs" /> … … 133 133 <Compile Include="ServiceContracts\ISlaveCommunicationCallbacks.cs" /> 134 134 <Compile Include="SlaveCommunicationService.cs" /> 135 <Compile Include="Slave Job.cs" />135 <Compile Include="SlaveTask.cs" /> 136 136 <Compile Include="SlaveStatusInfo.cs" /> 137 137 <Compile Include="StatusCommons.cs" /> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Manager/ConfigManager.cs
r6521 r6725 42 42 /// </summary> 43 43 public bool Asleep { get; set; } 44 private JobManager jobManager;44 private TaskManager jobManager; 45 45 private Slave slave; 46 46 private PerformanceCounter cpuCounter; … … 49 49 /// Constructor for the singleton, must recover Guid, Calendar, ... 50 50 /// </summary> 51 public ConfigManager( JobManager jobManager) {51 public ConfigManager(TaskManager jobManager) { 52 52 this.jobManager = jobManager; 53 53 cpuCounter = new PerformanceCounter(); … … 95 95 st.Asleep = this.Asleep; 96 96 97 st.JobsStarted = SlaveStatusInfo. JobsStarted;98 st.JobsAborted = SlaveStatusInfo. JobsAborted;99 st.JobsFinished = SlaveStatusInfo. JobsFinished;100 st.JobsFetched = SlaveStatusInfo. JobsFetched;101 st.JobsFailed = SlaveStatusInfo. JobsFailed;97 st.JobsStarted = SlaveStatusInfo.TasksStarted; 98 st.JobsAborted = SlaveStatusInfo.TasksAborted; 99 st.JobsFinished = SlaveStatusInfo.TasksFinished; 100 st.JobsFetched = SlaveStatusInfo.TasksFetched; 101 st.JobsFailed = SlaveStatusInfo.TasksFailed; 102 102 st.ExceptionsOccured = SlaveStatusInfo.ExceptionsOccured; 103 103 104 st.Jobs = jobManager.GetExecutionTimes().Select(x => new JobStatus { JobId = x.Key, ExecutionTime = x.Value }).ToList();104 st.Jobs = jobManager.GetExecutionTimes().Select(x => new TaskStatus { TaskId = x.Key, ExecutionTime = x.Value }).ToList(); 105 105 106 106 return st; -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Manager/PluginManager.cs
r6721 r6725 133 133 /// <summary> 134 134 /// Updates the plugin cache with missing plugins and 135 /// then copies the required plugins for the job.135 /// then copies the required plugins for the task. 136 136 /// </summary> 137 public void PreparePlugins(Task job, out string configFileName) {137 public void PreparePlugins(Task task, out string configFileName) { 138 138 lock (locker) { 139 log.LogMessage("Fetching plugins for job " + job.Id);139 log.LogMessage("Fetching plugins for task " + task.Id); 140 140 141 141 List<Guid> missingGuids = new List<Guid>(); 142 142 List<Plugin> neededPlugins = new List<Plugin>(); 143 143 lock (cachedPluginsGuids) { 144 foreach (Guid pluginId in job.PluginsNeededIds) {144 foreach (Guid pluginId in task.PluginsNeededIds) { 145 145 Plugin plugin = pluginService.GetPlugin(pluginId); 146 146 if (plugin != null) { … … 168 168 DoUpdateRun(); 169 169 } 170 CopyPluginsForJob(neededPlugins, job.Id, out configFileName);170 CopyPluginsForJob(neededPlugins, task.Id, out configFileName); 171 171 } else { 172 172 configFileName = ""; 173 173 } 174 log.LogMessage(string.Format("Fetched {0} plugins for job {1}", missingGuids.Count, job.Id));174 log.LogMessage(string.Format("Fetched {0} plugins for task {1}", missingGuids.Count, task.Id)); 175 175 } 176 176 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Manager/TaskManager.cs
r6721 r6725 30 30 31 31 /// <summary> 32 /// Holds a list of slave jobs and manages access to this list.33 /// Forwards events from Slave Job and forwards commands to SlaveJob.32 /// Holds a list of slave tasks and manages access to this list. 33 /// Forwards events from SlaveTask and forwards commands to SlaveTask. 34 34 /// </summary> 35 public class JobManager {36 private static ReaderWriterLockSlim slave JobsLocker = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);37 private Dictionary<Guid, Slave Job> slaveJobs;35 public class TaskManager { 36 private static ReaderWriterLockSlim slaveTasksLocker = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); 37 private Dictionary<Guid, SlaveTask> slaveTasks; 38 38 private ILog log; 39 39 private PluginManager pluginManager; 40 40 41 public int JobCount {41 public int TaskCount { 42 42 get { 43 slave JobsLocker.EnterReadLock();43 slaveTasksLocker.EnterReadLock(); 44 44 try { 45 return slave Jobs.Count;46 } 47 finally { slave JobsLocker.ExitReadLock(); }48 } 49 } 50 51 public Guid[] JobIds {45 return slaveTasks.Count; 46 } 47 finally { slaveTasksLocker.ExitReadLock(); } 48 } 49 } 50 51 public Guid[] TaskIds { 52 52 get { 53 slave JobsLocker.EnterReadLock();53 slaveTasksLocker.EnterReadLock(); 54 54 try { 55 return slave Jobs.Keys.ToArray();56 } 57 finally { slave JobsLocker.ExitReadLock(); }58 } 59 } 60 61 public JobManager(PluginManager pluginCache, ILog log) {55 return slaveTasks.Keys.ToArray(); 56 } 57 finally { slaveTasksLocker.ExitReadLock(); } 58 } 59 } 60 61 public TaskManager(PluginManager pluginCache, ILog log) { 62 62 this.pluginManager = pluginCache; 63 63 this.log = log; 64 this.slave Jobs = new Dictionary<Guid, SlaveJob>();64 this.slaveTasks = new Dictionary<Guid, SlaveTask>(); 65 65 } 66 66 67 67 #region Task Control methods 68 public void Start JobAsync(Task job, TaskData jobData) {69 Slave Job slaveJob= null;70 slave JobsLocker.EnterUpgradeableReadLock();71 try { 72 if (slave Jobs.ContainsKey(job.Id)) {68 public void StartTaskAsync(Task task, TaskData taskData) { 69 SlaveTask slaveTask = null; 70 slaveTasksLocker.EnterUpgradeableReadLock(); 71 try { 72 if (slaveTasks.ContainsKey(task.Id)) { 73 73 SlaveStatusInfo.IncrementExceptionOccured(); 74 throw new JobAlreadyRunningException(job.Id);74 throw new TaskAlreadyRunningException(task.Id); 75 75 } else { 76 slave Job = new SlaveJob(pluginManager, job.CoresNeeded, log);77 AddSlave Job(job, slaveJob);78 SlaveStatusInfo.Increment JobsFetched();79 } 80 } 81 finally { slave JobsLocker.ExitUpgradeableReadLock(); }82 83 if (slave Job!= null) {76 slaveTask = new SlaveTask(pluginManager, task.CoresNeeded, log); 77 AddSlaveTask(task, slaveTask); 78 SlaveStatusInfo.IncrementTasksFetched(); 79 } 80 } 81 finally { slaveTasksLocker.ExitUpgradeableReadLock(); } 82 83 if (slaveTask != null) { 84 84 try { 85 slave Job.StartJobAsync(job, jobData);85 slaveTask.StartJobAsync(task, taskData); 86 86 } 87 87 catch (Exception) { 88 RemoveSlave Job(job.Id, slaveJob); // clean up and rethrow89 slave Job.DisposeAppDomain();88 RemoveSlaveTask(task.Id, slaveTask); // clean up and rethrow 89 slaveTask.DisposeAppDomain(); 90 90 throw; 91 91 } … … 93 93 } 94 94 95 public void Pause JobAsync(Guid jobId) {96 slave JobsLocker.EnterUpgradeableReadLock();97 try { 98 if (!slave Jobs.ContainsKey(jobId)) throw new JobNotRunningException(jobId);99 Slave Job slaveJob = slaveJobs[jobId];100 slave Job.PauseJob();101 } 102 finally { slave JobsLocker.ExitUpgradeableReadLock(); }103 } 104 105 public void Stop JobAsync(Guid jobId) {106 slave JobsLocker.EnterUpgradeableReadLock();107 try { 108 if (!slave Jobs.ContainsKey(jobId)) throw new JobNotRunningException(jobId);109 Slave Job slaveJob = slaveJobs[jobId];110 slave Job.StopJob();111 } 112 finally { slave JobsLocker.ExitUpgradeableReadLock(); }113 } 114 115 public void Abort Job(Guid jobId) {116 Slave Job slaveJob= null;117 slave JobsLocker.EnterUpgradeableReadLock();118 try { 119 if (!slave Jobs.ContainsKey(jobId)) throw new JobNotRunningException(jobId);120 slave Job = slaveJobs[jobId];121 if (!slave Job.IsPrepared) throw new AppDomainNotCreatedException();122 RemoveSlave Job(jobId, slaveJob);123 } 124 finally { slave JobsLocker.ExitUpgradeableReadLock(); }125 slave Job.DisposeAppDomain();126 SlaveStatusInfo.Increment JobsAborted();127 On JobAborted(slaveJob);128 } 129 130 public void PauseAll JobsAsync() {131 slave JobsLocker.EnterUpgradeableReadLock();132 try { 133 foreach (var slave Job in slaveJobs.Values) {134 slave Job.PauseJob();135 } 136 } 137 finally { slave JobsLocker.ExitUpgradeableReadLock(); }138 } 139 140 public void StopAll JobsAsync() {141 slave JobsLocker.EnterUpgradeableReadLock();142 try { 143 foreach (var slave Job in slaveJobs.Values) {144 slave Job.StopJob();145 } 146 } 147 finally { slave JobsLocker.ExitUpgradeableReadLock(); }148 } 149 150 public void AbortAll Jobs() {151 slave JobsLocker.EnterUpgradeableReadLock();152 try { 153 foreach (var slave Job in slaveJobs.Values.ToArray()) {154 Abort Job(slaveJob.JobId);155 } 156 } 157 finally { slave JobsLocker.ExitUpgradeableReadLock(); }95 public void PauseTaskAsync(Guid taskId) { 96 slaveTasksLocker.EnterUpgradeableReadLock(); 97 try { 98 if (!slaveTasks.ContainsKey(taskId)) throw new TaskNotRunningException(taskId); 99 SlaveTask slaveTask = slaveTasks[taskId]; 100 slaveTask.PauseTask(); 101 } 102 finally { slaveTasksLocker.ExitUpgradeableReadLock(); } 103 } 104 105 public void StopTaskAsync(Guid taskId) { 106 slaveTasksLocker.EnterUpgradeableReadLock(); 107 try { 108 if (!slaveTasks.ContainsKey(taskId)) throw new TaskNotRunningException(taskId); 109 SlaveTask slaveTask = slaveTasks[taskId]; 110 slaveTask.StopTask(); 111 } 112 finally { slaveTasksLocker.ExitUpgradeableReadLock(); } 113 } 114 115 public void AbortTask(Guid taskId) { 116 SlaveTask slaveTask = null; 117 slaveTasksLocker.EnterUpgradeableReadLock(); 118 try { 119 if (!slaveTasks.ContainsKey(taskId)) throw new TaskNotRunningException(taskId); 120 slaveTask = slaveTasks[taskId]; 121 if (!slaveTask.IsPrepared) throw new AppDomainNotCreatedException(); 122 RemoveSlaveTask(taskId, slaveTask); 123 } 124 finally { slaveTasksLocker.ExitUpgradeableReadLock(); } 125 slaveTask.DisposeAppDomain(); 126 SlaveStatusInfo.IncrementTasksAborted(); 127 OnTaskAborted(slaveTask); 128 } 129 130 public void PauseAllTasksAsync() { 131 slaveTasksLocker.EnterUpgradeableReadLock(); 132 try { 133 foreach (var slaveTask in slaveTasks.Values) { 134 slaveTask.PauseTask(); 135 } 136 } 137 finally { slaveTasksLocker.ExitUpgradeableReadLock(); } 138 } 139 140 public void StopAllTasksAsync() { 141 slaveTasksLocker.EnterUpgradeableReadLock(); 142 try { 143 foreach (var slaveTask in slaveTasks.Values) { 144 slaveTask.StopTask(); 145 } 146 } 147 finally { slaveTasksLocker.ExitUpgradeableReadLock(); } 148 } 149 150 public void AbortAllTasks() { 151 slaveTasksLocker.EnterUpgradeableReadLock(); 152 try { 153 foreach (var slaveTask in slaveTasks.Values.ToArray()) { 154 AbortTask(slaveTask.TaskId); 155 } 156 } 157 finally { slaveTasksLocker.ExitUpgradeableReadLock(); } 158 158 } 159 159 #endregion 160 160 161 #region Add/Remove Slave Job162 private void AddSlave Job(Task job, SlaveJob slaveJob) {163 slave JobsLocker.EnterWriteLock();164 try { 165 slave Jobs.Add(job.Id, slaveJob);166 RegisterSlave JobEvents(slaveJob);167 } 168 finally { slave JobsLocker.ExitWriteLock(); }169 } 170 171 private void RemoveSlave Job(Guid jobId, SlaveJob slaveJob) {172 slave JobsLocker.EnterWriteLock();173 try { 174 slave Jobs.Remove(jobId);175 DeregisterSlave JobEvents(slaveJob);176 } 177 finally { slave JobsLocker.ExitWriteLock(); }161 #region Add/Remove SlaveTask 162 private void AddSlaveTask(Task task, SlaveTask slaveTask) { 163 slaveTasksLocker.EnterWriteLock(); 164 try { 165 slaveTasks.Add(task.Id, slaveTask); 166 RegisterSlaveTaskEvents(slaveTask); 167 } 168 finally { slaveTasksLocker.ExitWriteLock(); } 169 } 170 171 private void RemoveSlaveTask(Guid taskId, SlaveTask slaveTask) { 172 slaveTasksLocker.EnterWriteLock(); 173 try { 174 slaveTasks.Remove(taskId); 175 DeregisterSlaveTaskEvents(slaveTask); 176 } 177 finally { slaveTasksLocker.ExitWriteLock(); } 178 178 } 179 179 #endregion 180 180 181 #region Slave JobEvents182 private void RegisterSlave JobEvents(SlaveJob slaveJob) {183 slave Job.JobStarted += new EventHandler<EventArgs<Guid>>(slaveJob_JobStarted);184 slave Job.JobPaused += new EventHandler<EventArgs<Guid>>(slaveJob_JobPaused);185 slave Job.JobStopped += new EventHandler<EventArgs<Guid>>(slaveJob_JobStopped);186 slave Job.JobFailed += new EventHandler<EventArgs<Guid, Exception>>(slaveJob_JobFailed);187 slave Job.ExceptionOccured += new EventHandler<EventArgs<Guid, Exception>>(slaveJob_ExceptionOccured);188 } 189 190 private void DeregisterSlave JobEvents(SlaveJob slaveJob) {191 slave Job.JobStarted -= new EventHandler<EventArgs<Guid>>(slaveJob_JobStarted);192 slave Job.JobPaused -= new EventHandler<EventArgs<Guid>>(slaveJob_JobPaused);193 slave Job.JobStopped -= new EventHandler<EventArgs<Guid>>(slaveJob_JobStopped);194 slave Job.JobFailed -= new EventHandler<EventArgs<Guid, Exception>>(slaveJob_JobFailed);195 slave Job.ExceptionOccured -= new EventHandler<EventArgs<Guid, Exception>>(slaveJob_ExceptionOccured);196 } 197 198 private void slave Job_JobStarted(object sender, EventArgs<Guid> e) {199 Slave Job slaveJob;200 slave JobsLocker.EnterUpgradeableReadLock();201 try { 202 slave Job = slaveJobs[e.Value];203 } 204 finally { slave JobsLocker.ExitUpgradeableReadLock(); }205 206 SlaveStatusInfo.Increment JobsStarted();207 On JobStarted(slaveJob);208 } 209 210 private void slave Job_JobPaused(object sender, EventArgs<Guid> e) {211 Slave Job slaveJob;212 slave JobsLocker.EnterUpgradeableReadLock();213 try { 214 slave Job = slaveJobs[e.Value];215 RemoveSlave Job(e.Value, slaveJob);216 } 217 finally { slave JobsLocker.ExitUpgradeableReadLock(); }218 219 TaskData jobData = null;220 try { 221 jobData = slaveJob.GetJobData();222 if ( jobData == null) throw new SerializationException();223 SlaveStatusInfo.Increment JobsFinished();224 On JobPaused(slaveJob, jobData);181 #region SlaveTask Events 182 private void RegisterSlaveTaskEvents(SlaveTask slaveTask) { 183 slaveTask.TaskStarted += new EventHandler<EventArgs<Guid>>(slaveTask_TaskStarted); 184 slaveTask.TaskPaused += new EventHandler<EventArgs<Guid>>(slaveTask_TaskPaused); 185 slaveTask.TaskStopped += new EventHandler<EventArgs<Guid>>(slaveTask_TaskStopped); 186 slaveTask.TaskFailed += new EventHandler<EventArgs<Guid, Exception>>(slaveTask_TaskFailed); 187 slaveTask.ExceptionOccured += new EventHandler<EventArgs<Guid, Exception>>(slaveTask_ExceptionOccured); 188 } 189 190 private void DeregisterSlaveTaskEvents(SlaveTask slaveTask) { 191 slaveTask.TaskStarted -= new EventHandler<EventArgs<Guid>>(slaveTask_TaskStarted); 192 slaveTask.TaskPaused -= new EventHandler<EventArgs<Guid>>(slaveTask_TaskPaused); 193 slaveTask.TaskStopped -= new EventHandler<EventArgs<Guid>>(slaveTask_TaskStopped); 194 slaveTask.TaskFailed -= new EventHandler<EventArgs<Guid, Exception>>(slaveTask_TaskFailed); 195 slaveTask.ExceptionOccured -= new EventHandler<EventArgs<Guid, Exception>>(slaveTask_ExceptionOccured); 196 } 197 198 private void slaveTask_TaskStarted(object sender, EventArgs<Guid> e) { 199 SlaveTask slaveTask; 200 slaveTasksLocker.EnterUpgradeableReadLock(); 201 try { 202 slaveTask = slaveTasks[e.Value]; 203 } 204 finally { slaveTasksLocker.ExitUpgradeableReadLock(); } 205 206 SlaveStatusInfo.IncrementTasksStarted(); 207 OnTaskStarted(slaveTask); 208 } 209 210 private void slaveTask_TaskPaused(object sender, EventArgs<Guid> e) { 211 SlaveTask slaveTask; 212 slaveTasksLocker.EnterUpgradeableReadLock(); 213 try { 214 slaveTask = slaveTasks[e.Value]; 215 RemoveSlaveTask(e.Value, slaveTask); 216 } 217 finally { slaveTasksLocker.ExitUpgradeableReadLock(); } 218 219 TaskData taskData = null; 220 try { 221 taskData = slaveTask.GetTaskData(); 222 if (taskData == null) throw new SerializationException(); 223 SlaveStatusInfo.IncrementTasksFinished(); 224 OnTaskPaused(slaveTask, taskData); 225 225 } 226 226 catch (Exception ex) { 227 RemoveSlave Job(e.Value, slaveJob);228 SlaveStatusInfo.Increment JobsFailed();229 On JobFailed(slaveJob, jobData, ex);230 } 231 } 232 233 private void slave Job_JobStopped(object sender, EventArgs<Guid> e) {234 Slave Job slaveJob;235 slave JobsLocker.EnterUpgradeableReadLock();236 try { 237 slave Job = slaveJobs[e.Value];238 RemoveSlave Job(e.Value, slaveJob);239 } 240 finally { slave JobsLocker.ExitUpgradeableReadLock(); }241 242 TaskData jobData = null;243 try { 244 jobData = slaveJob.GetJobData();245 if ( jobData == null) throw new SerializationException();246 SlaveStatusInfo.Increment JobsFinished();247 On JobStopped(slaveJob, jobData);227 RemoveSlaveTask(e.Value, slaveTask); 228 SlaveStatusInfo.IncrementTasksFailed(); 229 OnTaskFailed(slaveTask, taskData, ex); 230 } 231 } 232 233 private void slaveTask_TaskStopped(object sender, EventArgs<Guid> e) { 234 SlaveTask slaveTask; 235 slaveTasksLocker.EnterUpgradeableReadLock(); 236 try { 237 slaveTask = slaveTasks[e.Value]; 238 RemoveSlaveTask(e.Value, slaveTask); 239 } 240 finally { slaveTasksLocker.ExitUpgradeableReadLock(); } 241 242 TaskData taskData = null; 243 try { 244 taskData = slaveTask.GetTaskData(); 245 if (taskData == null) throw new SerializationException(); 246 SlaveStatusInfo.IncrementTasksFinished(); 247 OnTaskStopped(slaveTask, taskData); 248 248 } 249 249 catch (Exception ex) { 250 RemoveSlave Job(e.Value, slaveJob);251 SlaveStatusInfo.Increment JobsFailed();252 On JobFailed(slaveJob, jobData, ex);253 } 254 } 255 256 private void slave Job_JobFailed(object sender, EventArgs<Guid, Exception> e) {257 Slave Job slaveJob;258 slave JobsLocker.EnterUpgradeableReadLock();259 try { 260 slave Job = slaveJobs[e.Value];261 RemoveSlave Job(e.Value, slaveJob);262 } 263 finally { slave JobsLocker.ExitUpgradeableReadLock(); }264 265 TaskData jobData = null;266 try { 267 jobData = slaveJob.GetJobData();268 if ( jobData == null) throw new SerializationException();269 } 270 catch { /* jobData will be null */ }271 SlaveStatusInfo.Increment JobsFailed();272 On JobFailed(slaveJob, jobData, e.Value2);273 } 274 275 private void slave Job_ExceptionOccured(object sender, EventArgs<Guid, Exception> e) {276 Slave Job slaveJob;277 slave JobsLocker.EnterUpgradeableReadLock();278 try { 279 slave Job = slaveJobs[e.Value];280 RemoveSlave Job(e.Value, slaveJob);281 } 282 finally { slave JobsLocker.ExitUpgradeableReadLock(); }250 RemoveSlaveTask(e.Value, slaveTask); 251 SlaveStatusInfo.IncrementTasksFailed(); 252 OnTaskFailed(slaveTask, taskData, ex); 253 } 254 } 255 256 private void slaveTask_TaskFailed(object sender, EventArgs<Guid, Exception> e) { 257 SlaveTask slaveTask; 258 slaveTasksLocker.EnterUpgradeableReadLock(); 259 try { 260 slaveTask = slaveTasks[e.Value]; 261 RemoveSlaveTask(e.Value, slaveTask); 262 } 263 finally { slaveTasksLocker.ExitUpgradeableReadLock(); } 264 265 TaskData taskData = null; 266 try { 267 taskData = slaveTask.GetTaskData(); 268 if (taskData == null) throw new SerializationException(); 269 } 270 catch { /* taskData will be null */ } 271 SlaveStatusInfo.IncrementTasksFailed(); 272 OnTaskFailed(slaveTask, taskData, e.Value2); 273 } 274 275 private void slaveTask_ExceptionOccured(object sender, EventArgs<Guid, Exception> e) { 276 SlaveTask slaveTask; 277 slaveTasksLocker.EnterUpgradeableReadLock(); 278 try { 279 slaveTask = slaveTasks[e.Value]; 280 RemoveSlaveTask(e.Value, slaveTask); 281 } 282 finally { slaveTasksLocker.ExitUpgradeableReadLock(); } 283 283 284 284 SlaveStatusInfo.IncrementExceptionOccured(); 285 OnExceptionOccured(slave Job, e.Value2);285 OnExceptionOccured(slaveTask, e.Value2); 286 286 } 287 287 #endregion 288 288 289 289 #region EventHandler 290 public event EventHandler<EventArgs<Slave Job>> JobStarted;291 private void On JobStarted(SlaveJob slaveJob) {292 var handler = JobStarted;293 if (handler != null) handler(this, new EventArgs<Slave Job>(slaveJob));294 } 295 296 public event EventHandler<EventArgs<Slave Job, TaskData>> JobStopped;297 private void On JobStopped(SlaveJob slaveJob, TaskData jobData) {298 var handler = JobStopped;299 if (handler != null) handler(this, new EventArgs<Slave Job, TaskData>(slaveJob, jobData));300 } 301 302 public event EventHandler<EventArgs<Slave Job, TaskData>> JobPaused;303 private void On JobPaused(SlaveJob slaveJob, TaskData jobData) {304 var handler = JobPaused;305 if (handler != null) handler(this, new EventArgs<Slave Job, TaskData>(slaveJob, jobData));306 } 307 308 public event EventHandler<EventArgs<Tuple<Slave Job, TaskData, Exception>>> JobFailed;309 private void On JobFailed(SlaveJob slaveJob, TaskData jobData, Exception exception) {310 var handler = JobFailed;311 if (handler != null) handler(this, new EventArgs<Tuple<Slave Job, TaskData, Exception>>(new Tuple<SlaveJob, TaskData, Exception>(slaveJob, jobData, exception)));312 } 313 314 public event EventHandler<EventArgs<Slave Job, Exception>> ExceptionOccured;315 private void OnExceptionOccured(Slave Job slaveJob, Exception exception) {290 public event EventHandler<EventArgs<SlaveTask>> TaskStarted; 291 private void OnTaskStarted(SlaveTask slaveTask) { 292 var handler = TaskStarted; 293 if (handler != null) handler(this, new EventArgs<SlaveTask>(slaveTask)); 294 } 295 296 public event EventHandler<EventArgs<SlaveTask, TaskData>> TaskStopped; 297 private void OnTaskStopped(SlaveTask slaveTask, TaskData taskData) { 298 var handler = TaskStopped; 299 if (handler != null) handler(this, new EventArgs<SlaveTask, TaskData>(slaveTask, taskData)); 300 } 301 302 public event EventHandler<EventArgs<SlaveTask, TaskData>> TaskPaused; 303 private void OnTaskPaused(SlaveTask slaveTask, TaskData taskData) { 304 var handler = TaskPaused; 305 if (handler != null) handler(this, new EventArgs<SlaveTask, TaskData>(slaveTask, taskData)); 306 } 307 308 public event EventHandler<EventArgs<Tuple<SlaveTask, TaskData, Exception>>> TaskFailed; 309 private void OnTaskFailed(SlaveTask slaveTask, TaskData taskData, Exception exception) { 310 var handler = TaskFailed; 311 if (handler != null) handler(this, new EventArgs<Tuple<SlaveTask, TaskData, Exception>>(new Tuple<SlaveTask, TaskData, Exception>(slaveTask, taskData, exception))); 312 } 313 314 public event EventHandler<EventArgs<SlaveTask, Exception>> ExceptionOccured; 315 private void OnExceptionOccured(SlaveTask slaveTask, Exception exception) { 316 316 var handler = ExceptionOccured; 317 if (handler != null) handler(this, new EventArgs<Slave Job, Exception>(slaveJob, exception));318 } 319 320 public event EventHandler<EventArgs<Slave Job>> JobAborted;321 private void On JobAborted(SlaveJob slaveJob) {322 var handler = JobAborted;323 if (handler != null) handler(this, new EventArgs<Slave Job>(slaveJob));317 if (handler != null) handler(this, new EventArgs<SlaveTask, Exception>(slaveTask, exception)); 318 } 319 320 public event EventHandler<EventArgs<SlaveTask>> TaskAborted; 321 private void OnTaskAborted(SlaveTask slaveTask) { 322 var handler = TaskAborted; 323 if (handler != null) handler(this, new EventArgs<SlaveTask>(slaveTask)); 324 324 } 325 325 #endregion 326 326 327 327 public Dictionary<Guid, TimeSpan> GetExecutionTimes() { 328 slave JobsLocker.EnterReadLock();329 try { 330 return slave Jobs.ToDictionary(x => x.Key, x => x.Value.ExecutionTime);331 } 332 finally { slave JobsLocker.ExitReadLock(); }328 slaveTasksLocker.EnterReadLock(); 329 try { 330 return slaveTasks.ToDictionary(x => x.Key, x => x.Value.ExecutionTime); 331 } 332 finally { slaveTasksLocker.ExitReadLock(); } 333 333 } 334 334 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/SlaveStatusInfo.cs
r6371 r6725 26 26 public class SlaveStatusInfo { 27 27 private static object coreLock = new object(); 28 private static int jobsFetched; // number of fetched jobs29 private static int jobsStarted; // number of started jobs30 private static int jobsFinished; // everything went fine31 private static int jobsAborted; // server sent abort32 private static int jobsFailed; // jobs that failed in the sandbox33 private static int exceptionsOccured; // number jobs failed caused by the business logic, not a faulted job28 private static int tasksFetched; // number of fetched jobs 29 private static int tasksStarted; // number of started jobs 30 private static int tasksFinished; // everything went fine 31 private static int tasksAborted; // server sent abort 32 private static int tasksFailed; // tasks that failed in the sandbox 33 private static int exceptionsOccured; // number jobs failed caused by the business logic, not a faulted task 34 34 private static int usedCores; // number of cores currently used 35 35 … … 40 40 } 41 41 42 public static int JobsStarted {43 get { return jobsStarted; }42 public static int TasksStarted { 43 get { return tasksStarted; } 44 44 } 45 45 46 public static int JobsFinished {47 get { return jobsFinished; }46 public static int TasksFinished { 47 get { return tasksFinished; } 48 48 } 49 49 50 public static int JobsAborted {51 get { return jobsAborted; }50 public static int TasksAborted { 51 get { return tasksAborted; } 52 52 } 53 53 54 public static int JobsFetched {55 get { return jobsFetched; }54 public static int TasksFetched { 55 get { return tasksFetched; } 56 56 } 57 57 58 public static int JobsFailed {59 get { return jobsFailed; }58 public static int TasksFailed { 59 get { return tasksFailed; } 60 60 } 61 61 … … 64 64 } 65 65 66 public static void Increment JobsStarted() {67 Interlocked.Increment(ref jobsStarted);66 public static void IncrementTasksStarted() { 67 Interlocked.Increment(ref tasksStarted); 68 68 } 69 69 70 public static void Increment JobsFinished() {71 Interlocked.Increment(ref jobsFinished);70 public static void IncrementTasksFinished() { 71 Interlocked.Increment(ref tasksFinished); 72 72 } 73 73 74 public static void Increment JobsFailed() {75 Interlocked.Increment(ref jobsFailed);74 public static void IncrementTasksFailed() { 75 Interlocked.Increment(ref tasksFailed); 76 76 } 77 77 78 public static void Increment JobsAborted() {79 Interlocked.Increment(ref jobsAborted);78 public static void IncrementTasksAborted() { 79 Interlocked.Increment(ref tasksAborted); 80 80 } 81 81 82 public static void Increment JobsFetched() {83 Interlocked.Increment(ref jobsFetched);82 public static void IncrementTasksFetched() { 83 Interlocked.Increment(ref tasksFetched); 84 84 } 85 85 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/SlaveTask.cs
r6721 r6725 31 31 32 32 /// <summary> 33 /// Manages a single joband it's appdomain.33 /// Manages a single task and it's appdomain. 34 34 /// </summary> 35 public class Slave Job: MarshalByRefObject {35 public class SlaveTask : MarshalByRefObject { 36 36 private Executor executor; 37 37 private AppDomain appDomain; … … 41 41 private PluginManager pluginManager; 42 42 private ILog log; 43 public Guid JobId { get; private set; }43 public Guid TaskId { get; private set; } 44 44 public bool IsPrepared { get; private set; } 45 45 … … 54 54 } 55 55 56 public Slave Job(PluginManager pluginManager, int coresNeeded, ILog log) {56 public SlaveTask(PluginManager pluginManager, int coresNeeded, ILog log) { 57 57 this.pluginManager = pluginManager; 58 58 this.coresNeeded = coresNeeded; … … 63 63 } 64 64 65 public void StartJobAsync(Task job, TaskData jobData) {65 public void StartJobAsync(Task task, TaskData taskData) { 66 66 try { 67 this. JobId = job.Id;68 Prepare( job);69 Start JobInAppDomain(jobData);67 this.TaskId = task.Id; 68 Prepare(task); 69 StartTaskInAppDomain(taskData); 70 70 } 71 71 catch (Exception) { … … 76 76 } 77 77 78 public void Pause Job() {78 public void PauseTask() { 79 79 if (!IsPrepared) throw new AppDomainNotCreatedException(); 80 80 if (!executor.IsPausing && !executor.IsStopping) executor.Pause(); 81 81 } 82 82 83 public void Stop Job() {83 public void StopTask() { 84 84 if (!IsPrepared) throw new AppDomainNotCreatedException(); 85 85 if (!executor.IsPausing && !executor.IsStopping) executor.Stop(); 86 86 } 87 87 88 private void Prepare(Task job) {89 string pluginDir = Path.Combine(pluginManager.PluginTempBaseDir, job.Id.ToString());88 private void Prepare(Task task) { 89 string pluginDir = Path.Combine(pluginManager.PluginTempBaseDir, task.Id.ToString()); 90 90 string configFileName; 91 pluginManager.PreparePlugins( job, out configFileName);92 appDomain = CreateAppDomain( job, pluginDir, configFileName);91 pluginManager.PreparePlugins(task, out configFileName); 92 appDomain = CreateAppDomain(task, pluginDir, configFileName); 93 93 IsPrepared = true; 94 94 } 95 95 96 private AppDomain CreateAppDomain(Task job, String pluginDir, string configFileName) {97 if ( job.IsPrivileged) {98 appDomain = SandboxManager.CreateAndInitPrivilegedSandbox( job.Id.ToString(), pluginDir, Path.Combine(pluginDir, configFileName));96 private AppDomain CreateAppDomain(Task task, String pluginDir, string configFileName) { 97 if (task.IsPrivileged) { 98 appDomain = SandboxManager.CreateAndInitPrivilegedSandbox(task.Id.ToString(), pluginDir, Path.Combine(pluginDir, configFileName)); 99 99 } else { 100 appDomain = SandboxManager.CreateAndInitSandbox( job.Id.ToString(), pluginDir, Path.Combine(pluginDir, configFileName));100 appDomain = SandboxManager.CreateAndInitSandbox(task.Id.ToString(), pluginDir, Path.Combine(pluginDir, configFileName)); 101 101 } 102 102 appDomain.UnhandledException += new UnhandledExceptionEventHandler(AppDomain_UnhandledException); … … 105 105 executor = (Executor)appDomain.CreateInstanceAndUnwrap(typeof(Executor).Assembly.GetName().Name, typeof(Executor).FullName); 106 106 107 executor. JobId = job.Id;108 executor.CoresNeeded = job.CoresNeeded;109 executor.MemoryNeeded = job.MemoryNeeded;107 executor.TaskId = task.Id; 108 executor.CoresNeeded = task.CoresNeeded; 109 executor.MemoryNeeded = task.MemoryNeeded; 110 110 return appDomain; 111 111 } 112 112 113 private void Start JobInAppDomain(TaskData jobData) {114 executor.Start( jobData.Data);113 private void StartTaskInAppDomain(TaskData taskData) { 114 executor.Start(taskData.Data); 115 115 waitForStartBeforeKillSem.Release(); 116 116 StartExecutorMonitoringThread(); … … 118 118 119 119 public void DisposeAppDomain() { 120 log.LogMessage(string.Format("Shutting down Appdomain for Task {0}", JobId));120 log.LogMessage(string.Format("Shutting down Appdomain for Task {0}", TaskId)); 121 121 StopExecutorMonitoringThread(); 122 122 … … 145 145 } 146 146 } 147 pluginManager.DeletePluginsForJob( JobId);147 pluginManager.DeletePluginsForJob(TaskId); 148 148 GC.Collect(); 149 149 } … … 154 154 } 155 155 156 public TaskData Get JobData() {157 return executor.Get JobData();156 public TaskData GetTaskData() { 157 return executor.GetTaskData(); 158 158 } 159 159 … … 176 176 /// Because the executor is in an appdomain and is not able to call back 177 177 /// (because of security -> lease time for marshall-by-ref object is 5 min), 178 /// we have to poll the executor for events we have to react to (e.g. jobfinished...)178 /// we have to poll the executor for events we have to react to (e.g. task finished...) 179 179 /// </summary> 180 180 private void MonitorExecutor() { … … 184 184 185 185 switch (message.MessageType) { 186 case ExecutorMessageType. JobStarted:187 On JobStarted();188 break; 189 190 case ExecutorMessageType. JobPaused:191 executorMonitoringRun = false; 192 On JobPaused();193 DisposeAppDomain(); 194 break; 195 196 case ExecutorMessageType. JobStopped:197 executorMonitoringRun = false; 198 On JobStopped();199 DisposeAppDomain(); 200 break; 201 202 case ExecutorMessageType. JobFailed:203 executorMonitoringRun = false; 204 On JobFailed(new JobFailedException(executor.CurrentExceptionStr));186 case ExecutorMessageType.TaskStarted: 187 OnTaskStarted(); 188 break; 189 190 case ExecutorMessageType.TaskPaused: 191 executorMonitoringRun = false; 192 OnTaskPaused(); 193 DisposeAppDomain(); 194 break; 195 196 case ExecutorMessageType.TaskStopped: 197 executorMonitoringRun = false; 198 OnTaskStopped(); 199 DisposeAppDomain(); 200 break; 201 202 case ExecutorMessageType.TaskFailed: 203 executorMonitoringRun = false; 204 OnTaskFailed(new TaskFailedException(executor.CurrentExceptionStr)); 205 205 DisposeAppDomain(); 206 206 break; … … 216 216 OnExceptionOccured(executor.CurrentException); 217 217 } else { 218 OnExceptionOccured(new Exception(string.Format("Unknow exception occured in Executor for job {0}", JobId)));218 OnExceptionOccured(new Exception(string.Format("Unknow exception occured in Executor for task {0}", TaskId))); 219 219 } 220 220 break; … … 224 224 #endregion 225 225 226 public event EventHandler<EventArgs<Guid>> JobStarted;227 private void On JobStarted() {228 var handler = JobStarted;229 if (handler != null) handler(this, new EventArgs<Guid>(this. JobId));230 } 231 232 public event EventHandler<EventArgs<Guid>> JobStopped;233 private void On JobStopped() {234 var handler = JobStopped;235 if (handler != null) handler(this, new EventArgs<Guid>(this. JobId));236 } 237 238 public event EventHandler<EventArgs<Guid>> JobPaused;239 private void On JobPaused() {240 var handler = JobPaused;241 if (handler != null) handler(this, new EventArgs<Guid>(this. JobId));242 } 243 244 public event EventHandler<EventArgs<Guid>> JobAborted;245 private void On JobAborted() {246 var handler = JobAborted;247 if (handler != null) handler(this, new EventArgs<Guid>(this. JobId));248 } 249 250 public event EventHandler<EventArgs<Guid, Exception>> JobFailed;251 private void On JobFailed(Exception exception) {252 var handler = JobFailed;253 if (handler != null) handler(this, new EventArgs<Guid, Exception>(this. JobId, exception));226 public event EventHandler<EventArgs<Guid>> TaskStarted; 227 private void OnTaskStarted() { 228 var handler = TaskStarted; 229 if (handler != null) handler(this, new EventArgs<Guid>(this.TaskId)); 230 } 231 232 public event EventHandler<EventArgs<Guid>> TaskStopped; 233 private void OnTaskStopped() { 234 var handler = TaskStopped; 235 if (handler != null) handler(this, new EventArgs<Guid>(this.TaskId)); 236 } 237 238 public event EventHandler<EventArgs<Guid>> TaskPaused; 239 private void OnTaskPaused() { 240 var handler = TaskPaused; 241 if (handler != null) handler(this, new EventArgs<Guid>(this.TaskId)); 242 } 243 244 public event EventHandler<EventArgs<Guid>> TaskAborted; 245 private void OnTaskAborted() { 246 var handler = TaskAborted; 247 if (handler != null) handler(this, new EventArgs<Guid>(this.TaskId)); 248 } 249 250 public event EventHandler<EventArgs<Guid, Exception>> TaskFailed; 251 private void OnTaskFailed(Exception exception) { 252 var handler = TaskFailed; 253 if (handler != null) handler(this, new EventArgs<Guid, Exception>(this.TaskId, exception)); 254 254 } 255 255 … … 257 257 private void OnExceptionOccured(Exception exception) { 258 258 var handler = ExceptionOccured; 259 if (handler != null) handler(this, new EventArgs<Guid, Exception>(this. JobId, exception));259 if (handler != null) handler(this, new EventArgs<Guid, Exception>(this.TaskId, exception)); 260 260 } 261 261 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/StatusCommons.cs
r6371 r6725 53 53 public int ExceptionsOccured { get; set; } 54 54 [DataMember] 55 public List< JobStatus> Jobs { get; set; }55 public List<TaskStatus> Jobs { get; set; } 56 56 [DataMember] 57 57 public bool Asleep { get; set; } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/TaskStatus.cs
r6721 r6725 25 25 namespace HeuristicLab.Clients.Hive.SlaveCore { 26 26 [DataContract] 27 public class JobStatus {27 public class TaskStatus { 28 28 /// <summary> 29 29 /// Id of the Task 30 30 /// </summary> 31 31 [DataMember] 32 public Guid JobId { get; set; }32 public Guid TaskId { get; set; } 33 33 /// <summary> 34 34 /// Current progress -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/WcfService.cs
r6721 r6725 70 70 71 71 /// <summary> 72 /// Uploads the jobData and sets a new jobState (while correctly setting Transferring state)72 /// Uploads the taskData and sets a new jobState (while correctly setting Transferring state) 73 73 /// </summary> 74 74 public void UpdateJobData(Task job, TaskData jobData, Guid slaveId, TaskState state, string exception = "") {
Note: See TracChangeset
for help on using the changeset viewer.