- Timestamp:
- 03/21/11 15:05:48 (14 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HeartbeatManager.cs
r5718 r5779 39 39 40 40 // assign new job 41 if (heartbeat.AssignJob && this.IsAllowedToSendJobs() &&slave.IsAllowedToCalculate && heartbeat.FreeCores > 0) {41 if (heartbeat.AssignJob && slave.IsAllowedToCalculate && heartbeat.FreeCores > 0) { 42 42 var availableJobs = dao.GetWaitingJobs(slave, 1); 43 43 if (availableJobs.Count() > 0) { … … 83 83 curJob.LastHeartbeat = DateTime.Now; 84 84 85 if (curJob.State == JobState.Aborted) { 86 // a request to abort the job has been set 87 actions.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id)); 85 switch (curJob.Command) { 86 case Command.Stop: 87 actions.Add(new MessageContainer(MessageContainer.MessageType.StopJob, curJob.Id)); 88 break; 89 case Command.Pause: 90 actions.Add(new MessageContainer(MessageContainer.MessageType.PauseJob, curJob.Id)); 91 break; 92 case Command.Abort: 93 actions.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id)); 94 break; 88 95 } 89 96 dao.UpdateJob(curJob); … … 93 100 return actions; 94 101 } 95 96 /// <summary>97 /// Returns true if there are enough resources to send a job98 /// There should not be too many jobs sent simultaniously99 /// </summary>100 private bool IsAllowedToSendJobs() {101 return true; // JobsCurrentlyTransferring < ApplicationConstants.MaxJobTransferCount;102 // Todo: see if unlimited job transfer count works. if not, look into db and count jobs in state Transferring103 }104 102 } 105 103 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HiveService.cs
r5708 r5779 139 139 // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)] 140 140 public Job UpdateJobState(Guid jobId, JobState jobState, Guid? slaveId, Guid? userId, string exception) { 141 return trans.UseTransaction(() => dao.UpdateJobState(jobId, jobState, slaveId, userId, exception)); 141 return trans.UseTransaction(() => { 142 Job job = dao.UpdateJobState(jobId, jobState, slaveId, userId, exception); 143 if (job.Command.HasValue && job.Command.Value == Command.Pause && job.State == JobState.Paused) { 144 job.Command = null; 145 } else if (job.Command.HasValue && job.Command.Value == Command.Abort && job.State == JobState.Aborted) { 146 job.Command = null; 147 } else if (job.Command.HasValue && job.Command.Value == Command.Stop && job.State == JobState.Aborted) { 148 job.Command = null; 149 } 150 dao.UpdateJob(job); 151 return job; 152 }); 142 153 } 143 154 #endregion … … 149 160 public void StopJob(Guid jobId) { 150 161 trans.UseTransaction(() => { 151 throw new NotImplementedException(); 162 //dao.UpdateJobState(jobId, JobState.Aborted, null, auth.UserId, string.Empty); 163 var job = dao.GetJob(jobId); 164 job.Command = Command.Stop; 165 dao.UpdateJob(job); 152 166 }); 153 167 } … … 158 172 public void PauseJob(Guid jobId) { 159 173 trans.UseTransaction(() => { 160 throw new NotImplementedException(); 174 //dao.UpdateJobState(jobId, JobState.Paused, null, auth.UserId, string.Empty); 175 var job = dao.GetJob(jobId); 176 job.Command = Command.Pause; 177 dao.UpdateJob(job); 178 }); 179 } 180 181 // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)] 182 // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)] 183 // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)] 184 public void RestartJob(Guid jobId) { 185 trans.UseTransaction(() => { 186 Job job = dao.UpdateJobState(jobId, JobState.Waiting, null, auth.UserId, string.Empty); 187 job.Command = null; 188 dao.UpdateJob(job); 161 189 }); 162 190 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/LifecycleManager.cs
r5718 r5779 55 55 var jobs = dao.GetJobs(x => x.State == JobState.Calculating).Where(x => x.StateLog.Last().SlaveId == slaveId); 56 56 foreach (var j in jobs) { 57 dao.UpdateJobState(j.Id, JobState.Waiting, slaveId, null, "Slave timed out"); 57 Job job = dao.UpdateJobState(j.Id, JobState.Waiting, slaveId, null, "Slave timed out"); 58 job.Command = null; 59 dao.UpdateJob(job); 58 60 } 59 61 }
Note: See TracChangeset
for help on using the changeset viewer.