当前位置: 首页>>代码示例>>C#>>正文


C# ClusterDescription类代码示例

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


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


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