Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/15/09 14:53:13 (16 years ago)
Author:
msteinbi
Message:

Implementing Lifecycle Management (#453)

File:
1 edited

Legend:

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

    r1121 r1133  
    3333
    3434    IJobAdapter jobAdapter;
     35    ILifecycleManager lifecycleManager;
    3536
    3637    #region IJobManager Members
     
    3839    public JobManager() {
    3940      jobAdapter = ServiceLocator.GetJobAdapter();
     41
     42      lifecycleManager = ServiceLocator.GetLifecycleManager();
     43
     44      lifecycleManager.RegisterStartup(new EventHandler(lifecycleManager_OnStartup));
     45      lifecycleManager.RegisterStartup(new EventHandler(lifecycleManager_OnShutdown));
     46    }
     47
     48    void checkForDeadJobs() {
     49      List<Job> allJobs = new List<Job>(jobAdapter.GetAll());
     50      foreach (Job curJob in allJobs) {
     51        if (curJob.State == State.calculating) {
     52          // TODO check for job results
     53          curJob.State = State.idle;
     54          curJob.Percentage = 0;
     55          curJob.Client = null;
     56        }
     57      }
     58    }
     59
     60    void lifecycleManager_OnStartup(object sender, EventArgs e) {
     61      checkForDeadJobs();
     62    }
     63
     64    void lifecycleManager_OnShutdown(object sender, EventArgs e) {
     65      checkForDeadJobs();
    4066    }
    4167
Note: See TracChangeset for help on using the changeset viewer.