Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/08/11 16:38:28 (13 years ago)
Author:
ascheibe
Message:

#1233 more renaming for more consistency

File:
1 moved

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Manager/TaskManager.cs

    r6721 r6725  
    3030
    3131  /// <summary>
    32   /// Holds a list of slave jobs and manages access to this list.
    33   /// Forwards events from SlaveJob 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.
    3434  /// </summary>
    35   public class JobManager {
    36     private static ReaderWriterLockSlim slaveJobsLocker = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
    37     private Dictionary<Guid, SlaveJob> slaveJobs;
     35  public class TaskManager {
     36    private static ReaderWriterLockSlim slaveTasksLocker = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
     37    private Dictionary<Guid, SlaveTask> slaveTasks;
    3838    private ILog log;
    3939    private PluginManager pluginManager;
    4040
    41     public int JobCount {
     41    public int TaskCount {
    4242      get {
    43         slaveJobsLocker.EnterReadLock();
     43        slaveTasksLocker.EnterReadLock();
    4444        try {
    45           return slaveJobs.Count;
    46         }
    47         finally { slaveJobsLocker.ExitReadLock(); }
    48       }
    49     }
    50 
    51     public Guid[] JobIds {
     45          return slaveTasks.Count;
     46        }
     47        finally { slaveTasksLocker.ExitReadLock(); }
     48      }
     49    }
     50
     51    public Guid[] TaskIds {
    5252      get {
    53         slaveJobsLocker.EnterReadLock();
     53        slaveTasksLocker.EnterReadLock();
    5454        try {
    55           return slaveJobs.Keys.ToArray();
    56         }
    57         finally { slaveJobsLocker.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) {
    6262      this.pluginManager = pluginCache;
    6363      this.log = log;
    64       this.slaveJobs = new Dictionary<Guid, SlaveJob>();
     64      this.slaveTasks = new Dictionary<Guid, SlaveTask>();
    6565    }
    6666
    6767    #region Task Control methods
    68     public void StartJobAsync(Task job, TaskData jobData) {
    69       SlaveJob slaveJob = null;
    70       slaveJobsLocker.EnterUpgradeableReadLock();
    71       try {
    72         if (slaveJobs.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)) {
    7373          SlaveStatusInfo.IncrementExceptionOccured();
    74           throw new JobAlreadyRunningException(job.Id);
     74          throw new TaskAlreadyRunningException(task.Id);
    7575        } else {
    76           slaveJob = new SlaveJob(pluginManager, job.CoresNeeded, log);
    77           AddSlaveJob(job, slaveJob);
    78           SlaveStatusInfo.IncrementJobsFetched();
    79         }
    80       }
    81       finally { slaveJobsLocker.ExitUpgradeableReadLock(); }
    82 
    83       if (slaveJob != 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) {
    8484        try {
    85           slaveJob.StartJobAsync(job, jobData);
     85          slaveTask.StartJobAsync(task, taskData);
    8686        }
    8787        catch (Exception) {
    88           RemoveSlaveJob(job.Id, slaveJob); // clean up and rethrow
    89           slaveJob.DisposeAppDomain();
     88          RemoveSlaveTask(task.Id, slaveTask); // clean up and rethrow
     89          slaveTask.DisposeAppDomain();
    9090          throw;
    9191        }
     
    9393    }
    9494
    95     public void PauseJobAsync(Guid jobId) {
    96       slaveJobsLocker.EnterUpgradeableReadLock();
    97       try {
    98         if (!slaveJobs.ContainsKey(jobId)) throw new JobNotRunningException(jobId);
    99         SlaveJob slaveJob = slaveJobs[jobId];
    100         slaveJob.PauseJob();
    101       }
    102       finally { slaveJobsLocker.ExitUpgradeableReadLock(); }
    103     }
    104 
    105     public void StopJobAsync(Guid jobId) {
    106       slaveJobsLocker.EnterUpgradeableReadLock();
    107       try {
    108         if (!slaveJobs.ContainsKey(jobId)) throw new JobNotRunningException(jobId);
    109         SlaveJob slaveJob = slaveJobs[jobId];
    110         slaveJob.StopJob();
    111       }
    112       finally { slaveJobsLocker.ExitUpgradeableReadLock(); }
    113     }
    114 
    115     public void AbortJob(Guid jobId) {
    116       SlaveJob slaveJob = null;
    117       slaveJobsLocker.EnterUpgradeableReadLock();
    118       try {
    119         if (!slaveJobs.ContainsKey(jobId)) throw new JobNotRunningException(jobId);
    120         slaveJob = slaveJobs[jobId];
    121         if (!slaveJob.IsPrepared) throw new AppDomainNotCreatedException();
    122         RemoveSlaveJob(jobId, slaveJob);
    123       }
    124       finally { slaveJobsLocker.ExitUpgradeableReadLock(); }
    125       slaveJob.DisposeAppDomain();
    126       SlaveStatusInfo.IncrementJobsAborted();
    127       OnJobAborted(slaveJob);
    128     }
    129 
    130     public void PauseAllJobsAsync() {
    131       slaveJobsLocker.EnterUpgradeableReadLock();
    132       try {
    133         foreach (var slaveJob in slaveJobs.Values) {
    134           slaveJob.PauseJob();
    135         }
    136       }
    137       finally { slaveJobsLocker.ExitUpgradeableReadLock(); }
    138     }
    139 
    140     public void StopAllJobsAsync() {
    141       slaveJobsLocker.EnterUpgradeableReadLock();
    142       try {
    143         foreach (var slaveJob in slaveJobs.Values) {
    144           slaveJob.StopJob();
    145         }
    146       }
    147       finally { slaveJobsLocker.ExitUpgradeableReadLock(); }
    148     }
    149 
    150     public void AbortAllJobs() {
    151       slaveJobsLocker.EnterUpgradeableReadLock();
    152       try {
    153         foreach (var slaveJob in slaveJobs.Values.ToArray()) {
    154           AbortJob(slaveJob.JobId);
    155         }
    156       }
    157       finally { slaveJobsLocker.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(); }
    158158    }
    159159    #endregion
    160160
    161     #region Add/Remove SlaveJob
    162     private void AddSlaveJob(Task job, SlaveJob slaveJob) {
    163       slaveJobsLocker.EnterWriteLock();
    164       try {
    165         slaveJobs.Add(job.Id, slaveJob);
    166         RegisterSlaveJobEvents(slaveJob);
    167       }
    168       finally { slaveJobsLocker.ExitWriteLock(); }
    169     }
    170 
    171     private void RemoveSlaveJob(Guid jobId, SlaveJob slaveJob) {
    172       slaveJobsLocker.EnterWriteLock();
    173       try {
    174         slaveJobs.Remove(jobId);
    175         DeregisterSlaveJobEvents(slaveJob);
    176       }
    177       finally { slaveJobsLocker.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(); }
    178178    }
    179179    #endregion
    180180
    181     #region SlaveJob Events
    182     private void RegisterSlaveJobEvents(SlaveJob slaveJob) {
    183       slaveJob.JobStarted += new EventHandler<EventArgs<Guid>>(slaveJob_JobStarted);
    184       slaveJob.JobPaused += new EventHandler<EventArgs<Guid>>(slaveJob_JobPaused);
    185       slaveJob.JobStopped += new EventHandler<EventArgs<Guid>>(slaveJob_JobStopped);
    186       slaveJob.JobFailed += new EventHandler<EventArgs<Guid, Exception>>(slaveJob_JobFailed);
    187       slaveJob.ExceptionOccured += new EventHandler<EventArgs<Guid, Exception>>(slaveJob_ExceptionOccured);
    188     }
    189 
    190     private void DeregisterSlaveJobEvents(SlaveJob slaveJob) {
    191       slaveJob.JobStarted -= new EventHandler<EventArgs<Guid>>(slaveJob_JobStarted);
    192       slaveJob.JobPaused -= new EventHandler<EventArgs<Guid>>(slaveJob_JobPaused);
    193       slaveJob.JobStopped -= new EventHandler<EventArgs<Guid>>(slaveJob_JobStopped);
    194       slaveJob.JobFailed -= new EventHandler<EventArgs<Guid, Exception>>(slaveJob_JobFailed);
    195       slaveJob.ExceptionOccured -= new EventHandler<EventArgs<Guid, Exception>>(slaveJob_ExceptionOccured);
    196     }
    197 
    198     private void slaveJob_JobStarted(object sender, EventArgs<Guid> e) {
    199       SlaveJob slaveJob;
    200       slaveJobsLocker.EnterUpgradeableReadLock();
    201       try {
    202         slaveJob = slaveJobs[e.Value];
    203       }
    204       finally { slaveJobsLocker.ExitUpgradeableReadLock(); }
    205 
    206       SlaveStatusInfo.IncrementJobsStarted();
    207       OnJobStarted(slaveJob);
    208     }
    209 
    210     private void slaveJob_JobPaused(object sender, EventArgs<Guid> e) {
    211       SlaveJob slaveJob;
    212       slaveJobsLocker.EnterUpgradeableReadLock();
    213       try {
    214         slaveJob = slaveJobs[e.Value];
    215         RemoveSlaveJob(e.Value, slaveJob);
    216       }
    217       finally { slaveJobsLocker.ExitUpgradeableReadLock(); }
    218 
    219       TaskData jobData = null;
    220       try {
    221         jobData = slaveJob.GetJobData();
    222         if (jobData == null) throw new SerializationException();
    223         SlaveStatusInfo.IncrementJobsFinished();
    224         OnJobPaused(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);
    225225      }
    226226      catch (Exception ex) {
    227         RemoveSlaveJob(e.Value, slaveJob);
    228         SlaveStatusInfo.IncrementJobsFailed();
    229         OnJobFailed(slaveJob, jobData, ex);
    230       }
    231     }
    232 
    233     private void slaveJob_JobStopped(object sender, EventArgs<Guid> e) {
    234       SlaveJob slaveJob;
    235       slaveJobsLocker.EnterUpgradeableReadLock();
    236       try {
    237         slaveJob = slaveJobs[e.Value];
    238         RemoveSlaveJob(e.Value, slaveJob);
    239       }
    240       finally { slaveJobsLocker.ExitUpgradeableReadLock(); }
    241 
    242       TaskData jobData = null;
    243       try {
    244         jobData = slaveJob.GetJobData();
    245         if (jobData == null) throw new SerializationException();
    246         SlaveStatusInfo.IncrementJobsFinished();
    247         OnJobStopped(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);
    248248      }
    249249      catch (Exception ex) {
    250         RemoveSlaveJob(e.Value, slaveJob);
    251         SlaveStatusInfo.IncrementJobsFailed();
    252         OnJobFailed(slaveJob, jobData, ex);
    253       }
    254     }
    255 
    256     private void slaveJob_JobFailed(object sender, EventArgs<Guid, Exception> e) {
    257       SlaveJob slaveJob;
    258       slaveJobsLocker.EnterUpgradeableReadLock();
    259       try {
    260         slaveJob = slaveJobs[e.Value];
    261         RemoveSlaveJob(e.Value, slaveJob);
    262       }
    263       finally { slaveJobsLocker.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.IncrementJobsFailed();
    272       OnJobFailed(slaveJob, jobData, e.Value2);
    273     }
    274 
    275     private void slaveJob_ExceptionOccured(object sender, EventArgs<Guid, Exception> e) {
    276       SlaveJob slaveJob;
    277       slaveJobsLocker.EnterUpgradeableReadLock();
    278       try {
    279         slaveJob = slaveJobs[e.Value];
    280         RemoveSlaveJob(e.Value, slaveJob);
    281       }
    282       finally { slaveJobsLocker.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(); }
    283283
    284284      SlaveStatusInfo.IncrementExceptionOccured();
    285       OnExceptionOccured(slaveJob, e.Value2);
     285      OnExceptionOccured(slaveTask, e.Value2);
    286286    }
    287287    #endregion
    288288
    289289    #region EventHandler
    290     public event EventHandler<EventArgs<SlaveJob>> JobStarted;
    291     private void OnJobStarted(SlaveJob slaveJob) {
    292       var handler = JobStarted;
    293       if (handler != null) handler(this, new EventArgs<SlaveJob>(slaveJob));
    294     }
    295 
    296     public event EventHandler<EventArgs<SlaveJob, TaskData>> JobStopped;
    297     private void OnJobStopped(SlaveJob slaveJob, TaskData jobData) {
    298       var handler = JobStopped;
    299       if (handler != null) handler(this, new EventArgs<SlaveJob, TaskData>(slaveJob, jobData));
    300     }
    301 
    302     public event EventHandler<EventArgs<SlaveJob, TaskData>> JobPaused;
    303     private void OnJobPaused(SlaveJob slaveJob, TaskData jobData) {
    304       var handler = JobPaused;
    305       if (handler != null) handler(this, new EventArgs<SlaveJob, TaskData>(slaveJob, jobData));
    306     }
    307 
    308     public event EventHandler<EventArgs<Tuple<SlaveJob, TaskData, Exception>>> JobFailed;
    309     private void OnJobFailed(SlaveJob slaveJob, TaskData jobData, Exception exception) {
    310       var handler = JobFailed;
    311       if (handler != null) handler(this, new EventArgs<Tuple<SlaveJob, TaskData, Exception>>(new Tuple<SlaveJob, TaskData, Exception>(slaveJob, jobData, exception)));
    312     }
    313 
    314     public event EventHandler<EventArgs<SlaveJob, Exception>> ExceptionOccured;
    315     private void OnExceptionOccured(SlaveJob 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) {
    316316      var handler = ExceptionOccured;
    317       if (handler != null) handler(this, new EventArgs<SlaveJob, Exception>(slaveJob, exception));
    318     }
    319 
    320     public event EventHandler<EventArgs<SlaveJob>> JobAborted;
    321     private void OnJobAborted(SlaveJob slaveJob) {
    322       var handler = JobAborted;
    323       if (handler != null) handler(this, new EventArgs<SlaveJob>(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));
    324324    }
    325325    #endregion
    326326
    327327    public Dictionary<Guid, TimeSpan> GetExecutionTimes() {
    328       slaveJobsLocker.EnterReadLock();
    329       try {
    330         return slaveJobs.ToDictionary(x => x.Key, x => x.Value.ExecutionTime);
    331       }
    332       finally { slaveJobsLocker.ExitReadLock(); }
     328      slaveTasksLocker.EnterReadLock();
     329      try {
     330        return slaveTasks.ToDictionary(x => x.Key, x => x.Value.ExecutionTime);
     331      }
     332      finally { slaveTasksLocker.ExitReadLock(); }
    333333    }
    334334  }
Note: See TracChangeset for help on using the changeset viewer.