Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/12/11 18:04:25 (13 years ago)
Author:
ascheibe
Message:

#1233

  • fixed a bug in the Slave UI
  • finished renaming Webservice and Dao methods to be consistent with Job/Task naming
  • some cosmetic changes and project dependencies cleanups
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Manager/HeartbeatManager.cs

    r6725 r6743  
    5454        dao.UpdateSlave(slave);
    5555
    56         // update job data
    57         actions.AddRange(UpdateJobs(heartbeat, slave.IsAllowedToCalculate));
     56        // update task data
     57        actions.AddRange(UpdateTasks(heartbeat, slave.IsAllowedToCalculate));
    5858
    59         // assign new job
     59        // assign new task
    6060        if (heartbeat.AssignJob && slave.IsAllowedToCalculate && heartbeat.FreeCores > 0) {
    61           var availableJobs = dao.GetWaitingJobs(slave, 1);
     61          var availableJobs = dao.GetWaitingTasks(slave, 1);
    6262          if (availableJobs.Count() > 0) {
    6363            var job = availableJobs.First();
     
    7171
    7272    // returns true if assignment was successful
    73     private bool AssignJob(Slave slave, Task job) {
    74       // load job again and check if it is still available (this is an attempt to reduce the race condition which causes multiple heartbeats to get the same job assigned)
    75       if (dao.GetJob(job.Id).State != TaskState.Waiting) return false;
     73    private bool AssignJob(Slave slave, Task task) {
     74      // load task again and check if it is still available (this is an attempt to reduce the race condition which causes multiple heartbeats to get the same task assigned)
     75      if (dao.GetTask(task.Id).State != TaskState.Waiting) return false;
    7676
    77       job = dao.UpdateJobState(job.Id, DataAccess.TaskState.Transferring, slave.Id, null, null);
     77      task = dao.UpdateTaskState(task.Id, DataAccess.TaskState.Transferring, slave.Id, null, null);
    7878
    79       // from now on the job has some time to send the next heartbeat (ApplicationConstants.TransferringJobHeartbeatTimeout)
    80       job.LastHeartbeat = DateTime.Now;
    81       dao.UpdateJob(job);
     79      // from now on the task has some time to send the next heartbeat (ApplicationConstants.TransferringJobHeartbeatTimeout)
     80      task.LastHeartbeat = DateTime.Now;
     81      dao.UpdateTask(task);
    8282      return true;
    8383    }
    8484
    8585    /// <summary>
    86     /// Update the progress of each job
    87     /// Checks if all the jobs sent by heartbeat are supposed to be calculated by this slave
     86    /// Update the progress of each task
     87    /// Checks if all the task sent by heartbeat are supposed to be calculated by this slave
    8888    /// </summary>
    89     private IEnumerable<MessageContainer> UpdateJobs(Heartbeat heartbeat, bool IsAllowedToCalculate) {
     89    private IEnumerable<MessageContainer> UpdateTasks(Heartbeat heartbeat, bool IsAllowedToCalculate) {
    9090      List<MessageContainer> actions = new List<MessageContainer>();
    9191
     
    9898        // process the jobProgresses
    9999        foreach (var jobProgress in heartbeat.JobProgress) {
    100           Task curJob = dao.GetJob(jobProgress.Key);
     100          Task curJob = dao.GetTask(jobProgress.Key);
    101101          if (curJob == null) {
    102             // job does not exist in db
     102            // task does not exist in db
    103103            actions.Add(new MessageContainer(MessageContainer.MessageType.AbortTask, jobProgress.Key));
    104104            DA.LogFactory.GetLogger(this.GetType().Namespace).Log("Job does not exist in DB: " + jobProgress.Key);
     
    108108              actions.Add(new MessageContainer(MessageContainer.MessageType.AbortTask, curJob.Id));
    109109              DA.LogFactory.GetLogger(this.GetType().Namespace).Log("The slave " + heartbeat.SlaveId + " is not supposed to calculate Job: " + curJob);
    110             } else if (!JobIsAllowedToBeCalculatedBySlave(heartbeat.SlaveId, curJob)) {
    111               // assigned resources ids of job do not match with slaveId (and parent resourceGroupIds); this might happen when slave is moved to different group
     110            } else if (!TaskIsAllowedToBeCalculatedBySlave(heartbeat.SlaveId, curJob)) {
     111              // assigned resources ids of task do not match with slaveId (and parent resourceGroupIds); this might happen when slave is moved to different group
    112112              actions.Add(new MessageContainer(MessageContainer.MessageType.PauseTask, curJob.Id));
    113113            } else {
    114               // save job execution time
     114              // save task execution time
    115115              curJob.ExecutionTime = jobProgress.Value;
    116116              curJob.LastHeartbeat = DateTime.Now;
     
    127127                  break;
    128128              }
    129               dao.UpdateJob(curJob);
     129              dao.UpdateTask(curJob);
    130130            }
    131131          }
     
    135135    }
    136136
    137     private bool JobIsAllowedToBeCalculatedBySlave(Guid slaveId, Task curJob) {
    138       var assignedResourceIds = dao.GetAssignedResources(curJob.Id).Select(x => x.Id);
     137    private bool TaskIsAllowedToBeCalculatedBySlave(Guid slaveId, Task curTask) {
     138      var assignedResourceIds = dao.GetAssignedResources(curTask.Id).Select(x => x.Id);
    139139      var slaveResourceIds = dao.GetParentResources(slaveId).Select(x => x.Id);
    140140      return assignedResourceIds.Any(x => slaveResourceIds.Contains(x));
Note: See TracChangeset for help on using the changeset viewer.