// Token: 0x06001053 RID: 4179 RVA: 0x00042B64 File Offset: 0x00040D64
 public void PromoteServer(PickerServer server)
 {
     lock (this.stateLock)
     {
         int num = this.serverList.IndexOf(server);
         if (num != -1)
         {
             this.currentServerIndex = num;
         }
     }
 }
 // Token: 0x06001056 RID: 4182 RVA: 0x00042DA4 File Offset: 0x00040FA4
 public void UpdateServerHealth(PickerServer server, bool?isHealthy)
 {
     lock (this.stateLock)
     {
         int num = this.serverList.IndexOf(server);
         if (num != -1)
         {
             server = this.serverList[num];
             server.InternalUpdateServerHealth(isHealthy);
         }
     }
 }
 // Token: 0x0600103F RID: 4159 RVA: 0x0004286C File Offset: 0x00040A6C
 internal void CopyStatusTo(PickerServer newServer)
 {
     if (!this.active)
     {
         lock (this.stateLock)
         {
             newServer.active        = this.active;
             newServer.nextRetryTime = this.nextRetryTime;
             newServer.retryAttempts = this.retryAttempts;
         }
     }
 }
        // Token: 0x0600105E RID: 4190 RVA: 0x00043118 File Offset: 0x00041318
        internal bool IsChangeIgnorable(Server server)
        {
            PickerServer pickerServer = this.FindMatchingServer(server);

            if (pickerServer == null)
            {
                if ((server.CurrentServerRole & this.context.ServerRole) == ServerRole.None)
                {
                    return(true);
                }
            }
            else if ((server.CurrentServerRole & this.context.ServerRole) != ServerRole.None && ADObjectId.Equals(server.ServerSite, this.localSite) && server.VersionNumber >= Server.CurrentProductMinimumVersion && pickerServer.ArePropertiesEqual(server, this.context.ServerRole))
            {
                return(true);
            }
            return(false);
        }
 // Token: 0x06001054 RID: 4180 RVA: 0x00042BB8 File Offset: 0x00040DB8
 private PickerServer PickNextUsingRoundRobin(bool preferNonLocal)
 {
     this.context.Tracer.TraceDebug <string>(0L, "Picking next server using round robin {0}", preferNonLocal ? "preferring non local" : string.Empty);
     if (this.serverList.Count == 0)
     {
         this.context.Tracer.TraceDebug <string>(0L, "No {0} servers found", this.context.ServerRole.ToString());
         return(null);
     }
     lock (this.stateLock)
     {
         bool flag2 = false;
         for (int i = 0; i < this.serverList.Count; i++)
         {
             if (this.currentServerIndex >= this.serverList.Count)
             {
                 this.currentServerIndex = 0;
             }
             PickerServer pickerServer = this.serverList[this.currentServerIndex++];
             if (preferNonLocal && pickerServer == this.localServer)
             {
                 this.context.Tracer.TraceDebug(0L, "Skipping local server in hopes of finding another.");
                 flag2 = true;
             }
             else if (pickerServer.IsEligibleForUse())
             {
                 this.context.Tracer.TraceDebug <string, string>(0L, "Found {0} as the next {1} server", pickerServer.LegacyDN, this.context.ServerRole.ToString());
                 return(pickerServer);
             }
         }
         if (flag2 && this.localServer.IsEligibleForUse())
         {
             this.context.Tracer.TraceDebug(0L, "Returning local server.");
             return(this.localServer);
         }
     }
     this.context.Tracer.TraceDebug <string>(0L, "No active {0} server available based on round robin", this.context.ServerRole.ToString());
     return(null);
 }
        // Token: 0x06001061 RID: 4193 RVA: 0x000431C8 File Offset: 0x000413C8
        internal void LoadFromAD(PickerServerList oldServers)
        {
            this.context.Tracer.TracePfd <int, string>(0L, "PFD EMS {0} Loading {1} servers From AD...", 30619, this.context.ServerRole.ToString());
            Server server = this.context.ConfigurationSession.FindLocalServer();

            if (server != null)
            {
                this.CheckForOverride(server);
                if (server.ServerSite == null)
                {
                    this.context.Tracer.TraceError(0L, "Local server doesn't belong to a site");
                    ExEventLog.EventTuple tuple = this.context.HasValidConfiguration ? ApplicationLogicEventLogConstants.Tuple_LocalServerNotInSiteWarning : ApplicationLogicEventLogConstants.Tuple_LocalServerNotInSite;
                    this.context.LogEvent(tuple, null, new object[0]);
                    return;
                }
                this.context.ServerPickerClient.LocalServerDiscovered(server);
                this.localSite = server.ServerSite;
                QueryFilter filter = new AndFilter(new QueryFilter[]
                {
                    new BitMaskAndFilter(ServerSchema.CurrentServerRole, (ulong)((long)this.context.ServerRole)),
                    new ComparisonFilter(ComparisonOperator.Equal, ServerSchema.ServerSite, server.ServerSite),
                    new ComparisonFilter(ComparisonOperator.GreaterThanOrEqual, ServerSchema.VersionNumber, Server.CurrentProductMinimumVersion),
                    new ComparisonFilter(ComparisonOperator.LessThan, ServerSchema.VersionNumber, Server.NextProductMinimumVersion)
                });
                HashSet <string>       hashSet       = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                HashSet <string>       hashSet2      = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                ADPagedReader <Server> adpagedReader = this.context.ConfigurationSession.FindPaged <Server>(null, QueryScope.SubTree, filter, null, 0);
                foreach (Server server2 in adpagedReader)
                {
                    ServiceState serviceState = ServerComponentStates.ReadEffectiveComponentState(server2.Fqdn, server2.ComponentStates, ServerComponentStateSources.AD, ServerComponentStates.GetComponentId(this.context.Component), ServiceState.Active);
                    if (this.context.Component != ServerComponentEnum.None && serviceState != ServiceState.Active)
                    {
                        this.context.Tracer.TraceDebug <string, string, ServiceState>(0L, "Component {0} is not active on server {1}. Current component state is {2}.", this.context.Component.ToString(), server2.DistinguishedName, serviceState);
                    }
                    else
                    {
                        bool flag = true;
                        if (this.overrideList != null && this.overrideList.Count > 0)
                        {
                            if (this.overrideList.Contains(server2.DistinguishedName))
                            {
                                this.context.Tracer.TraceDebug <string, string>(0L, "Adding {0} Server from override list: {1} to active list", this.context.ServerRole.ToString(), server2.DistinguishedName);
                            }
                            else
                            {
                                flag = false;
                            }
                        }
                        else
                        {
                            this.context.Tracer.TraceDebug <string, string, int>(0L, "Adding {0} Server: {1} Version: {2} to active list", this.context.ServerRole.ToString(), server2.DistinguishedName, server2.VersionNumber);
                        }
                        if (flag)
                        {
                            if (this.fqdnServers.ContainsKey(server2.Fqdn) || hashSet.Contains(server2.Name) || hashSet2.Contains(server2.ExchangeLegacyDN))
                            {
                                this.context.Tracer.TraceError <string, string, string>(0L, "Found more than one server with same FQDN {0} or LegacyDN {1} or MachineName {2}.", server2.Fqdn, server2.ExchangeLegacyDN, server2.Name);
                                this.context.LogEvent(ApplicationLogicEventLogConstants.Tuple_MisconfiguredServer, server2.Fqdn, new object[]
                                {
                                    server2.ExchangeLegacyDN,
                                    server2.Name
                                });
                            }
                            else
                            {
                                PickerServer pickerServer = this.context.ServerPickerClient.CreatePickerServer(server2, this);
                                if (oldServers != null)
                                {
                                    PickerServer pickerServer2 = oldServers.PickServerByFqdn(pickerServer.FQDN);
                                    if (pickerServer2 != null)
                                    {
                                        pickerServer2.CopyStatusTo(pickerServer);
                                    }
                                }
                                this.serverList.Add(pickerServer);
                                this.fqdnServers.Add(pickerServer.FQDN, pickerServer);
                                hashSet.Add(pickerServer.MachineName);
                                hashSet2.Add(pickerServer.LegacyDN);
                            }
                        }
                    }
                }
                this.context.ServerPickerClient.ServerListUpdated(this.serverList);
                if ((server.CurrentServerRole & this.context.ServerRole) == ServerRole.None)
                {
                    this.localServer = this.context.ServerPickerClient.CreatePickerServer(server, this);
                }
                else
                {
                    PickerServer pickerServer3 = this.FindMatchingServer(server);
                    if (pickerServer3 != null)
                    {
                        this.localServer = pickerServer3;
                    }
                    else
                    {
                        this.context.Tracer.TraceDebug <string>(0L, "Local server ({0}) meets criteria, but wasn't found in AD using list query; won't be preferred", server.Fqdn);
                        this.localServer = this.context.ServerPickerClient.CreatePickerServer(server, this);
                    }
                }
                try
                {
                    this.localIP = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0];
                }
                catch (SocketException ex)
                {
                    this.context.Tracer.TraceError <string>(0L, "Can't get local IP address due to: {0}", ex.ToString());
                    ExEventLog.EventTuple tuple2 = this.context.HasValidConfiguration ? ApplicationLogicEventLogConstants.Tuple_CantGetLocalIPWarning : ApplicationLogicEventLogConstants.Tuple_CantGetLocalIP;
                    this.context.LogEvent(tuple2, ex.GetType().FullName, new object[]
                    {
                        ex
                    });
                    return;
                }
                this.localIPBytes = this.localIP.GetAddressBytes();
                this.context.Tracer.TracePfd <int, string, int>(0L, "PFD EMS {0} Finished finding {1} servers: {2} found.", 19355, this.context.ServerRole.ToString(), this.serverList.Count);
                this.isValid = true;
            }
        }
        // Token: 0x0600105D RID: 4189 RVA: 0x000430E4 File Offset: 0x000412E4
        internal bool IsEligibleForUse(PickerServer server)
        {
            int num = this.serverList.IndexOf(server);

            return(num != -1 && this.serverList[num].IsEligibleForUse());
        }
        // Token: 0x06001039 RID: 4153 RVA: 0x0004252C File Offset: 0x0004072C
        public override bool Equals(object serverObj)
        {
            PickerServer pickerServer = serverObj as PickerServer;

            return(pickerServer != null && (string.Equals(this.LegacyDN, pickerServer.LegacyDN, StringComparison.OrdinalIgnoreCase) && string.Equals(this.FQDN, pickerServer.FQDN, StringComparison.OrdinalIgnoreCase)) && string.Equals(this.MachineName, pickerServer.MachineName, StringComparison.OrdinalIgnoreCase));
        }