IRoutingEntry IRoutingLookup.GetRoutingEntry(IRoutingKey routingKey, IRoutingDiagnostics diagnostics)
        {
            if (routingKey == null)
            {
                throw new ArgumentNullException("routingKey");
            }
            if (diagnostics == null)
            {
                throw new ArgumentNullException("diagnostics");
            }
            ServerRoutingKey serverRoutingKey = routingKey as ServerRoutingKey;

            if (serverRoutingKey == null)
            {
                string message = string.Format("Routing key type {0} is not supported", routingKey.GetType());
                throw new ArgumentException(message, "routingKey");
            }
            if (!string.IsNullOrEmpty(serverRoutingKey.Server))
            {
                int?version = null;
                if (serverRoutingKey.Version != null)
                {
                    version = serverRoutingKey.Version;
                }
                else
                {
                    version = this.versionLookup.LookupVersion(serverRoutingKey.Server);
                }
                return(new SuccessfulServerRoutingEntry(serverRoutingKey, new ServerRoutingDestination(serverRoutingKey.Server, version), DateTime.UtcNow.ToFileTimeUtc()));
            }
            ErrorRoutingDestination destination = new ErrorRoutingDestination("Could not extract server from ServerRoutingKey");

            return(new FailedServerRoutingEntry(serverRoutingKey, destination, DateTime.UtcNow.ToFileTimeUtc()));
        }
Esempio n. 2
0
        IRoutingKey[] IAddressFinder.Find(AddressFinderSource source, IAddressFinderDiagnostics diagnostics)
        {
            AddressFinderHelper.ThrowIfNull(source, diagnostics);
            string text = source.Headers["X-PreferServerAffinity"];

            if (!string.IsNullOrEmpty(text) && text.Equals(bool.TrueString, StringComparison.OrdinalIgnoreCase))
            {
                HttpCookie httpCookie = source.Cookies["X-BackEndOverrideCookie"];
                string     text2      = (httpCookie == null) ? null : httpCookie.Value;
                if (!string.IsNullOrEmpty(text2))
                {
                    string text3;
                    string s;
                    Utilities.GetTwoSubstrings(text2, '~', out text3, out s);
                    int value;
                    if (!string.IsNullOrWhiteSpace(text3) && int.TryParse(s, out value))
                    {
                        IRoutingKey routingKey = new ServerRoutingKey(text3, new int?(value));
                        diagnostics.AddRoutingkey(routingKey, "X-BackEndOverrideCookie");
                        return(AddressFinderHelper.GetRoutingKeyArray(new IRoutingKey[]
                        {
                            routingKey
                        }));
                    }
                    diagnostics.AddErrorInfo("Unable to parse TargetServer:" + text2);
                }
            }
            return(AddressFinderHelper.EmptyRoutingKeyArray);
        }
Esempio n. 3
0
 public SuccessfulServerRoutingEntry(ServerRoutingKey key, ServerRoutingDestination destination, long timestamp) : base(key, timestamp)
 {
     if (destination == null)
     {
         throw new ArgumentNullException("destination");
     }
     this.destination = destination;
 }
Esempio n. 4
0
 protected ServerRoutingEntry(ServerRoutingKey key, long timestamp)
 {
     if (key == null)
     {
         throw new ArgumentNullException("key");
     }
     this.key       = key;
     this.timestamp = timestamp;
 }
Esempio n. 5
0
        private static IRoutingKey FindByTargetServer(string targetServer, IAddressFinderDiagnostics diagnostics)
        {
            if (string.IsNullOrEmpty(targetServer))
            {
                return(null);
            }
            IRoutingKey routingKey = new ServerRoutingKey(targetServer);

            diagnostics.AddRoutingkey(routingKey, "TargetServerInHeader");
            return(routingKey);
        }
Esempio n. 6
0
        private static IRoutingKey DeserializeRoutingKey(string type, string value)
        {
            switch (type)
            {
            case "ArchiveSmtp":
            {
                ArchiveSmtpRoutingKey result;
                if (ArchiveSmtpRoutingKey.TryParse(value, out result))
                {
                    return(result);
                }
                break;
            }

            case "DatabaseGuid":
            {
                DatabaseGuidRoutingKey result2;
                if (DatabaseGuidRoutingKey.TryParse(value, out result2))
                {
                    return(result2);
                }
                break;
            }

            case "MailboxGuid":
            {
                MailboxGuidRoutingKey result3;
                if (MailboxGuidRoutingKey.TryParse(value, out result3))
                {
                    return(result3);
                }
                break;
            }

            case "Smtp":
            {
                SmtpRoutingKey result4;
                if (SmtpRoutingKey.TryParse(value, out result4))
                {
                    return(result4);
                }
                break;
            }

            case "Server":
            {
                ServerRoutingKey result5;
                if (ServerRoutingKey.TryParse(value, out result5))
                {
                    return(result5);
                }
                break;
            }

            case "Oid":
            {
                ExternalDirectoryObjectIdRoutingKey result6;
                if (ExternalDirectoryObjectIdRoutingKey.TryParse(value, out result6))
                {
                    return(result6);
                }
                break;
            }

            case "LiveIdMemberName":
            {
                LiveIdMemberNameRoutingKey result7;
                if (LiveIdMemberNameRoutingKey.TryParse(value, out result7))
                {
                    return(result7);
                }
                break;
            }
            }
            return(new UnknownRoutingKey(type, value));
        }