コード例 #1
0
        // Token: 0x06004F88 RID: 20360 RVA: 0x0012586C File Offset: 0x00123A6C
        internal static List <TopologySite> OrderDestinationSites(ICollection <TopologySite> sites, TopologySite sourceSite, ICollection <TopologySite> destinationSites)
        {
            int num  = (sites == null) ? 0 : sites.Count;
            int num2 = (destinationSites == null) ? 0 : destinationSites.Count;
            Dictionary <TopologySite, int> costMap = new Dictionary <TopologySite, int>(num + num2);

            if (num != 0 && num2 != 0 && sourceSite != null)
            {
                foreach (TopologySite key in sites)
                {
                    costMap[key] = int.MaxValue;
                }
                foreach (TopologySite key2 in destinationSites)
                {
                    costMap[key2] = int.MaxValue;
                }
                costMap[sourceSite] = 0;
                List <TopologySite> list = new List <TopologySite>(costMap.Count);
                list.Add(sourceSite);
                while (list.Count > 0)
                {
                    list.Sort((TopologySite a, TopologySite b) => costMap[b].CompareTo(costMap[a]));
                    TopologySite topologySite = list[list.Count - 1];
                    list.RemoveAt(list.Count - 1);
                    foreach (ITopologySiteLink topologySiteLink in topologySite.TopologySiteLinks)
                    {
                        TopologySiteLink topologySiteLink2 = (TopologySiteLink)topologySiteLink;
                        foreach (ITopologySite topologySite2 in topologySiteLink2.TopologySites)
                        {
                            TopologySite topologySite3 = (TopologySite)topologySite2;
                            if (topologySite3 != topologySite && costMap.ContainsKey(topologySite3))
                            {
                                int num3 = costMap[topologySite] + topologySiteLink2.Cost;
                                if (num3 < costMap[topologySite3])
                                {
                                    costMap[topologySite3] = num3;
                                    if (!list.Contains(topologySite3))
                                    {
                                        list.Add(topologySite3);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            List <TopologySite> list2 = new List <TopologySite>(num2);

            foreach (TopologySite item in costMap.Keys)
            {
                if (destinationSites.Contains(item))
                {
                    list2.Add(item);
                }
            }
            list2.Sort((TopologySite a, TopologySite b) => costMap[a].CompareTo(costMap[b]));
            return(list2);
        }
コード例 #2
0
        public TopologySite FindClosestDestinationSite(TopologySite sourceSite, ICollection <TopologySite> destinationSites)
        {
            if (destinationSites == null || destinationSites.Count == 0)
            {
                return(null);
            }
            if (sourceSite == null || destinationSites.Contains(sourceSite))
            {
                return(sourceSite);
            }
            ReadOnlyCollection <TopologySite> sitesSortedByCostFromSite = this.GetSitesSortedByCostFromSite(sourceSite);

            foreach (TopologySite topologySite in sitesSortedByCostFromSite)
            {
                if (destinationSites.Contains(topologySite))
                {
                    return(topologySite);
                }
            }
            return(null);
        }
コード例 #3
0
        // Token: 0x06004F87 RID: 20359 RVA: 0x001252FC File Offset: 0x001234FC
        private void BuildInitialLinks()
        {
            ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int>(0L, "PFD ADPEXT {0} - Creating topology objects and building links", 18613);
            this.aDServerSiteDictionary = new Dictionary <string, TopologySite>(StringComparer.OrdinalIgnoreCase);
            this.siteADServerDictionary = new Dictionary <string, List <ADServer> >(StringComparer.OrdinalIgnoreCase);
            this.topoSites      = new List <TopologySite>(this.sites.Count);
            this.topoSiteLinks  = new List <TopologySiteLink>(this.siteLinks.Count);
            this.siteDictionary = new Dictionary <string, TopologySite>(this.sites.Count, StringComparer.OrdinalIgnoreCase);
            this.topoServers    = new List <TopologyServer>(this.servers.Count);
            Dictionary <TopologySite, List <ITopologySiteLink> > dictionary = new Dictionary <TopologySite, List <ITopologySiteLink> >(this.sites.Count);
            bool flag = ExchangeTopologyDiscovery.IncludeADServers(this.topologyScope);

            ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int>(0L, "PFD ADPEXT {0} - Creating TopologySites and hash them by site DN", 22709);
            foreach (ADSite site in this.sites)
            {
                TopologySite topologySite = new TopologySite(site);
                this.siteDictionary.Add(topologySite.DistinguishedName, topologySite);
                dictionary.Add(topologySite, new List <ITopologySiteLink>());
                this.topoSites.Add(topologySite);
            }
            ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int>(0L, "PFD ADPEXT {0} - Creating TopologySiteLinks and filling the TopologySites collection", 30901);
            foreach (ADSiteLink adsiteLink in this.siteLinks)
            {
                TopologySiteLink     topologySiteLink = new TopologySiteLink(adsiteLink);
                List <ITopologySite> list             = new List <ITopologySite>(topologySiteLink.Sites.Count);
                foreach (ADObjectId adobjectId in topologySiteLink.Sites)
                {
                    TopologySite topologySite2 = null;
                    if (!this.siteDictionary.TryGetValue(adobjectId.DistinguishedName, out topologySite2))
                    {
                        ExTraceGlobals.ExchangeTopologyTracer.TraceWarning <string, string>(0L, "Site link {0} points to nonexistent site {1} (likely a transient replication issue). Ignoring this pointer.", adsiteLink.Name, adobjectId.DistinguishedName);
                    }
                    else
                    {
                        list.Add(topologySite2);
                        dictionary[topologySite2].Add(topologySiteLink);
                    }
                }
                topologySiteLink.TopologySites = new ReadOnlyCollection <ITopologySite>(list);
                this.topoSiteLinks.Add(topologySiteLink);
            }
            ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int>(0L, "PFD ADPEXT {0} - Filling each site's TopologySiteLinks collection", 16565);
            foreach (TopologySite topologySite3 in this.topoSites)
            {
                List <ITopologySiteLink> list2 = null;
                if (!dictionary.TryGetValue(topologySite3, out list2))
                {
                    if (this.topoSites.Count > 1)
                    {
                        ExTraceGlobals.ExchangeTopologyTracer.TraceWarning <string>(0L, "Site {0} is not linked to any sites.", topologySite3.Name);
                    }
                    list2 = new List <ITopologySiteLink>();
                }
                topologySite3.TopologySiteLinks = new ReadOnlyCollection <ITopologySiteLink>(list2);
            }
            ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int>(0L, "PFD ADPEXT {0} - Creating TopologyServers", 24757);
            foreach (MiniTopologyServer server in this.servers)
            {
                TopologyServer item = new TopologyServer(server);
                this.topoServers.Add(item);
            }
            if (flag)
            {
                ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int>(0L, "PFD ADPEXT {0} - Filling the ADServerSite dictionary with domain controller site mappings", 28853);
                foreach (ADServer adserver in this.aDServers)
                {
                    string       distinguishedName = adserver.Id.Parent.Parent.DistinguishedName;
                    TopologySite topologySite4;
                    if (!this.siteDictionary.TryGetValue(distinguishedName, out topologySite4))
                    {
                        ExTraceGlobals.ExchangeTopologyTracer.TraceWarning <string, string>(0L, "AD Server {0} points to nonexistent site {1} (likely a replication issue).", adserver.DnsHostName, distinguishedName);
                    }
                    else
                    {
                        this.aDServerSiteDictionary[adserver.DnsHostName] = topologySite4;
                        this.aDServerSiteDictionary[adserver.Name]        = topologySite4;
                        ExTraceGlobals.ExchangeTopologyTracer.TraceDebug <string, string>(0L, "ADServer {0} is assigned a static site {1}.", adserver.DnsHostName, topologySite4.Name);
                        List <ADServer> list3;
                        if (!this.siteADServerDictionary.TryGetValue(distinguishedName, out list3))
                        {
                            list3 = new List <ADServer>();
                            this.siteADServerDictionary.Add(distinguishedName, list3);
                            ExTraceGlobals.ExchangeTopologyTracer.TraceDebug <string>(0L, "Adding site {0} to the siteADServerDictionary.", topologySite4.Name);
                        }
                        list3.Add(adserver);
                        ExTraceGlobals.ExchangeTopologyTracer.TraceDebug <string, string>(0L, "Adding ADServer {0} to the siteADServerDictionary under site {1}.", adserver.DnsHostName, topologySite4.Name);
                    }
                }
            }
        }
コード例 #4
0
 public ReadOnlyCollection <TopologySite> GetSitesSortedByCostFromSite(TopologySite sourceSite)
 {
     return(new ReadOnlyCollection <TopologySite>(ExchangeTopologyDiscovery.OrderDestinationSites(this.allTopologySites, sourceSite, this.allTopologySites)));
 }
コード例 #5
0
 internal ExchangeTopology(DateTime discoveryStarted, ExchangeTopologyScope topologyScope, ReadOnlyCollection <TopologyServer> allTopologyServers, ReadOnlyCollection <TopologySite> allTopologySites, ReadOnlyCollection <TopologySiteLink> allTopologySiteLinks, ReadOnlyCollection <MiniVirtualDirectory> allVirtualDirectories, ReadOnlyCollection <MiniEmailTransport> allEmailTransports, ReadOnlyCollection <MiniReceiveConnector> allSmtpReceiveConnectors, ReadOnlyCollection <ADServer> allAdServers, Dictionary <string, TopologySite> aDServerSiteDictionary, Dictionary <string, ReadOnlyCollection <ADServer> > siteADServerDictionary, Dictionary <string, TopologySite> siteDictionary, string localServerFqdn)
 {
     this.discoveryStarted         = discoveryStarted;
     this.topologyScope            = topologyScope;
     this.allTopologyServers       = allTopologyServers;
     this.allTopologySites         = allTopologySites;
     this.allTopologySiteLinks     = allTopologySiteLinks;
     this.allVirtualDirectories    = allVirtualDirectories;
     this.allEmailTransports       = allEmailTransports;
     this.allSmtpReceiveConnectors = allSmtpReceiveConnectors;
     this.aDServerSiteDictionary   = aDServerSiteDictionary;
     this.siteADServerDictionary   = siteADServerDictionary;
     this.whenCreated = DateTime.UtcNow;
     ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int>(0L, "PFD ADPEXT {0} - Creating ExchangeTopology for public consumption", 25525);
     this.exchangeServerDictionary = new Dictionary <string, TopologyServer>(this.allTopologyServers.Count, StringComparer.OrdinalIgnoreCase);
     foreach (TopologyServer topologyServer in this.allTopologyServers)
     {
         this.exchangeServerDictionary.Add(topologyServer.Id.DistinguishedName, topologyServer);
         if (this.localServer == null && string.Compare(localServerFqdn, topologyServer.Fqdn, StringComparison.OrdinalIgnoreCase) == 0)
         {
             this.localServer = topologyServer;
         }
     }
     ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int, string>(0L, "PFD ADPEXT {0} - The local server is {1}", 17333, (this.localServer != null) ? this.localServer.Fqdn : "<undefined>");
     if (this.localServer != null)
     {
         this.localSite = this.localServer.TopologySite;
         ExTraceGlobals.ExchangeTopologyTracer.TraceDebug <string>(0L, "Local site: {0}", (this.localSite != null) ? this.localSite.Name : "none");
     }
     else
     {
         string siteName = NativeHelpers.GetSiteName(false);
         if (string.IsNullOrEmpty(siteName))
         {
             ExTraceGlobals.ExchangeTopologyTracer.TraceDebug(0L, "Computer doesn't belong to any site");
         }
         else
         {
             ExTraceGlobals.ExchangeTopologyTracer.TraceDebug <string>(0L, "GetSiteName returned: {0}", siteName);
             foreach (TopologySite topologySite in this.allTopologySites)
             {
                 if (string.Compare(topologySite.Name, siteName) == 0)
                 {
                     this.localSite = topologySite;
                     ExTraceGlobals.ExchangeTopologyTracer.TraceDebug <string>(0L, "Local site: {0}", this.localSite.Name);
                     break;
                 }
             }
         }
     }
     ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int, string>(0L, "PFD ADPEXT {0} - The local site is {1}", 31669, (this.localSite != null) ? this.localSite.Name : "<undefined>");
     if (allAdServers != null)
     {
         this.adServerDictionary = new Dictionary <string, ADServer>(allAdServers.Count, StringComparer.OrdinalIgnoreCase);
         foreach (ADServer adserver in allAdServers)
         {
             this.adServerDictionary.Add(adserver.DnsHostName, adserver);
         }
     }
     if (ExTraceGlobals.ExchangeTopologyTracer.IsTraceEnabled(TraceType.PfdTrace))
     {
         foreach (TopologyServer topologyServer2 in this.allTopologyServers)
         {
             ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int, string, string>((long)this.GetHashCode(), "PFD ADPEXT {0} - Server: {1} belongs to {2}", 23477, topologyServer2.Name, (topologyServer2.TopologySite == null) ? "no site" : topologyServer2.TopologySite.Name);
             ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int, string, string>((long)this.GetHashCode(), "PFD ADPEXT {0} - Server: FQDN for {1} is {2}", 22453, topologyServer2.Name, topologyServer2.Fqdn);
         }
         foreach (TopologySite topologySite2 in this.allTopologySites)
         {
             StringBuilder stringBuilder = new StringBuilder();
             foreach (ITopologySiteLink topologySiteLink in topologySite2.TopologySiteLinks)
             {
                 TopologySiteLink topologySiteLink2 = (TopologySiteLink)topologySiteLink;
                 stringBuilder.Append(topologySiteLink2.Name);
                 stringBuilder.Append(", ");
             }
             ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int, string, StringBuilder>((long)this.GetHashCode(), "PFD ADPEXT {0} - Site: {1} links to {2}", 30645, topologySite2.Name, stringBuilder);
         }
         foreach (TopologySiteLink topologySiteLink3 in this.allTopologySiteLinks)
         {
             StringBuilder stringBuilder2 = new StringBuilder();
             foreach (ITopologySite topologySite3 in topologySiteLink3.TopologySites)
             {
                 TopologySite topologySite4 = (TopologySite)topologySite3;
                 stringBuilder2.Append(topologySite4.Name);
                 stringBuilder2.Append(", ");
             }
             ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int, string, StringBuilder>((long)this.GetHashCode(), "PFD ADPEXT {0} - SiteLink: {1} connects {2}", 19381, topologySiteLink3.Name, stringBuilder2);
         }
         if (this.allVirtualDirectories != null)
         {
             foreach (MiniVirtualDirectory miniVirtualDirectory in this.allVirtualDirectories)
             {
                 ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int, string, ADObjectId>((long)this.GetHashCode(), "PFD ADPEXT {0} - VirtualDirectory: {1} on {2}", 27573, miniVirtualDirectory.Name, miniVirtualDirectory.Server);
             }
         }
         if (this.allEmailTransports != null)
         {
             foreach (MiniEmailTransport miniEmailTransport in this.allEmailTransports)
             {
                 ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int, string>((long)this.GetHashCode(), "PFD ADPEXT {0} - Email Transport: {1}", 63987, miniEmailTransport.Name);
             }
         }
         if (this.allSmtpReceiveConnectors != null)
         {
             foreach (MiniReceiveConnector miniReceiveConnector in this.allSmtpReceiveConnectors)
             {
                 ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int, string>((long)this.GetHashCode(), "PFD ADPEXT {0} - SMTP Receive Connector: {1}", 47603, miniReceiveConnector.Name);
             }
         }
         if (allAdServers != null)
         {
             foreach (ADServer adserver2 in allAdServers)
             {
                 ExTraceGlobals.ExchangeTopologyTracer.TracePfd <int, string, AdName>((long)this.GetHashCode(), "PFD ADPEXT {0} - Domain Controller: {1} on Site {2}", 54149, adserver2.DnsHostName, adserver2.Id.Parent.Parent.Rdn);
             }
         }
     }
 }