public bool CheckAndTrackDynamicThrottleMDBTimeout(Guid databaseGuid, IMailboxDatabaseConnectionInfo mdbConnectionInfo, IMailboxDatabaseConnectionManager mdbConnectionManager, long smtpSessionId, IPAddress sessionRemoteEndPointAddress, TimeSpan connectionWaitTime, List <KeyValuePair <string, double> > mdbHealthMonitorValues)
 {
     ArgumentValidator.ThrowIfNull("databaseGuid", databaseGuid);
     ArgumentValidator.ThrowIfNull("mdbConnectionManager", mdbConnectionManager);
     ArgumentValidator.ThrowIfNull("sessionRemoteEndPointAddress", sessionRemoteEndPointAddress);
     if (!mdbConnectionManager.TryAcquire(smtpSessionId, sessionRemoteEndPointAddress, connectionWaitTime, out mdbConnectionInfo))
     {
         DeliveryThrottling.Diag.TraceDebug <Guid, long, IPAddress>(0, (long)this.GetHashCode(), "Dynamic Throttling: Connection was unable to be acquired. Dynamic Throttling Limit Exceeded. MDB {0} SessionId {1} IP {2}", databaseGuid, smtpSessionId, sessionRemoteEndPointAddress);
         this.DeliveryThrottlingLogWorker.TrackMDBThrottle(true, databaseGuid.ToString(), (double)DeliveryConfiguration.Instance.Throttling.MaxMailboxDeliveryPerMdbConnections, mdbHealthMonitorValues, ThrottlingResource.Threads_PendingConnectionTimedOut);
         return(false);
     }
     DeliveryThrottling.Diag.TraceDebug <Guid, long, IPAddress>(0, (long)this.GetHashCode(), "Dynamic Throttling: Connection was acquired. MDB {0} SessionId {1} IP {2}", databaseGuid, smtpSessionId, sessionRemoteEndPointAddress);
     this.DeliveryThrottlingLogWorker.TrackMDBThrottle(false, databaseGuid.ToString(), (double)DeliveryConfiguration.Instance.Throttling.MaxMailboxDeliveryPerMdbConnections, mdbHealthMonitorValues, ThrottlingResource.Threads_PendingConnectionTimedOut);
     return(true);
 }
Exemple #2
0
        public bool Release(ref IMailboxDatabaseConnectionInfo mdbConnectionInfo)
        {
            if (mdbConnectionInfo == null)
            {
                throw new ArgumentNullException("mdbConnectionInfo");
            }
            if (this.connections.Count == 0)
            {
                return(false);
            }
            long smtpSessionId = mdbConnectionInfo.SmtpSessionId;

            mdbConnectionInfo = null;
            this.UpdateLastActivityTime(smtpSessionId);
            lock (this.syncObject)
            {
                this.DeactivateConnection(smtpSessionId);
                this.ActivateNextConnection();
            }
            return(true);
        }
Exemple #3
0
        public bool TryAcquire(long smtpSessionId, IPAddress remoteIPAddress, TimeSpan timeout, out IMailboxDatabaseConnectionInfo mdbConnectionInfo)
        {
            bool result;

            try
            {
                mdbConnectionInfo = this.Acquire(smtpSessionId, remoteIPAddress, timeout);
                result            = true;
            }
            catch (InvalidOperationException)
            {
                mdbConnectionInfo = null;
                result            = false;
            }
            return(result);
        }