Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/15/09 15:56:08 (15 years ago)
Author:
msteinbi
Message:

Implementing Lifecycle Management (#453)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Server.Core/ClientCommunicator.cs

    r1139 r1141  
    3333using HeuristicLab.Hive.JobBase;
    3434using System.Runtime.CompilerServices;
     35using HeuristicLab.Hive.Server.Core.InternalInterfaces;
    3536
    3637namespace HeuristicLab.Hive.Server.Core {
     
    4647    IJobResultsAdapter jobResultAdapter;
    4748    ILifecycleManager lifecycleManager;
     49    IInternalJobManager jobManager;
    4850
    4951    /// <summary>
     
    5759      jobResultAdapter = ServiceLocator.GetJobResultsAdapter();
    5860      lifecycleManager = ServiceLocator.GetLifecycleManager();
     61      jobManager = ServiceLocator.GetJobManager() as
     62        IInternalJobManager;
    5963
    6064      lifecycleManager.RegisterHeartbeat(
     
    9094                foreach (Job job in allJobs) {
    9195                  if (job.Client.ClientId == client.ClientId) {
    92                     resetJobsDependingOnResults(job);
     96                    jobManager.ResetJobsDependingOnResults(job);
    9397                  }
    9498                }
     
    108112    }
    109113
    110     private void resetJobsDependingOnResults(Job job) {
    111       List<JobResult> allJobResults = new List<JobResult>(jobResultAdapter.GetAll());
    112       JobResult lastJobResult = null;
    113       foreach (JobResult jR in allJobResults) {
    114         if (jR.Job != null && jR.Job.Id == job.Id) {
    115           if (lastJobResult != null) {
    116             // if lastJobResult was before the current jobResult the lastJobResult must be updated
    117             if ((jR.timestamp.Subtract(lastJobResult.timestamp)).Seconds > 0)
    118               lastJobResult = jR;
    119           }
    120         }
    121       }
    122       if (lastJobResult != null) {
    123         job.Client = null;
    124         job.Percentage = lastJobResult.Percentage;
    125         job.State = State.idle;
    126         job.SerializedJob = lastJobResult.Result;
    127       } else {
    128         job.Client = null;
    129         job.Percentage = 0;
    130         job.State = State.idle;
    131       }
    132       jobAdapter.Update(job);
    133     }
    134 
    135114    #region IClientCommunicator Members
    136115
     
    338317        foreach (Job job in allJobs) {
    339318          if (job.Client.ClientId == client.ClientId) {
    340             resetJobsDependingOnResults(job);
     319            jobManager.ResetJobsDependingOnResults(job);
    341320          }
    342321        }
Note: See TracChangeset for help on using the changeset viewer.