public DeliveryThrottlingLogData(ThrottlingScope scope, ThrottlingResource resource, double resourceThreshold, ThrottlingImpactUnits impactUnits, uint impact, long total, Guid externalOrganizationId, string recipient, string mdbName, IList <KeyValuePair <string, double> > mdbHealth, IList <KeyValuePair <string, string> > customData) { this.ThrottlingScope = scope; this.ThrottlingResource = resource; this.Threshold = resourceThreshold; this.ImpactUnits = impactUnits; this.Impact = impact; this.Total = total; this.ExternalOrganizationId = externalOrganizationId; this.Recipient = recipient; this.MDBName = mdbName; this.MDBHealth = mdbHealth; this.CustomData = customData; }
public void LogSummary(string sequenceNumber, ThrottlingScope scope, ThrottlingResource resource, double resourceThreshold, ThrottlingImpactUnits impactUnits, uint impact, double impactRate, Guid externalOrganizationId, string recipient, string mdbName, IList <KeyValuePair <string, double> > mdbHealth, IList <KeyValuePair <string, string> > customData) { if (!this.enabled) { return; } ArgumentValidator.ThrowIfNullOrEmpty("sequenceNumber", sequenceNumber); LogRowFormatter logRowFormatter = new LogRowFormatter(DeliveryThrottlingLog.logSchema); logRowFormatter[2] = sequenceNumber; logRowFormatter[1] = ThrottlingEvent.SummaryThrottle; logRowFormatter[3] = scope; logRowFormatter[4] = resource; if (!resourceThreshold.Equals(double.NaN)) { logRowFormatter[5] = resourceThreshold; } logRowFormatter[6] = impactUnits; logRowFormatter[7] = impact; logRowFormatter[8] = impactRate; if (externalOrganizationId != Guid.Empty) { logRowFormatter[9] = externalOrganizationId; } if (!string.IsNullOrEmpty(recipient)) { logRowFormatter[10] = recipient; } if (!string.IsNullOrEmpty(mdbName)) { logRowFormatter[11] = mdbName; } if (mdbHealth != null && mdbHealth.Count > 0) { logRowFormatter[12] = mdbHealth; } if (customData != null && customData.Count > 0) { logRowFormatter[13] = customData; } this.Append(logRowFormatter); }
public void TrackMDBThrottle(bool isThrottle, string mdbName, double mdbResourceThreshold, List <KeyValuePair <string, double> > healthMonitorList, ThrottlingResource throttleResource) { if (!this.deliveryThrottlingLog.Enabled) { return; } List <KeyValuePair <string, string> > list = new List <KeyValuePair <string, string> >(); if (string.IsNullOrEmpty(mdbName)) { list.Add(new KeyValuePair <string, string>("InvalidMDBName", (mdbName == null) ? "NULL" : "EMPTY")); mdbName = string.Empty; } if (!mdbResourceThreshold.Equals(double.NaN) && mdbResourceThreshold <= 0.0) { list.Add(new KeyValuePair <string, string>("InvalidMDBResourceThreshold", mdbResourceThreshold.ToString("F0", NumberFormatInfo.InvariantInfo))); mdbResourceThreshold = double.NaN; } if (list.Count == 0) { list = null; } Dictionary <string, DeliveryThrottlingLogData> dictionary = null; ReaderWriterLockSlim dictionaryLock = null; switch (throttleResource) { case ThrottlingResource.Threads: dictionary = this.mdbThrottleInfoDynamicThrottleDisabled; dictionaryLock = this.mdbThrottleInfoDynamicThrottleDisabledLock; break; case ThrottlingResource.Threads_MaxPerHub: dictionary = this.mdbThrottleInfoPendingConnections; dictionaryLock = this.mdbThrottleInfoPendingConnectionsLock; break; case ThrottlingResource.Threads_PendingConnectionTimedOut: dictionary = this.mdbThrottleInfoTimeout; dictionaryLock = this.mdbThrottleInfoTimeoutLock; break; } this.TrackData(dictionary, dictionaryLock, mdbName, isThrottle, ThrottlingScope.MDB, throttleResource, mdbResourceThreshold, ThrottlingImpactUnits.Sessions, 1U, Guid.Empty, string.Empty, mdbName, healthMonitorList, list); }
private void TrackData(Dictionary <string, DeliveryThrottlingLogData> dictionary, ReaderWriterLockSlim dictionaryLock, string key, bool isThrottle, ThrottlingScope scope, ThrottlingResource resource, double threshold, ThrottlingImpactUnits impactUnits, uint impactDelta, Guid tenantID, string recipient, string mdbName, IList <KeyValuePair <string, double> > health, IList <KeyValuePair <string, string> > customData) { if (dictionary == null) { throw new ArgumentNullException("dictionary"); } if (dictionaryLock == null) { throw new ArgumentNullException("dictionaryLock"); } dictionaryLock.EnterWriteLock(); try { if (dictionary.ContainsKey(key)) { if (isThrottle) { dictionary[key].Impact += impactDelta; } dictionary[key].Total += (long)((ulong)impactDelta); if (dictionary[key].MDBHealth == null && health != null && health.Count > 0) { dictionary[key].MDBHealth = health; } if (dictionary[key].CustomData == null && customData != null && customData.Count > 0) { dictionary[key].CustomData = customData; } } else { DeliveryThrottlingLogData value; if (isThrottle) { value = new DeliveryThrottlingLogData(scope, resource, threshold, impactUnits, impactDelta, (long)((ulong)impactDelta), tenantID, recipient, mdbName, health, customData); } else { value = new DeliveryThrottlingLogData(scope, resource, threshold, impactUnits, 0U, (long)((ulong)impactDelta), tenantID, recipient, mdbName, health, customData); } dictionary.Add(key, value); } } finally { dictionaryLock.ExitWriteLock(); } }