Пример #1
0
 internal bool ResolveRoute(IRoutingKey routingKey, IRouteSelectorDiagnostics diagnostics, out IRoutingEntry foundEntry, out IList <IRoutingEntry> routingEntries)
 {
     routingEntries = new List <IRoutingEntry>();
     for (int i = 0; i < 5; i++)
     {
         diagnostics.ProcessRoutingKey(routingKey);
         IRoutingEntry routingEntry = ServerLocator.GetRoutingEntry(routingKey, this.sharedCacheLookupFactory, diagnostics);
         if (routingEntry != null)
         {
             diagnostics.ProcessRoutingEntry(routingEntry);
         }
         if (routingEntry == null)
         {
             routingEntry = ServerLocator.GetRoutingEntry(routingKey, this.locatorServiceLookupFactory, diagnostics);
             if (routingEntry != null)
             {
                 if (ServerLocator.IsMailboxServerCacheKey(routingEntry.Key) && !this.mailboxServerCacheClient.AddEntry(routingEntry))
                 {
                     string value = string.Format("[ServerLocator::ResolveRoute]: RoutingEntry returned from MBLS could not be added to MailboxServer cache: {0}", routingEntry);
                     diagnostics.AddErrorInfo(value);
                 }
                 if (ServerLocator.IsAnchorMailboxCacheKey(routingEntry.Key) && !this.anchorMailboxCacheClient.AddEntry(routingEntry))
                 {
                     string value2 = string.Format("[ServerLocator::ResolveRoute]: RoutingEntry returned from MBLS could not be added to AnchorMailbox cache: {0}", routingEntry);
                     diagnostics.AddErrorInfo(value2);
                 }
             }
             else
             {
                 string value3 = string.Format("[ServerLocator::ResolveRoute]: MBLS could not find entry for key {0}", routingKey);
                 diagnostics.AddErrorInfo(value3);
             }
         }
         if (routingEntry == null)
         {
             break;
         }
         routingEntries.Add(routingEntry);
         string text = ServerLocator.OrganizationNameForLogging(routingEntry.Key);
         if (!string.IsNullOrEmpty(text))
         {
             diagnostics.SetOrganization(text);
         }
         IRoutingKey routingKey2 = routingEntry.Destination.CreateRoutingKey();
         if (routingKey2 == null)
         {
             foundEntry = routingEntry;
             return(true);
         }
         routingKey = routingKey2;
     }
     foundEntry = null;
     return(false);
 }
Пример #2
0
        public virtual ServerLocatorReturn LocateServer(IRoutingKey[] keys, IRouteSelectorDiagnostics diagnostics)
        {
            IRoutingKey           successKey     = null;
            IRoutingEntry         routingEntry   = null;
            IList <IRoutingEntry> routingEntries = null;
            string value;

            if (keys != null)
            {
                foreach (IRoutingKey routingKey in keys)
                {
                    if (routingKey != null)
                    {
                        if (this.ResolveRoute(routingKey, diagnostics, out routingEntry, out routingEntries))
                        {
                            successKey = routingKey;
                            break;
                        }
                    }
                    else
                    {
                        value = "[ServerLocator::LocateServer]: null key value in collection.";
                        diagnostics.AddErrorInfo(value);
                    }
                }
            }
            else
            {
                value = "[ServerLocator::LocateServer]: null keys collection.";
                diagnostics.AddErrorInfo(value);
            }
            SuccessfulDatabaseGuidRoutingEntry successfulDatabaseGuidRoutingEntry = routingEntry as SuccessfulDatabaseGuidRoutingEntry;

            if (successfulDatabaseGuidRoutingEntry != null)
            {
                ServerRoutingDestination serverRoutingDestination = successfulDatabaseGuidRoutingEntry.Destination as ServerRoutingDestination;
                return(new ServerLocatorReturn(serverRoutingDestination.Fqdn, serverRoutingDestination.Version, successKey, routingEntries));
            }
            SuccessfulServerRoutingEntry successfulServerRoutingEntry = routingEntry as SuccessfulServerRoutingEntry;

            if (successfulServerRoutingEntry != null)
            {
                ServerRoutingDestination serverRoutingDestination2 = successfulServerRoutingEntry.Destination as ServerRoutingDestination;
                return(new ServerLocatorReturn(serverRoutingDestination2.Fqdn, serverRoutingDestination2.Version, successKey, routingEntries));
            }
            value = string.Format("[ServerLocator::LocateServer]: RoutingEntry returned was of an unexpected type: {0}", (routingEntry != null) ? routingEntry.GetType() : null);
            diagnostics.AddErrorInfo(value);
            return(null);
        }