Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16622


Ignore:
Timestamp:
02/27/19 12:44:11 (6 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
Location:
trunk
Files:
3 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    }
  • trunk/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/JobDao.cs

    r16565 r16622  
    8888        (from job in db.GetTable<Job>()
    8989         where job.State == JobState.StatisticsPending
    90          && (from task in db.GetTable<Task>()
    91              where task.JobId == job.JobId
    92              select task.State == TaskState.Finished
    93               || task.State == TaskState.Aborted
    94               || task.State == TaskState.Failed).All(x => x)
     90               && (from task in db.GetTable<Task>()
     91                   where task.JobId == job.JobId
     92                   select task).All(x => x.State == TaskState.Finished
     93                                      || x.State == TaskState.Aborted
     94                                      || x.State == TaskState.Failed)
    9595         select job));
    9696    #endregion
  • trunk/HeuristicLab.Services.Hive/3.3/HiveStatisticsGenerator.cs

    r16565 r16622  
    6666
    6767          pm.UseTransaction(() => {
    68             UpdateFactTaskTable(pm);
    6968            try {
    70               pm.SubmitChanges();
     69              UpdateFactTaskTable(pm);
    7170              UpdateExistingDimJobs(pm);
     71              FlagJobsForDeletion(pm);
    7272              pm.SubmitChanges();
    7373            }
     
    8181          });
    8282        }
    83 
    84         pm.UseTransaction(() => {
    85           FlagJobsForDeletion(pm);
    86           pm.SubmitChanges();
    87         });
    8883      }
    8984    }
Note: See TracChangeset for help on using the changeset viewer.