Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1088


Ignore:
Timestamp:
01/07/09 17:04:39 (15 years ago)
Author:
msteinbi
Message:

Started implementation of Lifecycle Management for CLient Communicator (#453)

Location:
trunk/sources
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Contracts/Interfaces/ILifecycleManager.cs

    r948 r1088  
    2525using System.Text;
    2626
    27 namespace HeuristicLab.Hive.Contracts.Interfaces {
     27namespace HeuristicLab.Hive.Contracts.Interfaces {   
    2828  /// <summary>
    2929  /// Manages the lifecycle of the application
    3030  /// </summary>
    31   public interface ILifecycleManager {
     31  public interface ILifecycleManager {   
    3232    /// <summary>
    3333    /// Initializes the application
    3434    /// </summary>
    3535    void Init();
     36
     37    /// <summary>
     38    /// The server heartbeat
     39    /// </summary>
     40    event EventHandler OnServerHeartbeat;
    3641
    3742    /// <summary>
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/CachedDataAdapter.cs

    r1029 r1088  
    5252    }
    5353
     54    [MethodImpl(MethodImplOptions.Synchronized)]
    5455    protected virtual RowT FindSingleRow(Selector dbSelector,
    5556      Selector cacheSelector) {
     
    6667    }
    6768
     69    [MethodImpl(MethodImplOptions.Synchronized)]
    6870    protected virtual IEnumerable<RowT> FindMultipleRows(Selector dbSelector,
    6971        Selector cacheSelector) {
     
    8385    }
    8486
     87    [MethodImpl(MethodImplOptions.Synchronized)]
    8588    protected virtual ObjT FindSingle(Selector dbSelector,
    8689      Selector cacheSelector) {
     
    97100    }
    98101
     102    [MethodImpl(MethodImplOptions.Synchronized)]
    99103    protected virtual ICollection<ObjT> FindMultiple(Selector dbSelector,
    100104      Selector cacheSelector) {
     
    142146    }
    143147
     148    [MethodImpl(MethodImplOptions.Synchronized)]
    144149    protected override RowT GetRowById(long id) {
    145150      RowT row =
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/DataAdapterBase.cs

    r1025 r1088  
    5151    protected delegate IEnumerable<RowT> Selector();
    5252
     53    [MethodImpl(MethodImplOptions.Synchronized)]
    5354    protected virtual RowT FindSingleRow(Selector selector) {
    5455      RowT row = default(RowT);
     
    6364    }
    6465
     66    [MethodImpl(MethodImplOptions.Synchronized)]
    6567    protected virtual ObjT FindSingle(Selector selector) {
    6668      RowT row = FindSingleRow(selector);
     
    7678    }
    7779
     80    [MethodImpl(MethodImplOptions.Synchronized)]
    7881    protected virtual ICollection<ObjT> FindMultiple(Selector selector) {
    7982      IEnumerable<RowT> found =
     
    9295    }
    9396
     97    [MethodImpl(MethodImplOptions.Synchronized)]
    9498    protected virtual RowT GetRowById(long id) {
    9599      return FindSingleRow(
     
    117121    }
    118122
     123    [MethodImpl(MethodImplOptions.Synchronized)]
    119124    public virtual ObjT GetById(long id) {
    120125      return FindSingle(delegate() {
     
    123128    }
    124129
     130    [MethodImpl(MethodImplOptions.Synchronized)]
    125131    public virtual ICollection<ObjT> GetAll() {
    126132      return new List<ObjT>(
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/HeuristicLab.Hive.Server.ADODataAccess.csproj

    r1000 r1088  
    9494  </ItemGroup>
    9595  <ItemGroup>
     96    <None Include="app.config" />
    9697    <None Include="dsHiveServer.xsc">
    9798      <DependentUpon>dsHiveServer.xsd</DependentUpon>
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/Properties/Settings.Designer.cs

    r826 r1088  
    2727        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    2828        [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)]
    29         [global::System.Configuration.DefaultSettingValueAttribute("Data Source=10.22.20.84;Initial Catalog=HiveServer;Persist Security Info=True;Use" +
    30             "r ID=hive;Password=hive")]
     29        [global::System.Configuration.DefaultSettingValueAttribute("Data Source=10.22.20.84;Initial Catalog=HiveServer;MultipleActiveResultSets=True;" +
     30            "Persist Security Info=True;User ID=hive;Password=hive")]
    3131        public string HiveServerConnectionString {
    3232            get {
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/Properties/Settings.settings

    r826 r1088  
    66      <DesignTimeValue Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
    77&lt;SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
    8   &lt;ConnectionString&gt;Data Source=10.22.20.84;Initial Catalog=HiveServer;Persist Security Info=True;User ID=hive;Password=hive&lt;/ConnectionString&gt;
     8  &lt;ConnectionString&gt;Data Source=10.22.20.84;Initial Catalog=HiveServer;MultipleActiveResultSets=True;Persist Security Info=True;User ID=hive;Password=hive&lt;/ConnectionString&gt;
    99  &lt;ProviderName&gt;System.Data.SqlClient&lt;/ProviderName&gt;
    1010&lt;/SerializableConnectionString&gt;</DesignTimeValue>
    11       <Value Profile="(Default)">Data Source=10.22.20.84;Initial Catalog=HiveServer;Persist Security Info=True;User ID=hive;Password=hive</Value>
     11      <Value Profile="(Default)">Data Source=10.22.20.84;Initial Catalog=HiveServer;MultipleActiveResultSets=True;Persist Security Info=True;User ID=hive;Password=hive</Value>
    1212    </Setting>
    1313  </Settings>
  • trunk/sources/HeuristicLab.Hive.Server.Core/ClientCommunicator.cs

    r1022 r1088  
    1818  public class ClientCommunicator: IClientCommunicator {
    1919    int nrOfJobs = 0;
     20    Dictionary<Guid, DateTime> lastHeartbeats;
    2021
    2122    IClientAdapter clientAdapter;
    2223    IJobAdapter jobAdapter;
    2324    IJobResultsAdapter jobResultAdapter;
     25    ILifecycleManager lifecycleManager;
    2426
    2527    public ClientCommunicator() {
     
    2729      jobAdapter = ServiceLocator.GetJobAdapter();
    2830      jobResultAdapter = ServiceLocator.GetJobResultsAdapter();
     31      lifecycleManager = ServiceLocator.GetLifecycleManager();
     32
     33      lifecycleManager.OnServerHeartbeat +=
     34        new EventHandler(lifecycleManager_OnServerHeartbeat);
    2935
    3036      for (int i = 0; i < nrOfJobs; i++) {
     
    3440        jobAdapter.Update(job);
    3541      }
     42      lastHeartbeats = new Dictionary<Guid, DateTime>();
    3643
     44    }
     45
     46    void lifecycleManager_OnServerHeartbeat(object sender, EventArgs e) {
     47      List<ClientInfo> allClients = new List<ClientInfo>(clientAdapter.GetAll());
     48
     49      foreach (ClientInfo client in allClients) {
     50       
     51      }
    3752    }
    3853
     
    5873    public ResponseHB SendHeartBeat(HeartBeatData hbData) {
    5974      ResponseHB response = new ResponseHB();
     75
     76      if (lastHeartbeats.ContainsKey(hbData.ClientId)) {
     77        lastHeartbeats[hbData.ClientId] = DateTime.Now;
     78      } else {
     79        lastHeartbeats.Add(hbData.ClientId, DateTime.Now);
     80      }
    6081
    6182      response.Success = true;
  • trunk/sources/HeuristicLab.Hive.Server.Core/LifecycleManager.cs

    r948 r1088  
    2626using HeuristicLab.Hive.Contracts.Interfaces;
    2727using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess;
     28using System.Timers;
    2829
    2930namespace HeuristicLab.Hive.Server.Core {
    3031  class LifecycleManager: ILifecycleManager {
     32    private static Timer timer =
     33      new Timer();
     34
    3135    #region ILifecycleManager Members
     36    public event EventHandler OnServerHeartbeat;
     37
     38    public LifecycleManager() {
     39      timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
     40    }
    3241
    3342    public void Init() {
    34       //nothing to do
     43      timer.Interval = new TimeSpan(0, 0, 10).TotalMilliseconds; // TODO: global constant needed
     44      timer.Start();
     45    }
     46
     47    void timer_Elapsed(object sender, ElapsedEventArgs e) {
     48      if (OnServerHeartbeat != null)
     49        OnServerHeartbeat(this, null);
    3550    }
    3651
  • trunk/sources/HeuristicLab.Hive.Server.Core/ServiceLocator.cs

    r1005 r1088  
    4949
    5050  private static IJobResultsAdapter jobResultsAdapter = null;
     51
     52  private static ILifecycleManager lifecycleManager = null;
    5153
    5254  /// <summary>
     
    166168    return jobResultsAdapter;
    167169  }
     170
     171  /// <summary>
     172  /// Gets the lifecycle manager
     173  /// </summary>
     174  /// <returns></returns>
     175  [MethodImpl(MethodImplOptions.Synchronized)]
     176  public static ILifecycleManager GetLifecycleManager() {
     177    if (lifecycleManager == null) {
     178      lifecycleManager = discoveryService.GetInstances<ILifecycleManager>()[0];
     179    }
     180
     181    return lifecycleManager;
     182  }
    168183}
Note: See TracChangeset for help on using the changeset viewer.