- Timestamp:
- 06/19/11 23:21:21 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HeartbeatManager.cs
r6431 r6444 62 62 if (availableJobs.Count() > 0) { 63 63 var job = availableJobs.First(); 64 actions.Add(new MessageContainer(MessageContainer.MessageType.CalculateJob, job.Id));65 AssignJob(slave, job);64 if (AssignJob(slave, job)) 65 actions.Add(new MessageContainer(MessageContainer.MessageType.CalculateJob, job.Id)); 66 66 } 67 67 } … … 70 70 } 71 71 72 private void AssignJob(Slave slave, Job job) { 72 // returns true if assignment was successful 73 private bool AssignJob(Slave slave, Job 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 != JobState.Waiting) return false; 76 73 77 job = dao.UpdateJobState(job.Id, JobState.Transferring, slave.Id, null, null); 74 dao.UpdateSlave(slave);75 78 76 79 // from now on the job has some time to send the next heartbeat (ApplicationConstants.TransferringJobHeartbeatTimeout) 77 80 job.LastHeartbeat = DateTime.Now; 78 81 dao.UpdateJob(job); 82 return true; 79 83 } 80 84
Note: See TracChangeset
for help on using the changeset viewer.