コード例 #1
0
        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);
        }
コード例 #2
0
 // 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));
 }
コード例 #3
0
 // 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));
 }
コード例 #4
0
 public void Setup()
 {
     _clusterId             = new ClusterId();
     _clusterConnectionMode = ClusterConnectionMode.Standalone;
     _connectionPoolFactory = Substitute.For <IConnectionPoolFactory>();
     _endPoint             = new DnsEndPoint("localhost", 27017);
     _serverMonitorFactory = Substitute.For <IServerMonitorFactory>();
     _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();
 }
コード例 #6
0
 public void Setup()
 {
     _clusterId = new ClusterId();
     _clusterConnectionMode = ClusterConnectionMode.Standalone;
     _connectionPoolFactory = Substitute.For<IConnectionPoolFactory>();
     _endPoint = new DnsEndPoint("localhost", 27017);
     _serverMonitorFactory = Substitute.For<IServerMonitorFactory>();
     _eventSubscriber = Substitute.For<IEventSubscriber>();
     _settings = new ServerSettings();
 }
コード例 #7
0
 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();
 }
コード例 #8
0
        // 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));
        }
コード例 #9
0
        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();
        }
コード例 #10
0
        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();
        }
コード例 #11
0
        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);

            _serverMonitor = Substitute.For<IServerMonitor>();
            _serverMonitorFactory = Substitute.For<IServerMonitorFactory>();
            _serverMonitorFactory.Create(null, null).ReturnsForAnyArgs(_serverMonitor);

            _capturedEvents = new EventCapturer();
            _settings = new ServerSettings(heartbeatInterval: Timeout.InfiniteTimeSpan);

            _subject = new Server(_clusterId, _clusterConnectionMode, _settings, _endPoint, _connectionPoolFactory, _serverMonitorFactory, _capturedEvents);
        }
コード例 #12
0
        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);

            _serverMonitor        = Substitute.For <IServerMonitor>();
            _serverMonitorFactory = Substitute.For <IServerMonitorFactory>();
            _serverMonitorFactory.Create(null, null).ReturnsForAnyArgs(_serverMonitor);

            _capturedEvents = new EventCapturer();
            _settings       = new ServerSettings(heartbeatInterval: Timeout.InfiniteTimeSpan);

            _subject = new Server(_clusterId, _clusterConnectionMode, _settings, _endPoint, _connectionPoolFactory, _serverMonitorFactory, _capturedEvents);
        }
コード例 #13
0
ファイル: Server.cs プロジェクト: LJM74520/nice
        // 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);
        }