Ejemplo n.º 1
0
 /// <summary>
 /// Creates a new server core
 /// </summary>
 /// <param name="baseLocation">Path to the stores directory</param>
 /// <param name="storeName">Name of store</param>
 public StoreWorker(string baseLocation, string storeName)
 {
     _baseLocation  = baseLocation;
     _storeName     = storeName;
     _storeLocation = Path.Combine(baseLocation, storeName);
     Logging.LogInfo("StoreWorker created with location {0}", _storeLocation);
     _jobs = new ConcurrentQueue <Job>();
     _jobExecutionStatus = new ConcurrentDictionary <string, JobExecutionStatus>();
     _storeManager       = StoreManagerFactory.GetStoreManager();
     _transactionLog     = _storeManager.GetTransactionLog(_storeLocation);
     _storeStatisticsLog = _storeManager.GetStatisticsLog(_storeLocation);
     _statsMonitor       = new StatsMonitor();
     InitializeStatsMonitor();
     _shutdownCompleted = new ManualResetEvent(false);
 }
Ejemplo n.º 2
0
 public void TestTriggerByTransaction()
 {
     Configuration.StatsUpdateTransactionCount = 10;
      Configuration.StatsUpdateTimespan = 0;
     bool triggered = false;
     var statsMonitor = new StatsMonitor();
     statsMonitor.Initialize(new StoreStatistics(10UL, DateTime.UtcNow, 0UL, new Dictionary<string, ulong>()),
         18UL, () => { triggered = true; });
     statsMonitor.OnJobScheduled();
     Assert.IsFalse(triggered);
     statsMonitor.OnJobScheduled();
     Assert.IsTrue(triggered);
      triggered = false;
      statsMonitor.OnJobScheduled();
      Assert.IsFalse(triggered, "Monitor should not retrigger on txn immediately after firing.");
 }
Ejemplo n.º 3
0
 public void TestTriggerByTimespan()
 {
     Configuration.StatsUpdateTimespan = 60;
     Configuration.StatsUpdateTransactionCount = 0;
     bool triggered = false;
     var statsMonitor = new StatsMonitor();
     statsMonitor.Initialize(new StoreStatistics(10UL, DateTime.UtcNow.Subtract(TimeSpan.FromSeconds(59)),0UL, new Dictionary<string, ulong>()),
         12UL, () => { triggered = true; });
     statsMonitor.OnJobScheduled();
     Assert.IsFalse(triggered);
     Thread.Sleep(TimeSpan.FromSeconds(2.0));
     statsMonitor.OnJobScheduled();
     Assert.IsTrue(triggered);
     triggered = false;
     statsMonitor.OnJobScheduled();
     Assert.IsFalse(triggered, "Monitor should not retrigger on time immediately after firing.");
 }
Ejemplo n.º 4
0
 public void TestTriggerByBoth()
 {
     Configuration.StatsUpdateTimespan = 60;
     Configuration.StatsUpdateTransactionCount = 6;
     bool triggered = false;
     var statsMonitor = new StatsMonitor();
     statsMonitor.Initialize(new StoreStatistics(10UL, DateTime.UtcNow.Subtract(TimeSpan.FromSeconds(59)), 0UL, new Dictionary<string, ulong>()),
         12UL, () => { triggered = true; });
     statsMonitor.OnJobScheduled(); // 13
     Assert.IsFalse(triggered);
     Thread.Sleep(TimeSpan.FromSeconds(2.0));
     statsMonitor.OnJobScheduled(); // 14
     Assert.IsFalse(triggered);
     statsMonitor.OnJobScheduled(); // 15
     Assert.IsFalse(triggered);
     statsMonitor.OnJobScheduled(); // 16 - should trigger udpate
     Assert.IsTrue(triggered);
     triggered = false;
     // Subsequent job should not re-trigger
     statsMonitor.OnJobScheduled();
     Assert.IsFalse(triggered);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates a new server core 
 /// </summary>
 /// <param name="baseLocation">Path to the stores directory</param>
 /// <param name="storeName">Name of store</param>
 public StoreWorker(string baseLocation, string storeName)
 {
     _baseLocation = baseLocation;
     _storeName = storeName;
     _storeLocation = Path.Combine(baseLocation, storeName);
     Logging.LogInfo("StoreWorker created with location {0}", _storeLocation);
     _jobs = new ConcurrentQueue<Job>();
     _jobExecutionStatus = new ConcurrentDictionary<string, JobExecutionStatus>();
     _storeManager = StoreManagerFactory.GetStoreManager();
     _transactionLog = _storeManager.GetTransactionLog(_storeLocation);
     _storeStatisticsLog = _storeManager.GetStatisticsLog(_storeLocation);
     _statsMonitor = new StatsMonitor();
     InitializeStatsMonitor();
     _shutdownCompleted = new ManualResetEvent(false);
 }