public void RegisterRequest(string clientId, long requestId, long commandId, long lastAcknowledged) { if (RequestLoggingEnabled) { if (!String.IsNullOrEmpty(clientId)) { ClientRequestAccount account = new ClientRequestAccount(); lock (ledger) { if (!ledger.ContainsKey(clientId)) { ledger.Add(clientId, account); } else { account = (ClientRequestAccount)ledger[clientId]; } } size -= account.InMemorySize; account.RegisterRequest(requestId, commandId, lastAcknowledged); size += account.InMemorySize; _perfStatsCollector.IncrementRequestLogPerSec(); _perfStatsCollector.IncrementRequestLogCount(1); _perfStatsCollector.RequestLogSize = InMemorySize; } } }
public void Clean() { while (isRunning) { try { if (RequestLoggingEnabled) { string[] keys = new string[ledger.Count]; ledger.Keys.CopyTo(keys, 0); for (int i = 0; i < keys.Length; i++) { ClientRequestAccount account = (ClientRequestAccount)ledger[keys[i]]; size -= account.InMemorySize; int removed = account.Clean(cleanInterval); _perfStatsCollector.DecrementRequestLogCount(removed); if (account.Count == 0) { lock (ledger) { ledger.Remove(keys[i]); } } else { size += account.InMemorySize; } if (size < 0) { size = 0; } _perfStatsCollector.RequestLogSize = InMemorySize; } if (ledger.Count == 0) { _perfStatsCollector.RequestLogCount = 0; } if (ServiceConfiguration.RequestInquiryCleanInterval != CleanInterval) { cleanInterval = ServiceConfiguration.RequestInquiryCleanInterval; } } Thread.Sleep(cleanInterval * 1000); } catch (ThreadAbortException) { return; } catch (ThreadInterruptedException) { return; } } }