Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1139


Ignore:
Timestamp:
01/15/09 15:50:43 (16 years ago)
Author:
msteinbi
Message:

Implementing Lifecycle Management (#453)

Location:
trunk/sources/HeuristicLab.Hive.Server.Core
Files:
2 edited

Legend:

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

    r1137 r1139  
    130130        job.State = State.idle;
    131131      }
     132      jobAdapter.Update(job);
    132133    }
    133134
  • trunk/sources/HeuristicLab.Hive.Server.Core/JobManager.cs

    r1133 r1139  
    3333
    3434    IJobAdapter jobAdapter;
     35    IJobResultsAdapter jobResultAdapter;
    3536    ILifecycleManager lifecycleManager;
    3637
     
    3940    public JobManager() {
    4041      jobAdapter = ServiceLocator.GetJobAdapter();
     42      jobResultAdapter = ServiceLocator.GetJobResultsAdapter();
    4143
    4244      lifecycleManager = ServiceLocator.GetLifecycleManager();
     
    4648    }
    4749
     50    private void resetJobsDependingOnResults(Job job) {
     51      List<JobResult> allJobResults = new List<JobResult>(jobResultAdapter.GetAll());
     52      JobResult lastJobResult = null;
     53      foreach (JobResult jR in allJobResults) {
     54        if (jR.Job != null && jR.Job.Id == job.Id) {
     55          if (lastJobResult != null) {
     56            // if lastJobResult was before the current jobResult the lastJobResult must be updated
     57            if ((jR.timestamp.Subtract(lastJobResult.timestamp)).Seconds > 0)
     58              lastJobResult = jR;
     59          }
     60        }
     61      }
     62      if (lastJobResult != null) {
     63        job.Client = null;
     64        job.Percentage = lastJobResult.Percentage;
     65        job.State = State.idle;
     66        job.SerializedJob = lastJobResult.Result;
     67      } else {
     68        job.Client = null;
     69        job.Percentage = 0;
     70        job.State = State.idle;
     71      }
     72      jobAdapter.Update(job);
     73    }
     74
    4875    void checkForDeadJobs() {
    4976      List<Job> allJobs = new List<Job>(jobAdapter.GetAll());
    5077      foreach (Job curJob in allJobs) {
    5178        if (curJob.State == State.calculating) {
    52           // TODO check for job results
    53           curJob.State = State.idle;
    54           curJob.Percentage = 0;
    55           curJob.Client = null;
     79          resetJobsDependingOnResults(curJob);
    5680        }
    5781      }
Note: See TracChangeset for help on using the changeset viewer.