|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--anvil.database.ConnectionPool
Pool for storing limited amount of connections as PooledConnection.
Pool is used by ConnectionAccessQueue which takes care of the situations
when connections aren't immediately available.
Methods which might alter the connection vectors are internally synchronized so that only one thread at a time can perform operations on them. However several threads may be creating connections at the same time.
PooledConnection,
ConnectionAccessQueue,
ConnectionFactory| Nested Class Summary | |
class |
ConnectionPool.ConnectionAllocator
Connection allocator runs through the loop sleeping specified amount on each loop and invoking checkConnections method on each loop. |
| Constructor Summary | |
ConnectionPool(Zone zone,
PoolPreferences prefs)
Constructs the pool. |
|
| Method Summary | |
PooledConnection |
acquire(int timeout)
Acquires new connection from the pool. |
void |
connectionAcquireTimedout(ConnectionPool pool,
long duration)
Notifies unsuccessful attempt to acquire connection. |
void |
connectionClosed(PooledConnection connection)
Notifies that connection is being closed, because maximum lifetime has been exceeded or java.sql.Connection instance has been
expliticly closed (for instance with java.sql.Connection.close()). |
void |
connectionCreated(PooledConnection connection,
long duration)
Notifies creation of connection. |
void |
connectionException(java.lang.String source,
java.lang.Exception exception)
Notifies exception situation. |
void |
connectionReleased(PooledConnection connection)
Notifies release of connection immediately after operation has been performed. |
void |
connectionReserved(PooledConnection connection,
long duration)
Notifies reservation of connection immediately after operation has been performed. |
void |
connectionTimeout(PooledConnection connection)
Notifies that the maximum reservation time of connection has been exceed. |
int |
getActiveConnections()
Gets the current amount of connections active. |
int |
getConnectionAcquireTimeout()
Gets the connection reservation timeout. |
int |
getConnectionLifetime()
Gets the connection lifetime. |
int |
getConnectionTimeout()
Gets the connection reservation timeout. |
java.lang.String |
getDriver()
Gets the class of driver. |
int |
getFreeConnections()
Gets the current amount of connections free. |
int |
getMaxConnections()
Gets the maximum amount of connections. |
int |
getMinConnections()
Gets the recommended minimum amount of connections. |
java.lang.String |
getName()
Gets the name of pool. |
java.lang.String |
getPassword()
|
int |
getPendingConnections()
Gets the current amount of pending connections, ie. |
java.lang.Object |
getPreference(java.lang.String name)
Gets preference by name from PoolPreferences. |
int |
getTotalConnections()
Gets the current amount of connections on this pool. |
java.lang.String |
getURL()
|
java.lang.String |
getUsername()
|
Zone |
getZone()
Gets the zhe for this pool. |
void |
initialize(ConnectionPool pool)
Initializes the monitor, called after the manager has been started up. |
void |
release(PooledConnection connection)
Notifies pool about the connection being released. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ConnectionPool(Zone zone,
PoolPreferences prefs)
| Method Detail |
public java.lang.String getName()
public java.lang.String getDriver()
public Zone getZone()
public java.lang.String getURL()
public java.lang.String getUsername()
public java.lang.String getPassword()
public int getMinConnections()
public int getMaxConnections()
public int getConnectionLifetime()
public int getConnectionTimeout()
public int getConnectionAcquireTimeout()
public java.lang.Object getPreference(java.lang.String name)
public int getActiveConnections()
public int getPendingConnections()
public int getFreeConnections()
public int getTotalConnections()
public PooledConnection acquire(int timeout)
throws java.lang.Exception
freeConnections vector is scanned through for
a usable connection from the beginning until one is found.
timeout - Timeout override (if > 0)
null if it couldn't be created
java.lang.Exceptionpublic void release(PooledConnection connection)
connection - Connectionpublic void initialize(ConnectionPool pool)
ConnectionMonitor
initialize in interface ConnectionMonitorpool - Instance of connection pool
public void connectionCreated(PooledConnection connection,
long duration)
ConnectionMonitor
connectionCreated in interface ConnectionMonitorconnection - PooledConnectionduration - Duration of operation, in milliseconds
public void connectionReserved(PooledConnection connection,
long duration)
ConnectionMonitor
connectionReserved in interface ConnectionMonitorconnection - PooledConnectionduration - Duration of operation, in milliseconds
public void connectionAcquireTimedout(ConnectionPool pool,
long duration)
ConnectionMonitor
connectionAcquireTimedout in interface ConnectionMonitorpool - ConnectionPoolduration - Duration of operation, in millisecondspublic void connectionReleased(PooledConnection connection)
ConnectionMonitor
connectionReleased in interface ConnectionMonitorconnection - PooledConnectionpublic void connectionClosed(PooledConnection connection)
ConnectionMonitorjava.sql.Connection instance has been
expliticly closed (for instance with java.sql.Connection.close()).
connectionClosed in interface ConnectionMonitorconnection - PooledConnectionpublic void connectionTimeout(PooledConnection connection)
ConnectionMonitor
connectionTimeout in interface ConnectionMonitorconnection - PooledConnection
public void connectionException(java.lang.String source,
java.lang.Exception exception)
ConnectionMonitor
connectionException in interface ConnectionMonitorsource - Informative source name (class.method)exception - Exception that occured
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||