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


C# ServerType.IsReplicaSetMember方法代码示例

本文整理汇总了C#中ServerType.IsReplicaSetMember方法的典型用法代码示例。如果您正苦于以下问题:C# ServerType.IsReplicaSetMember方法的具体用法?C# ServerType.IsReplicaSetMember怎么用?C# ServerType.IsReplicaSetMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ServerType的用法示例。


在下文中一共展示了ServerType.IsReplicaSetMember方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsServerValidForCluster

        private bool IsServerValidForCluster(ClusterType clusterType, ClusterConnectionMode connectionMode, ServerType serverType)
        {
            switch (clusterType)
            {
                case ClusterType.ReplicaSet:
                    return serverType.IsReplicaSetMember();

                case ClusterType.Sharded:
                    return serverType == ServerType.ShardRouter;

                case ClusterType.Standalone:
                    return serverType == ServerType.Standalone;

                case ClusterType.Unknown:
                    switch (connectionMode)
                    {
                        case ClusterConnectionMode.Automatic:
                        case ClusterConnectionMode.Direct:
                            return true;

                        default:
                            throw new MongoInternalException("Unexpected connection mode.");
                    }

                default:
                    throw new MongoInternalException("Unexpected cluster type.");
            }
        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:28,代码来源:SingleServerCluster.cs

示例2: PublishDescription

        private void PublishDescription(EndPoint endPoint, ServerType serverType, IEnumerable<EndPoint> hosts = null, string setName = null, EndPoint primary = null, ElectionId electionId = null, EndPoint canonicalEndPoint = null)
        {
            var current = _serverFactory.GetServerDescription(endPoint);

            var config = new ReplicaSetConfig(
                hosts ?? new[] { _firstEndPoint, _secondEndPoint, _thirdEndPoint },
                setName ?? "test",
                primary,
                null);

            var description = current.With(
                averageRoundTripTime: TimeSpan.FromMilliseconds(10),
                replicaSetConfig: serverType.IsReplicaSetMember() ? config : null,
                canonicalEndPoint: canonicalEndPoint,
                electionId: electionId,
                state: ServerState.Connected,
                tags: null,
                type: serverType,
                version: new SemanticVersion(2, 6, 3),
                wireVersionRange: new Range<int>(0, int.MaxValue));

            _serverFactory.PublishDescription(description);
        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:23,代码来源:MultiServerClusterTests.cs

示例3: PublishDescription

        private void PublishDescription(ICluster cluster, EndPoint endPoint, ServerType serverType, IEnumerable<EndPoint> hosts = null, string setName = null, EndPoint primary = null, ElectionId electionId = null, EndPoint canonicalEndPoint = null, int? setVersion = null)
        {
            var current = _serverFactory.GetServerDescription(endPoint);

            var config = new ReplicaSetConfig(
                hosts ?? new[] { _firstEndPoint, _secondEndPoint, _thirdEndPoint },
                setName ?? "test",
                primary,
                setVersion);

            var serverDescription = current.With(
                averageRoundTripTime: TimeSpan.FromMilliseconds(10),
                replicaSetConfig: serverType.IsReplicaSetMember() ? config : null,
                canonicalEndPoint: canonicalEndPoint,
                electionId: electionId,
                state: ServerState.Connected,
                tags: null,
                type: serverType,
                version: new SemanticVersion(2, 6, 3),
                wireVersionRange: new Range<int>(0, int.MaxValue));

            var currentClusterDescription = cluster.Description;
            _serverFactory.PublishDescription(serverDescription);
            SpinWait.SpinUntil(() => !object.ReferenceEquals(cluster.Description, currentClusterDescription), 100); // sometimes returns false and that's OK
        }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:25,代码来源:MultiServerClusterTests.cs

示例4: PublishDescription

        private void PublishDescription(EndPoint endPoint, ServerType serverType, IEnumerable<EndPoint> hosts = null, string setName = null, EndPoint primary = null)
        {
            var current = _serverFactory.GetServerDescription(endPoint);

            var config = new ReplicaSetConfig(
                hosts ?? new[] { _firstEndPoint, _secondEndPoint, _thirdEndPoint },
                setName ?? "test",
                primary,
                null);

            var description = current.WithHeartbeatInfo(
                TimeSpan.FromMilliseconds(10),
                serverType.IsReplicaSetMember() ? config : null,
                null,
                serverType,
                new SemanticVersion(2, 6, 3),
                new Range<int>(0, int.MaxValue));

            _serverFactory.PublishDescription(description);
        }
开发者ID:Nakro,项目名称:mongo-csharp-driver,代码行数:20,代码来源:MultiServerClusterTests.cs


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