Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/04/19 15:20:26 (5 years ago)
Author:
mkommend
Message:

#2839: Merged 16622, 16878 into stable.

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Clients.Hive.Slave

  • stable/HeuristicLab.Clients.Hive.Slave/3.3/Core.cs

    r15584 r17067  
    3838  /// </summary>
    3939  public class Core : MarshalByRefObject {
     40    private static readonly object locker = new object();
     41
    4042    private static HeartbeatManager heartbeatManager;
    4143    public static HeartbeatManager HeartbeatManager {
     
    240242        task = wcfService.GetTask(taskId);
    241243        if (task == null) throw new TaskNotFoundException(taskId);
    242         if (ConfigManager.Instance.GetFreeCores() < task.CoresNeeded) throw new OutOfCoresException();
    243         if (ConfigManager.Instance.GetFreeMemory() < task.MemoryNeeded) throw new OutOfMemoryException();
    244         SlaveStatusInfo.IncrementUsedCores(task.CoresNeeded); usedCores = task.CoresNeeded;
     244        lock (locker) {
     245          // the amount of used cores/memory could exceed the amount of available cores/memory
     246          // if HandleCalculateTask is called simultaneously from within two different tasks
     247          if (ConfigManager.Instance.GetFreeCores() < task.CoresNeeded) throw new OutOfCoresException();
     248          if (ConfigManager.Instance.GetFreeMemory() < task.MemoryNeeded) throw new OutOfMemoryException();
     249          SlaveStatusInfo.IncrementUsedCores(task.CoresNeeded); usedCores = task.CoresNeeded;
     250        }
    245251        TaskData taskData = wcfService.GetTaskData(taskId);
    246252        if (taskData == null) throw new TaskDataNotFoundException(taskId);
     
    400406
    401407    private void taskManager_TaskAborted(object sender, EventArgs<SlaveTask> e) {
     408      var slaveTask = e.Value;
     409      var task = wcfService.GetTask(slaveTask.TaskId);
     410      wcfService.UpdateJobState(task.Id, TaskState.Aborted, null);
    402411      SlaveStatusInfo.DecrementUsedCores(e.Value.CoresNeeded);
    403412    }
Note: See TracChangeset for help on using the changeset viewer.