Ejemplo n.º 1
0
        // Token: 0x060001F3 RID: 499 RVA: 0x00009988 File Offset: 0x00007B88
        private ServiceType GetClientAccessServiceFromList <ServiceType>(List <DownLevelServerStatusEntry> serverList, ServiceTopology topology, AnchorMailbox anchorMailbox, Site targetSite, ClientAccessType clientAccessType, Predicate <ServiceType> otherFilter, RequestDetailsLogger logger, DownLevelServerManager.DownlevelExchangeServerVersion targetDownlevelExchangeServerVersion) where ServiceType : HttpService
        {
            string text     = anchorMailbox.ToCookieKey();
            int    hashCode = HttpProxyBackEndHelper.GetHashCode(text);

            serverList = this.GetFilteredServerListByVersion(serverList, targetDownlevelExchangeServerVersion);
            int[] shuffledList = DownLevelServerManager.GetShuffledList(serverList.Count, hashCode);
            if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <string, int, string>((long)this.GetHashCode(), "[DownLevelServerManager::GetClientAccessServiceFromList]: HashKey: {0}, HashCode: {1}, Anchor mailbox {2}.", text, hashCode, anchorMailbox.ToString());
            }
            for (int i = 0; i < shuffledList.Length; i++)
            {
                int num = shuffledList[i];
                DownLevelServerStatusEntry currentServer = serverList[num];
                if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                {
                    ExTraceGlobals.VerboseTracer.TraceDebug <string, int, bool>((long)this.GetHashCode(), "[DownLevelServerManager::GetClientAccessServiceFromList]: Back end server {0} is selected by current index {1}. IsHealthy = {2}", currentServer.BackEndServer.Fqdn, num, currentServer.IsHealthy);
                }
                if (currentServer.IsHealthy)
                {
                    ServiceType serviceType = topology.FindAny <ServiceType>(clientAccessType, (ServiceType service) => service != null && service.ServerFullyQualifiedDomainName.Equals(currentServer.BackEndServer.Fqdn, StringComparison.OrdinalIgnoreCase) && !service.IsOutOfService && otherFilter(service), "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", "GetClientAccessServiceFromList", 799);
                    if (serviceType != null)
                    {
                        if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1))
                        {
                            ExTraceGlobals.VerboseTracer.TraceDebug <Uri, string>((long)this.GetHashCode(), "[DownLevelServerManager::GetClientAccessServiceFromList]: Found service {0} matching back end server {1}.", serviceType.Url, currentServer.BackEndServer.Fqdn);
                        }
                        RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(logger, "DownLevelTargetRandomHashing", string.Format("{0}/{1}", i, serverList.Count));

                        return(serviceType);
                    }
                    if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(3))
                    {
                        ExTraceGlobals.VerboseTracer.TraceError <string>((long)this.GetHashCode(), "[DownLevelServerManager::GetClientAccessServiceFromList]: Back end server {0} cannot be found by ServiceDiscovery.", currentServer.BackEndServer.Fqdn);
                    }
                }
                else if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(2))
                {
                    ExTraceGlobals.VerboseTracer.TraceWarning <string>((long)this.GetHashCode(), "[DownLevelServerManager::GetClientAccessServiceFromList]: Back end server {0} is marked as unhealthy.", currentServer.BackEndServer.Fqdn);
                }
            }
            RequestDetailsLoggerBase <RequestDetailsLogger> .SafeAppendGenericInfo(logger, "DownLevelTargetRandomHashingFailure", string.Format("{0}", serverList.Count));

            this.TriggerServerMapRefreshIfNeeded(topology, serverList);
            string text2 = string.Format("Unable to find proper back end service for {0} in site {1}.", anchorMailbox, targetSite.DistinguishedName);

            if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(3))
            {
                ExTraceGlobals.VerboseTracer.TraceError <string>((long)this.GetHashCode(), "[DownLevelServerManager::GetClientAccessServiceFromList]: {0}", text2);
            }
            throw new NoAvailableDownLevelBackEndException(text2);
        }
Ejemplo n.º 2
0
        private void InternalRefresh()
        {
            Exception ex = null;

            Server[] array = null;
            try
            {
                ITopologyConfigurationSession configurationSession = DirectoryHelper.GetConfigurationSession();
                ADPagedReader <Server>        adpagedReader        = configurationSession.FindPaged <Server>(null, QueryScope.SubTree, DownLevelServerManager.ServerVersionFilter, null, 0);
                array = adpagedReader.ReadAllPages();
            }
            catch (ADTransientException ex2)
            {
                ex = ex2;
            }
            catch (DataValidationException ex3)
            {
                ex = ex3;
            }
            catch (DataSourceOperationException ex4)
            {
                ex = ex4;
            }
            if (ex != null)
            {
                ExTraceGlobals.VerboseTracer.TraceError <Exception>((long)this.GetHashCode(), "[DownLevelServerManager::RefreshServerMap]: Active Directory exception: {0}", ex);
                Diagnostics.Logger.LogEvent(FrontEndHttpProxyEventLogConstants.Tuple_ErrorRefreshDownLevelServerMap, null, new object[]
                {
                    HttpProxyGlobals.ProtocolType.ToString(),
                    ex.ToString()
                });
                return;
            }
            Dictionary <string, List <DownLevelServerStatusEntry> > downLevelServerMap = this.GetDownLevelServerMap();
            Dictionary <string, List <DownLevelServerStatusEntry> > dictionary         = new Dictionary <string, List <DownLevelServerStatusEntry> >(downLevelServerMap.Count, StringComparer.OrdinalIgnoreCase);

            Server[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                Server server = array2[i];
                if ((server.CurrentServerRole & ServerRole.ClientAccess) > ServerRole.None && server.ServerSite != null)
                {
                    List <DownLevelServerStatusEntry> list = null;
                    if (!dictionary.TryGetValue(server.ServerSite.DistinguishedName, out list))
                    {
                        list = new List <DownLevelServerStatusEntry>();
                        dictionary.Add(server.ServerSite.DistinguishedName, list);
                    }
                    DownLevelServerStatusEntry        downLevelServerStatusEntry = null;
                    List <DownLevelServerStatusEntry> list2 = null;
                    if (downLevelServerMap.TryGetValue(server.ServerSite.DistinguishedName, out list2))
                    {
                        downLevelServerStatusEntry = list2.Find((DownLevelServerStatusEntry x) => x.BackEndServer.Fqdn.Equals(server.Fqdn, StringComparison.OrdinalIgnoreCase));
                    }
                    if (downLevelServerStatusEntry == null)
                    {
                        downLevelServerStatusEntry = new DownLevelServerStatusEntry
                        {
                            BackEndServer = new BackEndServer(server.Fqdn, server.VersionNumber),
                            IsHealthy     = true
                        };
                    }
                    list.Add(downLevelServerStatusEntry);
                    list.Sort((DownLevelServerStatusEntry x, DownLevelServerStatusEntry y) => x.BackEndServer.Fqdn.CompareTo(y.BackEndServer.Fqdn));
                }
            }
            this.downLevelServers = dictionary;
            if (dictionary.Count > 0 && DownLevelServerManager.DownLevelServerPingEnabled.Value && this.pingManager == null)
            {
                this.pingManager = new DownLevelServerPingManager(new Func <Dictionary <string, List <DownLevelServerStatusEntry> > >(this.GetDownLevelServerMap));
            }
        }
Ejemplo n.º 3
0
        public BackEndServer GetDownLevelClientAccessServerWithPreferredServer <ServiceType>(AnchorMailbox anchorMailbox, string preferredCasServerFqdn, ClientAccessType clientAccessType, RequestDetailsLogger logger, int destinationVersion) where ServiceType : HttpService
        {
            Predicate <ServiceType> predicate  = null;
            Predicate <ServiceType> predicate2 = null;

            if (anchorMailbox == null)
            {
                throw new ArgumentNullException("anchorMailbox");
            }
            if (string.IsNullOrEmpty(preferredCasServerFqdn))
            {
                throw new ArgumentException("preferredCasServerFqdn cannot be empty!");
            }
            ServiceTopology currentLegacyServiceTopology = ServiceTopology.GetCurrentLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", "GetDownLevelClientAccessServerWithPreferredServer", 253);
            Site            site = currentLegacyServiceTopology.GetSite(preferredCasServerFqdn, "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", "GetDownLevelClientAccessServerWithPreferredServer", 254);
            Dictionary <string, List <DownLevelServerStatusEntry> > downLevelServerMap = this.GetDownLevelServerMap();
            List <DownLevelServerStatusEntry> list = null;

            if (!downLevelServerMap.TryGetValue(site.DistinguishedName, out list))
            {
                string text = string.Format("Unable to find site {0} in the down level server map.", site.DistinguishedName);
                ExTraceGlobals.VerboseTracer.TraceError <string>((long)this.GetHashCode(), "[DownLevelServerManager::GetDownLevelClientAccessServerWithPreferredServer]: {0}", text);
                ThreadPool.QueueUserWorkItem(delegate(object o)
                {
                    this.RefreshServerMap(true);
                });
                throw new NoAvailableDownLevelBackEndException(text);
            }
            DownLevelServerStatusEntry downLevelServerStatusEntry = list.Find((DownLevelServerStatusEntry backend) => preferredCasServerFqdn.Equals(backend.BackEndServer.Fqdn, StringComparison.OrdinalIgnoreCase));

            if (downLevelServerStatusEntry == null)
            {
                string text2 = string.Format("Unable to find preferred server {0} in the back end server map.", preferredCasServerFqdn);
                ExTraceGlobals.VerboseTracer.TraceError <string>((long)this.GetHashCode(), "[DownLevelServerManager::GetDownLevelClientAccessServerWithPreferredServer]: {0}", text2);
                throw new NoAvailableDownLevelBackEndException(text2);
            }
            if (downLevelServerStatusEntry.IsHealthy)
            {
                ExTraceGlobals.VerboseTracer.TraceDebug <DownLevelServerStatusEntry>((long)this.GetHashCode(), "[DownLevelServerManager::GetDownLevelClientAccessServerWithPreferredServer]: The preferred server {0} is healthy.", downLevelServerStatusEntry);
                return(downLevelServerStatusEntry.BackEndServer);
            }
            ServiceType serviceType = default(ServiceType);

            if (destinationVersion < Server.E14MinVersion)
            {
                try
                {
                    List <DownLevelServerStatusEntry> serverList = list;
                    ServiceTopology topology   = currentLegacyServiceTopology;
                    Site            targetSite = site;
                    if (predicate == null)
                    {
                        predicate = ((ServiceType service) => service.ServerVersionNumber >= Server.E2007MinVersion && service.ServerVersionNumber < Server.E14MinVersion);
                    }
                    serviceType = this.GetClientAccessServiceFromList <ServiceType>(serverList, topology, anchorMailbox, targetSite, clientAccessType, predicate, logger, DownLevelServerManager.DownlevelExchangeServerVersion.Exchange2007);
                }
                catch (NoAvailableDownLevelBackEndException)
                {
                    ExTraceGlobals.VerboseTracer.TraceError((long)this.GetHashCode(), "[DownLevelServerManager::GetDownLevelClientAccessServerWithPreferredServer]: No E12 CAS could be found for E12 destination. Looking for E14 CAS.");
                }
            }
            if (serviceType == null)
            {
                List <DownLevelServerStatusEntry> serverList2 = list;
                ServiceTopology topology2   = currentLegacyServiceTopology;
                Site            targetSite2 = site;
                if (predicate2 == null)
                {
                    predicate2 = ((ServiceType service) => service.ServerVersionNumber >= Server.E14MinVersion && service.ServerVersionNumber < Server.E15MinVersion);
                }
                serviceType = this.GetClientAccessServiceFromList <ServiceType>(serverList2, topology2, anchorMailbox, targetSite2, clientAccessType, predicate2, logger, DownLevelServerManager.DownlevelExchangeServerVersion.Exchange2010);
            }
            return(new BackEndServer(serviceType.ServerFullyQualifiedDomainName, serviceType.ServerVersionNumber));
        }
Ejemplo n.º 4
0
        // Token: 0x060001F5 RID: 501 RVA: 0x00009C6C File Offset: 0x00007E6C
        private void InternalRefresh()
        {
            Exception ex = null;

            Server[] array = null;
            try
            {
                array = DirectoryHelper.GetConfigurationSession().FindPaged <Server>(null, 2, DownLevelServerManager.ServerVersionFilter, null, 0, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\DownLevelServerManager\\DownLevelServerManager.cs", 910, "InternalRefresh").ReadAllPages();
            }
            catch (ADTransientException ex)
            {
            }
            catch (DataValidationException ex)
            {
            }
            catch (DataSourceOperationException ex)
            {
            }
            if (ex != null)
            {
                if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(3))
                {
                    ExTraceGlobals.VerboseTracer.TraceError <Exception>((long)this.GetHashCode(), "[DownLevelServerManager::RefreshServerMap]: Active Directory exception: {0}", ex);
                }
                Diagnostics.Logger.LogEvent(FrontEndHttpProxyEventLogConstants.Tuple_ErrorRefreshDownLevelServerMap, null, new object[]
                {
                    HttpProxyGlobals.ProtocolType.ToString(),
                    ex.ToString()
                });
                return;
            }
            Dictionary <string, List <DownLevelServerStatusEntry> > downLevelServerMap = this.GetDownLevelServerMap();
            Dictionary <string, List <DownLevelServerStatusEntry> > dictionary         = new Dictionary <string, List <DownLevelServerStatusEntry> >(downLevelServerMap.Count, StringComparer.OrdinalIgnoreCase);

            Server[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                Server server = array2[i];
                if ((server.CurrentServerRole & 4) > 0 && server.ServerSite != null)
                {
                    List <DownLevelServerStatusEntry> list = null;
                    if (!dictionary.TryGetValue(server.ServerSite.DistinguishedName, out list))
                    {
                        list = new List <DownLevelServerStatusEntry>();
                        dictionary.Add(server.ServerSite.DistinguishedName, list);
                    }
                    DownLevelServerStatusEntry        downLevelServerStatusEntry = null;
                    List <DownLevelServerStatusEntry> list2 = null;
                    if (downLevelServerMap.TryGetValue(server.ServerSite.DistinguishedName, out list2))
                    {
                        downLevelServerStatusEntry = list2.Find((DownLevelServerStatusEntry x) => x.BackEndServer.Fqdn.Equals(server.Fqdn, StringComparison.OrdinalIgnoreCase));
                    }
                    if (downLevelServerStatusEntry == null)
                    {
                        downLevelServerStatusEntry = new DownLevelServerStatusEntry
                        {
                            BackEndServer = new BackEndServer(server.Fqdn, server.VersionNumber),
                            IsHealthy     = true
                        };
                    }
                    list.Add(downLevelServerStatusEntry);
                    list.Sort((DownLevelServerStatusEntry x, DownLevelServerStatusEntry y) => x.BackEndServer.Fqdn.CompareTo(y.BackEndServer.Fqdn));
                }
            }
            this.downLevelServers = dictionary;
            if (dictionary.Count > 0 && DownLevelServerManager.DownLevelServerPingEnabled.Value && this.pingManager == null)
            {
                this.pingManager = new DownLevelServerPingManager(new Func <Dictionary <string, List <DownLevelServerStatusEntry> > >(this.GetDownLevelServerMap));
            }
        }