Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1141


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

Implementing Lifecycle Management (#453)

Location:
trunk/sources/HeuristicLab.Hive.Server.Core
Files:
1 added
3 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        }
  • trunk/sources/HeuristicLab.Hive.Server.Core/HeuristicLab.Hive.Server.Core.csproj

    r1120 r1141  
    8282    <Compile Include="InternalInterfaces\DataAccess\IUserAdapter.cs" />
    8383    <Compile Include="InternalInterfaces\DataAccess\IUserGroupAdapter.cs" />
     84    <Compile Include="InternalInterfaces\IInternalJobManager.cs" />
    8485    <Compile Include="JobManager.cs" />
    8586    <Compile Include="LifecycleManager.cs" />
  • trunk/sources/HeuristicLab.Hive.Server.Core/JobManager.cs

    r1139 r1141  
    2828using HeuristicLab.Hive.Contracts;
    2929using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess;
     30using HeuristicLab.Hive.Server.Core.InternalInterfaces;
    3031
    3132namespace HeuristicLab.Hive.Server.Core {
    32   class JobManager: IJobManager {
     33  class JobManager: IJobManager, IInternalJobManager {
    3334
    3435    IJobAdapter jobAdapter;
     
    4849    }
    4950
    50     private void resetJobsDependingOnResults(Job job) {
     51    public void ResetJobsDependingOnResults(Job job) {
    5152      List<JobResult> allJobResults = new List<JobResult>(jobResultAdapter.GetAll());
    5253      JobResult lastJobResult = null;
     
    7778      foreach (Job curJob in allJobs) {
    7879        if (curJob.State == State.calculating) {
    79           resetJobsDependingOnResults(curJob);
     80          ResetJobsDependingOnResults(curJob);
    8081        }
    8182      }
Note: See TracChangeset for help on using the changeset viewer.