private static HttpProxyBackEndHelper.TopologyWithSites GetServiceTopologyWithSites(string serverFqdn, ServiceTopology topology) { if (string.IsNullOrEmpty(serverFqdn)) { throw new ArgumentNullException("serverFqdn"); } HttpProxyBackEndHelper.TopologyWithSites topologyWithSites = new HttpProxyBackEndHelper.TopologyWithSites { ServiceTopology = topology }; try { topologyWithSites.TargetSite = topology.GetSite(serverFqdn, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetServiceTopologyWithSites", 1065); } catch (ServerNotInSiteException arg) { ExTraceGlobals.CafeTracer.TraceError <string, ServerNotInSiteException>(0L, "[HttpProxyBackEndHelper.GetServiceTopologyWithSites] Could not find site for server {0} - ServerNotInSiteException {1}", serverFqdn, arg); } catch (ServerNotFoundException arg2) { ExTraceGlobals.CafeTracer.TraceError <string, ServerNotFoundException>(0L, "[HttpProxyBackEndHelper.GetServiceTopologyWithSites] Could not find site for server {0} - ServerNotFoundException {1}", serverFqdn, arg2); } try { topologyWithSites.CurrentSite = HttpProxyBackEndHelper.localSite.Member; } catch (CannotGetSiteInfoException arg3) { ExTraceGlobals.CafeTracer.TraceError <string, CannotGetSiteInfoException>(0L, "[HttpProxyBackEndHelper.GetServiceTopologyWithSites] Could not find site for current server {0} - CannotGetSiteInfoException {1}", LocalServerCache.LocalServerFqdn, arg3); } return(topologyWithSites); }
internal static BackEndServer GetDeterministicBackEndServer <ServiceType>(BackEndServer mailboxServer, string identifier, ClientAccessType clientAccessType) where ServiceType : HttpService { if (mailboxServer == null) { throw new ArgumentNullException("mailboxServer"); } if (string.IsNullOrEmpty(identifier)) { throw new ArgumentNullException("identifier"); } if (VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled && VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Cafe.ServersCache.Enabled) { MiniServer deterministicBackEndServerFromSameSite = ServersCache.GetDeterministicBackEndServerFromSameSite(mailboxServer.Fqdn, Server.E15MinVersion, identifier, false); return(new BackEndServer(deterministicBackEndServerFromSameSite.Fqdn, deterministicBackEndServerFromSameSite.VersionNumber)); } HttpProxyBackEndHelper.TopologyWithSites completeServiceTopologyWithSites = HttpProxyBackEndHelper.GetCompleteServiceTopologyWithSites(mailboxServer.Fqdn); HttpService[] array = (HttpService[])HttpProxyBackEndHelper.FindAcceptableBackEndService <ServiceType>(completeServiceTopologyWithSites, clientAccessType, (int x) => x >= Server.E15MinVersion); if (array.Length > 0) { int num = HttpProxyBackEndHelper.ComputeIndex(identifier, array.Length); ExTraceGlobals.CafeTracer.TraceDebug <int, string, int>(0L, "[HttpProxyBackEndHelper.GetDeterministicBackEndServer] Buckets: {0} Identifier: {1} Index: {2}", array.Length, identifier, num); return(new BackEndServer(array[num].ServerFullyQualifiedDomainName, array[num].ServerVersionNumber)); } throw new ServerNotFoundException("Unable to find proper HTTP service."); }
private static ServiceType[] FindAcceptableBackEndService <ServiceType>(HttpProxyBackEndHelper.TopologyWithSites topology, ClientAccessType clientAccessType, Predicate <int> versionNumberCondition) where ServiceType : HttpService { if (topology == null) { throw new ArgumentNullException("topology"); } if (versionNumberCondition == null) { throw new ArgumentNullException("versionNumberCondition"); } List <ServiceType> tempServices = new List <ServiceType>(); Site lookupSite = (topology.TargetSite != null) ? topology.TargetSite : topology.CurrentSite; if (lookupSite != null) { topology.ServiceTopology.ForEach <ServiceType>(delegate(ServiceType service) { if ((service.ServerRole & ServerRole.Mailbox) == ServerRole.Mailbox && service.ClientAccessType == clientAccessType && !service.IsOutOfService && service.Site.Equals(lookupSite) && versionNumberCondition(service.ServerVersionNumber)) { tempServices.Add(service); } }, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "FindAcceptableBackEndService", 948); if (tempServices.Count == 0) { ExTraceGlobals.CafeTracer.TraceError <Site>(0L, "[HttpProxyBackEndHelper.FindAcceptableBackEndService] Could not find BE server for site {0}", lookupSite); } } if (tempServices.Count == 0 && topology.CurrentSite != null) { topology.ServiceTopology.ForEach <ServiceType>(delegate(ServiceType service) { if ((service.ServerRole & ServerRole.Mailbox) == ServerRole.Mailbox && service.ClientAccessType == clientAccessType && !service.IsOutOfService && service.Site.Equals(topology.CurrentSite) && versionNumberCondition(service.ServerVersionNumber)) { tempServices.Add(service); } }, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "FindAcceptableBackEndService", 974); if (tempServices.Count == 0) { ExTraceGlobals.CafeTracer.TraceError <Site>(0L, "[HttpProxyBackEndHelper.FindAcceptableBackEndService] Could not find BE server for current site {0}", topology.CurrentSite); } } if (tempServices.Count == 0) { topology.ServiceTopology.ForEach <ServiceType>(delegate(ServiceType service) { if ((service.ServerRole & ServerRole.Mailbox) == ServerRole.Mailbox && service.ClientAccessType == clientAccessType && !service.IsOutOfService && versionNumberCondition(service.ServerVersionNumber)) { tempServices.Add(service); } }, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "FindAcceptableBackEndService", 999); if (tempServices.Count == 0) { ExTraceGlobals.CafeTracer.TraceError(0L, "[HttpProxyBackEndHelper.FindAcceptableBackEndService] Could not find any applicable BE server"); } } return(tempServices.ToArray()); }
internal static Uri GetE12ExternalUrl <ServiceType>(BackEndServer mailboxServer) where ServiceType : HttpService { if (mailboxServer == null) { throw new ArgumentNullException("mailboxServer"); } if (mailboxServer.Version >= Server.E14MinVersion) { throw new ArgumentException("Mailbox server version is higher then E12", "mailboxServer"); } HttpProxyBackEndHelper.TopologyWithSites legacyServiceTopologyWithSites = HttpProxyBackEndHelper.GetLegacyServiceTopologyWithSites(mailboxServer.Fqdn); HttpService httpService = HttpProxyBackEndHelper.GetBestBackEndServiceForVersion <ServiceType>(legacyServiceTopologyWithSites, ClientAccessType.External, (int x) => x >= Server.E2007MinVersion && x < Server.E14MinVersion); return(httpService.Url); }
private static ServiceType GetBestBackEndServiceForVersion <ServiceType>(HttpProxyBackEndHelper.TopologyWithSites topology, ClientAccessType clientAccessType, Predicate <int> versionNumberCondition) where ServiceType : HttpService { if (topology == null) { throw new ArgumentNullException("topology"); } if (versionNumberCondition == null) { throw new ArgumentNullException("versionNumberCondition"); } ServiceType serviceType = default(ServiceType); Site lookupSite = (topology.TargetSite != null) ? topology.TargetSite : topology.CurrentSite; if (lookupSite != null) { serviceType = topology.ServiceTopology.FindAny <ServiceType>(clientAccessType, (ServiceType service) => service != null && service.Site.Equals(lookupSite) && !service.IsOutOfService && versionNumberCondition(service.ServerVersionNumber), "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetBestBackEndServiceForVersion", 847); if (serviceType == null) { ExTraceGlobals.CafeTracer.TraceError <Site>(0L, "[HttpProxyBackEndHelper.GetBestBackEndServiceForVersion] Could not find server for site {0}", lookupSite); } } if (serviceType == null && topology.CurrentSite != null) { serviceType = topology.ServiceTopology.FindAny <ServiceType>(clientAccessType, (ServiceType service) => service != null && service.Site.Equals(topology.CurrentSite) && !service.IsOutOfService && versionNumberCondition(service.ServerVersionNumber), "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetBestBackEndServiceForVersion", 870); if (serviceType == null) { ExTraceGlobals.CafeTracer.TraceError <Site>(0L, "[HttpProxyBackEndHelper.GetBestBackEndServiceForVersion] Could not find server for current site {0}!", topology.CurrentSite); } } if (serviceType == null) { serviceType = topology.ServiceTopology.FindAny <ServiceType>(clientAccessType, (ServiceType service) => service != null && !service.IsOutOfService && versionNumberCondition(service.ServerVersionNumber), "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetBestBackEndServiceForVersion", 893); if (serviceType == null) { ExTraceGlobals.CafeTracer.TraceError(0L, "[HttpProxyBackEndHelper.GetBestBackEndServiceForVersion] Could not find any applicable CAS server! (Last chance - returning null."); } } if (serviceType == null) { throw new ServerNotFoundException("Unable to find proper HTTP service."); } return(serviceType); }
internal static Uri GetBackEndServiceUrlByServer <ServiceType>(BackEndServer backEndServer) where ServiceType : HttpService { if (backEndServer.IsE15OrHigher) { return(GlobalServiceUrls.GetInternalUrl <ServiceType>(backEndServer.Fqdn)); } HttpProxyBackEndHelper.TopologyWithSites legacyServiceTopologyWithSites = HttpProxyBackEndHelper.GetLegacyServiceTopologyWithSites(backEndServer.Fqdn); ServiceType serviceType = legacyServiceTopologyWithSites.ServiceTopology.FindAny <ServiceType>(ClientAccessType.InternalNLBBypass, (ServiceType service) => service != null && !service.IsFrontEnd && service.ServerFullyQualifiedDomainName.Equals(backEndServer.Fqdn, StringComparison.OrdinalIgnoreCase), "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetBackEndServiceUrlByServer", 568); if (serviceType != null) { ExTraceGlobals.CafeTracer.TraceDebug <BackEndServer>(0L, "[HttpProxyBackEndHelper.GetBackEndServiceUrlByServer] Found HTTP service on the specified back end server {0}.", backEndServer); return(serviceType.Url); } serviceType = HttpProxyBackEndHelper.GetBestBackEndServiceForVersion <ServiceType>(legacyServiceTopologyWithSites, ClientAccessType.InternalNLBBypass, (int x) => new ServerVersion(x).Major == new ServerVersion(backEndServer.Version).Major); ExTraceGlobals.CafeTracer.TraceDebug <string, int>(0L, "[HttpProxyBackEndHelper.GetBackEndServiceByServer] Found HTTP service {0} with version {1}.", serviceType.ServerFullyQualifiedDomainName, serviceType.ServerVersionNumber); if (serviceType != null) { return(serviceType.Url); } throw new ServerNotFoundException("Unable to find proper HTTP service."); }