Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/27/19 12:44:11 (5 years ago)
Author:
jkarder
Message:

#2839: worked on hive project management

  • Core.cs
    • locked checks for amount of available resources (cores/memory)
    • task state of aborted tasks is now updated accordingly
  • JobDao.cs
    • improved readability of GetJobsReadyForDeletionQuery
  • HiveStatisticsGenerator.cs
    • DimJobs, FactTasks and Jobs (DeletionPending) are now updated in one transaction
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Clients.Hive.Slave/3.3/Core.cs

    r16565 r16622  
    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.