• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Configuration.ClusterSettings类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MongoDB.Driver.Core.Configuration.ClusterSettings的典型用法代码示例。如果您正苦于以下问题:C# ClusterSettings类的具体用法?C# ClusterSettings怎么用?C# ClusterSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ClusterSettings类属于MongoDB.Driver.Core.Configuration命名空间,在下文中一共展示了ClusterSettings类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: Setup

 public void Setup()
 {
     _settings = new ClusterSettings();
     _serverFactory = new MockClusterableServerFactory();
     _capturedEvents = new EventCapturer();
 }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:6,代码来源:SingleServerClusterTests.cs


示例17: CreateMultiServerCluster

 private MultiServerCluster CreateMultiServerCluster(ClusterSettings settings)
 {
     var shardedCluster = new MultiServerCluster(settings, _serverFactory, _eventSubscriber);
     shardedCluster.Initialize();
     return shardedCluster;
 }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:6,代码来源:ClusterFactory.cs


示例18: ClusterOpenedEvent

 /// <summary>
 /// Initializes a new instance of the <see cref="ClusterOpenedEvent"/> struct.
 /// </summary>
 /// <param name="clusterId">The cluster identifier.</param>
 /// <param name="clusterSettings">The cluster settings.</param>
 /// <param name="duration">The duration of time it took to open the cluster.</param>
 public ClusterOpenedEvent(ClusterId clusterId, ClusterSettings clusterSettings, TimeSpan duration)
 {
     _clusterId = clusterId;
     _clusterSettings = clusterSettings;
     _duration = duration;
 }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:12,代码来源:ClusterOpenedEvent.cs


示例19: ClusterFactory

 // constructors
 public ClusterFactory(ClusterSettings settings, IClusterableServerFactory serverFactory, IEventSubscriber eventSubscriber)
 {
     _settings = Ensure.IsNotNull(settings, "settings");
     _serverFactory = Ensure.IsNotNull(serverFactory, "serverFactory");
     _eventSubscriber = Ensure.IsNotNull(eventSubscriber, "eventSubscriber");
 }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:7,代码来源:ClusterFactory.cs


示例20: StubCluster

            public StubCluster(ClusterSettings settings, IClusterableServerFactory serverFactory, IEventSubscriber eventSubscriber)
                : base(settings, serverFactory, eventSubscriber)
            {


            }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:6,代码来源:ClusterTests.cs



注:本文中的MongoDB.Driver.Core.Configuration.ClusterSettings类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# GridFS.MongoGridFS类代码示例发布时间:2022-05-26
下一篇:
C# Driver.SafeMode类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap