本文整理汇总了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.");
}
}
示例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);
}
示例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
}
示例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);
}