Changeset 5593 for branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/LifecycleManager.cs
- Timestamp:
- 03/02/11 15:23:59 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/LifecycleManager.cs
r5526 r5593 1 1 using System; 2 2 using System.Linq; 3 using HeuristicLab.Core;4 3 using HeuristicLab.Services.Hive.Common; 5 4 using HeuristicLab.Services.Hive.Common.DataTransfer; … … 7 6 namespace HeuristicLab.Services.Hive { 8 7 /// <summary> 9 /// This class holds the state of all recent heartbeats and decides to reschedule jobs and set slaves offline8 /// This class offers methods for cleaning up offline slaves and jobs 10 9 /// </summary> 11 10 public class LifecycleManager : ILifecycleManager { … … 19 18 get { return ServiceLocator.Instance.AuthorizationManager; } 20 19 } 21 22 private static object locker = new object(); 23 24 // Windows-Forms timer is single threaded, so callbacks will be synchron 25 private System.Windows.Forms.Timer timer; 26 27 public ExecutionState ExecutionState { 28 get { return timer.Enabled ? ExecutionState.Started : Core.ExecutionState.Stopped; } 20 private ILogger log { 21 get { return LogFactory.GetLogger(this.GetType().Namespace); } 29 22 } 30 23 31 public LifecycleManager() { 32 this.timer = new System.Windows.Forms.Timer(); 33 this.timer.Tick += new EventHandler(timer_Tick); 34 } 35 36 public void Start() { 37 if (ExecutionState == Core.ExecutionState.Stopped) { 38 // kick off the event immediately 39 timer_Tick(this, EventArgs.Empty); 40 41 // start the timer 42 this.timer.Interval = (int)new TimeSpan(0, 0, 30).TotalMilliseconds; 43 this.timer.Start(); 44 } 45 } 46 47 public void Stop() { 48 if (ExecutionState == Core.ExecutionState.Started) { 49 timer.Stop(); 50 } 51 } 52 53 /// <summary> 54 /// This method is supposed to check if slaves are online 55 /// if not -> set them offline and check if they where calculating a job 56 /// </summary> 57 private void timer_Tick(object sender, EventArgs e) { 58 lock (locker) { 59 using (trans.OpenTransaction()) { 60 SetTimeoutSlavesOffline(); 61 FinishParentJobs(); 62 } 63 } 24 public void Cleanup() { 25 log.Log("LifecycleManager.Cleanup()"); 26 SetTimeoutSlavesOffline(); 27 FinishParentJobs(); 64 28 } 65 29 … … 101 65 } 102 66 } 67 103 68 } 104 69 }
Note: See TracChangeset
for help on using the changeset viewer.