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

C# ClusterDescription类代码示例

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

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



ClusterDescription类属于命名空间,在下文中一共展示了ClusterDescription类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ClusterSelectedServerEvent

 /// <summary>
 /// Initializes a new instance of the <see cref="ClusterSelectedServerEvent" /> struct.
 /// </summary>
 /// <param name="clusterDescription">The cluster description.</param>
 /// <param name="serverSelector">The server selector.</param>
 /// <param name="selectedServer">The selected server.</param>
 /// <param name="duration">The duration of time it took to select the server.</param>
 public ClusterSelectedServerEvent(ClusterDescription clusterDescription, IServerSelector serverSelector, ServerDescription selectedServer, TimeSpan duration)
 {
     _clusterDescription = clusterDescription;
     _serverSelector = serverSelector;
     _selectedServer = selectedServer;
     _duration = duration;
 }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:14,代码来源:ClusterSelectedServerEvent.cs


示例2: SelectServers

 // methods
 /// <inheritdoc/>
 public IEnumerable<ServerDescription> SelectServers(ClusterDescription cluster, IEnumerable<Servers.ServerDescription> servers)
 {
     return servers.Where(x =>
         x.Type == ServerType.ReplicaSetPrimary ||
         x.Type == ServerType.ShardRouter ||
         x.Type == ServerType.Standalone);
 }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:9,代码来源:WritableServerSelector.cs


示例3: SelectServers

        // methods
        /// <inheritdoc/>
        public IEnumerable<ServerDescription> SelectServers(ClusterDescription cluster, IEnumerable<ServerDescription> servers)
        {
            if (_maxStaleness.HasValue)
            {
                if (cluster.Servers.Any(s => s.Type != ServerType.Unknown && !Feature.MaxStaleness.IsSupported(s.Version)))
                {
                    throw new NotSupportedException("All servers must be version 3.4 or newer to use max staleness.");
                }
            }

            if (cluster.ConnectionMode == ClusterConnectionMode.Direct)
            {
                return servers;
            }

            switch (cluster.Type)
            {
                case ClusterType.ReplicaSet: return SelectForReplicaSet(cluster, servers);
                case ClusterType.Sharded: return SelectForShardedCluster(servers);
                case ClusterType.Standalone: return SelectForStandaloneCluster(servers);
                case ClusterType.Unknown: return __noServers;
                default:
                    var message = string.Format("ReadPreferenceServerSelector is not implemented for cluster of type: {0}.", cluster.Type);
                    throw new NotImplementedException(message);
            }
        }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:28,代码来源:ReadPreferenceServerSelector.cs


示例4: ClusterSelectingServerFailedEvent

 /// <summary>
 /// Initializes a new instance of the <see cref="ClusterSelectingServerFailedEvent" /> struct.
 /// </summary>
 /// <param name="clusterDescription">The cluster description.</param>
 /// <param name="serverSelector">The server selector.</param>
 /// <param name="exception">The exception.</param>
 /// <param name="operationId">The operation identifier.</param>
 public ClusterSelectingServerFailedEvent(ClusterDescription clusterDescription, IServerSelector serverSelector, Exception exception, long? operationId)
 {
     _clusterDescription = clusterDescription;
     _serverSelector = serverSelector;
     _exception = exception;
     _operationId = operationId;
 }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:14,代码来源:ClusterSelectingServerFailedEvent.cs


示例5: SelectServers

 // methods
 public IEnumerable<ServerDescription> SelectServers(ClusterDescription cluster, IEnumerable<ServerDescription> servers)
 {
     var selectedServers = servers;
     foreach (var selector in _selectors)
     {
         selectedServers = selector.SelectServers(cluster, selectedServers);
     }
     return selectedServers;
 }
开发者ID:Nakro,项目名称:mongo-csharp-driver,代码行数:10,代码来源:CompositeServerSelector.cs


示例6: TestFixtureSetup

 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);
 }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:10,代码来源:MongoIncompatibleDriverExceptionTests.cs


示例7: 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


示例8: Constructor_should_initialize_instance

 public void Constructor_should_initialize_instance()
 {
     var subject = new ClusterDescription(
         __clusterId,
         ClusterType.ReplicaSet,
         new[] { __serverDescription1, __serverDescription2 });
     subject.ClusterId.Should().Be(__clusterId);
     subject.Servers.Should().ContainInOrder(new[] { __serverDescription1, __serverDescription2 });
     subject.State.Should().Be(ClusterState.Disconnected);
     subject.Type.Should().Be(ClusterType.ReplicaSet);
 }
开发者ID:bollinim,项目名称:mongo-csharp-driver,代码行数:11,代码来源:ClusterDescriptionTests.cs


示例9: MongoIncompatibleDriverExceptionTests

 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);
 }
开发者ID:XiaoPingJiang,项目名称:mongo-csharp-driver,代码行数:11,代码来源:MongoIncompatibleDriverExceptionTests.cs


示例10: Setup

        public void Setup()
        {
            var clusterId = new ClusterId();
            _primary = ServerDescriptionHelper.Connected(clusterId, new DnsEndPoint("localhost", 27017), ServerType.ReplicaSetPrimary, new TagSet(new [] { new Tag("a", "1") }));
            _secondary1 = ServerDescriptionHelper.Connected(clusterId, new DnsEndPoint("localhost", 27018), ServerType.ReplicaSetSecondary, new TagSet(new [] { new Tag("a", "1") }));
            _secondary2 = ServerDescriptionHelper.Connected(clusterId, new DnsEndPoint("localhost", 27019), ServerType.ReplicaSetSecondary, new TagSet(new[] { new Tag("a", "2") }));

            _description = new ClusterDescription(
                clusterId,
                ClusterType.ReplicaSet,
                new[] { _primary, _secondary1, _secondary2 });
        }
开发者ID:kay-kim,项目名称:mongo-csharp-driver,代码行数:12,代码来源:ReadPreferenceServerSelectorTests.cs


示例11: SelectServers

 // methods
 public IEnumerable<ServerDescription> SelectServers(ClusterDescription cluster, IEnumerable<ServerDescription> servers)
 {
     var list = servers.ToList();
     switch (list.Count)
     {
         case 0:
         case 1:
             return list;
         default:
             var index = ThreadStaticRandom.Next(list.Count);
             return new[] { list[index] };
     }
 }
开发者ID:Nakro,项目名称:mongo-csharp-driver,代码行数:14,代码来源:RandomServerSelector.cs


示例12: Setup

 public void Setup()
 {
     var clusterId = new ClusterId();
     _description = new ClusterDescription(
         clusterId,
         ClusterType.Unknown,
         new[]
         {
             ServerDescriptionHelper.Connected(clusterId, new DnsEndPoint("localhost", 27017), averageRoundTripTime: TimeSpan.FromMilliseconds(10)),
             ServerDescriptionHelper.Connected(clusterId, new DnsEndPoint("localhost", 27018), averageRoundTripTime: TimeSpan.FromMilliseconds(30)),
             ServerDescriptionHelper.Connected(clusterId, new DnsEndPoint("localhost", 27019), averageRoundTripTime: TimeSpan.FromMilliseconds(20))
         });
 }
开发者ID:Nakro,项目名称:mongo-csharp-driver,代码行数:13,代码来源:RandomServerSelectorTests.cs


示例13: Setup

 public void Setup()
 {
     var clusterId = new ClusterId();
     _description = new ClusterDescription(
         clusterId,
         ClusterType.Unknown,
         new[]
         {
             ServerDescriptionHelper.Connected(clusterId, new DnsEndPoint("localhost", 27017)),
             ServerDescriptionHelper.Connected(clusterId, new DnsEndPoint("localhost", 27018)),
             ServerDescriptionHelper.Connected(clusterId, new DnsEndPoint("localhost", 27019)),
         });
 }
开发者ID:Nakro,项目名称:mongo-csharp-driver,代码行数:13,代码来源:EndPointServerSelectorTests.cs


示例14: SelectServers

 // methods
 /// <inheritdoc/>
 public IEnumerable<ServerDescription> SelectServers(ClusterDescription cluster, IEnumerable<ServerDescription> servers)
 {
     switch (cluster.Type)
     {
         case ClusterType.ReplicaSet: return SelectForReplicaSet(servers);
         case ClusterType.Sharded: return SelectForShardedCluster(servers);
         case ClusterType.Standalone: return SelectForStandaloneCluster(servers);
         case ClusterType.Unknown: return __noServers;
         default:
             var message = string.Format("ReadPreferenceServerSelector is not implemented for cluster of type: {0}.", cluster.Type);
             throw new NotImplementedException(message);
     }
 }
开发者ID:kay-kim,项目名称:mongo-csharp-driver,代码行数:15,代码来源:ReadPreferenceServerSelector.cs


示例15: LatencyLimitingServerSelectorTests

 public LatencyLimitingServerSelectorTests()
 {
     var clusterId = new ClusterId();
     _description = new ClusterDescription(
         clusterId,
         ClusterConnectionMode.Automatic,
         ClusterType.Unknown,
         new[]
         {
             ServerDescriptionHelper.Connected(clusterId, new DnsEndPoint("localhost", 27017), averageRoundTripTime: TimeSpan.FromMilliseconds(10)),
             ServerDescriptionHelper.Connected(clusterId, new DnsEndPoint("localhost", 27018), averageRoundTripTime: TimeSpan.FromMilliseconds(30)),
             ServerDescriptionHelper.Connected(clusterId, new DnsEndPoint("localhost", 27019), averageRoundTripTime: TimeSpan.FromMilliseconds(20))
         });
 }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:14,代码来源:LatencyLimitingServerSelectorTests.cs


示例16: EndPointServerSelectorTests

 public EndPointServerSelectorTests()
 {
     var clusterId = new ClusterId();
     _description = new ClusterDescription(
         clusterId,
         ClusterConnectionMode.Automatic,
         ClusterType.Unknown,
         new[]
         {
             ServerDescriptionHelper.Connected(clusterId, new DnsEndPoint("localhost", 27017)),
             ServerDescriptionHelper.Connected(clusterId, new DnsEndPoint("localhost", 27018)),
             ServerDescriptionHelper.Connected(clusterId, new DnsEndPoint("localhost", 27019)),
         });
 }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:14,代码来源:EndPointServerSelectorTests.cs


示例17: ExecuteAsync

        public async Task ExecuteAsync(ClusterDescription clusterDescription, IMongoDatabase database, IMongoCollection<BsonDocument> collection, BsonDocument arguments)
        {
            ClusterDescription = clusterDescription;

            foreach (var argument in arguments.Elements)
            {
                if (!TrySetArgument(argument.Name, argument.Value))
                {
                    throw new NotImplementedException("The argument " + argument.Name + " has not been implemented in " + GetType());
                }
            }

            await ExecuteAsync(collection);
        }
开发者ID:RainsSoft,项目名称:mongo-csharp-driver,代码行数:14,代码来源:CrudOperationTestBase.cs


示例18: 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


示例19: SelectServers

        // methods
        /// <inheritdoc/>
        public IEnumerable<ServerDescription> SelectServers(ClusterDescription cluster, IEnumerable<ServerDescription> servers)
        {
            if (_allowedLatencyRange == Timeout.InfiniteTimeSpan)
            {
                return servers;
            }

            var list = servers.ToList();
            switch (list.Count)
            {
                case 0:
                case 1:
                    return list;
                default:
                    var minAverageRoundTripTime = list.Min(s => s.AverageRoundTripTime);
                    var maxAverageRoundTripTime = minAverageRoundTripTime.Add(_allowedLatencyRange);
                    return list.Where(s => s.AverageRoundTripTime <= maxAverageRoundTripTime);
            }
        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:21,代码来源:LatencyLimitingServerSelector.cs


示例20: ClusterSelectingServerEvent

 /// <summary>
 /// Initializes a new instance of the <see cref="ClusterSelectingServerEvent" /> struct.
 /// </summary>
 /// <param name="clusterDescription">The cluster description.</param>
 /// <param name="serverSelector">The server selector.</param>
 public ClusterSelectingServerEvent(ClusterDescription clusterDescription, IServerSelector serverSelector)
 {
     _clusterDescription = clusterDescription;
     _serverSelector = serverSelector;
 }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:10,代码来源:ClusterSelectingServerEvent.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# CmdRequest类代码示例发布时间:2022-05-24
下一篇:
C# ClusterConfig类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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