internal void QueuePoolGroupForRelease(System.Data.ProviderBase.DbConnectionPoolGroup poolGroup) { Bid.Trace("<prov.DbConnectionFactory.QueuePoolGroupForRelease|RES|INFO|CPOOL> %d#, poolGroup=%d#\n", this.ObjectID, poolGroup.ObjectID); lock (this._poolGroupsToRelease) { this._poolGroupsToRelease.Add(poolGroup); } this.PerformanceCounters.NumberOfInactiveConnectionPoolGroups.Increment(); }
internal System.Data.ProviderBase.DbMetaDataFactory GetMetaDataFactory(System.Data.ProviderBase.DbConnectionPoolGroup connectionPoolGroup, System.Data.ProviderBase.DbConnectionInternal internalConnection) { System.Data.ProviderBase.DbMetaDataFactory metaDataFactory = connectionPoolGroup.MetaDataFactory; if (metaDataFactory == null) { bool cacheMetaDataFactory = false; metaDataFactory = this.CreateMetaDataFactory(internalConnection, out cacheMetaDataFactory); if (cacheMetaDataFactory) { connectionPoolGroup.MetaDataFactory = metaDataFactory; } } return(metaDataFactory); }
public void ClearPool(DbConnection connection) { IntPtr ptr; System.Data.Common.ADP.CheckArgumentNull(connection, "connection"); Bid.ScopeEnter(out ptr, "<prov.DbConnectionFactory.ClearPool|API> %d#", this.GetObjectId(connection)); try { System.Data.ProviderBase.DbConnectionPoolGroup connectionPoolGroup = this.GetConnectionPoolGroup(connection); if (connectionPoolGroup != null) { connectionPoolGroup.Clear(); } } finally { Bid.ScopeLeave(ref ptr); } }
public void ClearAllPools() { IntPtr ptr; Bid.ScopeEnter(out ptr, "<prov.DbConnectionFactory.ClearAllPools|API> "); try { foreach (KeyValuePair <string, System.Data.ProviderBase.DbConnectionPoolGroup> pair in this._connectionPoolGroups) { System.Data.ProviderBase.DbConnectionPoolGroup group = pair.Value; if (group != null) { group.Clear(); } } } finally { Bid.ScopeLeave(ref ptr); } }
internal System.Data.ProviderBase.DbConnectionInternal GetConnection(DbConnection owningConnection) { System.Data.ProviderBase.DbConnectionInternal connection; int num2 = 10; int millisecondsTimeout = 1; do { System.Data.ProviderBase.DbConnectionPoolGroup connectionPoolGroup = this.GetConnectionPoolGroup(owningConnection); System.Data.ProviderBase.DbConnectionPool connectionPool = this.GetConnectionPool(owningConnection, connectionPoolGroup); if (connectionPool == null) { connectionPoolGroup = this.GetConnectionPoolGroup(owningConnection); connection = this.CreateNonPooledConnection(owningConnection, connectionPoolGroup); this.PerformanceCounters.NumberOfNonPooledConnections.Increment(); } else { connection = connectionPool.GetConnection(owningConnection); if (connection == null) { if (connectionPool.IsRunning) { Bid.Trace("<prov.DbConnectionFactory.GetConnection|RES|CPOOL> %d#, GetConnection failed because a pool timeout occurred.\n", this.ObjectID); throw System.Data.Common.ADP.PooledOpenTimeout(); } Thread.Sleep(millisecondsTimeout); millisecondsTimeout *= 2; } } }while ((connection == null) && (num2-- > 0)); if (connection == null) { Bid.Trace("<prov.DbConnectionFactory.GetConnection|RES|CPOOL> %d#, GetConnection failed because a pool timeout occurred and all retries were exhausted.\n", this.ObjectID); throw System.Data.Common.ADP.PooledOpenTimeout(); } return(connection); }
internal System.Data.ProviderBase.DbConnectionInternal CreateNonPooledConnection(DbConnection owningConnection, System.Data.ProviderBase.DbConnectionPoolGroup poolGroup) { System.Data.Common.DbConnectionOptions connectionOptions = poolGroup.ConnectionOptions; System.Data.ProviderBase.DbConnectionPoolGroupProviderInfo providerInfo = poolGroup.ProviderInfo; System.Data.ProviderBase.DbConnectionInternal internal2 = this.CreateConnection(connectionOptions, providerInfo, null, owningConnection); if (internal2 != null) { this.PerformanceCounters.HardConnectsPerSecond.Increment(); internal2.MakeNonPooledObject(owningConnection, this.PerformanceCounters); } Bid.Trace("<prov.DbConnectionFactory.CreateNonPooledConnection|RES|CPOOL> %d#, Non-pooled database connection created.\n", this.ObjectID); return(internal2); }
internal abstract void SetConnectionPoolGroup(DbConnection outerConnection, System.Data.ProviderBase.DbConnectionPoolGroup poolGroup);
internal System.Data.ProviderBase.DbConnectionPoolGroup GetConnectionPoolGroup(string connectionString, System.Data.ProviderBase.DbConnectionPoolGroupOptions poolOptions, ref System.Data.Common.DbConnectionOptions userConnectionOptions) { System.Data.ProviderBase.DbConnectionPoolGroup group; if (System.Data.Common.ADP.IsEmpty(connectionString)) { return(null); } if (!this._connectionPoolGroups.TryGetValue(connectionString, out group) || (group.IsDisabled && (group.PoolGroupOptions != null))) { System.Data.Common.DbConnectionOptions options = this.CreateConnectionOptions(connectionString, userConnectionOptions); if (options == null) { throw System.Data.Common.ADP.InternalConnectionError(System.Data.Common.ADP.ConnectionError.ConnectionOptionsMissing); } string str = connectionString; if (userConnectionOptions == null) { userConnectionOptions = options; str = options.Expand(); if (str != connectionString) { return(this.GetConnectionPoolGroup(str, null, ref userConnectionOptions)); } } if ((poolOptions == null) && System.Data.Common.ADP.IsWindowsNT) { if (group != null) { poolOptions = group.PoolGroupOptions; } else { poolOptions = this.CreateConnectionPoolGroupOptions(options); } } System.Data.ProviderBase.DbConnectionPoolGroup group2 = new System.Data.ProviderBase.DbConnectionPoolGroup(options, poolOptions) { ProviderInfo = this.CreateConnectionPoolGroupProviderInfo(options) }; lock (this) { Dictionary <string, System.Data.ProviderBase.DbConnectionPoolGroup> dictionary = this._connectionPoolGroups; if (!dictionary.TryGetValue(str, out group)) { Dictionary <string, System.Data.ProviderBase.DbConnectionPoolGroup> dictionary2 = new Dictionary <string, System.Data.ProviderBase.DbConnectionPoolGroup>(1 + dictionary.Count); foreach (KeyValuePair <string, System.Data.ProviderBase.DbConnectionPoolGroup> pair in dictionary) { dictionary2.Add(pair.Key, pair.Value); } dictionary2.Add(str, group2); this.PerformanceCounters.NumberOfActiveConnectionPoolGroups.Increment(); group = group2; this._connectionPoolGroups = dictionary2; } return(group); } } if (userConnectionOptions == null) { userConnectionOptions = group.ConnectionOptions; } return(group); }
private System.Data.ProviderBase.DbConnectionPool GetConnectionPool(DbConnection owningObject, System.Data.ProviderBase.DbConnectionPoolGroup connectionPoolGroup) { if (connectionPoolGroup.IsDisabled && (connectionPoolGroup.PoolGroupOptions != null)) { Bid.Trace("<prov.DbConnectionFactory.GetConnectionPool|RES|INFO|CPOOL> %d#, DisabledPoolGroup=%d#\n", this.ObjectID, connectionPoolGroup.ObjectID); System.Data.ProviderBase.DbConnectionPoolGroupOptions poolGroupOptions = connectionPoolGroup.PoolGroupOptions; System.Data.Common.DbConnectionOptions connectionOptions = connectionPoolGroup.ConnectionOptions; string connectionString = connectionOptions.UsersConnectionString(false); connectionPoolGroup = this.GetConnectionPoolGroup(connectionString, poolGroupOptions, ref connectionOptions); this.SetConnectionPoolGroup(owningObject, connectionPoolGroup); } return(connectionPoolGroup.GetConnectionPool(this)); }
internal System.Data.ProviderBase.DbConnectionPoolGroup GetConnectionPoolGroup(string connectionString, System.Data.ProviderBase.DbConnectionPoolGroupOptions poolOptions, ref System.Data.Common.DbConnectionOptions userConnectionOptions) { System.Data.ProviderBase.DbConnectionPoolGroup group; if (System.Data.Common.ADP.IsEmpty(connectionString)) { return null; } if (!this._connectionPoolGroups.TryGetValue(connectionString, out group) || (group.IsDisabled && (group.PoolGroupOptions != null))) { System.Data.Common.DbConnectionOptions options = this.CreateConnectionOptions(connectionString, userConnectionOptions); if (options == null) { throw System.Data.Common.ADP.InternalConnectionError(System.Data.Common.ADP.ConnectionError.ConnectionOptionsMissing); } string str = connectionString; if (userConnectionOptions == null) { userConnectionOptions = options; str = options.Expand(); if (str != connectionString) { return this.GetConnectionPoolGroup(str, null, ref userConnectionOptions); } } if ((poolOptions == null) && System.Data.Common.ADP.IsWindowsNT) { if (group != null) { poolOptions = group.PoolGroupOptions; } else { poolOptions = this.CreateConnectionPoolGroupOptions(options); } } System.Data.ProviderBase.DbConnectionPoolGroup group2 = new System.Data.ProviderBase.DbConnectionPoolGroup(options, poolOptions) { ProviderInfo = this.CreateConnectionPoolGroupProviderInfo(options) }; lock (this) { Dictionary<string, System.Data.ProviderBase.DbConnectionPoolGroup> dictionary = this._connectionPoolGroups; if (!dictionary.TryGetValue(str, out group)) { Dictionary<string, System.Data.ProviderBase.DbConnectionPoolGroup> dictionary2 = new Dictionary<string, System.Data.ProviderBase.DbConnectionPoolGroup>(1 + dictionary.Count); foreach (KeyValuePair<string, System.Data.ProviderBase.DbConnectionPoolGroup> pair in dictionary) { dictionary2.Add(pair.Key, pair.Value); } dictionary2.Add(str, group2); this.PerformanceCounters.NumberOfActiveConnectionPoolGroups.Increment(); group = group2; this._connectionPoolGroups = dictionary2; } return group; } } if (userConnectionOptions == null) { userConnectionOptions = group.ConnectionOptions; } return group; }
protected internal override DataTable GetSchema(System.Data.ProviderBase.DbConnectionFactory factory, System.Data.ProviderBase.DbConnectionPoolGroup poolGroup, DbConnection outerConnection, string collectionName, string[] restrictions) { throw System.Data.Common.ADP.ClosedConnectionError(); }
protected internal virtual DataTable GetSchema(System.Data.ProviderBase.DbConnectionFactory factory, System.Data.ProviderBase.DbConnectionPoolGroup poolGroup, DbConnection outerConnection, string collectionName, string[] restrictions) { return(factory.GetMetaDataFactory(poolGroup, this).GetSchema(outerConnection, collectionName, restrictions)); }