Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/08/11 13:41:25 (13 years ago)
Author:
ascheibe
Message:

#1233 Review comments: renamed Job to Task

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.3/Core.cs

    r6546 r6721  
    2929using HeuristicLab.Common;
    3030using HeuristicLab.Core;
     31using TS = System.Threading.Tasks;
    3132
    3233
     
    148149    /// <param name="container">The container, containing the message</param>
    149150    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));
    151152
    152153      if (container is ExecutorMessageContainer<Guid>) {
     
    156157        switch (container.Message) {
    157158          case MessageContainer.MessageType.CalculateJob:
    158             CalculateJobAsync(container.JobId);
     159            CalculateJobAsync(container.TaskId);
    159160            break;
    160161          case MessageContainer.MessageType.AbortJob:
    161             AbortJobAsync(container.JobId);
     162            AbortJobAsync(container.TaskId);
    162163            break;
    163164          case MessageContainer.MessageType.StopJob:
    164             StopJobAsync(container.JobId);
     165            StopJobAsync(container.TaskId);
    165166            break;
    166167          case MessageContainer.MessageType.PauseJob:
    167             PauseJobAsync(container.JobId);
     168            PauseJobAsync(container.TaskId);
    168169            break;
    169170          case MessageContainer.MessageType.StopAll:
     
    195196
    196197    private void CalculateJobAsync(Guid jobId) {
    197       Task.Factory.StartNew(HandleCalculateJob, jobId)
     198      TS.Task.Factory.StartNew(HandleCalculateJob, jobId)
    198199      .ContinueWith((t) => {
    199200        SlaveStatusInfo.IncrementExceptionOccured();
     
    203204
    204205    private void StopJobAsync(Guid jobId) {
    205       Task.Factory.StartNew(HandleStopJob, jobId)
     206      TS.Task.Factory.StartNew(HandleStopJob, jobId)
    206207       .ContinueWith((t) => {
    207208         SlaveStatusInfo.IncrementExceptionOccured();
     
    211212
    212213    private void PauseJobAsync(Guid jobId) {
    213       Task.Factory.StartNew(HandlePauseJob, jobId)
     214      TS.Task.Factory.StartNew(HandlePauseJob, jobId)
    214215       .ContinueWith((t) => {
    215216         SlaveStatusInfo.IncrementExceptionOccured();
     
    219220
    220221    private void AbortJobAsync(Guid jobId) {
    221       Task.Factory.StartNew(HandleAbortJob, jobId)
     222      TS.Task.Factory.StartNew(HandleAbortJob, jobId)
    222223       .ContinueWith((t) => {
    223224         SlaveStatusInfo.IncrementExceptionOccured();
     
    228229    private void HandleCalculateJob(object jobIdObj) {
    229230      Guid jobId = (Guid)jobIdObj;
    230       Job job = null;
     231      Task job = null;
    231232      int usedCores = 0;
    232233      try {
     
    236237        if (ConfigManager.GetFreeMemory() < job.MemoryNeeded) throw new OutOfMemoryException();
    237238        SlaveStatusInfo.IncrementUsedCores(job.CoresNeeded); usedCores = job.CoresNeeded;
    238         JobData jobData = wcfService.GetJobData(jobId);
     239        TaskData jobData = wcfService.GetJobData(jobId);
    239240        if (jobData == null) throw new JobDataNotFoundException(jobId);
    240         job = wcfService.UpdateJobState(jobId, JobState.Calculating, null);
     241        job = wcfService.UpdateJobState(jobId, TaskState.Calculating, null);
    241242        if (job == null) throw new JobNotFoundException(jobId);
    242243        jobManager.StartJobAsync(job, jobData);
     
    255256      }
    256257      catch (OutOfCoresException) {
    257         wcfService.UpdateJobState(jobId, JobState.Waiting, "No more cores available");
     258        wcfService.UpdateJobState(jobId, TaskState.Waiting, "No more cores available");
    258259        throw;
    259260      }
    260261      catch (OutOfMemoryException) {
    261         wcfService.UpdateJobState(jobId, JobState.Waiting, "No more memory available");
     262        wcfService.UpdateJobState(jobId, TaskState.Waiting, "No more memory available");
    262263        throw;
    263264      }
    264265      catch (Exception e) {
    265266        SlaveStatusInfo.DecrementUsedCores(usedCores);
    266         wcfService.UpdateJobState(jobId, JobState.Waiting, e.ToString()); // unknown internal error - report and set waiting again
     267        wcfService.UpdateJobState(jobId, TaskState.Waiting, e.ToString()); // unknown internal error - report and set waiting again
    267268        throw;
    268269      }
     
    272273      Guid jobId = (Guid)jobIdObj;
    273274      try {
    274         Job job = wcfService.GetJob(jobId);
     275        Task job = wcfService.GetJob(jobId);
    275276        if (job == null) throw new JobNotFoundException(jobId);
    276277        jobManager.StopJobAsync(jobId);
     
    290291      Guid jobId = (Guid)jobIdObj;
    291292      try {
    292         Job job = wcfService.GetJob(jobId);
     293        Task job = wcfService.GetJob(jobId);
    293294        if (job == null) throw new JobNotFoundException(jobId);
    294295        jobManager.PauseJobAsync(jobId);
     
    318319    private void RegisterJobManagerEvents() {
    319320      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);
    323324      this.jobManager.ExceptionOccured += new EventHandler<EventArgs<SlaveJob, Exception>>(jobManager_ExceptionOccured);
    324325      this.jobManager.JobAborted += new EventHandler<EventArgs<SlaveJob>>(jobManager_JobAborted);
     
    329330    }
    330331
    331     private void jobManager_JobPaused(object sender, EventArgs<SlaveJob, JobData> e) {
     332    private void jobManager_JobPaused(object sender, EventArgs<SlaveJob, TaskData> e) {
    332333      try {
    333334        SlaveStatusInfo.DecrementUsedCores(e.Value.CoresNeeded);
    334335        heartbeatManager.AwakeHeartBeatThread();
    335         Job job = wcfService.GetJob(e.Value.JobId);
     336        Task job = wcfService.GetJob(e.Value.JobId);
    336337        if (job == null) throw new JobNotFoundException(e.Value.JobId);
    337338        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);
    340341      }
    341342      catch (JobNotFoundException ex) {
     
    347348    }
    348349
    349     private void jobManager_JobStopped(object sender, EventArgs<SlaveJob, JobData> e) {
     350    private void jobManager_JobStopped(object sender, EventArgs<SlaveJob, TaskData> e) {
    350351      try {
    351352        SlaveStatusInfo.DecrementUsedCores(e.Value.CoresNeeded);
    352353        heartbeatManager.AwakeHeartBeatThread();
    353         Job job = wcfService.GetJob(e.Value.JobId);
     354        Task job = wcfService.GetJob(e.Value.JobId);
    354355        if (job == null) throw new JobNotFoundException(e.Value.JobId);
    355356        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);
    358359      }
    359360      catch (JobNotFoundException ex) {
     
    365366    }
    366367
    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) {
    368369      try {
    369370        SlaveStatusInfo.DecrementUsedCores(e.Value.Item1.CoresNeeded);
    370371        heartbeatManager.AwakeHeartBeatThread();
    371372        SlaveJob slaveJob = e.Value.Item1;
    372         JobData jobData = e.Value.Item2;
     373        TaskData jobData = e.Value.Item2;
    373374        Exception exception = e.Value.Item3;
    374375
    375         Job job = wcfService.GetJob(slaveJob.JobId);
     376        Task job = wcfService.GetJob(slaveJob.JobId);
    376377        if (job == null) throw new JobNotFoundException(slaveJob.JobId);
    377378        job.ExecutionTime = slaveJob.ExecutionTime;
    378379        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());
    380381        } else {
    381           wcfService.UpdateJobState(job.Id, JobState.Failed, exception.ToString());
     382          wcfService.UpdateJobState(job.Id, TaskState.Failed, exception.ToString());
    382383        }
    383384        clientCom.LogMessage(exception.Message);
     
    398399      heartbeatManager.AwakeHeartBeatThread();
    399400      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());
    401402    }
    402403
Note: See TracChangeset for help on using the changeset viewer.