Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9526


Ignore:
Timestamp:
05/24/13 14:45:51 (12 years ago)
Author:
pfleck
Message:

#2063
Added StatisticsGenerator for generating statistic data for Hive.
ServiceLocator returns the StatisticsGenerator.
Integrated StatisticsGenerator in Janitor service for periodic calls.

Location:
branches/HiveStatistics/sources
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive.JanitorService/3.3/JanitorService.cs

    r7259 r9526  
    2626  public partial class JanitorService : ServiceBase {
    2727    private HiveJanitor janitor;
    28     private Thread janitorThread;
     28    private Thread janitorCleanupThread;
     29    private Thread janitorGenerateStatisticsThread;
    2930
    3031    public JanitorService() {
     
    3536      janitor = new HiveJanitor();
    3637
    37       janitorThread = new Thread(janitor.Run);
    38       janitorThread.IsBackground = true; //dont keep app alive
    39       janitorThread.Start();
     38      janitorCleanupThread = new Thread(janitor.RunCleanup) {
     39        IsBackground = true
     40      };
     41      janitorGenerateStatisticsThread = new Thread(janitor.RunGenerateStatistics) {
     42        IsBackground = true
     43      };
     44
     45      janitorCleanupThread.Start();
     46      janitorGenerateStatisticsThread.Start();
    4047    }
    4148
    4249    protected override void OnStop() {
    4350      janitor.StopJanitor();
    44       janitorThread.Join();
     51      janitorCleanupThread.Join();
     52      janitorGenerateStatisticsThread.Join();
    4553    }
    4654  }
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/HeuristicLab.Services.Hive-3.3.csproj

    r9434 r9526  
    137137    <Compile Include="DataTransfer\Statistics.cs" />
    138138    <Compile Include="DataTransfer\UserStatistics.cs" />
     139    <Compile Include="HiveStatisticsGenerator.cs" />
     140    <Compile Include="Interfaces\IStatisticsGenerator.cs" />
    139141    <Compile Include="OptimizedHiveDao.cs" />
    140142    <Compile Include="HiveDao.cs" />
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/HiveJanitor.cs

    r9434 r9526  
    2727  public class HiveJanitor {
    2828    private bool stop;
    29     private AutoResetEvent waitHandle;
     29    private AutoResetEvent cleanupWaitHandle;
     30    private AutoResetEvent generateStatisticsWaitHandle;
    3031
    3132    private DataAccess.ITransactionManager trans {
     
    3738    }
    3839
     40    private IStatisticsGenerator statisticsGenerator {
     41      get { return ServiceLocator.Instance.StatisticsGenerator; }
     42    }
     43
    3944    private IHiveDao dao {
    4045      get { return ServiceLocator.Instance.HiveDao; }
     
    4348    public HiveJanitor() {
    4449      stop = false;
    45       waitHandle = new AutoResetEvent(true);
     50      cleanupWaitHandle = new AutoResetEvent(true);
     51      generateStatisticsWaitHandle = new AutoResetEvent(true);
    4652    }
    4753
    4854    public void StopJanitor() {
    4955      stop = true;
    50       waitHandle.Set();
     56      cleanupWaitHandle.Set();
    5157    }
    5258
    53     public void Run() {
     59    public void RunCleanup() {
    5460      while (!stop) {
    5561        try {
     
    7278          LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log(string.Format("HiveJanitor: The following exception occured: {0}", e.ToString()));
    7379        }
    74         waitHandle.WaitOne(HeuristicLab.Services.Hive.Properties.Settings.Default.CleanupInterval);
     80        cleanupWaitHandle.WaitOne(HeuristicLab.Services.Hive.Properties.Settings.Default.CleanupInterval);
    7581      }
    76       waitHandle.Close();
     82      cleanupWaitHandle.Close();
     83    }
     84
     85    public void RunGenerateStatistics() {
     86      while (!stop) {
     87        try {
     88          LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: starting generate statistics");
     89          statisticsGenerator.GenerateStatistics();
     90          LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: generate statistics finished");
     91        }
     92        catch (Exception e) {
     93          LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log(string.Format("HiveJanitor: The following exception occured: {0}", e));
     94        }
     95
     96        generateStatisticsWaitHandle.WaitOne(Properties.Settings.Default.GenerateStatisticsInterval);
     97      }
     98
     99      generateStatisticsWaitHandle.Close();
    77100    }
    78101  }
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/Interfaces/IServiceLocator.cs

    r9434 r9526  
    2929    IOptimizedHiveDao OptimizedHiveDao { get; }
    3030    IEventManager EventManager { get; }
     31    IStatisticsGenerator StatisticsGenerator { get; }
    3132    ITransactionManager TransactionManager { get; }
    3233    Access.IUserManager UserManager { get; }
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/Properties/Settings.Designer.cs

    r9123 r9526  
    22// <auto-generated>
    33//     This code was generated by a tool.
    4 //     Runtime Version:4.0.30319.17929
     4//     Runtime Version:4.0.30319.18034
    55//
    66//     Changes to this file may cause incorrect behavior and will be lost if
     
    8686            }
    8787        }
     88       
     89        [global::System.Configuration.ApplicationScopedSettingAttribute()]
     90        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     91        [global::System.Configuration.DefaultSettingValueAttribute("00:05:00")]
     92        public global::System.TimeSpan GenerateStatisticsInterval {
     93            get {
     94                return ((global::System.TimeSpan)(this["GenerateStatisticsInterval"]));
     95            }
     96        }
    8897    }
    8998}
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/Properties/Settings.settings

    r9123 r9526  
    2424      <Value Profile="(Default)">00:00:20</Value>
    2525    </Setting>
     26    <Setting Name="GenerateStatisticsInterval" Type="System.TimeSpan" Scope="Application">
     27      <Value Profile="(Default)">00:05:00</Value>
     28    </Setting>
    2629  </Settings>
    2730</SettingsFile>
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/ServiceLocator.cs

    r9434 r9526  
    7474    }
    7575
     76    private IStatisticsGenerator statisticsGenerator;
     77    public IStatisticsGenerator StatisticsGenerator {
     78      get { return statisticsGenerator ?? (statisticsGenerator = new HiveStatisticsGenerator()); }
     79    }
     80
    7681    private ITransactionManager transactionManager;
    7782    public ITransactionManager TransactionManager {
  • branches/HiveStatistics/sources/HeuristicLab.Services.Hive/3.3/app.config

    r9123 r9526  
    2929                <value>00:00:20</value>
    3030            </setting>
     31            <setting name="GenerateStatisticsInterval" serializeAs="String">
     32                <value>00:05:00</value>
     33            </setting>
    3134        </HeuristicLab.Services.Hive.Properties.Settings>
    3235    </applicationSettings>
Note: See TracChangeset for help on using the changeset viewer.