Exemplo n.º 1
0
        public static ServerRole GetProperty(string property, ServerRole defaultValue)
        {
            string value = ReadString(property);

            if (value == null)
            {
                return(defaultValue);
            }

            switch (value.ToLower())
            {
            case "1":
            case "node":
                return(ServerRole.Node);

            case "0":
            case "proxy":
                return(ServerRole.Proxy);

            case "2":
            case "full":
                return(ServerRole.Full);

            default:
                return(defaultValue);
            }
        }
Exemplo n.º 2
0
        private TransportService GetDefaultTransportServiceRole()
        {
            ITopologyConfigurationSession session = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 258, "GetDefaultTransportServiceRole", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\transport\\AgentLog\\GetAgentLog.cs");
            Server            localServer         = null;
            ADOperationResult adoperationResult   = ADNotificationAdapter.TryRunADOperation(delegate()
            {
                localServer = session.FindLocalServer();
            });

            if (!adoperationResult.Succeeded)
            {
                base.WriteError(adoperationResult.Exception, ErrorCategory.ReadError, null);
            }
            ServerRole currentServerRole = localServer.CurrentServerRole;

            if ((currentServerRole & ServerRole.HubTransport) != ServerRole.None)
            {
                return(TransportService.Hub);
            }
            if ((currentServerRole & ServerRole.Edge) != ServerRole.None)
            {
                return(TransportService.Edge);
            }
            if ((currentServerRole & ServerRole.FrontendTransport) != ServerRole.None)
            {
                return(TransportService.FrontEnd);
            }
            if ((currentServerRole & ServerRole.Mailbox) != ServerRole.None)
            {
                return(TransportService.MailboxDelivery);
            }
            return(TransportService.Hub);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new server.
        /// </summary>
        /// <param name="createServerDto">The creation request data.</param>
        /// <param name="owner">The user creating the server.</param>
        /// <returns>The result of the creation.</returns>
        public async Task <CreateServerResult> CreateServerAsync(CreateServerDto createServerDto, ApplicationUser owner)
        {
            var validationResult = AnnotationValidator.TryValidate(createServerDto);

            if (validationResult.Failed)
            {
                return(CreateServerResult.Fail(validationResult.Error.ToErrorList()));
            }

            var server   = new Server(createServerDto.Name, createServerDto.PrivacyLevel, createServerDto.Description);
            var category = Category.CreateDefaultWelcomeCategory(server);

            server.Categories.Add(category);
            server.Members.Add(owner);

            var adminRole = ServerRole.CreateDefaultAdminRole(server);

            await _serverRepository.InsertAsync(server);

            await _serverRoleRepository.InsertAsync(adminRole);

            await _userRoleRepository.InsertAsync(new IdentityUserRole <Guid>
            {
                UserId = owner.Id,
                RoleId = adminRole.Id
            });

            await _serverRepository.CommitAsync();

            return(CreateServerResult.Ok(server));
        }
        public override int GetHashCode()
        {
            int hashcode = 157;

            unchecked {
                if ((ServiceName != null))
                {
                    hashcode = (hashcode * 397) + ServiceName.GetHashCode();
                }
                if ((ServerRole != null))
                {
                    hashcode = (hashcode * 397) + ServerRole.GetHashCode();
                }
                if ((Host != null))
                {
                    hashcode = (hashcode * 397) + Host.GetHashCode();
                }
                if ((Port != null))
                {
                    hashcode = (hashcode * 397) + Port.GetHashCode();
                }
                hashcode = (hashcode * 397) + Transport.GetHashCode();
                if ((Downstream_ != null) && __isset.downstream)
                {
                    hashcode = (hashcode * 397) + Downstream_.GetHashCode();
                }
            }
            return(hashcode);
        }
Exemplo n.º 5
0
        // Token: 0x060054C6 RID: 21702 RVA: 0x001325B4 File Offset: 0x001307B4
        internal static ServerRole ConvertE15ServerRoleToOutput(ServerRole serverRole)
        {
            if (serverRole == ServerRole.Edge)
            {
                return(serverRole);
            }
            bool       flag        = (serverRole & ServerRole.Cafe) != ServerRole.None;
            bool       flag2       = (serverRole & ServerRole.Mailbox) != ServerRole.None;
            ServerRole serverRole2 = ServerRole.Mailbox;

            if (Globals.IsDatacenter)
            {
                if (!flag)
                {
                    serverRole2 |= ServerRole.FrontendTransport;
                }
                if (!flag2)
                {
                    serverRole2 |= ServerRole.HubTransport;
                }
            }
            serverRole &= serverRole2;
            if (flag)
            {
                serverRole |= ServerRole.ClientAccess;
            }
            return(serverRole);
        }
        public override string ToString()
        {
            var sb = new StringBuilder("Downstream(");

            if ((ServiceName != null))
            {
                sb.Append(", ServiceName: ");
                ServiceName.ToString(sb);
            }
            if ((ServerRole != null))
            {
                sb.Append(", ServerRole: ");
                ServerRole.ToString(sb);
            }
            if ((Host != null))
            {
                sb.Append(", Host: ");
                Host.ToString(sb);
            }
            if ((Port != null))
            {
                sb.Append(", Port: ");
                Port.ToString(sb);
            }
            sb.Append(", Transport: ");
            Transport.ToString(sb);
            if ((Downstream_ != null) && __isset.downstream)
            {
                sb.Append(", Downstream_: ");
                Downstream_.ToString(sb);
            }
            sb.Append(')');
            return(sb.ToString());
        }
        // Token: 0x060008D9 RID: 2265 RVA: 0x0001EEA8 File Offset: 0x0001D0A8
        internal static bool HasRole(ADObjectId identity, ServerRole role, IConfigDataProvider session)
        {
            ServerIdParameter serverIdParameter = new ServerIdParameter(identity.DescendantDN(8));

            ServerInfo[] serverInfo = serverIdParameter.GetServerInfo(session);
            return(serverInfo != null && serverInfo.Length == 1 && (serverInfo[0].Role & role) != ServerRole.None);
        }
Exemplo n.º 8
0
        internal static ServerRole GetLocalE12ServerRolesFromRegistry()
        {
            ServerRole serverRole = ServerRole.None;

            using (RegistryKey localMachine = Registry.LocalMachine)
            {
                using (RegistryKey registryKey = localMachine.OpenSubKey("SOFTWARE\\Microsoft\\ExchangeServer\\v15", RegistryKeyPermissionCheck.Default))
                {
                    if (registryKey != null)
                    {
                        foreach (MpServerRoles.RoleOnRegistry roleOnRegistry in MpServerRoles.E12MpRolesOnRegistry)
                        {
                            using (RegistryKey registryKey2 = registryKey.OpenSubKey(roleOnRegistry.SubKey))
                            {
                                if (registryKey2 != null)
                                {
                                    serverRole |= roleOnRegistry.RoleFlag;
                                }
                            }
                        }
                    }
                }
            }
            return(serverRole);
        }
 public ServerIdentity(string address, IEnumerable <ushort> ports, ServerRole serverRole)
 {
     Address     = address;
     Ports       = ports.ToList();
     ServerRole  = serverRole;
     PortsString = GetAsPortString(Ports);
 }
 public ServerIdentity(string address, string ports, ServerRole serverRole)
 {
     Address     = address;
     PortsString = ports;
     ServerRole  = serverRole;
     Ports       = GetAsUshortList(PortsString).ToList();
 }
Exemplo n.º 11
0
        public bool TryGetRandomServer(Site site, ServerRole serverRole, ServerVersion serverVersion, ServiceTopology.RandomServerSearchType searchType, out string serverFqdn, out int foundVersion, [CallerFilePath] string callerFilePath = null, [CallerMemberName] string memberName = null, [CallerLineNumber] int callerFileLine = 0)
        {
            ServiceTopologyLog.Instance.Append(callerFilePath, memberName, callerFileLine);
            List <TopologyServerInfo> list;

            if (this.siteToServersDictionary.TryGetValue(site, out list))
            {
                List <TopologyServerInfo> list2;
                if (ServiceTopology.RandomServerSearchType.ExactVersion == searchType)
                {
                    list2 = list.FindAll((TopologyServerInfo server) => (server.Role & serverRole) != ServerRole.None && !server.IsOutOfService && server.AdminDisplayVersionNumber == serverVersion);
                }
                else if (searchType == ServiceTopology.RandomServerSearchType.MinimumVersion)
                {
                    list2 = list.FindAll((TopologyServerInfo server) => (server.Role & serverRole) != ServerRole.None && !server.IsOutOfService && ServerVersion.Compare(server.AdminDisplayVersionNumber, serverVersion) >= 0);
                }
                else
                {
                    ServerVersion nextVersion = new ServerVersion(serverVersion.Major + 1, 0, 0, 0);
                    list2 = list.FindAll((TopologyServerInfo server) => (server.Role & serverRole) != ServerRole.None && !server.IsOutOfService && ServerVersion.Compare(server.AdminDisplayVersionNumber, serverVersion) >= 0 && ServerVersion.Compare(server.AdminDisplayVersionNumber, nextVersion) < 0);
                }
                if (list2.Count > 0)
                {
                    int index = ServiceTopology.Random.Next(list2.Count);
                    serverFqdn   = list2[index].ServerFullyQualifiedDomainName;
                    foundVersion = list2[index].VersionNumber;
                    return(true);
                }
            }
            serverFqdn   = null;
            foundVersion = 0;
            return(false);
        }
Exemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CreateServerRoleModel" /> class.
 /// </summary>
 /// <param name="createServerRoleFromApi">The server role from API.</param>
 public CreateServerRoleModel(ServerRole createServerRoleFromApi)
 {
     this.ServerRoleId = createServerRoleFromApi.ServerRoleId;
     this.Name         = createServerRoleFromApi.Name;
     this.Description  = createServerRoleFromApi.Description;
     this.IsActive     = createServerRoleFromApi.IsActive;
 }
        public bool IsAuthorized(string id, ServerRole serverRole, string topic = null)
        {
            if (string.IsNullOrWhiteSpace(id) && !AllowAnonymous)
            {
                return(false);
            }


            IEnumerable <AuthorizationProvider> roleProviders = null;

            if (string.IsNullOrWhiteSpace(topic))
            {
                roleProviders = Providers.Where(p => p.ContainsServerRole(serverRole) && p.ContainsNoTopics());
            }
            else
            {
                roleProviders = Providers.Where(p => p.ContainsServerRole(serverRole) && p.ContainsTopic(topic));
            }


            AuthorizationType isAuthorized = AuthorizationType.None;

            foreach (AuthorizationProvider provider in roleProviders)
            {
                isAuthorized |= provider.IsAuthorized(id);
            }


            bool ok = false;

            if ((isAuthorized & AuthorizationType.ExplicitDeny) == AuthorizationType.ExplicitDeny)
            {
                ok = false;
            }
            else if ((isAuthorized & AuthorizationType.ExplicitAllow) == AuthorizationType.ExplicitAllow)
            {
                ok = true;
            }
            else if ((isAuthorized & AuthorizationType.ImplicitDeny) == AuthorizationType.ImplicitDeny)
            {
                ok = false;
            }
            else if ((isAuthorized & AuthorizationType.ImplicitAllow) == AuthorizationType.ImplicitAllow)
            {
                ok = true;
            }
            else if (isAuthorized == AuthorizationType.None)
            {
                ok = true;
            }


            if (!ok)
            {
                SynapseServer.Logger.Debug($"Access Denied!  User: [{id}], Role: [{serverRole}], Topic: [{topic}].");
            }


            return(ok);
        }
        public static Uri GetOtherTierURL(IConfiguration configuration = null, ServerRole role = ServerRole.None)
        {
            var config = configuration == null?ServiceLocator.Current.GetInstance <IConfiguration>() : configuration;

            var serverRole = role == ServerRole.None ? Web.GetCurrentServerRole(configuration) : role;

            var appSetting = "";

            switch (serverRole)
            {
            case Web.ServerRole.Application:
                appSetting = "WebServerUrl";
                break;

            case Web.ServerRole.Web:
                appSetting = "AppServerUrl";
                break;

            default:
                return(null);
            }

            var baseUri = config[$"configuration:appSettings:add:{appSetting}:value"];

            if (!string.IsNullOrWhiteSpace(baseUri))
            {
                if (Uri.TryCreate(baseUri, UriKind.Absolute, out Uri result))
                {
                    return(result);
                }
            }

            return(null);
        }
Exemplo n.º 15
0
        public bool TryGetRandomServer(Site site, ServerRole serverRole, out string serverFqdn, [CallerFilePath] string callerFilePath = null, [CallerMemberName] string memberName = null, [CallerLineNumber] int callerFileLine = 0)
        {
            ServiceTopologyLog.Instance.Append(callerFilePath, memberName, callerFileLine);
            int num;

            return(this.TryGetRandomServer(site, serverRole, 0, out serverFqdn, out num, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\ServiceTopology.cs", "TryGetRandomServer", 1081));
        }
Exemplo n.º 16
0
        public async Task <bool> DeleteServerRoleAsync(ServerRole serverRole)
        {
            var response = await GetInfrastructureApiClient($"roles/delete/{serverRole?.Name}")
                           .PostJsonAsync(serverRole);

            return(response.IsSuccessStatusCode);
        }
Exemplo n.º 17
0
 public bool ContainsServerRole(ServerRole serverRole)
 {
     if (AppliesTo == null)
     {
         AppliesTo = new AuthorizationProviderFilter();
     }
     return((AppliesTo.ServerRole & serverRole) == serverRole);
 }
Exemplo n.º 18
0
 public MailboxDatabaseCalculatedCounters()
 {
     this.databaseRefreshFrequency       = Configuration.GetConfigTimeSpan("MailboxDatabaseCalculatedCounterADRefreshFrequency", TimeSpan.FromMinutes(1.0), TimeSpan.FromDays(7.0), TimeSpan.FromDays(1.0));
     this.statisticsRefreshFrequency     = Configuration.GetConfigTimeSpan("MailboxDatabaseCalculatedCounterStatisticsRefreshFrequency", TimeSpan.FromMinutes(5.0), TimeSpan.FromDays(1.0), TimeSpan.FromMinutes(5.0));
     this.lastMailboxDatabaseNameRefresh = DateTime.MinValue;
     this.lastStatisticsRefresh          = DateTime.MinValue;
     this.IsValidRole = ServerRole.IsRole("Mailbox");
 }
 public BalancingBundleInfoProviderConfig(bool overwriteBundle, string routerUrl, string publicName, IEnumerable <ushort> ports, ServerRole role)
 {
     OverwriteBundle = overwriteBundle;
     RouterUrl       = routerUrl;
     PublicName      = publicName;
     Ports           = ports;
     Role            = role;
 }
 public DatabaseMountedBitmapCalculatedCounter() : base("MSExchange Active Manager", "Database Mounted Bitmap", new string[]
 {
     "Database Mounted"
 })
 {
     this.stepDuration      = Configuration.GetConfigTimeSpan("PerfLogAggregatorAnalyzerStepDuration", TimeSpan.FromMinutes(1.0), TimeSpan.MaxValue, TimeSpan.FromMinutes(5.0));
     this.previousTimestamp = DateTime.MinValue;
     this.isEnabled         = (this.stepDuration.Ticks != 0L && ServerRole.IsRole("Mailbox"));
 }
Exemplo n.º 21
0
 // Token: 0x0600100D RID: 4109 RVA: 0x00041B44 File Offset: 0x0003FD44
 public ServerPickerManager(string serviceName, ServerRole serverRole, Trace tracer, ServerPickerClient serverPickerClient)
 {
     this.serverRole           = serverRole;
     this.serviceName          = serviceName;
     this.tracer               = tracer;
     this.serverPickerClient   = serverPickerClient;
     this.configurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 98, ".ctor", "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\ServerPicker\\ServerPickerManager.cs");
     base.ReadConfiguration();
 }
Exemplo n.º 22
0
        private void cbRole_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbRole.SelectedItem == null)
            {
                return;
            }

            ServerRole selectedRole = (ServerRole)Enum.Parse(typeof(ServerRole), cbRole.SelectedItem.ToString());

            pnlRedirectinformations.Visible = selectedRole == ServerRole.Remote;
        }
Exemplo n.º 23
0
 public bool TryGetRandomServerFromCurrentSite(ServerRole serverRole, ServerVersion serverVersion, ServiceTopology.RandomServerSearchType searchType, out string serverFqdn, out int foundVersion, [CallerFilePath] string callerFilePath = null, [CallerMemberName] string memberName = null, [CallerLineNumber] int callerFileLine = 0)
 {
     ServiceTopologyLog.Instance.Append(callerFilePath, memberName, callerFileLine);
     if ((this.localServerInfo.Role & serverRole) > ServerRole.None && ((ServiceTopology.RandomServerSearchType.ExactVersion == searchType && this.localServerInfo.AdminDisplayVersionNumber == serverVersion) || (searchType == ServiceTopology.RandomServerSearchType.MinimumVersion && ServerVersion.Compare(this.localServerInfo.AdminDisplayVersionNumber, serverVersion) >= 0) || (ServiceTopology.RandomServerSearchType.MinimumVersionMatchMajor == searchType && ServerVersion.Compare(this.localServerInfo.AdminDisplayVersionNumber, serverVersion) >= 0 && new ServerVersion(this.localServerInfo.VersionNumber).Major == serverVersion.Major)))
     {
         serverFqdn   = this.localServerInfo.ServerFullyQualifiedDomainName;
         foundVersion = this.localServerInfo.VersionNumber;
         return(true);
     }
     return(this.TryGetRandomServer(this.localServerInfo.Site, serverRole, serverVersion, searchType, out serverFqdn, out foundVersion, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\ServiceTopology.cs", "TryGetRandomServerFromCurrentSite", 1058));
 }
Exemplo n.º 24
0
        /// <summary>
        /// Returns the name of a server that is next to the user.
        /// </summary>
        /// <param name="IP">The ip of the user.</param>
        /// <returns></returns>
        public string GetServer(string IP, ServerRole role = ServerRole.Primary)
        {
            string country;

            try {
                country = GetCountry(IP);
            }
            catch
            {
                foreach (string server in this.Items.Keys)
                {
                    if (this.Items[server].Role == role && this.Items[server].State == ServerState.Online)
                    {
                        return(server);
                    }
                }

                return(null);
                //return this.Items.Where(x => x.Value.Role == role && x.Value.State == ServerState.Online).First().Key;
            }

            Dictionary <string, int> servers = new Dictionary <string, int>();

            // Run through all servers.
            foreach (string server in this.Items.Keys)
            {
                if (this.Items[server].State == ServerState.Offline)
                {
                    continue;
                }

                // Check if the country is assigned to the server.
                if (this.Items[server].Countries.Contains(country))
                {
                    servers.Add(server, this.Items[server].Sessions);
                }
            }

            // Check if servers where found for the country.
            if (servers.Count == 0)
            {
                KeyValuePair <string, Server>[] items = this.Items.Where(x => x.Value.Role == role && x.Value.State == ServerState.Online).ToArray();

                if (items.Length == 0)
                {
                    return(null);
                }

                return(items.First().Key);
            }

            // Return the server with least amount of sessions.
            return(servers.OrderBy(x => x.Value).First().Key);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Waits until the profile server receives a response message to the specific request message.
        /// </summary>
        /// <param name="Role">Specifies the role of the server to which the message had to arrive to be accepted by this wait function.</param>
        /// <param name="RequestMessage">Request message for which corresponding response we are waiting for.</param>
        /// <param name="ClearMessageList">If set to true, the message list will be cleared once the wait is finished.</param>
        /// <returns>Message the profile server received.</returns>
        public async Task <IncomingServerMessage> WaitForResponse(ServerRole Role, Message RequestMessage, bool ClearMessageList = true)
        {
            log.Trace("()");
            IncomingServerMessage res = null;
            bool done = false;

            while (!done)
            {
                lock (messageListLock)
                {
                    foreach (IncomingServerMessage ism in messageList)
                    {
                        if (!Role.HasFlag(ism.Role))
                        {
                            continue;
                        }

                        Message message = ism.IncomingMessage;
                        if (message.MessageTypeCase != Message.MessageTypeOneofCase.Response)
                        {
                            continue;
                        }

                        if (message.Id != RequestMessage.Id)
                        {
                            continue;
                        }

                        res  = ism;
                        done = true;
                        break;
                    }

                    if (done && ClearMessageList)
                    {
                        messageList.Clear();
                    }
                }

                if (!done)
                {
                    try
                    {
                        await Task.Delay(1000, shutdownCancellationTokenSource.Token);
                    }
                    catch
                    {
                    }
                }
            }

            log.Trace("(-)");
            return(res);
        }
Exemplo n.º 26
0
        // for tests
        internal ConfigServerRegistrar(IDistributedCallSection settings)
        {
            if (settings.Enabled == false)
            {
                _addresses             = new List <IServerAddress>();
                _serverRole            = ServerRole.Single;
                _umbracoApplicationUrl = null; // unspecified
                return;
            }

            var serversA = settings.Servers.ToArray();

            _addresses = serversA
                         .Select(x => new ConfigServerAddress(x))
                         .Cast <IServerAddress>()
                         .ToList();

            if (serversA.Length == 0)
            {
                _serverRole = ServerRole.Unknown; // config error, actually
                LogHelper.Debug <ConfigServerRegistrar>(string.Format("Server Role Unknown: DistributedCalls are enabled but no servers are listed"));
            }
            else
            {
                var master     = serversA[0]; // first one is master
                var appId      = master.AppId;
                var serverName = master.ServerName;

                if (appId.IsNullOrWhiteSpace() && serverName.IsNullOrWhiteSpace())
                {
                    _serverRole = ServerRole.Unknown; // config error, actually
                    LogHelper.Debug <ConfigServerRegistrar>(string.Format("Server Role Unknown: Server Name or AppId missing from Server configuration in DistributedCalls settings"));
                }
                else
                {
                    _serverRole = IsCurrentServer(appId, serverName)
                        ? ServerRole.Master
                        : ServerRole.Slave;
                }
            }

            var currentServer = serversA.FirstOrDefault(x => IsCurrentServer(x.AppId, x.ServerName));

            if (currentServer != null)
            {
                // match, use the configured url
                _umbracoApplicationUrl = string.Format("{0}://{1}:{2}/{3}",
                                                       currentServer.ForceProtocol.IsNullOrWhiteSpace() ? "http" : currentServer.ForceProtocol,
                                                       currentServer.ServerAddress,
                                                       currentServer.ForcePortnumber.IsNullOrWhiteSpace() ? "80" : currentServer.ForcePortnumber,
                                                       IOHelper.ResolveUrl(SystemDirectories.Umbraco).TrimStart('/'));
            }
        }
        private ScheduledPublishing CreateScheduledPublishing(
            bool enabled = true,
            RuntimeLevel runtimeLevel = RuntimeLevel.Run,
            ServerRole serverRole     = ServerRole.Single,
            bool isMainDom            = true)
        {
            if (enabled)
            {
                Suspendable.ScheduledPublishing.Resume();
            }
            else
            {
                Suspendable.ScheduledPublishing.Suspend();
            }

            var mockRunTimeState = new Mock <IRuntimeState>();

            mockRunTimeState.SetupGet(x => x.Level).Returns(runtimeLevel);

            var mockServerRegistrar = new Mock <IServerRoleAccessor>();

            mockServerRegistrar.Setup(x => x.CurrentServerRole).Returns(serverRole);

            var mockMainDom = new Mock <IMainDom>();

            mockMainDom.SetupGet(x => x.IsMainDom).Returns(isMainDom);

            _mockContentService = new Mock <IContentService>();

            var mockUmbracoContextFactory = new Mock <IUmbracoContextFactory>();

            mockUmbracoContextFactory.Setup(x => x.EnsureUmbracoContext()).Returns(new UmbracoContextReference(null, false, null));

            _mockLogger = new Mock <ILogger <ScheduledPublishing> >();

            var mockServerMessenger = new Mock <IServerMessenger>();

            var mockScopeProvider = new Mock <IScopeProvider>();

            mockScopeProvider
            .Setup(x => x.CreateScope(It.IsAny <IsolationLevel>(), It.IsAny <RepositoryCacheMode>(), It.IsAny <IEventDispatcher>(), It.IsAny <IScopedNotificationPublisher>(), It.IsAny <bool?>(), It.IsAny <bool>(), It.IsAny <bool>()))
            .Returns(Mock.Of <IScope>());

            return(new ScheduledPublishing(
                       mockRunTimeState.Object,
                       mockMainDom.Object,
                       mockServerRegistrar.Object,
                       _mockContentService.Object,
                       mockUmbracoContextFactory.Object,
                       _mockLogger.Object,
                       mockServerMessenger.Object,
                       mockScopeProvider.Object));
        }
Exemplo n.º 28
0
        /// <summary>
        /// Handler for each client that connects to the TCP server.
        /// </summary>
        /// <param name="Client">Client that is connected to TCP server.</param>
        /// <param name="Role"></param>
        /// <remarks>The client is being handled in the processing loop until the connection to it
        /// is terminated by either side. This function implements reading the message from the network stream,
        /// which includes reading the message length prefix followed by the entire message.</remarks>
        private async void ClientHandlerAsync(TcpClient Client, ServerRole Role)
        {
            log.Debug("(Client.Client.RemoteEndPoint:{0})", Client.Client.RemoteEndPoint);

            bool           useTls = Role != ServerRole.Primary;
            IncomingClient client = new IncomingClient(this, Client, useTls, Role);
            await client.ReceiveMessageLoop();

            client.Dispose();

            log.Debug("(-)");
        }
        public override int GetHashCode()
        {
            int hashcode = 157;

            unchecked {
                hashcode = (hashcode * 397) + ServerRole.GetHashCode();
                hashcode = (hashcode * 397) + Sampled.GetHashCode();
                hashcode = (hashcode * 397) + Baggage.GetHashCode();
                hashcode = (hashcode * 397) + Downstream.GetHashCode();
            }
            return(hashcode);
        }
Exemplo n.º 30
0
 public bool TryGetServerForRoleAndVersion(ServerRole serverRole, ServerVersion version, [CallerFilePath] string callerFilePath = null, [CallerMemberName] string memberName = null, [CallerLineNumber] int callerFileLine = 0)
 {
     ServiceTopologyLog.Instance.Append(callerFilePath, memberName, callerFileLine);
     foreach (KeyValuePair <Site, List <TopologyServerInfo> > keyValuePair in this.siteToServersDictionary)
     {
         if (keyValuePair.Value.Count((TopologyServerInfo server) => (server.Role & serverRole) == serverRole && server.AdminDisplayVersionNumber.Equals(version)) > 0)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 31
0
        public static ServerRole GetProperty(string property, ServerRole defaultValue)
        {
            string value = ReadString(property);
            if (value == null) return defaultValue;

            switch (value.ToLower())
            {
                case "1":
                case "node":
                    return ServerRole.Node;
                case "0":
                case "proxy":
                    return ServerRole.Proxy;
                case "2":
                case "full":
                    return ServerRole.Full;
                default:
                    return defaultValue;
            }
        }