// constructors public BinaryConnection(ServerId serverId, EndPoint endPoint, ConnectionSettings settings, IStreamFactory streamFactory, IConnectionInitializer connectionInitializer, IEventSubscriber eventSubscriber) { Ensure.IsNotNull(serverId, nameof(serverId)); _endPoint = Ensure.IsNotNull(endPoint, nameof(endPoint)); _settings = Ensure.IsNotNull(settings, nameof(settings)); _streamFactory = Ensure.IsNotNull(streamFactory, nameof(streamFactory)); _connectionInitializer = Ensure.IsNotNull(connectionInitializer, nameof(connectionInitializer)); Ensure.IsNotNull(eventSubscriber, nameof(eventSubscriber)); _backgroundTaskCancellationTokenSource = new CancellationTokenSource(); _backgroundTaskCancellationToken = _backgroundTaskCancellationTokenSource.Token; _connectionId = new ConnectionId(serverId); _receiveLock = new SemaphoreSlim(1); _sendLock = new SemaphoreSlim(1); _state = new InterlockedInt32(State.Initial); _commandEventHelper = new CommandEventHelper(eventSubscriber); eventSubscriber.TryGetEventHandler(out _failedEventHandler); eventSubscriber.TryGetEventHandler(out _closingEventHandler); eventSubscriber.TryGetEventHandler(out _closedEventHandler); eventSubscriber.TryGetEventHandler(out _openingEventHandler); eventSubscriber.TryGetEventHandler(out _openedEventHandler); eventSubscriber.TryGetEventHandler(out _failedOpeningEventHandler); eventSubscriber.TryGetEventHandler(out _receivingMessageEventHandler); eventSubscriber.TryGetEventHandler(out _receivedMessageEventHandler); eventSubscriber.TryGetEventHandler(out _failedReceivingMessageEventHandler); eventSubscriber.TryGetEventHandler(out _sendingMessagesEventHandler); eventSubscriber.TryGetEventHandler(out _sentMessagesEventHandler); eventSubscriber.TryGetEventHandler(out _failedSendingMessagesEvent); }
public IConnectionPool CreateConnectionPool(ServerId serverId, EndPoint endPoint) { Ensure.IsNotNull(serverId, nameof(serverId)); Ensure.IsNotNull(endPoint, nameof(endPoint)); return new ExclusiveConnectionPool(serverId, endPoint, _settings, _connectionFactory, _eventSubscriber); }
public void Setup() { _capturedEvents = new EventCapturer() .Capture<CommandStartedEvent>() .Capture<CommandSucceededEvent>() .Capture<CommandFailedEvent>(); _streamFactory = Substitute.For<IStreamFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(new ClusterId(), _endPoint); _connectionInitializer = Substitute.For<IConnectionInitializer>(); _connectionInitializer.InitializeConnectionAsync(null, CancellationToken.None) .ReturnsForAnyArgs(Task.FromResult(new ConnectionDescription( new ConnectionId(serverId), new IsMasterResult(new BsonDocument()), new BuildInfoResult(new BsonDocument("version", "2.6.3"))))); _subject = new BinaryConnection( serverId: serverId, endPoint: _endPoint, settings: new ConnectionSettings(), streamFactory: _streamFactory, connectionInitializer: _connectionInitializer, eventSubscriber: _capturedEvents); _stream = new BlockingMemoryStream(); _streamFactory.CreateStreamAsync(null, CancellationToken.None) .ReturnsForAnyArgs(Task.FromResult<Stream>(_stream)); _subject.OpenAsync(CancellationToken.None).Wait(); _capturedEvents.Clear(); _operationIdDisposer = EventContext.BeginOperation(); }
public BinaryConnection_CommandEventTests() { _capturedEvents = new EventCapturer() .Capture<CommandStartedEvent>() .Capture<CommandSucceededEvent>() .Capture<CommandFailedEvent>(); _mockStreamFactory = new Mock<IStreamFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(new ClusterId(), _endPoint); _mockConnectionInitializer = new Mock<IConnectionInitializer>(); _mockConnectionInitializer.Setup(i => i.InitializeConnectionAsync(It.IsAny<IConnection>(), CancellationToken.None)) .Returns(() => Task.FromResult(new ConnectionDescription( new ConnectionId(serverId), new IsMasterResult(new BsonDocument()), new BuildInfoResult(new BsonDocument("version", "2.6.3"))))); _subject = new BinaryConnection( serverId: serverId, endPoint: _endPoint, settings: new ConnectionSettings(), streamFactory: _mockStreamFactory.Object, connectionInitializer: _mockConnectionInitializer.Object, eventSubscriber: _capturedEvents); _stream = new BlockingMemoryStream(); _mockStreamFactory.Setup(f => f.CreateStreamAsync(_endPoint, CancellationToken.None)) .Returns(Task.FromResult<Stream>(_stream)); _subject.OpenAsync(CancellationToken.None).Wait(); _capturedEvents.Clear(); _operationIdDisposer = EventContext.BeginOperation(); }
public IConnectionPool CreateConnectionPool(ServerId serverId, EndPoint endPoint) { Ensure.IsNotNull(serverId, "serverId"); Ensure.IsNotNull(endPoint, "endPoint"); return new ExclusiveConnectionPool(serverId, endPoint, _settings, _connectionFactory, _listener); }
// constructors public ExclusiveConnectionPool( ServerId serverId, EndPoint endPoint, ConnectionPoolSettings settings, IConnectionFactory connectionFactory, IEventSubscriber eventSubscriber) { _serverId = Ensure.IsNotNull(serverId, nameof(serverId)); _endPoint = Ensure.IsNotNull(endPoint, nameof(endPoint)); _settings = Ensure.IsNotNull(settings, nameof(settings)); _connectionFactory = Ensure.IsNotNull(connectionFactory, nameof(connectionFactory)); Ensure.IsNotNull(eventSubscriber, nameof(eventSubscriber)); _connectionHolder = new ListConnectionHolder(eventSubscriber); _poolQueue = new WaitQueue(settings.MaxConnections); _waitQueue = new SemaphoreSlim(settings.WaitQueueSize); _maintenanceCancellationTokenSource = new CancellationTokenSource(); _state = new InterlockedInt32(State.Initial); eventSubscriber.TryGetEventHandler(out _checkingOutConnectionEventHandler); eventSubscriber.TryGetEventHandler(out _checkedOutConnectionEventHandler); eventSubscriber.TryGetEventHandler(out _checkingOutConnectionFailedEventHandler); eventSubscriber.TryGetEventHandler(out _checkingInConnectionEventHandler); eventSubscriber.TryGetEventHandler(out _checkedInConnectionEventHandler); eventSubscriber.TryGetEventHandler(out _addingConnectionEventHandler); eventSubscriber.TryGetEventHandler(out _addedConnectionEventHandler); eventSubscriber.TryGetEventHandler(out _openingEventHandler); eventSubscriber.TryGetEventHandler(out _openedEventHandler); eventSubscriber.TryGetEventHandler(out _closingEventHandler); eventSubscriber.TryGetEventHandler(out _closedEventHandler); eventSubscriber.TryGetEventHandler(out _addingConnectionEventHandler); eventSubscriber.TryGetEventHandler(out _addedConnectionEventHandler); }
public void Equals_should_return_expected_result( int port1, int localValue1, int serverValue1, int port2, int localValue2, int serverValue2, bool expectedEqualsResult, bool expectedStructurallyEqualsResult) { var clusterId = new ClusterId(); var serverId1 = new ServerId(clusterId, new DnsEndPoint("localhost", port1)); var serverId2 = new ServerId(clusterId, new DnsEndPoint("localhost", port2)); var subject1 = new ConnectionId(serverId1, localValue1).WithServerValue(serverValue1); var subject2 = new ConnectionId(serverId2, localValue2).WithServerValue(serverValue2); // note: Equals ignores the server values and StructurallyEquals compares all fields var equalsResult1 = subject1.Equals(subject2); var equalsResult2 = subject2.Equals(subject1); var structurallyEqualsResult1 = subject1.StructurallyEquals(subject2); var structurallyEqualsResult2 = subject2.StructurallyEquals(subject1); var hashCode1 = subject1.GetHashCode(); var hashCode2 = subject2.GetHashCode(); equalsResult1.Should().Be(expectedEqualsResult); equalsResult2.Should().Be(expectedEqualsResult); structurallyEqualsResult1.Should().Be(expectedStructurallyEqualsResult); structurallyEqualsResult2.Should().Be(expectedStructurallyEqualsResult); (hashCode1 == hashCode2).Should().Be(expectedEqualsResult); }
public void Setup() { _capturedEvents = new EventCapturer(); _streamFactory = Substitute.For<IStreamFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(new ClusterId(), _endPoint); _connectionInitializer = Substitute.For<IConnectionInitializer>(); _connectionInitializer.InitializeConnection(null, CancellationToken.None) .ReturnsForAnyArgs(new ConnectionDescription( new ConnectionId(serverId), new IsMasterResult(new BsonDocument()), new BuildInfoResult(new BsonDocument("version", "2.6.3")))); _connectionInitializer.InitializeConnectionAsync(null, CancellationToken.None) .ReturnsForAnyArgs(Task.FromResult(new ConnectionDescription( new ConnectionId(serverId), new IsMasterResult(new BsonDocument()), new BuildInfoResult(new BsonDocument("version", "2.6.3"))))); _subject = new BinaryConnection( serverId: serverId, endPoint: _endPoint, settings: new ConnectionSettings(), streamFactory: _streamFactory, connectionInitializer: _connectionInitializer, eventSubscriber: _capturedEvents); }
public BinaryConnectionTests() { _capturedEvents = new EventCapturer(); _mockStreamFactory = new Mock<IStreamFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(new ClusterId(), _endPoint); _mockConnectionInitializer = new Mock<IConnectionInitializer>(); _mockConnectionInitializer.Setup(i => i.InitializeConnection(It.IsAny<IConnection>(), CancellationToken.None)) .Returns(() => new ConnectionDescription( new ConnectionId(serverId), new IsMasterResult(new BsonDocument()), new BuildInfoResult(new BsonDocument("version", "2.6.3")))); _mockConnectionInitializer.Setup(i => i.InitializeConnectionAsync(It.IsAny<IConnection>(), CancellationToken.None)) .Returns(() => Task.FromResult(new ConnectionDescription( new ConnectionId(serverId), new IsMasterResult(new BsonDocument()), new BuildInfoResult(new BsonDocument("version", "2.6.3"))))); _subject = new BinaryConnection( serverId: serverId, endPoint: _endPoint, settings: new ConnectionSettings(), streamFactory: _mockStreamFactory.Object, connectionInitializer: _mockConnectionInitializer.Object, eventSubscriber: _capturedEvents); }
public void TestFixtureSetup() { var clusterId = new ClusterId(1); var clusterType = ClusterType.Standalone; var endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(clusterId, endPoint); var server = new ServerDescription(serverId, endPoint); var servers = new[] { server }; _clusterDescription = new ClusterDescription(clusterId, clusterType, servers); }
// static constructor static ClusterDescriptionTests() { __clusterId = new ClusterId(); __endPoint1 = new DnsEndPoint("localhost", 27017); __endPoint2 = new DnsEndPoint("localhost", 27018); __serverId1 = new ServerId(__clusterId, __endPoint1); __serverId2 = new ServerId(__clusterId, __endPoint2); __serverDescription1 = new ServerDescription(__serverId1, __endPoint1); __serverDescription2 = new ServerDescription(__serverId2, __endPoint2); }
// constructors public SharedConnectionPool( ServerId serverId, EndPoint endPoint, ConnectionPoolSettings settings, IConnectionFactory connectionFactory) { _serverId = Ensure.IsNotNull(serverId, "serverId"); _endPoint = Ensure.IsNotNull(endPoint, "endPoint"); _settings = Ensure.IsNotNull(settings, "settings"); _connectionFactory = Ensure.IsNotNull(connectionFactory, "connectionFactory"); }
public void OneTimeSetUp() { var clusterId = new ClusterId(1); var connectionMode = ClusterConnectionMode.Standalone; var clusterType = ClusterType.Standalone; var endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(clusterId, endPoint); var server = new ServerDescription(serverId, endPoint); var servers = new[] { server }; _clusterDescription = new ClusterDescription(clusterId, connectionMode, clusterType, servers); }
public MongoIncompatibleDriverExceptionTests() { var clusterId = new ClusterId(1); var connectionMode = ClusterConnectionMode.Standalone; var clusterType = ClusterType.Standalone; var endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(clusterId, endPoint); var server = new ServerDescription(serverId, endPoint); var servers = new[] { server }; _clusterDescription = new ClusterDescription(clusterId, connectionMode, clusterType, servers); }
public ExclusiveConnectionPoolFactoryTests() { _connectionFactory = new Mock<IConnectionFactory>().Object; _endPoint = new DnsEndPoint("localhost", 27017); _serverId = new ServerId(new ClusterId(), _endPoint); _eventSubscriber = new Mock<IEventSubscriber>().Object; _settings = new ConnectionPoolSettings( maintenanceInterval: Timeout.InfiniteTimeSpan, maxConnections: 4, minConnections: 2, waitQueueSize: 1); }
public void Setup() { _connectionFactory = Substitute.For<IConnectionFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); _serverId = new ServerId(new ClusterId(), _endPoint); _eventSubscriber = Substitute.For<IEventSubscriber>(); _settings = new ConnectionPoolSettings( maintenanceInterval: Timeout.InfiniteTimeSpan, maxConnections: 4, minConnections: 2, waitQueueSize: 1); }
public void Setup() { _endPoint = new DnsEndPoint("localhost", 27017); _connection = new MockConnection(); _connectionFactory = Substitute.For<IConnectionFactory>(); _connectionFactory.CreateConnection(null, null) .ReturnsForAnyArgs(_connection); _capturedEvents = new EventCapturer(); _serverId = new ServerId(new ClusterId(), _endPoint); _subject = new ServerMonitor(_serverId, _endPoint, _connectionFactory, Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan, _capturedEvents); }
public ServerMonitorTests() { _endPoint = new DnsEndPoint("localhost", 27017); _serverId = new ServerId(new ClusterId(), _endPoint); _connection = new MockConnection(); _mockConnectionFactory = new Mock<IConnectionFactory>(); _mockConnectionFactory .Setup(f => f.CreateConnection(_serverId, _endPoint)) .Returns(_connection); _capturedEvents = new EventCapturer(); _subject = new ServerMonitor(_serverId, _endPoint, _mockConnectionFactory.Object, Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan, _capturedEvents); }
// static constructor static ServerDescriptionTests() { __clusterId = new ClusterId(); __endPoint = new DnsEndPoint("localhost", 27017); __serverId = new ServerId(__clusterId, __endPoint); __subject = new ServerDescription( __serverId, __endPoint, state: ServerState.Connected, type: ServerType.Standalone, averageRoundTripTime: TimeSpan.FromSeconds(1), version: new SemanticVersion(2, 6, 3), wireVersionRange: new Range<int>(0, 2)); }
public void CreateConnection_should_throw_an_ArgumentNullException_when_endPoint_is_null() { var streamFactory = new Mock<IStreamFactory>().Object; var eventSubscriber = new Mock<IEventSubscriber>().Object; var subject = new BinaryConnectionFactory( new ConnectionSettings(), streamFactory, eventSubscriber); var serverId = new ServerId(new ClusterId(), new DnsEndPoint("localhost", 27017)); Action act = () => subject.CreateConnection(serverId, null); act.ShouldThrow<ArgumentNullException>(); }
public void CreateConnection_should_return_a_BinaryConnection() { var streamFactory = Substitute.For<IStreamFactory>(); var listener = Substitute.For<IConnectionListener>(); var subject = new BinaryConnectionFactory( new ConnectionSettings(), streamFactory, listener); var serverId = new ServerId(new ClusterId(), new DnsEndPoint("localhost", 27017)); var connection = subject.CreateConnection(serverId, serverId.EndPoint); connection.Should().NotBeNull(); connection.Should().BeOfType<BinaryConnection>(); }
public ServerMonitor(ServerId serverId, EndPoint endPoint, IConnectionFactory connectionFactory, TimeSpan interval, TimeSpan timeout, IEventSubscriber eventSubscriber) { _serverId = Ensure.IsNotNull(serverId, nameof(serverId)); _endPoint = Ensure.IsNotNull(endPoint, nameof(endPoint)); _connectionFactory = Ensure.IsNotNull(connectionFactory, nameof(connectionFactory)); Ensure.IsNotNull(eventSubscriber, nameof(eventSubscriber)); _baseDescription = _currentDescription = new ServerDescription(_serverId, endPoint); _interval = interval; _timeout = timeout; _state = new InterlockedInt32(State.Initial); eventSubscriber.TryGetEventHandler(out _heartbeatStartedEventHandler); eventSubscriber.TryGetEventHandler(out _heartbeatSucceededEventHandler); eventSubscriber.TryGetEventHandler(out _heartbeatFailedEventHandler); }
public void Equals_should_return_correct_results() { var serverId1 = __serverId; var serverId2 = new ServerId(new ClusterId(), new DnsEndPoint("localhost", 27018)); var localValue1 = 10; var localValue2 = 11; var subject1 = new ConnectionId(serverId1, localValue1); var subject2 = new ConnectionId(serverId1, localValue1); var subject3 = new ConnectionId(serverId1, localValue2); var subject4 = new ConnectionId(serverId2, localValue1); subject1.Equals(subject2).Should().BeTrue(); subject1.Equals(subject3).Should().BeFalse(); subject1.Equals(subject4).Should().BeFalse(); }
// static constructor static ServerDescriptionTests() { __clusterId = new ClusterId(); __endPoint = new DnsEndPoint("localhost", 27017); __serverId = new ServerId(__clusterId, __endPoint); __subject = new ServerDescription( __serverId, __endPoint, ServerState.Connected, ServerType.Standalone, TimeSpan.FromSeconds(1), null, null, new SemanticVersion(2, 6, 3), new Range<int>(0, 2)); }
// constructors public ExclusiveConnectionPool( ServerId serverId, EndPoint endPoint, ConnectionPoolSettings settings, IConnectionFactory connectionFactory, IConnectionPoolListener listener) { _serverId = Ensure.IsNotNull(serverId, "serverId"); _endPoint = Ensure.IsNotNull(endPoint, "endPoint"); _settings = Ensure.IsNotNull(settings, "settings"); _connectionFactory = Ensure.IsNotNull(connectionFactory, "connectionFactory"); _listener = listener; _connectionHolder = new ListConnectionHolder(_listener); _poolQueue = new WaitQueue(settings.MaxConnections); _waitQueue = new SemaphoreSlim(settings.WaitQueueSize); _maintenanceCancellationTokenSource = new CancellationTokenSource(); _state = new InterlockedInt32(State.Initial); }
public void Setup() { _connectionFactory = Substitute.For<IConnectionFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); _capturedEvents = new EventCapturer(); _serverId = new ServerId(new ClusterId(), _endPoint); _settings = new ConnectionPoolSettings( maintenanceInterval: Timeout.InfiniteTimeSpan, maxConnections: 4, minConnections: 2, waitQueueSize: 1, waitQueueTimeout: TimeSpan.FromSeconds(2)); _subject = new ExclusiveConnectionPool( _serverId, _endPoint, _settings, _connectionFactory, _capturedEvents); }
public ExclusiveConnectionPoolTests() { _mockConnectionFactory = new Mock<IConnectionFactory> { DefaultValue = DefaultValue.Mock }; _endPoint = new DnsEndPoint("localhost", 27017); _capturedEvents = new EventCapturer(); _serverId = new ServerId(new ClusterId(), _endPoint); _settings = new ConnectionPoolSettings( maintenanceInterval: Timeout.InfiniteTimeSpan, maxConnections: 4, minConnections: 2, waitQueueSize: 1, waitQueueTimeout: TimeSpan.FromSeconds(2)); _subject = new ExclusiveConnectionPool( _serverId, _endPoint, _settings, _mockConnectionFactory.Object, _capturedEvents); }
public void LogicalSessionTimeout_should_return_expected_result_with_1_server(int?timeout1, int?expectedResultMinutes) { var clusterId = new ClusterId(1); var connectionMode = ClusterConnectionMode.Automatic; var type = ClusterType.ReplicaSet; var endPoint1 = new DnsEndPoint("localhost", 27017); var serverId1 = new ServerId(clusterId, endPoint1); var server1 = new ServerDescription( serverId1, endPoint1, state: ServerState.Connected, type: ServerType.ReplicaSetPrimary, logicalSessionTimeout: timeout1 == null ? (TimeSpan?)null : TimeSpan.FromMinutes(timeout1.Value)); var servers = new[] { server1 }; var subject = new ClusterDescription(clusterId, connectionMode, type, servers); var expectedResult = expectedResultMinutes == null ? (TimeSpan?)null : TimeSpan.FromMinutes(expectedResultMinutes.Value); var result = subject.LogicalSessionTimeout; result.Should().Be(expectedResult); }
public RemoteResult Rollback(ServerId server, InnerData data) { Logger.Logger.Instance.Debug(string.Format("DistributorNetModule: rollback = {0}, data = {1}", server, data.Transaction.EventHash)); var connection = FindServer(server) as SingleConnectionToWriter; if (connection == null) { ConnectToWriter(server); connection = FindServer(server) as SingleConnectionToWriter; } if (connection == null) { _distributor.ServerNotAvailable(server); RemoveConnection(server); return(new ServerNotFoundResult()); } return(connection.RollbackData(data)); }
/// <summary> /// Initializes a new instance of the <see cref="Disconnected"/> class. /// </summary> /// <param name="message">The disconnected message.</param> /// <param name="serverId">The server identifier.</param> /// <param name="sessionId">The disconnected session identifier.</param> /// <param name="correlationId">The response correlation identifier.</param> /// <param name="id">The response identifier.</param> /// <param name="timestamp">The response timestamp.</param> public Disconnected( string message, ServerId serverId, SessionId sessionId, Guid correlationId, Guid id, ZonedDateTime timestamp) : base( EventType, correlationId, id, timestamp) { Debug.NotEmptyOrWhiteSpace(message, nameof(message)); Debug.NotDefault(id, nameof(id)); Debug.NotDefault(timestamp, nameof(timestamp)); this.Message = message; this.ServerId = serverId; this.SessionId = sessionId; }
// constructors public ExclusiveConnectionPool( ServerId serverId, EndPoint endPoint, ConnectionPoolSettings settings, IConnectionFactory connectionFactory, IEventSubscriber eventSubscriber) { _serverId = Ensure.IsNotNull(serverId, nameof(serverId)); _endPoint = Ensure.IsNotNull(endPoint, nameof(endPoint)); _settings = Ensure.IsNotNull(settings, nameof(settings)); _connectionFactory = Ensure.IsNotNull(connectionFactory, nameof(connectionFactory)); Ensure.IsNotNull(eventSubscriber, nameof(eventSubscriber)); _connectingQueue = new SemaphoreSlimSignalable(MongoInternalDefaults.ConnectionPool.MaxConnecting); _connectionHolder = new ListConnectionHolder(eventSubscriber, _connectingQueue); _serviceStates = new ServiceStates(); _poolQueue = new WaitQueue(settings.MaxConnections); #pragma warning disable 618 _waitQueue = new SemaphoreSlim(settings.WaitQueueSize); #pragma warning restore 618 _maintenanceCancellationTokenSource = new CancellationTokenSource(); _state = new InterlockedInt32(State.Initial); eventSubscriber.TryGetEventHandler(out _checkingOutConnectionEventHandler); eventSubscriber.TryGetEventHandler(out _checkedOutConnectionEventHandler); eventSubscriber.TryGetEventHandler(out _checkingOutConnectionFailedEventHandler); eventSubscriber.TryGetEventHandler(out _checkingInConnectionEventHandler); eventSubscriber.TryGetEventHandler(out _checkedInConnectionEventHandler); eventSubscriber.TryGetEventHandler(out _addingConnectionEventHandler); eventSubscriber.TryGetEventHandler(out _addedConnectionEventHandler); eventSubscriber.TryGetEventHandler(out _openingEventHandler); eventSubscriber.TryGetEventHandler(out _openedEventHandler); eventSubscriber.TryGetEventHandler(out _closingEventHandler); eventSubscriber.TryGetEventHandler(out _closedEventHandler); eventSubscriber.TryGetEventHandler(out _addingConnectionEventHandler); eventSubscriber.TryGetEventHandler(out _addedConnectionEventHandler); eventSubscriber.TryGetEventHandler(out _clearingEventHandler); eventSubscriber.TryGetEventHandler(out _clearedEventHandler); eventSubscriber.TryGetEventHandler(out _connectionCreatedEventHandler); }
public BinaryConnection_CommandEventTests() { _capturedEvents = new EventCapturer() .Capture <CommandStartedEvent>() .Capture <CommandSucceededEvent>() .Capture <CommandFailedEvent>(); _mockStreamFactory = new Mock <IStreamFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(new ClusterId(), _endPoint); _mockConnectionInitializer = new Mock <IConnectionInitializer>(); _mockConnectionInitializer.Setup(i => i.SendHelloAsync(It.IsAny <IConnection>(), CancellationToken.None)) .Returns(() => Task.FromResult(new ConnectionDescription( new ConnectionId(serverId), new IsMasterResult(new BsonDocument()), new BuildInfoResult(new BsonDocument("version", "2.6.3"))))); _mockConnectionInitializer.Setup(i => i.AuthenticateAsync(It.IsAny <IConnection>(), It.IsAny <ConnectionDescription>(), CancellationToken.None)) .Returns(() => Task.FromResult(new ConnectionDescription( new ConnectionId(serverId), new IsMasterResult(new BsonDocument()), new BuildInfoResult(new BsonDocument("version", "2.6.3"))))); _subject = new BinaryConnection( serverId: serverId, endPoint: _endPoint, settings: new ConnectionSettings(), streamFactory: _mockStreamFactory.Object, connectionInitializer: _mockConnectionInitializer.Object, eventSubscriber: _capturedEvents); _stream = new BlockingMemoryStream(); _mockStreamFactory.Setup(f => f.CreateStreamAsync(_endPoint, CancellationToken.None)) .Returns(Task.FromResult <Stream>(_stream)); _subject.OpenAsync(CancellationToken.None).Wait(); _capturedEvents.Clear(); _operationIdDisposer = EventContext.BeginOperation(); }
public void ProxyDistributorModule_TransactionDestination_CreateTransAndGetDestination() { var model = new DistributorSystemModel(); var server1 = new ServerId("localhost", 1); var server2 = new ServerId("localhost", 2); model.AddServer(server1); model.AddServer(server2); const string hash = "123"; var res1 = model.CreateTransaction(hash); Assert.IsNotNull(res1); var res2 = model.GetDestination(res1.UserTransaction); Assert.IsTrue(server1.Equals(res2)); var res3 = model.CreateTransaction(hash); Assert.IsNotNull(res3); var res4 = model.GetDestination(res3.UserTransaction); Assert.IsTrue(server2.Equals(res4)); model.ServerNotAvailable(server1); var res5 = model.CreateTransaction(hash); Assert.IsNotNull(res5); var res6 = model.GetDestination(res5.UserTransaction); Assert.IsTrue(server2.Equals(res6)); model.ServerNotAvailable(server2); var res7 = model.CreateTransaction(hash); Assert.AreEqual(Errors.NotAvailableServersInSystem + "; ", res7.ErrorDescription); }
public override int GetHashCode() { int hash = 1; if (CmdCode.Length != 0) { hash ^= CmdCode.GetHashCode(); } if (Identity.Length != 0) { hash ^= Identity.GetHashCode(); } if (OppositeId.Length != 0) { hash ^= OppositeId.GetHashCode(); } if (TimeToken.Length != 0) { hash ^= TimeToken.GetHashCode(); } if (ResultCode != 0) { hash ^= ResultCode.GetHashCode(); } if (ServerId != 0) { hash ^= ServerId.GetHashCode(); } if (Status.Length != 0) { hash ^= Status.GetHashCode(); } hash ^= lightNos_.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { int hash = 1; if (CmdCode.Length != 0) { hash ^= CmdCode.GetHashCode(); } if (Identity.Length != 0) { hash ^= Identity.GetHashCode(); } if (OppositeId.Length != 0) { hash ^= OppositeId.GetHashCode(); } if (TimeToken.Length != 0) { hash ^= TimeToken.GetHashCode(); } if (ServerId != 0) { hash ^= ServerId.GetHashCode(); } hash ^= lightNo_.GetHashCode(); if (LowValue != 0) { hash ^= LowValue.GetHashCode(); } if (HeighValue != 0) { hash ^= HeighValue.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public List <HashMapRecord> GetLocalMap(ServerId server) { var ret = new List <HashMapRecord>(); for (int i = 0; i < Map.Count; i++) { if (Map[i].Save.Equals(server)) { var list = Copy(i, _configuration.CountReplics); var intersect = ret.Intersect(list); if (intersect.Count() != 0) { //TODO в системен не хватает серверов для полного хранения реплик Logger.Logger.Instance.Error("Need more servres to store data"); } ret.AddRange(list); } } return(ret); }
private ConnectionDescription CreateConnectionDescription(bool withLogicalSessionTimeout, bool?serviceId = null) { var clusterId = new ClusterId(1); var endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(clusterId, endPoint); var connectionId = new ConnectionId(serverId, 1); var helloResultDocument = BsonDocument.Parse($"{{ ok : 1, maxWireVersion : {WireVersion.Server42} }}"); if (withLogicalSessionTimeout) { helloResultDocument["logicalSessionTimeoutMinutes"] = 1; helloResultDocument["msg"] = "isdbgrid"; // mongos } if (serviceId.HasValue) { helloResultDocument["serviceId"] = ObjectId.Empty; // load balancing mode } var helloResult = new HelloResult(helloResultDocument); var connectionDescription = new ConnectionDescription(connectionId, helloResult); return(connectionDescription); }
// private methods private ConnectionDescription CreateConnectionDescription( bool logicalSessionTimeoutMinutes = false, bool?serviceId = null) { var clusterId = new ClusterId(1); var endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(clusterId, endPoint); var connectionId = new ConnectionId(serverId, 1); var isMasterResult = new BsonDocument { { "ok", 1 }, { "logicalSessionTimeoutMinutes", 30, logicalSessionTimeoutMinutes }, { "serviceId", ObjectId.GenerateNewId(), serviceId.HasValue } }; var buildInfoResult = new BsonDocument { { "ok", 1 }, { "version", logicalSessionTimeoutMinutes ? "4.0" : "3.6" } }; return(new ConnectionDescription(connectionId, new IsMasterResult(isMasterResult), new BuildInfoResult(buildInfoResult))); }
public BinaryConnectionTests() { _capturedEvents = new EventCapturer(); _mockStreamFactory = new Mock <IStreamFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(new ClusterId(), _endPoint); var connectionId = new ConnectionId(serverId); var isMasterResult = new IsMasterResult(new BsonDocument { { "ok", 1 }, { "maxMessageSizeBytes", 48000000 } }); var buildInfoResult = new BuildInfoResult(new BsonDocument { { "ok", 1 }, { "version", "2.6.3" } }); _connectionDescription = new ConnectionDescription(connectionId, isMasterResult, buildInfoResult); _mockConnectionInitializer = new Mock <IConnectionInitializer>(); _mockConnectionInitializer .Setup(i => i.SendHello(It.IsAny <IConnection>(), CancellationToken.None)) .Returns(_connectionDescription); _mockConnectionInitializer .Setup(i => i.Authenticate(It.IsAny <IConnection>(), It.IsAny <ConnectionDescription>(), CancellationToken.None)) .Returns(_connectionDescription); _mockConnectionInitializer .Setup(i => i.SendHelloAsync(It.IsAny <IConnection>(), CancellationToken.None)) .ReturnsAsync(_connectionDescription); _mockConnectionInitializer .Setup(i => i.AuthenticateAsync(It.IsAny <IConnection>(), It.IsAny <ConnectionDescription>(), CancellationToken.None)) .ReturnsAsync(_connectionDescription); _subject = new BinaryConnection( serverId: serverId, endPoint: _endPoint, settings: new ConnectionSettings(), streamFactory: _mockStreamFactory.Object, connectionInitializer: _mockConnectionInitializer.Object, eventSubscriber: _capturedEvents); }
public static TestWriterServer OpenWriterHost(ServerId server, ConnectionConfiguration config) { var ret = new TestWriterServer(); var host = new ServiceHost(ret, new Uri(string.Format("net.tcp://{0}:{1}/{2}", server.RemoteHost, server.Port, config.ServiceName))); var binding = new NetTcpBinding { Security = { Mode = SecurityMode.None }, TransactionFlow = true }; var contractType = typeof(ICommonNetReceiverWriterForWrite); host.AddServiceEndpoint(contractType, binding, ""); var behavior = host.Description.Behaviors.Find <ServiceBehaviorAttribute>(); behavior.InstanceContextMode = InstanceContextMode.Single; host.Open(); return(ret); }
public void AddNewDataserver(String hostname, Boolean launch = true) { int serverNumber = _nextDataServerId++; int port = _nextDataServerPort++; int recoverPort = _nextDataServerRecoverPort++; ServerId server = new ServerId(); server.id = "d-" + serverNumber; server.hostname = hostname; server.port = port; server.recoverPort = recoverPort; DataserverList.Add(server); if (launch) { Process dataServer = new Process(); dataServer.StartInfo.FileName = Path.Combine(_baseDirectory, "DataServer\\bin\\Debug\\DataServer.exe"); dataServer.StartInfo.Arguments = ms0IP + " " + ms0Port + " " + ms1IP + " " + ms1Port + " " + ms2IP + " " + ms2Port + " " + port + " " + serverNumber + " " + recoverPort; dataServer.Start(); } }
public override int GetHashCode() { int hash = 1; if (Game != 0) { hash ^= Game.GetHashCode(); } if (ServerId.Length != 0) { hash ^= ServerId.GetHashCode(); } if (Channel.Length != 0) { hash ^= Channel.GetHashCode(); } if (Aggregate != 0) { hash ^= Aggregate.GetHashCode(); } return(hash); }
public ExclusiveConnectionPoolTests() { _mockConnectionFactory = new Mock <IConnectionFactory> { DefaultValue = DefaultValue.Mock }; _endPoint = new DnsEndPoint("localhost", 27017); _capturedEvents = new EventCapturer(); _serverId = new ServerId(new ClusterId(), _endPoint); _settings = new ConnectionPoolSettings( maintenanceInterval: Timeout.InfiniteTimeSpan, maxConnections: 4, minConnections: 2, waitQueueSize: 1, waitQueueTimeout: TimeSpan.FromSeconds(2)); _subject = new ExclusiveConnectionPool( _serverId, _endPoint, _settings, _mockConnectionFactory.Object, _capturedEvents); }
public override int GetHashCode() { int hash = 1; if (CmdCode.Length != 0) { hash ^= CmdCode.GetHashCode(); } if (Identity.Length != 0) { hash ^= Identity.GetHashCode(); } if (OppositeId.Length != 0) { hash ^= OppositeId.GetHashCode(); } if (TimeToken.Length != 0) { hash ^= TimeToken.GetHashCode(); } if (ServerId != 0) { hash ^= ServerId.GetHashCode(); } if (CellAddr != 0) { hash ^= CellAddr.GetHashCode(); } if (LightNo.Length != 0) { hash ^= LightNo.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { int hash = 1; if (ServerName.Length != 0) { hash ^= ServerName.GetHashCode(); } if (ServerId != 0L) { hash ^= ServerId.GetHashCode(); } if (Address.Length != 0) { hash ^= Address.GetHashCode(); } if (Port != 0) { hash ^= Port.GetHashCode(); } if (MaxRoomCount != 0) { hash ^= MaxRoomCount.GetHashCode(); } if (MaxPlayerPerRoom != 0) { hash ^= MaxPlayerPerRoom.GetHashCode(); } if (AddressReal.Length != 0) { hash ^= AddressReal.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { int hash = 1; if (Username.Length != 0) { hash ^= Username.GetHashCode(); } if (Protocol != 0) { hash ^= Protocol.GetHashCode(); } if (Client.Length != 0) { hash ^= Client.GetHashCode(); } if (Uuid.Length != 0) { hash ^= Uuid.GetHashCode(); } if (Secret.Length != 0) { hash ^= Secret.GetHashCode(); } if (ServerId.Length != 0) { hash ^= ServerId.GetHashCode(); } if (ProxySupportedVersion != 0) { hash ^= ProxySupportedVersion.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public void EnsureTransactionsAreSupported_should_have_expected_result_for_server_version_and_type(string versionString, ServerType serverType, string expectedMessage) { var clusterId = new ClusterId(1); var endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(clusterId, endPoint); var version = SemanticVersion.Parse(versionString); var servers = new[] { CreateServerDescription(serverId, endPoint, ServerState.Connected, serverType, version) }; var clusterType = serverType == ServerType.ShardRouter ? ClusterType.Sharded : ClusterType.ReplicaSet; var clusterDescription = CreateClusterDescription(clusterId: clusterId, connectionMode: ClusterConnectionMode.Automatic, type: clusterType, servers: servers); var subject = CreateSubject(clusterDescription); var exception = Record.Exception(() => subject.EnsureTransactionsAreSupported()); if (expectedMessage == null) { exception.Should().BeNull(); } else { var e = exception.Should().BeOfType <NotSupportedException>().Subject; e.Message.Should().Contain(expectedMessage); } }
public void IsCompatibleWithDriver_should_return_true_if_server_unknown(int[] wireRanges) { var clusterId = new ClusterId(1); #pragma warning disable CS0618 // Type or member is obsolete var connectionMode = ClusterConnectionMode.Automatic; var connectionModeSwitch = ConnectionModeSwitch.NotSet; var subject = ClusterDescription.CreateInitial(clusterId, connectionMode, connectionModeSwitch, directConnection: null); #pragma warning restore CS0618 // Type or member is obsolete for (var i = 0; i < wireRanges.Length; i++) { var endPoint = new DnsEndPoint("localhost", i); var serverId = new ServerId(clusterId, endPoint); var wireRange = wireRanges[i]; var wireVersionRange = wireRange == 0 ? new Range <int>(0, 0) : wireRange == 1 ? new Range <int>(6, 15) : null; var server = new ServerDescription(serverId, endPoint, wireVersionRange: wireVersionRange, type: ServerType.Unknown); subject = subject.WithServerDescription(server); } var result = subject.IsCompatibleWithDriver; result.Should().BeTrue(); }
private ConnectionDescription CreateConnectionDescription(bool withLogicalSessionTimeout, bool?serviceId = null) { var clusterId = new ClusterId(1); var endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(clusterId, endPoint); var connectionId = new ConnectionId(serverId, 1); var isMasterResultDocument = BsonDocument.Parse("{ ok : 1 }"); if (withLogicalSessionTimeout) { isMasterResultDocument["logicalSessionTimeoutMinutes"] = 1; isMasterResultDocument["msg"] = "isdbgrid"; // mongos } if (serviceId.HasValue) { isMasterResultDocument["serviceId"] = ObjectId.Empty; // load balancing mode } var isMasterResult = new IsMasterResult(isMasterResultDocument); var buildInfoResult = new BuildInfoResult(BsonDocument.Parse("{ ok : 1, version : '4.2.0' }")); var connectionDescription = new ConnectionDescription(connectionId, isMasterResult, buildInfoResult); return(connectionDescription); }
public void EnsureTransactionsAreSupported_should_throw_when_there_are_no_connected_data_bearing_servers(string scenarios) { var clusterId = new ClusterId(1); var servers = SplitScenarios(scenarios) .Select((scenario, i) => { var endPoint = new DnsEndPoint("localhost", 27017 + i); var serverId = new ServerId(clusterId, endPoint); var state = MapServerStateCode(scenario[0]); var type = MapServerTypeCode(scenario[1]); return(CreateServerDescription(serverId, endPoint, state, type)); }) .ToList(); var cluster = CreateClusterDescription(clusterId, servers: servers); var subject = CreateSubject(cluster); var exception = Record.Exception(() => subject.EnsureTransactionsAreSupported()); var e = exception.Should().BeOfType <NotSupportedException>().Subject; e.Message.Should().Be("StartTransaction cannot determine if transactions are supported because there are no connected servers."); }
public AsyncDbWorkModule(WriterNetModule writerNet, AsyncTaskModule async, DbModuleCollection db, RestoreModuleConfiguration initiatorConfiguration, RestoreModuleConfiguration transferConfiguration, RestoreModuleConfiguration timeoutConfiguration, QueueConfiguration queueConfiguration, ServerId local, bool isNeedRestore = false) { Contract.Requires(initiatorConfiguration != null); Contract.Requires(transferConfiguration != null); Contract.Requires(timeoutConfiguration != null); Contract.Requires(queueConfiguration != null); Contract.Requires(db != null); Contract.Requires(writerNet != null); Contract.Requires(async != null); Contract.Requires(local != null); _stateHelper = new RestoreStateHelper(isNeedRestore); _initiatorRestore = new InitiatorRestoreModule(initiatorConfiguration, writerNet, async); _transfer = new TransferRestoreModule(transferConfiguration, writerNet, async, db, local, queueConfiguration); _timeout = new TimeoutModule(writerNet, async, queueConfiguration, db, timeoutConfiguration); }
public void IsCompatibleWithDriver_should_return_expected_result(int[] wireRanges, bool expectedResult) { var clusterId = new ClusterId(1); #pragma warning disable CS0618 var connectionMode = ClusterConnectionMode.Automatic; var connectionModeSwitch = ConnectionModeSwitch.NotSet; var subject = ClusterDescription.CreateInitial(clusterId, connectionMode, connectionModeSwitch, directConnection: null); #pragma warning restore CS0618 for (var i = 0; i < wireRanges.Length; i++) { var endPoint = new DnsEndPoint("localhost", i); var serverId = new ServerId(clusterId, endPoint); var wireRange = wireRanges[i]; var wireVersionRange = wireRange == 0 ? new Range <int>(0, 0) : wireRange == 1 ? new Range <int>(6, 14) : null; var server = new ServerDescription(serverId, endPoint, wireVersionRange: wireVersionRange, type: ServerType.Standalone); subject = subject.WithServerDescription(server); } var result = subject.IsCompatibleWithDriver; result.Should().Be(expectedResult); }
public RemoteResult SayIAmHere(ServerId destination) { if (!_net.ConnectToDistributor(destination)) { return(new ServerNotAvailable(destination)); } _distributorSystemModel.AddServer(destination); var ret = _net.SendDistributor(destination, new TakeInfoCommand()); if (ret is SystemInfoResult) { var data = ret as SystemInfoResult; AddNewDistributorList(data.DataContainer.AllDistributors); } else { ret = new FailNetResult(Errors.InnerServerError); } return(ret); }
public RemoteResult SayIAmHereRemoteResult(ServerId destination) { if (!_distributorNet.ConnectToDistributor(destination)) { return(new ServerNotAvailable(destination)); } var ret = _distributorNet.SendToDistributor(destination, new AddDistributorFromDistributorCommand(new ServerId(_localforproxy))); if (!ret.IsError) { _modelOfAnotherDistributors.AddServer(destination); ret = _distributorNet.SendToDistributor(destination, new TakeInfoCommand()); if (!ret.IsError) { var data = ret as SystemInfoResult; AddDistributors(data.DataContainer.AllDistributors); } } return(ret); }
public void Setup() { _listener = Substitute.For <IConnectionListener>(); _streamFactory = Substitute.For <IStreamFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(new ClusterId(), _endPoint); _connectionInitializer = Substitute.For <IConnectionInitializer>(); _connectionInitializer.InitializeConnectionAsync(null, CancellationToken.None) .ReturnsForAnyArgs(Task.FromResult(new ConnectionDescription( new ConnectionId(serverId), new IsMasterResult(new BsonDocument()), new BuildInfoResult(new BsonDocument("version", "2.6.3"))))); _subject = new BinaryConnection( serverId: serverId, endPoint: _endPoint, settings: new ConnectionSettings(), streamFactory: _streamFactory, connectionInitializer: _connectionInitializer, listener: _listener); }
public void AddNewMetaserver(int serverNumber, Boolean launch = true) { ServerId server = new ServerId(); server.id = "m-" + serverNumber; switch (serverNumber) { case 0: server.hostname = ms0IP; server.port = ms0Port; server.recoverPort = ms0RecPort; break; case 1: server.hostname = ms1IP; server.port = ms1Port; server.recoverPort = ms1RecPort; break; case 2: server.hostname = ms2IP; server.port = ms2Port; server.recoverPort = ms2RecPort; break; default: throw new Exception("Invalid metaserver number"); } MetaserverList.Add(server); if (launch) { Process metaServer = new Process(); metaServer.StartInfo.FileName = Path.Combine(_baseDirectory, "Metadata\\bin\\Debug\\Metadata.exe"); metaServer.StartInfo.Arguments = ms0IP + " " + ms0Port + " " + ms1IP + " " + ms1Port + " " + ms2IP + " " + ms2Port + " " + serverNumber + " " + server.recoverPort; metaServer.Start(); } }
public DistributorSystem(ServerId localfordb, ServerId localforproxy, DistributorHashConfiguration distributorHashConfiguration, QueueConfiguration queueConfiguration, ConnectionConfiguration connectionConfiguration, DistributorCacheConfiguration cacheConfiguration, NetReceiverConfiguration receiverConfigurationForDb, NetReceiverConfiguration receiverConfigurationForProxy, TransactionConfiguration transactionConfiguration, HashMapConfiguration hashMapConfiguration, AsyncTasksConfiguration pingConfig, AsyncTasksConfiguration checkConfig, ConnectionTimeoutConfiguration connectionTimeoutConfiguration) { Contract.Requires(distributorHashConfiguration != null); Contract.Requires(_queueConfiguration != null); Contract.Requires(connectionConfiguration != null); Contract.Requires(cacheConfiguration != null); Contract.Requires(receiverConfigurationForDb != null); Contract.Requires(receiverConfigurationForProxy != null); Contract.Requires(transactionConfiguration != null); Contract.Requires(localfordb != null); Contract.Requires(localforproxy != null); Contract.Requires(hashMapConfiguration != null); Contract.Requires(pingConfig != null); Contract.Requires(checkConfig != null); _pingConfig = pingConfig; _checkConfig = checkConfig; _connectionTimeoutConfiguration = connectionTimeoutConfiguration; _distributorHashConfiguration = distributorHashConfiguration; _hashMapConfiguration = hashMapConfiguration; _queueConfiguration = queueConfiguration; _connectionConfiguration = connectionConfiguration; _cacheConfiguration = cacheConfiguration; _receiverConfigurationForDb = receiverConfigurationForDb; _receiverConfigurationForProxy = receiverConfigurationForProxy; _transactionConfiguration = transactionConfiguration; _localfordb = localfordb; _localforproxy = localforproxy; }
/// <summary> /// Initializes a new instance of the <see cref="ServerClosingEvent"/> struct. /// </summary> /// <param name="serverId">The server identifier.</param> public ServerClosingEvent(ServerId serverId) { _serverId = serverId; }
/// <summary> /// Initializes a new instance of the <see cref="ClusterRemovingServerEvent"/> struct. /// </summary> /// <param name="serverId">The server identifier.</param> /// <param name="reason">The reason the server is being removed.</param> public ClusterRemovingServerEvent(ServerId serverId, string reason) { _serverId = serverId; _reason = reason; }
/// <summary> /// Initializes a new instance of the <see cref="ServerOpeningEvent"/> struct. /// </summary> /// <param name="serverId">The server identifier.</param> /// <param name="serverSettings">The server settings.</param> public ServerOpeningEvent(ServerId serverId, ServerSettings serverSettings) { _serverId = serverId; _serverSettings = serverSettings; }