- Timestamp:
- 03/02/11 15:23:59 (13 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HeuristicLab.Services.Hive-3.4.csproj
r5405 r5593 115 115 <Compile Include="Interfaces\ILifecycleManager.cs" /> 116 116 <Compile Include="Interfaces\IServiceLocator.cs" /> 117 <Compile Include="Standalone\HeuristicLabServicesHiveApplication.cs" />118 <Compile Include="Standalone\MainForm.cs">119 <SubType>Form</SubType>120 </Compile>121 <Compile Include="Standalone\MainForm.Designer.cs">122 <DependentUpon>MainForm.cs</DependentUpon>123 </Compile>124 117 <Compile Include="AuthorizationManager.cs" /> 125 118 <Compile Include="HeuristicLabServicesHivePlugin.cs" /> … … 148 141 </ItemGroup> 149 142 <ItemGroup> 150 <EmbeddedResource Include="Standalone\MainForm.resx"> 151 <DependentUpon>MainForm.cs</DependentUpon> 152 </EmbeddedResource> 143 <Folder Include="Standalone\" /> 153 144 </ItemGroup> 154 145 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HiveService.cs
r5535 r5593 229 229 // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)] 230 230 public List<MessageContainer> Heartbeat(Heartbeat heartbeat) { 231 TriggerLifecycle(); 232 231 233 using (trans.OpenTransaction()) { 232 234 return heartbeatManager.ProcessHeartbeat(heartbeat); … … 255 257 // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)] 256 258 public IEnumerable<Plugin> GetPlugins() { 257 return dao.GetPlugins(x => true);259 return dao.GetPlugins(x => x.IsLocal == false); 258 260 } 259 261 … … 382 384 } 383 385 } 386 387 public void TriggerLifecycle() { 388 using (trans.OpenTransaction()) { 389 DateTime lastCleanup = dao.GetLastCleanup(); 390 if (DateTime.Now - lastCleanup > TimeSpan.FromSeconds(59)) { 391 dao.SetLastCleanup(DateTime.Now); 392 lifecycleManager.Cleanup(); 393 } 394 } 395 } 384 396 #endregion 385 397 -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/Interfaces/ILifecycleManager.cs
r5405 r5593 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using HeuristicLab.Services.Hive.Common; 6 using HeuristicLab.Services.Hive.Common.DataTransfer; 7 1 8 2 namespace HeuristicLab.Services.Hive { 9 3 /// <summary> … … 11 5 /// </summary> 12 6 public interface ILifecycleManager { 13 void Start(); 14 15 void Stop(); 7 void Cleanup(); 16 8 } 17 9 } -
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.