Changeset 8997
- Timestamp:
- 12/04/12 16:34:49 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveTaskScheduler/HeuristicLab.Services.Hive/3.3/Manager/HeartbeatManager.cs
r8995 r8997 79 79 if (availableJobs.Any()) { 80 80 var job = availableJobs.First(); 81 if (AssignJob(slave, job))82 81 AssignJob(slave, job); 82 actions.Add(new MessageContainer(MessageContainer.MessageType.CalculateTask, job.Id)); 83 83 } 84 84 } … … 95 95 } 96 96 97 // returns true if assignment was successful 98 private bool AssignJob(Slave slave, Task task) { 99 // 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) 100 if (dao.GetTask(task.Id).State != TaskState.Waiting) return false; 101 97 private void AssignJob(Slave slave, Task task) { 102 98 task = dao.UpdateTaskState(task.Id, DataAccess.TaskState.Transferring, slave.Id, null, null); 103 99 … … 105 101 task.LastHeartbeat = DateTime.Now; 106 102 dao.UpdateTask(task); 107 return true;108 103 } 109 104
Note: See TracChangeset
for help on using the changeset viewer.