private ClusterConnectionPool(IEnumerable <Uri> initUris, IConnectionPoolFactory poolFactory, ILogger logger) { _logger = logger; _poolFactory = poolFactory; Add(initUris); }
// constructors public ServerFactory(ServerSettings settings, IConnectionPoolFactory connectionPoolFactory, IConnectionFactory heartbeatConnectionFactory, IServerListener listener) { _settings = Ensure.IsNotNull(settings, "settings"); _connectionPoolFactory = Ensure.IsNotNull(connectionPoolFactory, "connectionPoolFactory"); _heartbeatConnectionFactory = Ensure.IsNotNull(heartbeatConnectionFactory, "heartbeatConnectionFactory"); _listener = listener; }
public ClusterNode(ClusterContext context, IConnectionPoolFactory connectionPoolFactory, ILogger <ClusterNode> logger, ObjectPool <OperationBuilder> operationBuilderPool, ICircuitBreaker circuitBreaker, ISaslMechanismFactory saslMechanismFactory, IRedactor redactor, IPEndPoint endPoint, BucketType bucketType, NodeAdapter nodeAdapter, IRequestTracer tracer) { _context = context ?? throw new ArgumentNullException(nameof(context)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _circuitBreaker = circuitBreaker ?? throw new ArgumentException(nameof(circuitBreaker)); _operationBuilderPool = operationBuilderPool ?? throw new ArgumentNullException(nameof(operationBuilderPool)); _saslMechanismFactory = saslMechanismFactory ?? throw new ArgumentException(nameof(saslMechanismFactory)); _redactor = redactor ?? throw new ArgumentNullException(nameof(redactor)); _tracer = tracer; BucketType = bucketType; EndPoint = endPoint ?? throw new ArgumentNullException(nameof(endPoint)); _cachedToString = $"{EndPoint}-{_id}"; KeyEndPoints = new ReadOnlyObservableCollection <IPEndPoint>(_keyEndPoints); UpdateKeyEndPoints(); ((INotifyCollectionChanged)_keyEndPoints).CollectionChanged += (_, e) => OnKeyEndPointsChanged(e); if (connectionPoolFactory == null) { throw new ArgumentNullException(nameof(connectionPoolFactory)); } ConnectionPool = connectionPoolFactory.Create(this); if (nodeAdapter != null) { NodesAdapter = nodeAdapter; } }
public DefaultServer( ClusterId clusterId, IClusterClock clusterClock, #pragma warning disable CS0618 // Type or member is obsolete ClusterConnectionMode clusterConnectionMode, ConnectionModeSwitch connectionModeSwitch, #pragma warning restore CS0618 // Type or member is obsolete bool?directConnection, ServerSettings settings, EndPoint endPoint, IConnectionPoolFactory connectionPoolFactory, IServerMonitorFactory monitorFactory, IEventSubscriber eventSubscriber, ServerApi serverApi) : base( clusterId, clusterClock, clusterConnectionMode, connectionModeSwitch, directConnection, settings, endPoint, connectionPoolFactory, eventSubscriber, serverApi) { _monitor = Ensure.IsNotNull(monitorFactory, nameof(monitorFactory)).Create(ServerId, endPoint); _baseDescription = _currentDescription = new ServerDescription(ServerId, endPoint, reasonChanged: "ServerInitialDescription", heartbeatInterval: settings.HeartbeatInterval); }
// constructors public ServerFactory(ClusterConnectionMode clusterConnectionMode, ServerSettings settings, IConnectionPoolFactory connectionPoolFactory, IConnectionFactory heartbeatConnectionFactory, IEventSubscriber eventSubscriber) { _clusterConnectionMode = clusterConnectionMode; _settings = Ensure.IsNotNull(settings, "settings"); _connectionPoolFactory = Ensure.IsNotNull(connectionPoolFactory, "connectionPoolFactory"); _heartbeatConnectionFactory = Ensure.IsNotNull(heartbeatConnectionFactory, "heartbeatConnectionFactory"); _eventSubscriber = Ensure.IsNotNull(eventSubscriber, "eventSubscriber"); }
// constructors public ServerFactory(ClusterConnectionMode clusterConnectionMode, ServerSettings settings, IConnectionPoolFactory connectionPoolFactory, IServerMonitorFactory serverMonitoryFactory, IEventSubscriber eventSubscriber) { _clusterConnectionMode = clusterConnectionMode; _settings = Ensure.IsNotNull(settings, nameof(settings)); _connectionPoolFactory = Ensure.IsNotNull(connectionPoolFactory, nameof(connectionPoolFactory)); _serverMonitorFactory = Ensure.IsNotNull(serverMonitoryFactory, nameof(serverMonitoryFactory)); _eventSubscriber = Ensure.IsNotNull(eventSubscriber, nameof(eventSubscriber)); }
// test only internal ClusterConnectionPool( IConnectionPoolFactory poolFactory, ConcurrentDictionary <Uri, IConnectionPool> clusterPool, ILogger logger = null ) : this(Enumerable.Empty <Uri>(), poolFactory, logger) { _pools = clusterPool; }
public void Setup() { _clusterId = new ClusterId(); _connectionPoolFactory = Substitute.For <IConnectionPoolFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); _heartbeatConnectionFactory = Substitute.For <IConnectionFactory>(); _listener = Substitute.For <IServerListener>(); _settings = new ServerSettings(); }
public void Setup() { _clusterId = new ClusterId(); _clusterConnectionMode = ClusterConnectionMode.Standalone; _connectionPoolFactory = Substitute.For<IConnectionPoolFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); _heartbeatConnectionFactory = Substitute.For<IConnectionFactory>(); _eventSubscriber = Substitute.For<IEventSubscriber>(); _settings = new ServerSettings(); }
public ServerFactoryTests() { _clusterId = new ClusterId(); _clusterConnectionMode = ClusterConnectionMode.Standalone; _connectionPoolFactory = new Mock<IConnectionPoolFactory>().Object; _endPoint = new DnsEndPoint("localhost", 27017); _serverMonitorFactory = new Mock<IServerMonitorFactory>().Object; _eventSubscriber = new Mock<IEventSubscriber>().Object; _settings = new ServerSettings(); }
public void Setup() { _clusterId = new ClusterId(); _clusterConnectionMode = ClusterConnectionMode.Standalone; _connectionPoolFactory = Substitute.For <IConnectionPoolFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); _heartbeatConnectionFactory = Substitute.For <IConnectionFactory>(); _eventSubscriber = Substitute.For <IEventSubscriber>(); _settings = new ServerSettings(); }
public ServerFactoryTests() { _clusterId = new ClusterId(); _clusterConnectionMode = ClusterConnectionMode.Standalone; _connectionPoolFactory = new Mock <IConnectionPoolFactory>().Object; _endPoint = new DnsEndPoint("localhost", 27017); _serverMonitorFactory = new Mock <IServerMonitorFactory>().Object; _eventSubscriber = new Mock <IEventSubscriber>().Object; _settings = new ServerSettings(); }
// constructors #pragma warning disable CS0618 // Type or member is obsolete public ServerFactory(ClusterConnectionMode clusterConnectionMode, ConnectionModeSwitch connectionModeSwitch, bool?directConnection, ServerSettings settings, IConnectionPoolFactory connectionPoolFactory, IServerMonitorFactory serverMonitoryFactory, IEventSubscriber eventSubscriber) #pragma warning restore CS0618 // Type or member is obsolete { ClusterConnectionModeHelper.EnsureConnectionModeValuesAreValid(clusterConnectionMode, connectionModeSwitch, directConnection); _clusterConnectionMode = clusterConnectionMode; _connectionModeSwitch = connectionModeSwitch; _directConnection = directConnection; _settings = Ensure.IsNotNull(settings, nameof(settings)); _connectionPoolFactory = Ensure.IsNotNull(connectionPoolFactory, nameof(connectionPoolFactory)); _serverMonitorFactory = Ensure.IsNotNull(serverMonitoryFactory, nameof(serverMonitoryFactory)); _eventSubscriber = Ensure.IsNotNull(eventSubscriber, nameof(eventSubscriber)); }
public ClusterNodeFactory(ClusterContext clusterContext, IConnectionPoolFactory connectionPoolFactory, ILogger <ClusterNode> logger, ObjectPool <OperationBuilder> operationBuilderPool, ICircuitBreaker circuitBreaker, ISaslMechanismFactory saslMechanismFactory, TypedRedactor redactor, IRequestTracer tracer) { _clusterContext = clusterContext ?? throw new ArgumentNullException(nameof(clusterContext)); _connectionPoolFactory = connectionPoolFactory ?? throw new ArgumentNullException(nameof(connectionPoolFactory)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _operationBuilderPool = operationBuilderPool ?? throw new ArgumentNullException(nameof(operationBuilderPool)); _circuitBreaker = circuitBreaker ?? throw new ArgumentException(nameof(circuitBreaker)); _saslMechanismFactory = saslMechanismFactory ?? throw new ArgumentNullException(nameof(saslMechanismFactory)); _redactor = redactor ?? throw new ArgumentNullException(nameof(redactor)); _tracer = tracer ?? throw new ArgumentNullException(nameof(tracer)); }
public ClusterNodeFactory(ClusterContext clusterContext, IConnectionPoolFactory connectionPoolFactory, ILogger <ClusterNode> logger, ITypeTranscoder transcoder, ICircuitBreaker circuitBreaker, ISaslMechanismFactory saslMechanismFactory, IIpEndPointService ipEndPointService, IRedactor redactor) { _clusterContext = clusterContext ?? throw new ArgumentNullException(nameof(clusterContext)); _connectionPoolFactory = connectionPoolFactory ?? throw new ArgumentNullException(nameof(connectionPoolFactory)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _transcoder = transcoder ?? throw new ArgumentNullException(nameof(transcoder)); _circuitBreaker = circuitBreaker ?? throw new ArgumentException(nameof(circuitBreaker)); _saslMechanismFactory = saslMechanismFactory; _ipEndPointService = ipEndPointService ?? throw new ArgumentNullException(nameof(ipEndPointService)); _redactor = redactor ?? throw new ArgumentNullException(nameof(redactor)); }
// constructors public ClusterableServer(ServerSettings settings, ClusterId clusterId, EndPoint endPoint, IConnectionPoolFactory connectionPoolFactory, IConnectionFactory hearbeatConnectionFactory, IServerListener listener) { _settings = Ensure.IsNotNull(settings, "settings");; Ensure.IsNotNull(clusterId, "clusterId"); _endPoint = Ensure.IsNotNull(endPoint, "endPoint"); _connectionPoolFactory = Ensure.IsNotNull(connectionPoolFactory, "connectionPoolFactory"); _heartbeatConnectionFactory = Ensure.IsNotNull(hearbeatConnectionFactory, "hearbeatConnectionFactory"); _listener = listener; _serverId = new ServerId(clusterId, endPoint); _baseDescription = _currentDescription = new ServerDescription(_serverId, endPoint); _connectionPool = connectionPoolFactory.CreateConnectionPool(_serverId, endPoint); _state = new InterlockedInt32(State.Initial); }
public ServerFactoryTests() { _clusterId = new ClusterId(); _clusterConnectionMode = ClusterConnectionMode.Standalone; _connectionPoolFactory = new Mock <IConnectionPoolFactory>().Object; _endPoint = new DnsEndPoint("localhost", 27017); var mockServerMonitor = new Mock <IServerMonitor>(); mockServerMonitor.Setup(m => m.Description).Returns(new ServerDescription(new ServerId(_clusterId, _endPoint), _endPoint)); var mockServerMonitorFactory = new Mock <IServerMonitorFactory>(); mockServerMonitorFactory.Setup(f => f.Create(It.IsAny <ServerId>(), _endPoint)).Returns(mockServerMonitor.Object); _serverMonitorFactory = mockServerMonitorFactory.Object; _eventSubscriber = new Mock <IEventSubscriber>().Object; _settings = new ServerSettings(); }
public ServerFactoryTests() { _clusterId = new ClusterId(); #pragma warning disable CS0618 // Type or member is obsolete _clusterConnectionMode = ClusterConnectionMode.Standalone; _connectionModeSwitch = ConnectionModeSwitch.UseConnectionMode; #pragma warning restore CS0618 // Type or member is obsolete _connectionPoolFactory = new Mock <IConnectionPoolFactory>().Object; _directConnection = null; _endPoint = new DnsEndPoint("localhost", 27017); var mockServerMonitor = new Mock <IServerMonitor>(); mockServerMonitor.Setup(m => m.Description).Returns(new ServerDescription(new ServerId(_clusterId, _endPoint), _endPoint)); var mockServerMonitorFactory = new Mock <IServerMonitorFactory>(); mockServerMonitorFactory.Setup(f => f.Create(It.IsAny <ServerId>(), _endPoint)).Returns(mockServerMonitor.Object); _serverMonitorFactory = mockServerMonitorFactory.Object; _eventSubscriber = new Mock <IEventSubscriber>().Object; _settings = new ServerSettings(); }
public void Setup() { _clusterId = new ClusterId(); _connectionPool = Substitute.For <IConnectionPool>(); _connectionPoolFactory = Substitute.For <IConnectionPoolFactory>(); _connectionPoolFactory.CreateConnectionPool(null, null) .ReturnsForAnyArgs(_connectionPool); _endPoint = new DnsEndPoint("localhost", 27017); _heartbeatConnection = new MockConnection(); _heartbeatConnectionFactory = Substitute.For <IConnectionFactory>(); _heartbeatConnectionFactory.CreateConnection(null, null) .ReturnsForAnyArgs(_heartbeatConnection); _listener = Substitute.For <IServerListener>(); _settings = new ServerSettings(heartbeatInterval: Timeout.InfiniteTimeSpan); _subject = new ClusterableServer(_settings, _clusterId, _endPoint, _connectionPoolFactory, _heartbeatConnectionFactory, _listener); }
public void Setup() { _clusterId = new ClusterId(); _clusterConnectionMode = ClusterConnectionMode.Standalone; _connectionPool = Substitute.For<IConnectionPool>(); _connectionPoolFactory = Substitute.For<IConnectionPoolFactory>(); _connectionPoolFactory.CreateConnectionPool(null, null) .ReturnsForAnyArgs(_connectionPool); _endPoint = new DnsEndPoint("localhost", 27017); _heartbeatConnection = new MockConnection(); _heartbeatConnectionFactory = Substitute.For<IConnectionFactory>(); _heartbeatConnectionFactory.CreateConnection(null, null) .ReturnsForAnyArgs(_heartbeatConnection); _capturedEvents = new EventCapturer(); _settings = new ServerSettings(heartbeatInterval: Timeout.InfiniteTimeSpan); _subject = new ClusterableServer(_clusterId, _clusterConnectionMode, _settings, _endPoint, _connectionPoolFactory, _heartbeatConnectionFactory, _capturedEvents); }
public void Setup() { _clusterId = new ClusterId(); _clusterConnectionMode = ClusterConnectionMode.Standalone; _connectionPool = Substitute.For <IConnectionPool>(); _connectionPoolFactory = Substitute.For <IConnectionPoolFactory>(); _connectionPoolFactory.CreateConnectionPool(null, null) .ReturnsForAnyArgs(_connectionPool); _endPoint = new DnsEndPoint("localhost", 27017); _heartbeatConnection = new MockConnection(); _heartbeatConnectionFactory = Substitute.For <IConnectionFactory>(); _heartbeatConnectionFactory.CreateConnection(null, null) .ReturnsForAnyArgs(_heartbeatConnection); _capturedEvents = new EventCapturer(); _settings = new ServerSettings(heartbeatInterval: Timeout.InfiniteTimeSpan); _subject = new ClusterableServer(_clusterId, _clusterConnectionMode, _settings, _endPoint, _connectionPoolFactory, _heartbeatConnectionFactory, _capturedEvents); }
public ClusterNode(ClusterContext context, IConnectionPoolFactory connectionPoolFactory, ILogger <ClusterNode> logger, ITypeTranscoder transcoder, ICircuitBreaker circuitBreaker, ISaslMechanismFactory saslMechanismFactory, IRedactor redactor, IPEndPoint endPoint) { _context = context ?? throw new ArgumentNullException(nameof(context)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _transcoder = transcoder ?? throw new ArgumentNullException(nameof(transcoder)); _circuitBreaker = circuitBreaker ?? throw new ArgumentException(nameof(circuitBreaker)); _saslMechanismFactory = saslMechanismFactory ?? throw new ArgumentException(nameof(saslMechanismFactory)); _redactor = redactor ?? throw new ArgumentNullException(nameof(redactor)); EndPoint = endPoint ?? throw new ArgumentNullException(nameof(endPoint)); KeyEndPoints = new ReadOnlyObservableCollection <IPEndPoint>(_keyEndPoints); UpdateKeyEndPoints(); ((INotifyCollectionChanged)_keyEndPoints).CollectionChanged += (_, e) => OnKeyEndPointsChanged(e); if (connectionPoolFactory == null) { throw new ArgumentNullException(nameof(connectionPoolFactory)); } ConnectionPool = connectionPoolFactory.Create(this); }
public LoadBalancedServer( ClusterId clusterId, IClusterClock clusterClock, ServerSettings serverSettings, EndPoint endPoint, IConnectionPoolFactory connectionPoolFactory, IEventSubscriber eventSubscriber, ServerApi serverApi) : base( clusterId, clusterClock, #pragma warning disable CS0618 // Type or member is obsolete ClusterConnectionMode.Automatic, ConnectionModeSwitch.UseConnectionMode, #pragma warning restore CS0618 // Type or member is obsolete directConnection: null, serverSettings, endPoint, connectionPoolFactory, eventSubscriber, serverApi) { _baseDescription = _currentDescription = new ServerDescription(ServerId, endPoint, reasonChanged: "ServerInitialDescription"); }
// constructors public Server( ClusterId clusterId, IClusterClock clusterClock, #pragma warning disable CS0618 // Type or member is obsolete ClusterConnectionMode clusterConnectionMode, ConnectionModeSwitch connectionModeSwitch, #pragma warning restore CS0618 // Type or member is obsolete bool?directConnection, ServerSettings settings, EndPoint endPoint, IConnectionPoolFactory connectionPoolFactory, IEventSubscriber eventSubscriber, ServerApi serverApi) { ClusterConnectionModeHelper.EnsureConnectionModeValuesAreValid(clusterConnectionMode, connectionModeSwitch, directConnection); _clusterClock = Ensure.IsNotNull(clusterClock, nameof(clusterClock)); _clusterConnectionMode = clusterConnectionMode; _connectionModeSwitch = connectionModeSwitch; _directConnection = directConnection; _settings = Ensure.IsNotNull(settings, nameof(settings)); _endPoint = Ensure.IsNotNull(endPoint, nameof(endPoint)); Ensure.IsNotNull(eventSubscriber, nameof(eventSubscriber)); _serverId = new ServerId(clusterId, endPoint); _connectionPool = Ensure.IsNotNull(connectionPoolFactory, nameof(connectionPoolFactory)).CreateConnectionPool(_serverId, endPoint); _state = new InterlockedInt32(State.Initial); _serverApi = serverApi; _outstandingOperationsCount = 0; eventSubscriber.TryGetEventHandler(out _openingEventHandler); eventSubscriber.TryGetEventHandler(out _openedEventHandler); eventSubscriber.TryGetEventHandler(out _closingEventHandler); eventSubscriber.TryGetEventHandler(out _closedEventHandler); eventSubscriber.TryGetEventHandler(out _descriptionChangedEventHandler); }
public void Setup() { _clusterId = new ClusterId(); _connectionPool = Substitute.For<IConnectionPool>(); _connectionPoolFactory = Substitute.For<IConnectionPoolFactory>(); _connectionPoolFactory.CreateConnectionPool(null, null) .ReturnsForAnyArgs(_connectionPool); _endPoint = new DnsEndPoint("localhost", 27017); _heartbeatConnection = new MockConnection(); _heartbeatConnectionFactory = Substitute.For<IConnectionFactory>(); _heartbeatConnectionFactory.CreateConnection(null, null) .ReturnsForAnyArgs(_heartbeatConnection); _listener = Substitute.For<IServerListener>(); _settings = new ServerSettings() .WithHeartbeatInterval(Timeout.InfiniteTimeSpan); _subject = new ClusterableServer(_settings, _clusterId, _endPoint, _connectionPoolFactory, _heartbeatConnectionFactory, _listener); }
public void Setup() { _clusterId = new ClusterId(); _connectionPoolFactory = Substitute.For<IConnectionPoolFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); _heartbeatConnectionFactory = Substitute.For<IConnectionFactory>(); _listener = Substitute.For<IServerListener>(); _settings = new ServerSettings(); }
// constructors public ClusterableServer(ClusterId clusterId, ClusterConnectionMode clusterConnectionMode, ServerSettings settings, EndPoint endPoint, IConnectionPoolFactory connectionPoolFactory, IConnectionFactory heartbeatConnectionFactory, IEventSubscriber eventSubscriber) { Ensure.IsNotNull(clusterId, nameof(clusterId)); _clusterConnectionMode = clusterConnectionMode; _settings = Ensure.IsNotNull(settings, nameof(settings));; _endPoint = Ensure.IsNotNull(endPoint, nameof(endPoint)); Ensure.IsNotNull(connectionPoolFactory, nameof(connectionPoolFactory)); _heartbeatConnectionFactory = Ensure.IsNotNull(heartbeatConnectionFactory, nameof(heartbeatConnectionFactory)); Ensure.IsNotNull(eventSubscriber, nameof(eventSubscriber)); _serverId = new ServerId(clusterId, endPoint); _baseDescription = _currentDescription = new ServerDescription(_serverId, endPoint); _connectionPool = connectionPoolFactory.CreateConnectionPool(_serverId, endPoint); _state = new InterlockedInt32(State.Initial); eventSubscriber.TryGetEventHandler(out _openingEventHandler); eventSubscriber.TryGetEventHandler(out _openedEventHandler); eventSubscriber.TryGetEventHandler(out _closingEventHandler); eventSubscriber.TryGetEventHandler(out _closedEventHandler); eventSubscriber.TryGetEventHandler(out _heartbeatStartedEventHandler); eventSubscriber.TryGetEventHandler(out _heartbeatSucceededEventHandler); eventSubscriber.TryGetEventHandler(out _heartbeatFailedEventHandler); eventSubscriber.TryGetEventHandler(out _descriptionChangedEventHandler); }
// constructors public Server(ClusterId clusterId, IClusterClock clusterClock, ClusterConnectionMode clusterConnectionMode, ServerSettings settings, EndPoint endPoint, IConnectionPoolFactory connectionPoolFactory, IServerMonitorFactory serverMonitorFactory, IEventSubscriber eventSubscriber) { Ensure.IsNotNull(clusterId, nameof(clusterId)); _clusterClock = Ensure.IsNotNull(clusterClock, nameof(clusterClock)); _clusterConnectionMode = clusterConnectionMode; _settings = Ensure.IsNotNull(settings, nameof(settings)); _endPoint = Ensure.IsNotNull(endPoint, nameof(endPoint)); Ensure.IsNotNull(connectionPoolFactory, nameof(connectionPoolFactory)); Ensure.IsNotNull(serverMonitorFactory, nameof(serverMonitorFactory)); Ensure.IsNotNull(eventSubscriber, nameof(eventSubscriber)); _serverId = new ServerId(clusterId, endPoint); _connectionPool = connectionPoolFactory.CreateConnectionPool(_serverId, endPoint); _state = new InterlockedInt32(State.Initial); _monitor = serverMonitorFactory.Create(_serverId, _endPoint); eventSubscriber.TryGetEventHandler(out _openingEventHandler); eventSubscriber.TryGetEventHandler(out _openedEventHandler); eventSubscriber.TryGetEventHandler(out _closingEventHandler); eventSubscriber.TryGetEventHandler(out _closedEventHandler); eventSubscriber.TryGetEventHandler(out _descriptionChangedEventHandler); }