- Timestamp:
- 09/08/11 13:41:25 (13 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Core.cs
r6546 r6721 29 29 using HeuristicLab.Common; 30 30 using HeuristicLab.Core; 31 using TS = System.Threading.Tasks; 31 32 32 33 … … 148 149 /// <param name="container">The container, containing the message</param> 149 150 private void DetermineAction(MessageContainer container) { 150 clientCom.LogMessage(string.Format("Message: {0} for job: {1} ", container.Message.ToString(), container. JobId));151 clientCom.LogMessage(string.Format("Message: {0} for job: {1} ", container.Message.ToString(), container.TaskId)); 151 152 152 153 if (container is ExecutorMessageContainer<Guid>) { … … 156 157 switch (container.Message) { 157 158 case MessageContainer.MessageType.CalculateJob: 158 CalculateJobAsync(container. JobId);159 CalculateJobAsync(container.TaskId); 159 160 break; 160 161 case MessageContainer.MessageType.AbortJob: 161 AbortJobAsync(container. JobId);162 AbortJobAsync(container.TaskId); 162 163 break; 163 164 case MessageContainer.MessageType.StopJob: 164 StopJobAsync(container. JobId);165 StopJobAsync(container.TaskId); 165 166 break; 166 167 case MessageContainer.MessageType.PauseJob: 167 PauseJobAsync(container. JobId);168 PauseJobAsync(container.TaskId); 168 169 break; 169 170 case MessageContainer.MessageType.StopAll: … … 195 196 196 197 private void CalculateJobAsync(Guid jobId) { 197 T ask.Factory.StartNew(HandleCalculateJob, jobId)198 TS.Task.Factory.StartNew(HandleCalculateJob, jobId) 198 199 .ContinueWith((t) => { 199 200 SlaveStatusInfo.IncrementExceptionOccured(); … … 203 204 204 205 private void StopJobAsync(Guid jobId) { 205 T ask.Factory.StartNew(HandleStopJob, jobId)206 TS.Task.Factory.StartNew(HandleStopJob, jobId) 206 207 .ContinueWith((t) => { 207 208 SlaveStatusInfo.IncrementExceptionOccured(); … … 211 212 212 213 private void PauseJobAsync(Guid jobId) { 213 T ask.Factory.StartNew(HandlePauseJob, jobId)214 TS.Task.Factory.StartNew(HandlePauseJob, jobId) 214 215 .ContinueWith((t) => { 215 216 SlaveStatusInfo.IncrementExceptionOccured(); … … 219 220 220 221 private void AbortJobAsync(Guid jobId) { 221 T ask.Factory.StartNew(HandleAbortJob, jobId)222 TS.Task.Factory.StartNew(HandleAbortJob, jobId) 222 223 .ContinueWith((t) => { 223 224 SlaveStatusInfo.IncrementExceptionOccured(); … … 228 229 private void HandleCalculateJob(object jobIdObj) { 229 230 Guid jobId = (Guid)jobIdObj; 230 Jobjob = null;231 Task job = null; 231 232 int usedCores = 0; 232 233 try { … … 236 237 if (ConfigManager.GetFreeMemory() < job.MemoryNeeded) throw new OutOfMemoryException(); 237 238 SlaveStatusInfo.IncrementUsedCores(job.CoresNeeded); usedCores = job.CoresNeeded; 238 JobData jobData = wcfService.GetJobData(jobId);239 TaskData jobData = wcfService.GetJobData(jobId); 239 240 if (jobData == null) throw new JobDataNotFoundException(jobId); 240 job = wcfService.UpdateJobState(jobId, JobState.Calculating, null);241 job = wcfService.UpdateJobState(jobId, TaskState.Calculating, null); 241 242 if (job == null) throw new JobNotFoundException(jobId); 242 243 jobManager.StartJobAsync(job, jobData); … … 255 256 } 256 257 catch (OutOfCoresException) { 257 wcfService.UpdateJobState(jobId, JobState.Waiting, "No more cores available");258 wcfService.UpdateJobState(jobId, TaskState.Waiting, "No more cores available"); 258 259 throw; 259 260 } 260 261 catch (OutOfMemoryException) { 261 wcfService.UpdateJobState(jobId, JobState.Waiting, "No more memory available");262 wcfService.UpdateJobState(jobId, TaskState.Waiting, "No more memory available"); 262 263 throw; 263 264 } 264 265 catch (Exception e) { 265 266 SlaveStatusInfo.DecrementUsedCores(usedCores); 266 wcfService.UpdateJobState(jobId, JobState.Waiting, e.ToString()); // unknown internal error - report and set waiting again267 wcfService.UpdateJobState(jobId, TaskState.Waiting, e.ToString()); // unknown internal error - report and set waiting again 267 268 throw; 268 269 } … … 272 273 Guid jobId = (Guid)jobIdObj; 273 274 try { 274 Jobjob = wcfService.GetJob(jobId);275 Task job = wcfService.GetJob(jobId); 275 276 if (job == null) throw new JobNotFoundException(jobId); 276 277 jobManager.StopJobAsync(jobId); … … 290 291 Guid jobId = (Guid)jobIdObj; 291 292 try { 292 Jobjob = wcfService.GetJob(jobId);293 Task job = wcfService.GetJob(jobId); 293 294 if (job == null) throw new JobNotFoundException(jobId); 294 295 jobManager.PauseJobAsync(jobId); … … 318 319 private void RegisterJobManagerEvents() { 319 320 this.jobManager.JobStarted += new EventHandler<EventArgs<SlaveJob>>(jobManager_JobStarted); 320 this.jobManager.JobPaused += new EventHandler<EventArgs<SlaveJob, JobData>>(jobManager_JobPaused);321 this.jobManager.JobStopped += new EventHandler<EventArgs<SlaveJob, JobData>>(jobManager_JobStopped);322 this.jobManager.JobFailed += new EventHandler<EventArgs<Tuple<SlaveJob, JobData, Exception>>>(jobManager_JobFailed);321 this.jobManager.JobPaused += new EventHandler<EventArgs<SlaveJob, TaskData>>(jobManager_JobPaused); 322 this.jobManager.JobStopped += new EventHandler<EventArgs<SlaveJob, TaskData>>(jobManager_JobStopped); 323 this.jobManager.JobFailed += new EventHandler<EventArgs<Tuple<SlaveJob, TaskData, Exception>>>(jobManager_JobFailed); 323 324 this.jobManager.ExceptionOccured += new EventHandler<EventArgs<SlaveJob, Exception>>(jobManager_ExceptionOccured); 324 325 this.jobManager.JobAborted += new EventHandler<EventArgs<SlaveJob>>(jobManager_JobAborted); … … 329 330 } 330 331 331 private void jobManager_JobPaused(object sender, EventArgs<SlaveJob, JobData> e) {332 private void jobManager_JobPaused(object sender, EventArgs<SlaveJob, TaskData> e) { 332 333 try { 333 334 SlaveStatusInfo.DecrementUsedCores(e.Value.CoresNeeded); 334 335 heartbeatManager.AwakeHeartBeatThread(); 335 Jobjob = wcfService.GetJob(e.Value.JobId);336 Task job = wcfService.GetJob(e.Value.JobId); 336 337 if (job == null) throw new JobNotFoundException(e.Value.JobId); 337 338 job.ExecutionTime = e.Value.ExecutionTime; 338 JobData jobData = e.Value.GetJobData();339 wcfService.UpdateJobData(job, jobData, configManager.GetClientInfo().Id, JobState.Paused);339 TaskData jobData = e.Value.GetJobData(); 340 wcfService.UpdateJobData(job, jobData, configManager.GetClientInfo().Id, TaskState.Paused); 340 341 } 341 342 catch (JobNotFoundException ex) { … … 347 348 } 348 349 349 private void jobManager_JobStopped(object sender, EventArgs<SlaveJob, JobData> e) {350 private void jobManager_JobStopped(object sender, EventArgs<SlaveJob, TaskData> e) { 350 351 try { 351 352 SlaveStatusInfo.DecrementUsedCores(e.Value.CoresNeeded); 352 353 heartbeatManager.AwakeHeartBeatThread(); 353 Jobjob = wcfService.GetJob(e.Value.JobId);354 Task job = wcfService.GetJob(e.Value.JobId); 354 355 if (job == null) throw new JobNotFoundException(e.Value.JobId); 355 356 job.ExecutionTime = e.Value.ExecutionTime; 356 JobData jobData = e.Value.GetJobData();357 wcfService.UpdateJobData(job, jobData, configManager.GetClientInfo().Id, JobState.Finished);357 TaskData jobData = e.Value.GetJobData(); 358 wcfService.UpdateJobData(job, jobData, configManager.GetClientInfo().Id, TaskState.Finished); 358 359 } 359 360 catch (JobNotFoundException ex) { … … 365 366 } 366 367 367 private void jobManager_JobFailed(object sender, EventArgs<Tuple<SlaveJob, JobData, Exception>> e) {368 private void jobManager_JobFailed(object sender, EventArgs<Tuple<SlaveJob, TaskData, Exception>> e) { 368 369 try { 369 370 SlaveStatusInfo.DecrementUsedCores(e.Value.Item1.CoresNeeded); 370 371 heartbeatManager.AwakeHeartBeatThread(); 371 372 SlaveJob slaveJob = e.Value.Item1; 372 JobData jobData = e.Value.Item2;373 TaskData jobData = e.Value.Item2; 373 374 Exception exception = e.Value.Item3; 374 375 375 Jobjob = wcfService.GetJob(slaveJob.JobId);376 Task job = wcfService.GetJob(slaveJob.JobId); 376 377 if (job == null) throw new JobNotFoundException(slaveJob.JobId); 377 378 job.ExecutionTime = slaveJob.ExecutionTime; 378 379 if (jobData != null) { 379 wcfService.UpdateJobData(job, jobData, configManager.GetClientInfo().Id, JobState.Failed, exception.ToString());380 wcfService.UpdateJobData(job, jobData, configManager.GetClientInfo().Id, TaskState.Failed, exception.ToString()); 380 381 } else { 381 wcfService.UpdateJobState(job.Id, JobState.Failed, exception.ToString());382 wcfService.UpdateJobState(job.Id, TaskState.Failed, exception.ToString()); 382 383 } 383 384 clientCom.LogMessage(exception.Message); … … 398 399 heartbeatManager.AwakeHeartBeatThread(); 399 400 clientCom.LogMessage(string.Format("Exception occured for job {0}: {1}", e.Value.JobId, e.Value2.ToString())); 400 wcfService.UpdateJobState(e.Value.JobId, JobState.Waiting, e.Value2.ToString());401 wcfService.UpdateJobState(e.Value.JobId, TaskState.Waiting, e.Value2.ToString()); 401 402 } 402 403 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Exceptions/JobAlreadyRunningException.cs
r6357 r6721 24 24 namespace HeuristicLab.Clients.Hive.SlaveCore { 25 25 public class JobAlreadyRunningException : Exception { 26 public JobAlreadyRunningException(Guid jobId) : base(string.Format(" Jobwith Id {0} is already running.", jobId)) { }26 public JobAlreadyRunningException(Guid jobId) : base(string.Format("Task with Id {0} is already running.", jobId)) { } 27 27 } 28 28 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Exceptions/JobFailedException.cs
r6357 r6721 24 24 namespace HeuristicLab.Clients.Hive.SlaveCore { 25 25 public class JobFailedException : Exception { 26 public JobFailedException(string reason) : base(string.Format(" Jobfailed with reason: {0}", reason)) { }26 public JobFailedException(string reason) : base(string.Format("Task failed with reason: {0}", reason)) { } 27 27 } 28 28 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Exceptions/JobNotDataFoundException.cs
r6357 r6721 24 24 namespace HeuristicLab.Clients.Hive.SlaveCore { 25 25 public class JobDataNotFoundException : Exception { 26 public JobDataNotFoundException(Guid jobId) : base(string.Format(" JobData with JobId {0} was not found on server.", jobId)) { }26 public JobDataNotFoundException(Guid jobId) : base(string.Format("TaskData with TaskId {0} was not found on server.", jobId)) { } 27 27 } 28 28 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Exceptions/JobNotFoundException.cs
r6357 r6721 24 24 namespace HeuristicLab.Clients.Hive.SlaveCore { 25 25 public class JobNotFoundException : Exception { 26 public JobNotFoundException(Guid jobId) : base (string.Format(" Jobwith Id {0} was not found on server.", jobId)) { }26 public JobNotFoundException(Guid jobId) : base (string.Format("Task with Id {0} was not found on server.", jobId)) { } 27 27 } 28 28 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Exceptions/JobNotRunningException.cs
r6357 r6721 24 24 namespace HeuristicLab.Clients.Hive.SlaveCore { 25 25 public class JobNotRunningException : Exception { 26 public JobNotRunningException(Guid jobId) : base(string.Format(" Jobwith Id {0} is not running.", jobId)) { }26 public JobNotRunningException(Guid jobId) : base(string.Format("Task with Id {0} is not running.", jobId)) { } 27 27 } 28 28 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Executor.cs
r6464 r6721 100 100 public void Pause() { 101 101 IsPausing = true; 102 // wait until job is started. if this does not happen, the Jobis null an we give up102 // wait until job is started. if this does not happen, the Task is null an we give up 103 103 jobStartedSem.WaitOne(Settings.Default.ExecutorSemTimeouts); 104 104 if (job == null) { 105 CurrentException = new Exception("Pausing job " + this.JobId + ": Jobis null");105 CurrentException = new Exception("Pausing job " + this.JobId + ": Task is null"); 106 106 executorQueue.AddMessage(ExecutorMessageType.ExceptionOccured); 107 107 return; … … 123 123 public void Stop() { 124 124 IsStopping = true; 125 // wait until job is started. if this does not happen, the Jobis null an we give up125 // wait until job is started. if this does not happen, the Task is null an we give up 126 126 jobStartedSem.WaitOne(Settings.Default.ExecutorSemTimeouts); 127 127 if (job == null) { 128 CurrentException = new Exception("Stopping job " + this.JobId + ": Jobis null");128 CurrentException = new Exception("Stopping job " + this.JobId + ": Task is null"); 129 129 executorQueue.AddMessage(ExecutorMessageType.ExceptionOccured); 130 130 } … … 157 157 } 158 158 159 #region JobEvents159 #region Task Events 160 160 private void Job_JobFailed(object sender, EventArgs e) { 161 161 IsStopping = true; … … 185 185 #endregion 186 186 187 public JobData GetJobData() {187 public TaskData GetJobData() { 188 188 if (jobDataInvalid) return null; 189 189 190 190 if (job.ExecutionState == ExecutionState.Started) { 191 throw new InvalidStateException(" Jobis still running");191 throw new InvalidStateException("Task is still running"); 192 192 } else { 193 JobData jobData = new JobData();193 TaskData jobData = new TaskData(); 194 194 if (job == null) { 195 195 //send empty job and save exception 196 jobData.Data = PersistenceUtil.Serialize(new JobData());196 jobData.Data = PersistenceUtil.Serialize(new TaskData()); 197 197 if (CurrentException == null) { 198 CurrentException = new Exception(" Jobwith id " + this.JobId + " is null, sending empty job");198 CurrentException = new Exception("Task with id " + this.JobId + " is null, sending empty job"); 199 199 } 200 200 } else { 201 201 jobData.Data = PersistenceUtil.Serialize(job); 202 202 } 203 jobData. JobId = JobId;203 jobData.TaskId = JobId; 204 204 return jobData; 205 205 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/JobStatus.cs
r6371 r6721 27 27 public class JobStatus { 28 28 /// <summary> 29 /// Id of the Job29 /// Id of the Task 30 30 /// </summary> 31 31 [DataMember] -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Manager/JobManager.cs
r6381 r6721 65 65 } 66 66 67 #region JobControl methods68 public void StartJobAsync( Job job, JobData jobData) {67 #region Task Control methods 68 public void StartJobAsync(Task job, TaskData jobData) { 69 69 SlaveJob slaveJob = null; 70 70 slaveJobsLocker.EnterUpgradeableReadLock(); … … 160 160 161 161 #region Add/Remove SlaveJob 162 private void AddSlaveJob( Jobjob, SlaveJob slaveJob) {162 private void AddSlaveJob(Task job, SlaveJob slaveJob) { 163 163 slaveJobsLocker.EnterWriteLock(); 164 164 try { … … 217 217 finally { slaveJobsLocker.ExitUpgradeableReadLock(); } 218 218 219 JobData jobData = null;219 TaskData jobData = null; 220 220 try { 221 221 jobData = slaveJob.GetJobData(); … … 240 240 finally { slaveJobsLocker.ExitUpgradeableReadLock(); } 241 241 242 JobData jobData = null;242 TaskData jobData = null; 243 243 try { 244 244 jobData = slaveJob.GetJobData(); … … 263 263 finally { slaveJobsLocker.ExitUpgradeableReadLock(); } 264 264 265 JobData jobData = null;265 TaskData jobData = null; 266 266 try { 267 267 jobData = slaveJob.GetJobData(); … … 294 294 } 295 295 296 public event EventHandler<EventArgs<SlaveJob, JobData>> JobStopped;297 private void OnJobStopped(SlaveJob slaveJob, JobData jobData) {296 public event EventHandler<EventArgs<SlaveJob, TaskData>> JobStopped; 297 private void OnJobStopped(SlaveJob slaveJob, TaskData jobData) { 298 298 var handler = JobStopped; 299 if (handler != null) handler(this, new EventArgs<SlaveJob, JobData>(slaveJob, jobData));300 } 301 302 public event EventHandler<EventArgs<SlaveJob, JobData>> JobPaused;303 private void OnJobPaused(SlaveJob slaveJob, JobData jobData) {299 if (handler != null) handler(this, new EventArgs<SlaveJob, TaskData>(slaveJob, jobData)); 300 } 301 302 public event EventHandler<EventArgs<SlaveJob, TaskData>> JobPaused; 303 private void OnJobPaused(SlaveJob slaveJob, TaskData jobData) { 304 304 var handler = JobPaused; 305 if (handler != null) handler(this, new EventArgs<SlaveJob, JobData>(slaveJob, jobData));306 } 307 308 public event EventHandler<EventArgs<Tuple<SlaveJob, JobData, Exception>>> JobFailed;309 private void OnJobFailed(SlaveJob slaveJob, JobData jobData, Exception exception) {305 if (handler != null) handler(this, new EventArgs<SlaveJob, TaskData>(slaveJob, jobData)); 306 } 307 308 public event EventHandler<EventArgs<Tuple<SlaveJob, TaskData, Exception>>> JobFailed; 309 private void OnJobFailed(SlaveJob slaveJob, TaskData jobData, Exception exception) { 310 310 var handler = JobFailed; 311 if (handler != null) handler(this, new EventArgs<Tuple<SlaveJob, JobData, Exception>>(new Tuple<SlaveJob, JobData, Exception>(slaveJob, jobData, exception)));311 if (handler != null) handler(this, new EventArgs<Tuple<SlaveJob, TaskData, Exception>>(new Tuple<SlaveJob, TaskData, Exception>(slaveJob, jobData, exception))); 312 312 } 313 313 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Manager/PluginManager.cs
r6456 r6721 135 135 /// then copies the required plugins for the job. 136 136 /// </summary> 137 public void PreparePlugins( Jobjob, out string configFileName) {137 public void PreparePlugins(Task job, out string configFileName) { 138 138 lock (locker) { 139 139 log.LogMessage("Fetching plugins for job " + job.Id); -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/SlaveJob.cs
r6464 r6721 63 63 } 64 64 65 public void StartJobAsync( Job job, JobData jobData) {65 public void StartJobAsync(Task job, TaskData jobData) { 66 66 try { 67 67 this.JobId = job.Id; … … 86 86 } 87 87 88 private void Prepare( Jobjob) {88 private void Prepare(Task job) { 89 89 string pluginDir = Path.Combine(pluginManager.PluginTempBaseDir, job.Id.ToString()); 90 90 string configFileName; … … 94 94 } 95 95 96 private AppDomain CreateAppDomain( Jobjob, String pluginDir, string configFileName) {96 private AppDomain CreateAppDomain(Task job, String pluginDir, string configFileName) { 97 97 if (job.IsPrivileged) { 98 98 appDomain = SandboxManager.CreateAndInitPrivilegedSandbox(job.Id.ToString(), pluginDir, Path.Combine(pluginDir, configFileName)); … … 111 111 } 112 112 113 private void StartJobInAppDomain( JobData jobData) {113 private void StartJobInAppDomain(TaskData jobData) { 114 114 executor.Start(jobData.Data); 115 115 waitForStartBeforeKillSem.Release(); … … 118 118 119 119 public void DisposeAppDomain() { 120 log.LogMessage(string.Format("Shutting down Appdomain for Job{0}", JobId));120 log.LogMessage(string.Format("Shutting down Appdomain for Task {0}", JobId)); 121 121 StopExecutorMonitoringThread(); 122 122 … … 154 154 } 155 155 156 public JobData GetJobData() {156 public TaskData GetJobData() { 157 157 return executor.GetJobData(); 158 158 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/WcfService.cs
r6456 r6721 54 54 } 55 55 56 #region JobMethods57 public JobGetJob(Guid jobId) {56 #region Task Methods 57 public Task GetJob(Guid jobId) { 58 58 return CallHiveService(s => s.GetJob(jobId)); 59 59 } 60 60 61 public void UpdateJob( Jobjob) {61 public void UpdateJob(Task job) { 62 62 CallHiveService(s => s.UpdateJob(job)); 63 63 } 64 64 #endregion 65 65 66 #region JobData Methods67 public JobData GetJobData(Guid jobId) {66 #region TaskData Methods 67 public TaskData GetJobData(Guid jobId) { 68 68 return CallHiveService(s => s.GetJobData(jobId)); 69 69 } … … 72 72 /// Uploads the jobData and sets a new jobState (while correctly setting Transferring state) 73 73 /// </summary> 74 public void UpdateJobData( Job job, JobData jobData, Guid slaveId, JobState state, string exception = "") {74 public void UpdateJobData(Task job, TaskData jobData, Guid slaveId, TaskState state, string exception = "") { 75 75 CallHiveService(service => { 76 76 service.UpdateJob(job); 77 job = service.UpdateJobState(job.Id, JobState.Transferring, slaveId, null, null);77 job = service.UpdateJobState(job.Id, TaskState.Transferring, slaveId, null, null); 78 78 HiveClient.TryAndRepeat(() => { 79 79 service.UpdateJobData(job, jobData); … … 83 83 } 84 84 85 public Job UpdateJobState(Guid jobId, JobState jobState, string exception) {85 public Task UpdateJobState(Guid jobId, TaskState jobState, string exception) { 86 86 return CallHiveService(s => s.UpdateJobState(jobId, jobState, ConfigManager.Instance.GetClientInfo().Id, null, exception)); 87 87 }
Note: See TracChangeset
for help on using the changeset viewer.