// Token: 0x06000247 RID: 583 RVA: 0x0000B750 File Offset: 0x00009950 private void PopulateCache(Dictionary <Guid, DatabaseToServerMappingInfo> databaseToServerMappingInfo, string resourceForest) { if (databaseToServerMappingInfo != null) { foreach (KeyValuePair <Guid, DatabaseToServerMappingInfo> keyValuePair in databaseToServerMappingInfo) { MailboxServerCacheEntry entry = new MailboxServerCacheEntry(new BackEndServer(keyValuePair.Value.ServerFqdn, keyValuePair.Value.ServerVersion), resourceForest, keyValuePair.Value.DatabaseFailoverSequenceNumber); this.Add(keyValuePair.Key, entry, null); } } }
private void Add(Guid database, MailboxServerCacheEntry entry, Guid initiatingRequestId, IRequestContext requestContext, bool addToSharedCache = true) { ExTraceGlobals.VerboseTracer.TraceDebug <Guid, BackEndServer, bool>((long)this.GetHashCode(), "[MailboxServerCache::Add]: Adding database {0} with server {1} to cache. addToSharedCache={2}", database, entry.BackEndServer, addToSharedCache); this.serversCache.TryInsertAbsolute(database, entry, MailboxServerCache.MailboxServerCacheAbsoluteTimeout); if (HttpProxySettings.MailboxServerLocatorSharedCacheEnabled.Value && addToSharedCache) { long latency = 0L; string diagInfo = null; LatencyTracker.GetLatency <bool>(() => this.sharedCacheClient.TryInsert(database.ToString(), entry, entry.LastRefreshTime, initiatingRequestId, out diagInfo), out latency); if (requestContext != null) { requestContext.LogSharedCacheCall(latency, diagInfo); } } LocalSiteMailboxServerCache.Instance.Add(database, entry.BackEndServer, entry.ResourceForest); }
public override bool Equals(object obj) { MailboxServerCacheEntry mailboxServerCacheEntry = obj as MailboxServerCacheEntry; if (mailboxServerCacheEntry != null && this.LastRefreshTime == mailboxServerCacheEntry.LastRefreshTime && this.IsSourceCachedData == mailboxServerCacheEntry.IsSourceCachedData && ((string.IsNullOrEmpty(this.ResourceForest) && string.IsNullOrEmpty(mailboxServerCacheEntry.ResourceForest)) || string.Equals(this.ResourceForest, mailboxServerCacheEntry.ResourceForest))) { if (this.BackEndServer == null) { return(mailboxServerCacheEntry.BackEndServer == null); } if (mailboxServerCacheEntry.BackEndServer != null) { return(this.BackEndServer.Version == mailboxServerCacheEntry.BackEndServer.Version && ((string.IsNullOrEmpty(this.BackEndServer.Fqdn) && string.IsNullOrEmpty(mailboxServerCacheEntry.BackEndServer.Fqdn)) || string.Equals(this.BackEndServer.Fqdn, mailboxServerCacheEntry.BackEndServer.Fqdn))); } } return(false); }
// 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); }
// Token: 0x0600023F RID: 575 RVA: 0x0000B278 File Offset: 0x00009478 private void Add(Guid database, MailboxServerCacheEntry entry, IRequestContext requestContext) { string text = database.ToString(); if (entry == null) { throw new ArgumentNullException("entry"); } if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1)) { ExTraceGlobals.VerboseTracer.TraceDebug <string, BackEndServer>((long)this.GetHashCode(), "[MailboxServerCache::Add]: Adding database {0} with server {1} to cache.", text, entry.BackEndServer); } if (this.TryAddToInMemoryCache(text, entry)) { this.UpdateInMemoryCacheSizeCounter(); } SharedCacheDiagnostics sharedCacheDiagnostics; this.TryAddToSharedCache(text, entry, out sharedCacheDiagnostics); MailboxServerCache.LogSharedCacheDiagnostics(requestContext, sharedCacheDiagnostics); LocalSiteMailboxServerCache.Instance.Add(database, entry.BackEndServer, entry.ResourceForest); }
private void Add(Guid database, MailboxServerCacheEntry entry, IRequestContext requestContext, bool addToSharedCache) { this.Add(database, entry, requestContext.ActivityId, requestContext, addToSharedCache); }
private static bool IsE14ServerStale(MailboxServerCacheEntry cacheEntry) { return(!cacheEntry.BackEndServer.IsE15OrHigher && !DownLevelServerManager.IsServerDiscoverable(cacheEntry.BackEndServer.Fqdn)); }
public void Add(Guid database, BackEndServer server, string resourceForestFqdn, bool isSourceCachedData, IRequestContext requestContext) { MailboxServerCacheEntry entry = new MailboxServerCacheEntry(server, resourceForestFqdn, DateTime.UtcNow, isSourceCachedData); this.Add(database, entry, requestContext.ActivityId, requestContext, true); }
public void Add(Guid database, BackEndServer server, string resourceForestFqdn, bool isSourceCachedData, Guid initiatingRequestId) { MailboxServerCacheEntry entry = new MailboxServerCacheEntry(server, resourceForestFqdn, DateTime.UtcNow, isSourceCachedData); this.Add(database, entry, initiatingRequestId, null, true); }
// Token: 0x06000239 RID: 569 RVA: 0x0000B140 File Offset: 0x00009340 public void Add(Guid database, BackEndServer server, string resourceForestFqdn, long failoverSequenceNumber, IRequestContext requestContext) { MailboxServerCacheEntry entry = new MailboxServerCacheEntry(server, resourceForestFqdn, failoverSequenceNumber); this.Add(database, entry, requestContext); }
// Token: 0x0600024E RID: 590 RVA: 0x0000B8C1 File Offset: 0x00009AC1 private bool TryGetFromSharedCache(string key, out MailboxServerCacheEntry entry, out SharedCacheDiagnostics sharedCacheDiagnostics) { entry = null; sharedCacheDiagnostics = null; return(HttpProxySettings.MailboxServerLocatorSharedCacheEnabled.Value && this.sharedCacheClient.TryGet <MailboxServerCacheEntry>(key, ref entry, ref sharedCacheDiagnostics)); }
// Token: 0x0600024D RID: 589 RVA: 0x0000B8A1 File Offset: 0x00009AA1 private bool TryGetFromInMemoryCache(string key, out MailboxServerCacheEntry entry) { entry = null; return(MailboxServerCache.InMemoryCacheEnabled.Value && this.inMemoryCache.TryGet(key, ref entry)); }
// Token: 0x0600024A RID: 586 RVA: 0x0000B830 File Offset: 0x00009A30 private bool TryAddToSharedCache(string key, MailboxServerCacheEntry entry, out SharedCacheDiagnostics sharedCacheDiagnostics) { sharedCacheDiagnostics = null; return(HttpProxySettings.MailboxServerLocatorSharedCacheEnabled.Value && this.sharedCacheClient.TryInsert(key, entry, entry.FailoverSequenceNumber, ref sharedCacheDiagnostics)); }
// Token: 0x06000249 RID: 585 RVA: 0x0000B813 File Offset: 0x00009A13 private bool TryAddToInMemoryCache(string key, MailboxServerCacheEntry entry) { return(MailboxServerCache.InMemoryCacheEnabled.Value && this.inMemoryCache.TryAddOrUpdate(key, entry)); }
private void OnRemoveItem(Guid database, MailboxServerCacheEntry entry, RemoveReason reason) { LocalSiteMailboxServerCache.Instance.Remove(database); this.UpdateSizeCounter(); }
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); }
// Token: 0x06000233 RID: 563 RVA: 0x0000AEDB File Offset: 0x000090DB public bool TryGet(Guid database, out MailboxServerCacheEntry cacheEntry) { return(this.TryGet(database, null, out cacheEntry)); }