當前位置: 首頁>>代碼示例>>C#>>正文


C# Configuration.ClusterSettings類代碼示例

本文整理匯總了C#中MongoDB.Driver.Core.Configuration.ClusterSettings的典型用法代碼示例。如果您正苦於以下問題:C# ClusterSettings類的具體用法?C# ClusterSettings怎麽用?C# ClusterSettings使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ClusterSettings類屬於MongoDB.Driver.Core.Configuration命名空間,在下文中一共展示了ClusterSettings類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Setup

 public void Setup()
 {
     _settings = new ClusterSettings(serverSelectionTimeout: TimeSpan.FromSeconds(2),
         postServerSelector: new LatencyLimitingServerSelector(TimeSpan.FromMinutes(2)));
     _serverFactory = Substitute.For<IClusterableServerFactory>();
     _capturedEvents = new EventCapturer();
 }
開發者ID:fir3pho3nixx,項目名稱:mongo-csharp-driver,代碼行數:7,代碼來源:ClusterTests.cs

示例2: SingleServerCluster

        // constructor
        internal SingleServerCluster(ClusterSettings settings, IClusterableServerFactory serverFactory, IClusterListener listener)
            : base(settings, serverFactory, listener)
        {
            Ensure.IsEqualTo(settings.EndPoints.Count, 1, "settings.EndPoints.Count");

            _state = new InterlockedInt32(State.Initial);
        }
開發者ID:Nakro,項目名稱:mongo-csharp-driver,代碼行數:8,代碼來源:SingleServerCluster.cs

示例3: Constructor_should_throw_if_no_endpoints_are_specified

        public void Constructor_should_throw_if_no_endpoints_are_specified()
        {
            var settings = new ClusterSettings(endPoints: new EndPoint[0]);
            Action act = () => new MultiServerCluster(settings, _serverFactory, _capturedEvents);

            act.ShouldThrow<ArgumentOutOfRangeException>();
        }
開發者ID:RavenZZ,項目名稱:MDRelation,代碼行數:7,代碼來源:MultiServerClusterTests.cs

示例4: MultiServerCluster

        // constructors
        public MultiServerCluster(ClusterSettings settings, IClusterableServerFactory serverFactory, IEventSubscriber eventSubscriber)
            : base(settings, serverFactory, eventSubscriber)
        {
            Ensure.IsGreaterThanZero(settings.EndPoints.Count, "settings.EndPoints.Count");
            if (settings.ConnectionMode == ClusterConnectionMode.Standalone)
            {
                throw new ArgumentException("ClusterConnectionMode.StandAlone is not supported for a MultiServerCluster.");
            }
            if (settings.ConnectionMode == ClusterConnectionMode.Direct)
            {
                throw new ArgumentException("ClusterConnectionMode.Direct is not supported for a MultiServerCluster.");
            }

            _monitorServersCancellationTokenSource = new CancellationTokenSource();
            _serverDescriptionChangedQueue = new AsyncQueue<ServerDescriptionChangedEventArgs>();
            _servers = new List<IClusterableServer>();
            _state = new InterlockedInt32(State.Initial);
            _replicaSetName = settings.ReplicaSetName;

            eventSubscriber.TryGetEventHandler(out _closingEventHandler);
            eventSubscriber.TryGetEventHandler(out _closedEventHandler);
            eventSubscriber.TryGetEventHandler(out _openingEventHandler);
            eventSubscriber.TryGetEventHandler(out _openedEventHandler);
            eventSubscriber.TryGetEventHandler(out _addingServerEventHandler);
            eventSubscriber.TryGetEventHandler(out _addedServerEventHandler);
            eventSubscriber.TryGetEventHandler(out _removingServerEventHandler);
            eventSubscriber.TryGetEventHandler(out _removedServerEventHandler);
        }
開發者ID:kay-kim,項目名稱:mongo-csharp-driver,代碼行數:29,代碼來源:MultiServerCluster.cs

示例5: ClusterBuilder

 // constructors
 public ClusterBuilder()
 {
     _clusterSettings = new ClusterSettings();
     _serverSettings = new ServerSettings();
     _connectionPoolSettings = new ConnectionPoolSettings();
     _connectionSettings = new ConnectionSettings();
     _tcpStreamSettings = new TcpStreamSettings();
     _streamFactoryWrapper = inner => inner;
 }
開發者ID:Nakro,項目名稱:mongo-csharp-driver,代碼行數:10,代碼來源:ClusterBuilder.cs

示例6: Constructor_should_throw_if_cluster_connection_mode_is_not_supported

        public void Constructor_should_throw_if_cluster_connection_mode_is_not_supported(ClusterConnectionMode mode)
        {
            var settings = new ClusterSettings(
                endPoints: new[] { new DnsEndPoint("localhost", 27017) },
                connectionMode: mode);
            Action act = () => new MultiServerCluster(settings, _serverFactory, _capturedEvents);

            act.ShouldThrow<ArgumentException>();
        }
開發者ID:RavenZZ,項目名稱:MDRelation,代碼行數:9,代碼來源:MultiServerClusterTests.cs

示例7: constructor_should_initialize_instance

        public void constructor_should_initialize_instance()
        {
            var subject = new ClusterSettings();

            subject.ConnectionMode.Should().Be(ClusterConnectionMode.Automatic);
            subject.EndPoints.Should().EqualUsing(new[] { new DnsEndPoint("localhost", 27017) }, EndPointHelper.EndPointEqualityComparer);
            subject.MaxServerSelectionWaitQueueSize.Should().Be(500);
            subject.ReplicaSetName.Should().Be(null);
            subject.ServerSelectionTimeout.Should().Be(TimeSpan.FromSeconds(30));
        }
開發者ID:narutoswj,項目名稱:mongo-csharp-driver,代碼行數:10,代碼來源:ClusterSettingsTests.cs

示例8: ConfigureCluster

 private ClusterSettings ConfigureCluster(ClusterSettings settings, ClusterKey clusterKey)
 {
     var endPoints = clusterKey.Servers.Select(s => (EndPoint)new DnsEndPoint(s.Host, s.Port));
     return settings.With(
         connectionMode: clusterKey.ConnectionMode.ToCore(),
         endPoints: Optional.Enumerable(endPoints),
         replicaSetName: clusterKey.ReplicaSetName,
         maxServerSelectionWaitQueueSize: clusterKey.WaitQueueSize,
         serverSelectionTimeout: clusterKey.ServerSelectionTimeout,
         postServerSelector: new LatencyLimitingServerSelector(clusterKey.LocalThreshold));
 }
開發者ID:kay-kim,項目名稱:mongo-csharp-driver,代碼行數:11,代碼來源:ClusterRegistry.cs

示例9: Cluster

        // constructors
        protected Cluster(ClusterSettings settings, IClusterableServerFactory serverFactory, IClusterListener listener)
        {
            _settings = Ensure.IsNotNull(settings, "settings");
            _serverFactory = Ensure.IsNotNull(serverFactory, "serverFactory");
            _listener = listener;
            _state = new InterlockedInt32(State.Initial);

            _clusterId = new ClusterId();
            _description = ClusterDescription.CreateInitial(_clusterId, _settings.ConnectionMode.ToClusterType());
            _descriptionChangedTaskCompletionSource = new TaskCompletionSource<bool>();
        }
開發者ID:Nakro,項目名稱:mongo-csharp-driver,代碼行數:12,代碼來源:Cluster.cs

示例10: MultiServerCluster

        // constructors
        public MultiServerCluster(ClusterSettings settings, IClusterableServerFactory serverFactory, IClusterListener listener)
            : base(settings, serverFactory, listener)
        {
            Ensure.IsGreaterThanZero(settings.EndPoints.Count, "settings.EndPoints.Count");

            _monitorServersCancellationTokenSource = new CancellationTokenSource();
            _serverDescriptionChangedQueue = new AsyncQueue<ServerDescriptionChangedEventArgs>();
            _servers = new List<IClusterableServer>();
            _state = new InterlockedInt32(State.Initial);
            _replicaSetName = settings.ReplicaSetName;
        }
開發者ID:Nakro,項目名稱:mongo-csharp-driver,代碼行數:12,代碼來源:MultiServerCluster.cs

示例11: constructor_with_endPoints_should_initialize_instance

        public void constructor_with_endPoints_should_initialize_instance()
        {
            var endPoints = new[] { new DnsEndPoint("remotehost", 27123) };

            var subject = new ClusterSettings(endPoints: endPoints);

            subject.ConnectionMode.Should().Be(__defaults.ConnectionMode);
            subject.EndPoints.Should().EqualUsing(endPoints, EndPointHelper.EndPointEqualityComparer);
            subject.MaxServerSelectionWaitQueueSize.Should().Be(__defaults.MaxServerSelectionWaitQueueSize);
            subject.ReplicaSetName.Should().Be(__defaults.ReplicaSetName);
            subject.ServerSelectionTimeout.Should().Be(__defaults.ServerSelectionTimeout);
        }
開發者ID:narutoswj,項目名稱:mongo-csharp-driver,代碼行數:12,代碼來源:ClusterSettingsTests.cs

示例12: constructor_with_connectionMode_should_initialize_instance

        public void constructor_with_connectionMode_should_initialize_instance()
        {
            var connectionMode = ClusterConnectionMode.ReplicaSet;

            var subject = new ClusterSettings(connectionMode: connectionMode);

            subject.ConnectionMode.Should().Be(connectionMode);
            subject.EndPoints.Should().EqualUsing(__defaults.EndPoints, EndPointHelper.EndPointEqualityComparer);
            subject.MaxServerSelectionWaitQueueSize.Should().Be(__defaults.MaxServerSelectionWaitQueueSize);
            subject.ReplicaSetName.Should().Be(__defaults.ReplicaSetName);
            subject.ServerSelectionTimeout.Should().Be(__defaults.ServerSelectionTimeout);
        }
開發者ID:narutoswj,項目名稱:mongo-csharp-driver,代碼行數:12,代碼來源:ClusterSettingsTests.cs

示例13: ClusterTests

 public ClusterTests()
 {
     _settings = new ClusterSettings(serverSelectionTimeout: TimeSpan.FromSeconds(2),
         postServerSelector: new LatencyLimitingServerSelector(TimeSpan.FromMinutes(2)));
     _mockServerFactory = new Mock<IClusterableServerFactory>();
     _mockServerFactory.Setup(f => f.CreateServer(It.IsAny<ClusterId>(), It.IsAny<EndPoint>()))
         .Returns((ClusterId clusterId, EndPoint endPoint) =>
         {
             var mockServer = new Mock<IClusterableServer>();
             mockServer.SetupGet(s => s.EndPoint).Returns(endPoint);
             return mockServer.Object;
         });
     _capturedEvents = new EventCapturer();
 }
開發者ID:RavenZZ,項目名稱:MDRelation,代碼行數:14,代碼來源:ClusterTests.cs

示例14: SingleServerCluster

        // constructor
        internal SingleServerCluster(ClusterSettings settings, IClusterableServerFactory serverFactory, IEventSubscriber eventSubscriber)
            : base(settings, serverFactory, eventSubscriber)
        {
            Ensure.IsEqualTo(settings.EndPoints.Count, 1, "settings.EndPoints.Count");

            _state = new InterlockedInt32(State.Initial);

            eventSubscriber.TryGetEventHandler(out _closingEventHandler);
            eventSubscriber.TryGetEventHandler(out _closedEventHandler);
            eventSubscriber.TryGetEventHandler(out _openingEventHandler);
            eventSubscriber.TryGetEventHandler(out _openedEventHandler);
            eventSubscriber.TryGetEventHandler(out _addingServerEventHandler);
            eventSubscriber.TryGetEventHandler(out _addedServerEventHandler);
            eventSubscriber.TryGetEventHandler(out _removingServerEventHandler);
            eventSubscriber.TryGetEventHandler(out _removedServerEventHandler);
        }
開發者ID:narutoswj,項目名稱:mongo-csharp-driver,代碼行數:17,代碼來源:SingleServerCluster.cs

示例15: Cluster

        // constructors
        protected Cluster(ClusterSettings settings, IClusterableServerFactory serverFactory, IEventSubscriber eventSubscriber)
        {
            _settings = Ensure.IsNotNull(settings, "settings");
            _serverFactory = Ensure.IsNotNull(serverFactory, "serverFactory");
            Ensure.IsNotNull(eventSubscriber, "eventSubscriber");
            _state = new InterlockedInt32(State.Initial);

            _clusterId = new ClusterId();
            _description = ClusterDescription.CreateInitial(_clusterId, _settings.ConnectionMode);
            _descriptionChangedTaskCompletionSource = new TaskCompletionSource<bool>();

            _rapidHeartbeatTimer = new Timer(RapidHeartbeatTimerCallback, null, Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan);

            eventSubscriber.TryGetEventHandler(out _descriptionChangedEventHandler);
            eventSubscriber.TryGetEventHandler(out _selectingServerEventHandler);
            eventSubscriber.TryGetEventHandler(out _selectedServerEventHandler);
            eventSubscriber.TryGetEventHandler(out _selectingServerFailedEventHandler);
        }
開發者ID:rtfmpliz,項目名稱:mongo-csharp-driver,代碼行數:19,代碼來源:Cluster.cs


注:本文中的MongoDB.Driver.Core.Configuration.ClusterSettings類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。