本文整理汇总了C#中MongoDB.Driver.Core.Configuration.ClusterSettings类的典型用法代码示例。如果您正苦于以下问题:C# ClusterSettings类的具体用法?C# ClusterSettings怎么用?C# ClusterSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClusterSettings类属于MongoDB.Driver.Core.Configuration命名空间,在下文中一共展示了ClusterSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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);
}
示例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>();
}
示例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);
}
示例5: ClusterBuilder
// constructors
public ClusterBuilder()
{
_clusterSettings = new ClusterSettings();
_serverSettings = new ServerSettings();
_connectionPoolSettings = new ConnectionPoolSettings();
_connectionSettings = new ConnectionSettings();
_tcpStreamSettings = new TcpStreamSettings();
_streamFactoryWrapper = inner => inner;
}
示例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>();
}
示例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));
}
示例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));
}
示例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>();
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}