public ClusterBuilder AddListener(IListener listener) { var clusterListener = listener as IClusterListener; if (clusterListener != null) { _clusterListener = ClusterListenerPair.Create(_clusterListener, clusterListener); } var serverListener = listener as IServerListener; if (serverListener != null) { _serverListener = ServerListenerPair.Create(_serverListener, serverListener); } var connectionPoolListener = listener as IConnectionPoolListener; if (connectionPoolListener != null) { _connectionPoolListener = ConnectionPoolListenerPair.Create(_connectionPoolListener, connectionPoolListener); } var connectionListener = listener as IConnectionListener; if (connectionListener != null) { _connectionListener = ConnectionListenerPair.Create(_connectionListener, connectionListener); } return(this); }
// static public static IConnectionPoolListener Create(IConnectionPoolListener first, IConnectionPoolListener second) { if (first == null) { return(second); } if (second == null) { return(first); } return(new ConnectionPoolListenerPair(first, second)); }
// static public static IConnectionPoolListener Create(IConnectionPoolListener first, IConnectionPoolListener second) { if (first == null) { return second; } if (second == null) { return first; } return new ConnectionPoolListenerPair(first, second); }
// constructors public ExclusiveConnectionPool( ServerId serverId, EndPoint endPoint, ConnectionPoolSettings settings, IConnectionFactory connectionFactory, IConnectionPoolListener listener) { _serverId = Ensure.IsNotNull(serverId, "serverId"); _endPoint = Ensure.IsNotNull(endPoint, "endPoint"); _settings = Ensure.IsNotNull(settings, "settings"); _connectionFactory = Ensure.IsNotNull(connectionFactory, "connectionFactory"); _listener = listener; _connectionHolder = new ListConnectionHolder(_listener); _poolQueue = new WaitQueue(settings.MaxConnections); _waitQueue = new SemaphoreSlim(settings.WaitQueueSize); _maintenanceCancellationTokenSource = new CancellationTokenSource(); _state = new InterlockedInt32(State.Initial); }
public void Setup() { _connectionFactory = Substitute.For <IConnectionFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); _listener = Substitute.For <IConnectionPoolListener>(); _serverId = new ServerId(new ClusterId(), _endPoint); _settings = new ConnectionPoolSettings() .WithMaintenanceInterval(Timeout.InfiniteTimeSpan) .WithMaxConnections(4) .WithMinConnections(2) .WithWaitQueueSize(1); _subject = new ExclusiveConnectionPool( _serverId, _endPoint, _settings, _connectionFactory, _listener); }
public void Setup() { _connectionFactory = Substitute.For <IConnectionFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); _listener = Substitute.For <IConnectionPoolListener>(); _serverId = new ServerId(new ClusterId(), _endPoint); _settings = new ConnectionPoolSettings( maintenanceInterval: Timeout.InfiniteTimeSpan, maxConnections: 4, minConnections: 2, waitQueueSize: 1, waitQueueTimeout: TimeSpan.FromSeconds(2)); _subject = new ExclusiveConnectionPool( _serverId, _endPoint, _settings, _connectionFactory, _listener); }
public ExclusiveConnectionPoolFactory(ConnectionPoolSettings settings, IConnectionFactory connectionFactory, IConnectionPoolListener listener) { _settings = Ensure.IsNotNull(settings, "settings"); _connectionFactory = Ensure.IsNotNull(connectionFactory, "connectionFactory"); _listener = listener; }
public ListConnectionHolder(IConnectionPoolListener listener) { _listener = listener; _connections = new List<PooledConnection>(); }
public ListConnectionHolder(IConnectionPoolListener listener) { _listener = listener; _connections = new List <PooledConnection>(); }
// constructors public ConnectionPoolListenerPair(IConnectionPoolListener first, IConnectionPoolListener second) { _first = Ensure.IsNotNull(first, "first"); _second = Ensure.IsNotNull(second, "second"); }
public void Setup() { _connectionFactory = Substitute.For<IConnectionFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); _listener = Substitute.For<IConnectionPoolListener>(); _serverId = new ServerId(new ClusterId(), _endPoint); _settings = new ConnectionPoolSettings() .WithMaintenanceInterval(Timeout.InfiniteTimeSpan) .WithMaxConnections(4) .WithMinConnections(2) .WithWaitQueueSize(1); _subject = new ExclusiveConnectionPool( _serverId, _endPoint, _settings, _connectionFactory, _listener); }
public ClusterBuilder AddListener(IListener listener) { var clusterListener = listener as IClusterListener; if (clusterListener != null) { _clusterListener = ClusterListenerPair.Create(_clusterListener, clusterListener); } var serverListener = listener as IServerListener; if (serverListener != null) { _serverListener = ServerListenerPair.Create(_serverListener, serverListener); } var connectionPoolListener = listener as IConnectionPoolListener; if (connectionPoolListener != null) { _connectionPoolListener = ConnectionPoolListenerPair.Create(_connectionPoolListener, connectionPoolListener); } var connectionListener = listener as IConnectionListener; if (connectionListener != null) { _connectionListener = ConnectionListenerPair.Create(_connectionListener, connectionListener); } return this; }