private static bool CheckWriteToStatsLog() { int defaultValue = VariantConfiguration.InvariantNoFlightingSnapshot.MessageTracking.StatsLogging.Enabled ? 1 : 0; int num = ServerCache.TryReadRegistryKey <int>("WriteToStatsLog", defaultValue); return(num == 1); }
public void TestDelayOperation(string operation) { if (ServerCache.Instance.IsTimeoutOverrideConfigured) { lock (TrackingEventBudget.TestOperationCount) { string text = ServerCache.TryReadRegistryKey <string>(operation, string.Empty); if (!string.IsNullOrEmpty(text)) { string[] array = text.Split(new char[] { ':' }); int num = -1; HostId hostId = ServerCache.Instance.HostId; string y = Names <HostId> .Map[(int)hostId]; if (array.Length != 2 || !StringComparer.OrdinalIgnoreCase.Equals(array[0], y) || !int.TryParse(array[1], out num)) { TraceWrapper.SearchLibraryTracer.TraceError <string>(this.GetHashCode(), "TEST CODE: Invalid registry key: {0}", text); } else { int num2 = 0; if (!TrackingEventBudget.TestOperationCount.TryGetValue(operation, out num2)) { num2 = 0; } num2++; TrackingEventBudget.TestOperationCount[operation] = num2; if (num2 > num) { TraceWrapper.SearchLibraryTracer.TraceDebug <string, int>(this.GetHashCode(), "TEST CODE: Delaying {0} operation, count={1}", operation, num2); TimeSpan elapsed = this.timer.Elapsed; if (elapsed < this.timeBudgetAllowed) { int num3 = (int)(this.timeBudgetAllowed - elapsed).TotalMilliseconds; TraceWrapper.SearchLibraryTracer.TraceDebug <int>(this.GetHashCode(), "TEST CODE: Pause injected, sleeping away remaining budget: {0} milliseconds", num3); Thread.Sleep(num3); TrackingEventBudget.TestOperationCount.Clear(); } else { TraceWrapper.SearchLibraryTracer.TraceDebug <double>(this.GetHashCode(), "TEST CODE: Already over budget, sleep skipped. Elapsed time for this request: {0}", elapsed.TotalMilliseconds); } } else { TraceWrapper.SearchLibraryTracer.TraceDebug <int, string, int>(this.GetHashCode(), "TEST CODE: {0} {1} operations completed (will delay after {2})", num2, operation, num); } } } } } }