public T FindAnyCafeService <T>(Predicate <T> serviceFilter, [CallerFilePath] string callerFilePath = null, [CallerMemberName] string memberName = null, [CallerLineNumber] int callerFileLine = 0) where T : Service { Func <Service, T> func = null; ServiceTopologyLog.Instance.Append(callerFilePath, memberName, callerFileLine); if (serviceFilter == null) { throw new ArgumentNullException("serviceFilter"); } ServiceType serviceType = ServiceTopology.ServiceTypeMapper <T> .GetServiceType(); List <Service> list = null; if (this.cafeServices.TryGetValue(serviceType, out list) && list != null && list.Count > 0) { IEnumerable <Service> source = from service in list where serviceFilter((T)((object)service)) select service; if (func == null) { func = ((Service service) => (T)((object)service)); } List <T> list2 = source.Select(func).ToList <T>(); if (list2.Count > 0) { int index = ServiceTopology.Random.Next(list2.Count); return(list2[index]); } } ServiceCache.TriggerCacheRefreshDueToCacheMiss(this); return(default(T)); }
private void TriggerCacheRefresh(object state, bool timedOut) { lock (this.thisLock) { this.notificationArrived = false; } ServiceCache.TriggerCacheRefreshDueToNotification(); }
internal static ServiceTopology GetCurrentLegacyServiceTopology(TimeSpan getServiceTopologyTimeout) { ServiceTopology currentServiceTopology = ServiceCache.GetCurrentServiceTopology(getServiceTopologyTimeout); ServiceTopology serviceTopology = ServiceCache.Instance.legacyServiceTopologyInstance; if (serviceTopology == null) { serviceTopology = currentServiceTopology.ToLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\ServiceCache.cs", "GetCurrentLegacyServiceTopology", 144); ServiceCache.Instance.legacyServiceTopologyInstance = serviceTopology; } return(serviceTopology); }
public Site GetSite(string serverFullyQualifiedDomainName, [CallerFilePath] string callerFilePath = null, [CallerMemberName] string memberName = null, [CallerLineNumber] int callerFileLine = 0) { ServiceTopologyLog.Instance.Append(callerFilePath, memberName, callerFileLine); Site result; if (this.serverToSiteDictionary.TryGetValue(serverFullyQualifiedDomainName, out result)) { return(result); } if (this.serversWithoutSite.Contains(serverFullyQualifiedDomainName)) { ExTraceGlobals.ServiceDiscoveryTracer.TraceDebug <string>((long)this.GetHashCode(), "ServiceTopology::FindServices. The server does not have a site defined. Server = {0}.", serverFullyQualifiedDomainName); throw new ServerNotInSiteException(ServerStrings.ExServerNotInSite(serverFullyQualifiedDomainName), serverFullyQualifiedDomainName); } ExTraceGlobals.ServiceDiscoveryTracer.TraceDebug <string>((long)this.GetHashCode(), "ServiceTopology::FindServices. The server we are accessing is not found in the Topology. Server = {0}.", serverFullyQualifiedDomainName); ServiceCache.TriggerCacheRefreshDueToCacheMiss(this); throw new ServerNotFoundException(ServerStrings.ExServerNotFound(serverFullyQualifiedDomainName), serverFullyQualifiedDomainName); }
internal static ServiceTopology GetCurrentServiceTopology(TimeSpan getServiceTopologyTimeout) { ServiceCache instance = ServiceCache.Instance; instance.DropCacheIfNeeded(); instance.TriggerCacheRefreshIfNeeded(); ServiceTopology serviceTopology = instance.serviceTopologyInstance; if (serviceTopology == null) { if (!instance.cachePresentEvent.WaitOne(getServiceTopologyTimeout, false)) { throw new ReadTopologyTimeoutException(ServerStrings.ExReadTopologyTimeout); } serviceTopology = instance.serviceTopologyInstance; } serviceTopology.IncrementRequestCount("f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\ServiceCache.cs", "GetCurrentServiceTopology", 188); return(serviceTopology); }
internal static void Purge() { ServiceCache instance = ServiceCache.Instance; instance.semaphore.WaitOne(); try { instance.DropCache(); instance.isFirstLoad = true; instance.notificationHandler.UnRegisterExchangeTopologyNotification(); instance.dropCacheOnInactivity = false; if (!(ServiceDiscovery.ExchangeTopologyBridge is ExchangeTopologyBridge)) { instance.notificationHandler.RegisterExchangeTopologyNotificationIfNeeded(); } } finally { instance.semaphore.Release(); } }
internal static ServiceTopology GetCurrentServiceTopology() { return(ServiceCache.GetCurrentServiceTopology(ServiceDiscovery.ExchangeTopologyBridge.GetServiceTopologyDefaultTimeout)); }
public static ServiceTopology GetCurrentServiceTopology(TimeSpan getServiceTopologyTimeout, [CallerFilePath] string callerFilePath = null, [CallerMemberName] string memberName = null, [CallerLineNumber] int callerFileLine = 0) { ServiceTopologyLog.Instance.Append(callerFilePath, memberName, callerFileLine); return(ServiceCache.GetCurrentServiceTopology(getServiceTopologyTimeout)); }
internal static void PurgeServiceCache() { ServiceCache.Purge(); }