public bool TryGet(Guid database, IRequestContext requestContext, out BackEndServer backEndServer)
        {
            if (requestContext == null)
            {
                throw new ArgumentNullException("requestContext");
            }
            backEndServer = null;
            PerfCounters.HttpProxyCacheCountersInstance.BackEndServerLocalCacheHitsRateBase.Increment();
            PerfCounters.HttpProxyCacheCountersInstance.BackEndServerOverallCacheHitsRateBase.Increment();
            PerfCounters.IncrementMovingPercentagePerformanceCounterBase(PerfCounters.HttpProxyCacheCountersInstance.MovingPercentageBackEndServerLocalCacheHitsRate);
            PerfCounters.IncrementMovingPercentagePerformanceCounterBase(PerfCounters.HttpProxyCacheCountersInstance.MovingPercentageBackEndServerOverallCacheHitsRate);
            MailboxServerCacheEntry mailboxServerCacheEntry = null;
            bool flag  = false;
            bool flag2 = this.serversCache.TryGetValue(database, out mailboxServerCacheEntry);

            if (flag2)
            {
                if (MailboxServerCache.IsE14ServerStale(mailboxServerCacheEntry))
                {
                    this.Remove(database, requestContext);
                    return(false);
                }
                backEndServer = mailboxServerCacheEntry.BackEndServer;
                PerfCounters.HttpProxyCacheCountersInstance.BackEndServerLocalCacheHitsRate.Increment();
                PerfCounters.UpdateMovingPercentagePerformanceCounter(PerfCounters.HttpProxyCacheCountersInstance.MovingPercentageBackEndServerLocalCacheHitsRate);
                if (mailboxServerCacheEntry.IsDueForRefresh(MailboxServerCache.GetRefreshInterval(backEndServer)))
                {
                    flag = true;
                }
            }
            if (HttpProxySettings.MailboxServerLocatorSharedCacheEnabled.Value && (!flag2 || flag))
            {
                MailboxServerCacheEntry sharedCacheEntry = null;
                long   latency  = 0L;
                string diagInfo = null;
                bool   latency2 = LatencyTracker.GetLatency <bool>(() => this.sharedCacheClient.TryGet <MailboxServerCacheEntry>(database.ToString(), requestContext.ActivityId, out sharedCacheEntry, out diagInfo), out latency);
                requestContext.LogSharedCacheCall(latency, diagInfo);
                if (latency2 && (!flag2 || sharedCacheEntry.LastRefreshTime > mailboxServerCacheEntry.LastRefreshTime))
                {
                    this.Add(database, sharedCacheEntry, requestContext, false);
                    mailboxServerCacheEntry = sharedCacheEntry;
                    flag2 = true;
                }
            }
            if (flag2)
            {
                backEndServer = mailboxServerCacheEntry.BackEndServer;
                PerfCounters.HttpProxyCacheCountersInstance.BackEndServerOverallCacheHitsRate.Increment();
                PerfCounters.UpdateMovingPercentagePerformanceCounter(PerfCounters.HttpProxyCacheCountersInstance.MovingPercentageBackEndServerOverallCacheHitsRate);
                if (!this.LazyRefreshDisabled && mailboxServerCacheEntry.IsDueForRefresh(MailboxServerCache.GetRefreshInterval(mailboxServerCacheEntry.BackEndServer)))
                {
                    if (MailboxServerCache.BackgroundServerRefreshEnabled.Value)
                    {
                        this.RegisterRefresh(new DatabaseWithForest(database, mailboxServerCacheEntry.ResourceForest, requestContext.ActivityId));
                    }
                    RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(requestContext.Logger, "ServerLocatorRefresh", database);

                    RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(requestContext.Logger, "RefreshingCacheEntry", mailboxServerCacheEntry.ToString());
                }
            }
            return(flag2);
        }
Esempio n. 2
0
        // Token: 0x06000234 RID: 564 RVA: 0x0000AEE8 File Offset: 0x000090E8
        public bool TryGet(Guid database, IRequestContext requestContext, out MailboxServerCacheEntry cacheEntry)
        {
            cacheEntry = null;
            PerfCounters.HttpProxyCacheCountersInstance.BackEndServerLocalCacheHitsRateBase.Increment();
            PerfCounters.HttpProxyCacheCountersInstance.BackEndServerOverallCacheHitsRateBase.Increment();
            PerfCounters.IncrementMovingPercentagePerformanceCounterBase(PerfCounters.HttpProxyCacheCountersInstance.MovingPercentageBackEndServerLocalCacheHitsRate);
            PerfCounters.IncrementMovingPercentagePerformanceCounterBase(PerfCounters.HttpProxyCacheCountersInstance.MovingPercentageBackEndServerOverallCacheHitsRate);
            string key  = database.ToString();
            bool   flag = this.TryGetFromInMemoryCache(key, out cacheEntry);

            if (flag)
            {
                if (MailboxServerCache.IsE14ServerStale(cacheEntry))
                {
                    this.Remove(database, requestContext);
                    return(false);
                }
                PerfCounters.HttpProxyCacheCountersInstance.BackEndServerLocalCacheHitsRate.Increment();
                PerfCounters.UpdateMovingPercentagePerformanceCounter(PerfCounters.HttpProxyCacheCountersInstance.MovingPercentageBackEndServerLocalCacheHitsRate);
            }
            else
            {
                SharedCacheDiagnostics sharedCacheDiagnostics = null;
                flag = this.TryGetFromSharedCache(key, out cacheEntry, out sharedCacheDiagnostics);
                MailboxServerCache.LogSharedCacheDiagnostics(requestContext, sharedCacheDiagnostics);
                if (flag && this.TryAddToInMemoryCache(key, cacheEntry))
                {
                    this.UpdateInMemoryCacheSizeCounter();
                }
            }
            if (flag)
            {
                PerfCounters.HttpProxyCacheCountersInstance.BackEndServerOverallCacheHitsRate.Increment();
                PerfCounters.UpdateMovingPercentagePerformanceCounter(PerfCounters.HttpProxyCacheCountersInstance.MovingPercentageBackEndServerOverallCacheHitsRate);
                if (MailboxServerCache.InMemoryCacheEnabled.Value && MailboxServerCache.InternalRefreshEnabled.Value && cacheEntry.IsDueForRefresh(MailboxServerCache.GetRefreshInterval(cacheEntry.BackEndServer)))
                {
                    this.RegisterRefresh(new DatabaseWithForest(database, cacheEntry.ResourceForest, requestContext.ActivityId));
                    RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(requestContext.Logger, "ServerLocatorRefresh", database);

                    RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(requestContext.Logger, "RefreshingCacheEntry", cacheEntry.ToString());
                }
            }
            return(flag);
        }
        private bool IsDueForRefresh(Guid database)
        {
            MailboxServerCacheEntry mailboxServerCacheEntry;

            return(!this.serversCache.TryGetValue(database, out mailboxServerCacheEntry) || mailboxServerCacheEntry.IsDueForRefresh(MailboxServerCache.GetRefreshInterval(mailboxServerCacheEntry.BackEndServer)));
        }
Esempio n. 4
0
        // Token: 0x06000248 RID: 584 RVA: 0x0000B7DC File Offset: 0x000099DC
        private bool IsDueForRefresh(Guid database)
        {
            MailboxServerCacheEntry mailboxServerCacheEntry;

            return(!this.TryGetFromInMemoryCache(database.ToString(), out mailboxServerCacheEntry) || mailboxServerCacheEntry.IsDueForRefresh(MailboxServerCache.GetRefreshInterval(mailboxServerCacheEntry.BackEndServer)));
        }