private void Handle(ConnectionPoolCheckedOutConnectionEvent @event)
        {
            ConnectionPoolPerformanceRecorder recorder;

            if (_connectionPoolRecorders.TryGetValue(@event.ServerId, out recorder))
            {
                recorder.ConnectionCheckedOut();
                recorder.WaitQueueExited();
            }
        }
Beispiel #2
0
            private IConnectionHandle EndCheckingOut(PooledConnection pooledConnection, Stopwatch stopwatch)
            {
                var reference        = new ReferenceCounted <PooledConnection>(pooledConnection, _pool.ReleaseConnection);
                var connectionHandle = new AcquiredConnection(_pool, reference);

                stopwatch.Stop();
                var checkedOutConnectionEvent = new ConnectionPoolCheckedOutConnectionEvent(connectionHandle.ConnectionId, stopwatch.Elapsed, EventContext.OperationId);

                _pool._checkedOutConnectionEventHandler?.Invoke(checkedOutConnectionEvent);

                // no need to release the semaphore
                _poolQueueWaitResult = SemaphoreSlimSignalable.SemaphoreWaitResult.None;

                return(connectionHandle);
            }
            private AcquiredConnection FinalizePoolEnterance(PooledConnection pooledConnection)
            {
                if (pooledConnection != null)
                {
                    var reference        = new ReferenceCounted <PooledConnection>(pooledConnection, _pool.ReleaseConnection);
                    var connectionHandle = new AcquiredConnection(_pool, reference);

                    var checkedOutConnectionEvent = new ConnectionPoolCheckedOutConnectionEvent(connectionHandle.ConnectionId, _stopwatch.Elapsed, EventContext.OperationId);
                    _pool._checkedOutConnectionEventHandler?.Invoke(checkedOutConnectionEvent);

                    return(connectionHandle);
                }
                else
                {
                    _stopwatch.Stop();

                    var message = $"Timed out waiting for a connection after {_stopwatch.ElapsedMilliseconds}ms.";
                    throw new TimeoutException(message);
                }
            }
Beispiel #4
0
 private void Handle(ConnectionPoolCheckedOutConnectionEvent @event)
 {
     Debug(TraceSourceEventHelper.ConnectionPoolIdBase + 9, "{0}-pool: checked out connection {1} in {2}ms.", TraceSourceEventHelper.Label(@event.ConnectionId.ServerId), TraceSourceEventHelper.Format(@event.ConnectionId), @event.Duration.TotalMilliseconds);
 }