Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5593


Ignore:
Timestamp:
03/02/11 15:23:59 (14 years ago)
Author:
cneumuel
Message:

#1233

  • changed the way lifecycle methods are called. The new service method TriggerLifecycle checks when the latest cleanup was made and performs one (if necessary). This can also be called by an external program (like a windows task)
  • robustified logging
Location:
branches/HeuristicLab.Hive-3.4/sources
Files:
9 added
17 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave.Tests/Mocks/MockHiveService.cs

    r5511 r5593  
    335335    #endregion
    336336
     337    #region Lifecycle Methods
     338    public void TriggerLifecycle() {
     339      throw new NotImplementedException();
     340    }
     341    #endregion
    337342  }
    338343}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/HeuristicLab.Clients.Hive.Slave-3.4.csproj

    r5591 r5593  
    124124    <Compile Include="StatusCommons.cs" />
    125125    <Compile Include="WcfService.cs" />
     126    <None Include="app.config" />
    126127    <None Include="app_ascheibe.config" />
    127128    <None Include="app_f005pc.config" />
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Hive 3.4.sln

    r5538 r5593  
    7272EndProject
    7373Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.DayView-1.0", "HeuristicLab.ExtLibs\HeuristicLab.DayView\1.0\HeuristicLab.DayView-1.0.csproj", "{02766ECC-D0F5-4115-9ECA-47409167B638}"
     74EndProject
     75Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreateEventLogSources", "CreateEventLogSources\CreateEventLogSources.csproj", "{A0EB9657-4D57-4CC1-A309-EC010D7F9EAB}"
     76EndProject
     77Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Clients.Hive.LifecycleClient", "HeuristicLab.Clients.Hive.LifecycleClient\HeuristicLab.Clients.Hive.LifecycleClient.csproj", "{54491B6A-1EDD-4C76-90A7-338BA9C1FBF8}"
    7478EndProject
    7579Global
     
    311315    {02766ECC-D0F5-4115-9ECA-47409167B638}.Release|x86.ActiveCfg = Release|x86
    312316    {02766ECC-D0F5-4115-9ECA-47409167B638}.Release|x86.Build.0 = Release|x86
     317    {A0EB9657-4D57-4CC1-A309-EC010D7F9EAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     318    {A0EB9657-4D57-4CC1-A309-EC010D7F9EAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
     319    {A0EB9657-4D57-4CC1-A309-EC010D7F9EAB}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
     320    {A0EB9657-4D57-4CC1-A309-EC010D7F9EAB}.Debug|Mixed Platforms.Build.0 = Debug|x86
     321    {A0EB9657-4D57-4CC1-A309-EC010D7F9EAB}.Debug|x64.ActiveCfg = Debug|x86
     322    {A0EB9657-4D57-4CC1-A309-EC010D7F9EAB}.Debug|x86.ActiveCfg = Debug|x86
     323    {A0EB9657-4D57-4CC1-A309-EC010D7F9EAB}.Debug|x86.Build.0 = Debug|x86
     324    {A0EB9657-4D57-4CC1-A309-EC010D7F9EAB}.Release|Any CPU.ActiveCfg = Release|x86
     325    {A0EB9657-4D57-4CC1-A309-EC010D7F9EAB}.Release|Mixed Platforms.ActiveCfg = Release|x86
     326    {A0EB9657-4D57-4CC1-A309-EC010D7F9EAB}.Release|Mixed Platforms.Build.0 = Release|x86
     327    {A0EB9657-4D57-4CC1-A309-EC010D7F9EAB}.Release|x64.ActiveCfg = Release|x86
     328    {A0EB9657-4D57-4CC1-A309-EC010D7F9EAB}.Release|x86.ActiveCfg = Release|x86
     329    {A0EB9657-4D57-4CC1-A309-EC010D7F9EAB}.Release|x86.Build.0 = Release|x86
     330    {54491B6A-1EDD-4C76-90A7-338BA9C1FBF8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     331    {54491B6A-1EDD-4C76-90A7-338BA9C1FBF8}.Debug|Any CPU.Build.0 = Debug|Any CPU
     332    {54491B6A-1EDD-4C76-90A7-338BA9C1FBF8}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
     333    {54491B6A-1EDD-4C76-90A7-338BA9C1FBF8}.Debug|Mixed Platforms.Build.0 = Debug|x86
     334    {54491B6A-1EDD-4C76-90A7-338BA9C1FBF8}.Debug|x64.ActiveCfg = Debug|x86
     335    {54491B6A-1EDD-4C76-90A7-338BA9C1FBF8}.Debug|x86.ActiveCfg = Debug|x86
     336    {54491B6A-1EDD-4C76-90A7-338BA9C1FBF8}.Debug|x86.Build.0 = Debug|x86
     337    {54491B6A-1EDD-4C76-90A7-338BA9C1FBF8}.Release|Any CPU.ActiveCfg = Release|x86
     338    {54491B6A-1EDD-4C76-90A7-338BA9C1FBF8}.Release|Mixed Platforms.ActiveCfg = Release|x86
     339    {54491B6A-1EDD-4C76-90A7-338BA9C1FBF8}.Release|Mixed Platforms.Build.0 = Release|x86
     340    {54491B6A-1EDD-4C76-90A7-338BA9C1FBF8}.Release|x64.ActiveCfg = Release|x86
     341    {54491B6A-1EDD-4C76-90A7-338BA9C1FBF8}.Release|x86.ActiveCfg = Release|x86
     342    {54491B6A-1EDD-4C76-90A7-338BA9C1FBF8}.Release|x86.Build.0 = Release|x86
    313343  EndGlobalSection
    314344  GlobalSection(SolutionProperties) = preSolution
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/Logger.cs

    r5511 r5593  
    11using System;
    22using System.Diagnostics;
     3using System.Security;
     4using System.Threading;
    35
    46namespace HeuristicLab.Services.Hive.Common {
     
    1719    private EventLog log;
    1820
     21    /// <summary>
     22    /// Creating an EventSource requires certain permissions, which by default a IIS AppPool user does not have.
     23    /// In this case just ignore security exceptions.
     24    /// In order to make this work, the eventsource needs to be created manually
     25    /// </summary>
    1926    public Logger(string name, string source) {
    20       //if (!EventLog.SourceExists(name)) {
    21       //  EventLog.CreateEventSource(source, name);
    22       //}
    23       //log = new EventLog(name);
    24       //log.Source = source;
     27      try {
     28        if (!EventLog.SourceExists(source)) {
     29          EventLog.CreateEventSource(source, name);
     30        }
     31        log = new EventLog(name);
     32        log.Source = source;
     33      }
     34      catch (SecurityException) { }
    2535    }
    2636
    2737    public void Log(string message) {
    28       //log.WriteEntry(string.Format("{0} (AppDomain: {1}, Thread: {2})", message, AppDomain.CurrentDomain.Id, Thread.CurrentThread.ManagedThreadId), EventLogEntryType.Information);
     38      try {
     39        log.WriteEntry(string.Format("{0} (AppDomain: {1}, Thread: {2})", message, AppDomain.CurrentDomain.Id, Thread.CurrentThread.ManagedThreadId), EventLogEntryType.Information);
     40      }
     41      catch (SecurityException) { }
    2942    }
    3043
    3144    public void Error(Exception e) {
    32       //log.WriteEntry(string.Format("{0} (AppDomain: {1}, Thread: {2})", e.Message, AppDomain.CurrentDomain.Id, Thread.CurrentThread.ManagedThreadId), EventLogEntryType.Error);
     45      try {
     46        log.WriteEntry(string.Format("{0} (AppDomain: {1}, Thread: {2})", e.Message, AppDomain.CurrentDomain.Id, Thread.CurrentThread.ManagedThreadId), EventLogEntryType.Error);
     47      }
     48      catch (SecurityException) { }
    3349    }
    3450  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/ServiceContracts/IHiveService.cs

    r5526 r5593  
    135135    Guid GetResourceId(string resourceName);
    136136
     137    [OperationContract]
     138    void TriggerLifecycle();
    137139    #endregion
    138140
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDao.cs

    r5526 r5593  
    558558    #endregion
    559559
     560    #region Lifecycle Methods
     561    public DateTime GetLastCleanup() {
     562      using (var db = CreateContext()) {
     563        var entity = db.Lifecycles.SingleOrDefault();
     564        return entity != null ? entity.LastCleanup : DateTime.MinValue;
     565      }
     566    }
     567
     568    public void SetLastCleanup(DateTime datetime) {
     569      using (var db = CreateContext()) {
     570        var entity = db.Lifecycles.SingleOrDefault();
     571        if (entity != null) {
     572          entity.LastCleanup = datetime;
     573        } else {
     574          entity = new Lifecycle();
     575          entity.LifecycleId = 0; // always only one entry with ID:0
     576          entity.LastCleanup = datetime;
     577          db.Lifecycles.InsertOnSubmit(entity);
     578        }
     579        db.SubmitChanges();
     580      }
     581    }
     582    #endregion
    560583  }
    561584}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDataContext.dbml

    r5526 r5593  
    143143    </Type>
    144144  </Table>
     145  <Table Name="" Member="Lifecycles">
     146    <Type Name="Lifecycle">
     147      <Column Name="LifecycleId" Type="System.Int32" DbType="Int" IsPrimaryKey="true" CanBeNull="false" />
     148      <Column Name="LastCleanup" Type="System.DateTime" DbType="DateTime" CanBeNull="false" />
     149    </Type>
     150  </Table>
    145151</Database>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDataContext.dbml.layout

    r5526 r5593  
    8383      </nodes>
    8484    </associationConnector>
    85     <associationConnector edgePoints="[(7.4687475 : 3.73240397135417); (7.4687475 : 5.5)]" fixedFrom="Algorithm" fixedTo="Algorithm">
     85    <associationConnector edgePoints="[(7.4687475 : 3.73240397135417); (7.4687475 : 5.5)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    8686      <AssociationMoniker Name="/HiveDataContext/Job/Job_RequiredPlugin" />
    8787      <nodes>
     
    104104      </nodes>
    105105    </associationConnector>
    106     <associationConnector edgePoints="[(6.5 : 3.17870198567708); (6.125 : 3.17870198567708)]" fixedFrom="Algorithm" fixedTo="Algorithm">
     106    <associationConnector edgePoints="[(6.5 : 3.17870198567708); (6.125 : 3.17870198567708)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    107107      <AssociationMoniker Name="/HiveDataContext/Job/Job_HiveExperiment" />
    108108      <nodes>
     
    130130      </nodes>
    131131    </associationConnector>
    132     <associationConnector edgePoints="[(6.5 : 1.69314697265625); (6.125 : 1.69314697265625)]" fixedFrom="Algorithm" fixedTo="Algorithm">
     132    <associationConnector edgePoints="[(6.5 : 1.69314697265625); (6.125 : 1.69314697265625)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    133133      <AssociationMoniker Name="/HiveDataContext/Job/Job_JobData" />
    134134      <nodes>
     
    163163      </nestedChildShapes>
    164164    </classShape>
    165     <associationConnector edgePoints="[(6.5 : 2.50564697265625); (3.75 : 2.50564697265625)]" fixedFrom="Algorithm" fixedTo="Algorithm">
     165    <associationConnector edgePoints="[(6.5 : 2.50564697265625); (3.75 : 2.50564697265625)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    166166      <AssociationMoniker Name="/HiveDataContext/Job/Job_StateLog" />
    167167      <nodes>
     
    170170      </nodes>
    171171    </associationConnector>
    172     <associationConnector edgePoints="[(11.25 : 1.78929768880208); (10.9375 : 1.78929768880208); (10.9375 : 0.6875); (2.75 : 0.6875); (2.75 : 1)]" fixedFrom="Algorithm" fixedTo="Algorithm">
     172    <associationConnector edgePoints="[(11.25 : 1.78929768880208); (10.9375 : 1.78929768880208); (10.9375 : 0.6875); (2.75 : 0.6875); (2.75 : 1)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    173173      <AssociationMoniker Name="/HiveDataContext/Resource/Resource_StateLog" />
    174174      <nodes>
     
    184184      </nodes>
    185185    </associationConnector>
     186    <classShape Id="b4e7aaa8-a382-4560-a1fd-498de77e9340" absoluteBounds="1.75, 5.5, 2, 1.1939925130208327">
     187      <DataClassMoniker Name="/HiveDataContext/Lifecycle" />
     188      <nestedChildShapes>
     189        <elementListCompartment Id="03597a2c-5c5d-4c2c-b741-c49ab5aa34d5" absoluteBounds="1.7650000000000001, 5.96, 1.9700000000000002, 0.63399251302083326" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />
     190      </nestedChildShapes>
     191    </classShape>
    186192  </nestedChildShapes>
    187193</ordesignerObjectsDiagram>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDataContext.designer.cs

    r5526 r5593  
    6464    partial void UpdateHiveExperimentPermission(HiveExperimentPermission instance);
    6565    partial void DeleteHiveExperimentPermission(HiveExperimentPermission instance);
     66    partial void InsertLifecycle(Lifecycle instance);
     67    partial void UpdateLifecycle(Lifecycle instance);
     68    partial void DeleteLifecycle(Lifecycle instance);
    6669    #endregion
    6770   
     
    175178      {
    176179        return this.GetTable<HiveExperimentPermission>();
     180      }
     181    }
     182   
     183    public System.Data.Linq.Table<Lifecycle> Lifecycles
     184    {
     185      get
     186      {
     187        return this.GetTable<Lifecycle>();
    177188      }
    178189    }
     
    31903201    }
    31913202  }
     3203 
     3204  [global::System.Data.Linq.Mapping.TableAttribute(Name="")]
     3205  public partial class Lifecycle : INotifyPropertyChanging, INotifyPropertyChanged
     3206  {
     3207   
     3208    private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
     3209   
     3210    private int _LifecycleId;
     3211   
     3212    private System.DateTime _LastCleanup;
     3213   
     3214    #region Extensibility Method Definitions
     3215    partial void OnLoaded();
     3216    partial void OnValidate(System.Data.Linq.ChangeAction action);
     3217    partial void OnCreated();
     3218    partial void OnLifecycleIdChanging(int value);
     3219    partial void OnLifecycleIdChanged();
     3220    partial void OnLastCleanupChanging(System.DateTime value);
     3221    partial void OnLastCleanupChanged();
     3222    #endregion
     3223   
     3224    public Lifecycle()
     3225    {
     3226      OnCreated();
     3227    }
     3228   
     3229    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_LifecycleId", DbType="Int", IsPrimaryKey=true)]
     3230    public int LifecycleId
     3231    {
     3232      get
     3233      {
     3234        return this._LifecycleId;
     3235      }
     3236      set
     3237      {
     3238        if ((this._LifecycleId != value))
     3239        {
     3240          this.OnLifecycleIdChanging(value);
     3241          this.SendPropertyChanging();
     3242          this._LifecycleId = value;
     3243          this.SendPropertyChanged("LifecycleId");
     3244          this.OnLifecycleIdChanged();
     3245        }
     3246      }
     3247    }
     3248   
     3249    [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_LastCleanup", DbType="DateTime")]
     3250    public System.DateTime LastCleanup
     3251    {
     3252      get
     3253      {
     3254        return this._LastCleanup;
     3255      }
     3256      set
     3257      {
     3258        if ((this._LastCleanup != value))
     3259        {
     3260          this.OnLastCleanupChanging(value);
     3261          this.SendPropertyChanging();
     3262          this._LastCleanup = value;
     3263          this.SendPropertyChanged("LastCleanup");
     3264          this.OnLastCleanupChanged();
     3265        }
     3266      }
     3267    }
     3268   
     3269    public event PropertyChangingEventHandler PropertyChanging;
     3270   
     3271    public event PropertyChangedEventHandler PropertyChanged;
     3272   
     3273    protected virtual void SendPropertyChanging()
     3274    {
     3275      if ((this.PropertyChanging != null))
     3276      {
     3277        this.PropertyChanging(this, emptyChangingEventArgs);
     3278      }
     3279    }
     3280   
     3281    protected virtual void SendPropertyChanged(String propertyName)
     3282    {
     3283      if ((this.PropertyChanged != null))
     3284      {
     3285        this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
     3286      }
     3287    }
     3288  }
    31923289}
    31933290#pragma warning restore 1591
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Interfaces/IHiveDao.cs

    r5526 r5593  
    100100    Guid GetExperimentForJob(Guid jobId);
    101101    #endregion
     102
     103    #region Lifecycle Methods
     104    DateTime GetLastCleanup();
     105    void SetLastCleanup(DateTime datetime);
     106    #endregion
    102107  }
    103108}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/Mocks/MockLifecycleManager.cs

    r5405 r5593  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using HeuristicLab.Services.Hive.Common;
    25 using HeuristicLab.Services.Hive.Common.DataTransfer;
    2622
    2723namespace HeuristicLab.Services.Hive.Tests.Mocks {
    2824  public class MockLifecycleManager : ILifecycleManager {
    29 
    30     public void Start() { }
    31 
    32     public void Stop() { }
     25    public void Cleanup() { }
    3326  }
    3427}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/ServiceTests.cs

    r5526 r5593  
    2323using System.Collections.Generic;
    2424using System.Linq;
    25 using System.Threading;
    2625using HeuristicLab.Services.Hive.Common;
    2726using HeuristicLab.Services.Hive.Common.DataTransfer;
     
    242241
    243242      // lifecycle - let it process one server-heartbeat; the parent job must NOT be set to finished
    244       var lifecycleManager = new LifecycleManager();
    245       lifecycleManager.Start();
    246       Thread.Sleep(1000);
    247       lifecycleManager.Stop();
     243      service.TriggerLifecycle();
    248244
    249245      parentJobLoaded = service.GetJob(parentJob.Id);
     
    255251
    256252      // lifecycle - let it process one server-heartbeat; this should set the parent job to finished
    257       lifecycleManager.Start();
    258       Thread.Sleep(1000);
    259       lifecycleManager.Stop();
     253      service.TriggerLifecycle();
    260254
    261255      // test if parent job is finished
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Web/Hive-3.4/Web.config

    r5591 r5593  
    7070
    7171  <system.webServer>
    72     <modules runAllManagedModulesForAllRequests="true">
     72    <!--<modules runAllManagedModulesForAllRequests="true">
    7373      <add name="HiveServerModule" type="HeuristicLab.Services.Hive.IISModules.HiveServerModule"/>
    74     </modules>
     74    </modules>-->
    7575    <directoryBrowse enabled="true"/>
    7676  </system.webServer>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HeuristicLab.Services.Hive-3.4.csproj

    r5405 r5593  
    115115    <Compile Include="Interfaces\ILifecycleManager.cs" />
    116116    <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>
    124117    <Compile Include="AuthorizationManager.cs" />
    125118    <Compile Include="HeuristicLabServicesHivePlugin.cs" />
     
    148141  </ItemGroup>
    149142  <ItemGroup>
    150     <EmbeddedResource Include="Standalone\MainForm.resx">
    151       <DependentUpon>MainForm.cs</DependentUpon>
    152     </EmbeddedResource>
     143    <Folder Include="Standalone\" />
    153144  </ItemGroup>
    154145  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HiveService.cs

    r5535 r5593  
    229229    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
    230230    public List<MessageContainer> Heartbeat(Heartbeat heartbeat) {
     231      TriggerLifecycle();
     232
    231233      using (trans.OpenTransaction()) {
    232234        return heartbeatManager.ProcessHeartbeat(heartbeat);
     
    255257    // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
    256258    public IEnumerable<Plugin> GetPlugins() {
    257       return dao.GetPlugins(x => true);
     259      return dao.GetPlugins(x => x.IsLocal == false);
    258260    }
    259261
     
    382384      }
    383385    }
     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    }
    384396    #endregion
    385397
  • 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
    82namespace HeuristicLab.Services.Hive {
    93  /// <summary>
     
    115  /// </summary>
    126  public interface ILifecycleManager {
    13     void Start();
    14 
    15     void Stop();
     7    void Cleanup();
    168  }
    179}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/LifecycleManager.cs

    r5526 r5593  
    11using System;
    22using System.Linq;
    3 using HeuristicLab.Core;
    43using HeuristicLab.Services.Hive.Common;
    54using HeuristicLab.Services.Hive.Common.DataTransfer;
     
    76namespace HeuristicLab.Services.Hive {
    87  /// <summary>
    9   /// This class holds the state of all recent heartbeats and decides to reschedule jobs and set slaves offline
     8  /// This class offers methods for cleaning up offline slaves and jobs
    109  /// </summary>
    1110  public class LifecycleManager : ILifecycleManager {
     
    1918      get { return ServiceLocator.Instance.AuthorizationManager; }
    2019    }
    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); }
    2922    }
    3023
    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();
    6428    }
    6529
     
    10165      }
    10266    }
     67
    10368  }
    10469}
Note: See TracChangeset for help on using the changeset viewer.