Esempio n. 1
0
        internal static BackEndServer GetAnyBackEndServerForVersion <ServiceType>(ServerVersion serverVersion, bool exactVersionMatch, ClientAccessType clientAccessType, bool currentSiteOnly = false) where ServiceType : HttpService
        {
            if (serverVersion == null)
            {
                throw new ArgumentNullException("version");
            }
            ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetAnyBackEndServerForVersion", 349);
            string          empty               = string.Empty;
            int             version             = 0;
            ServerRole      serverRoleToLookFor = (serverVersion.Major < 15) ? ServerRole.ClientAccess : ServerRole.Mailbox;

            if (currentServiceTopology.TryGetRandomServerFromCurrentSite(serverRoleToLookFor, serverVersion.ToInt(), ServiceTopology.RandomServerSearchType.ExactVersion, out empty, out version, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetAnyBackEndServerForVersion", 358))
            {
                return(new BackEndServer(empty, version));
            }
            if (!exactVersionMatch)
            {
                ServerVersion serverVersion2 = new ServerVersion(serverVersion.Major, 0, 0, 0);
                if (currentServiceTopology.TryGetRandomServerFromCurrentSite(serverRoleToLookFor, serverVersion2.ToInt(), ServiceTopology.RandomServerSearchType.MinimumVersionMatchMajor, out empty, out version, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetAnyBackEndServerForVersion", 374))
                {
                    return(new BackEndServer(empty, version));
                }
            }
            if (!currentSiteOnly)
            {
                HttpService httpService = currentServiceTopology.FindAny <ServiceType>(clientAccessType, (ServiceType service) => service != null && !service.IsFrontEnd && (service.ServerRole & serverRoleToLookFor) == serverRoleToLookFor && !service.IsOutOfService && service.AdminDisplayVersionNumber == serverVersion, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetAnyBackEndServerForVersion", 389);
                if (httpService != null)
                {
                    return(new BackEndServer(httpService.ServerFullyQualifiedDomainName, httpService.ServerVersionNumber));
                }
                if (!exactVersionMatch)
                {
                    new ServerVersion(serverVersion.Major, 0, 0, 0);
                    httpService = currentServiceTopology.FindAny <ServiceType>(clientAccessType, (ServiceType service) => service != null && !service.IsFrontEnd && (service.ServerRole & serverRoleToLookFor) == serverRoleToLookFor && !service.IsOutOfService && service.ServerVersionNumber > serverVersion.ToInt() && new ServerVersion(service.ServerVersionNumber).Major == serverVersion.Major, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetAnyBackEndServerForVersion", 408);
                    if (httpService != null)
                    {
                        return(new BackEndServer(httpService.ServerFullyQualifiedDomainName, httpService.ServerVersionNumber));
                    }
                }
            }
            if (!exactVersionMatch)
            {
                ServerVersion higherVersion = new ServerVersion(serverVersion.Major + 1, 0, 0, 0);
                ServerRole    higherVersionServerRoleToLookFor = (higherVersion.Major < 15) ? ServerRole.ClientAccess : ServerRole.Mailbox;
                if (currentServiceTopology.TryGetRandomServerFromCurrentSite(higherVersionServerRoleToLookFor, higherVersion.ToInt(), ServiceTopology.RandomServerSearchType.MinimumVersion, out empty, out version, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetAnyBackEndServerForVersion", 431))
                {
                    return(new BackEndServer(empty, version));
                }
                if (!currentSiteOnly)
                {
                    HttpService httpService2 = currentServiceTopology.FindAny <ServiceType>(clientAccessType, (ServiceType service) => service != null && !service.IsFrontEnd && (service.ServerRole & higherVersionServerRoleToLookFor) == higherVersionServerRoleToLookFor && !service.IsOutOfService && service.ServerVersionNumber > higherVersion.ToInt(), "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetAnyBackEndServerForVersion", 444);
                    if (httpService2 != null)
                    {
                        return(new BackEndServer(httpService2.ServerFullyQualifiedDomainName, httpService2.ServerVersionNumber));
                    }
                }
            }
            string message = string.Format("Unable to find any backend server for version {0}.", serverVersion);

            throw new ServerNotFoundException(message, serverVersion.ToString());
        }