|
|||||||||
| Home >> All >> com >> lutris >> appserver >> server >> sql >> [ standard overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.lutris.appserver.server.sql.standard
Class StandardConnectionAllocator

java.lang.Objectcom.lutris.appserver.server.sql.standard.StandardConnectionAllocator
- All Implemented Interfaces:
- com.lutris.appserver.server.sql.ConnectionAllocator
- public class StandardConnectionAllocator
- extends java.lang.Object
- implements com.lutris.appserver.server.sql.ConnectionAllocator
- extends java.lang.Object
Manages a pool (set) of connections to a database. The pool is named as a logical database. By naming a pool, this allows connection resource control to be on a finer grain that a database and allows for easier migration to multiple databases. One or more pools can map to the same actual database. A connection considered part of the pool, even if its allocated to a thread. These objects are all publicly accessed via the Database Manager, not directly.
If an error occurs in a connection, it is dropped from the pool. The process using the connection has already received an error which aborts the work in progress. By dropping the connection, waiting threads are restarted. If something is wrong with the database (e.g. server is down), they will recieve errors and also be aborted. A generation number is used to close down all connections that were open when the error occured, allowing new connections to be allocated.
The configuration data is specified in the section:
DatabaseManager.DB.dbName.Connection
Configuration sub fields are:
-
Url- The JDBC URLof the database. Manditary. E.g. "jdbc:sequelink://dbHost:4000/[Informix];Database=dummy" -
User- The database users used to access the database. Manditary. -
Password- The database user's password. Manditary. -
MaxPoolSize- The maximum number of open connections to the database. Optional, if not specified, then it default to 0. A value of 0 means that connections are allocated indefinitely or until the database (JDBC) refuses any new connections. -
Logging- Specify true to enable SQL logging, false to disable it. Optional, false if not specified. -
AllocationTimeout- The Maximum amount of time that a thread will wait for a connection from the connection allocator before an exception is thrown. This will prevent possible dead locks. The time out is in milliseconds. If the time out is <= 0, the allocation of connections will wait indefinitely. Optional, if not specified, then it defaults to 1000 (ms). -
QueryTimeout- The amount of time (in seconds) that a query will block before throwing an exception. If <= 0 then the query will not block. Optional, if not specified, then the value defaults to 0. This is not implemented by all logical databases. -
TransactionTimeout- The amount of time (in seconds) that a transaction will block before throwing an exception. If <= 0 then the transaction will not block. Optional, if not specified, then the value defaults to 0. This is not implemented by all logical databases. -
MaxPreparedStatements- If specified, overrides the JDBCConnection.getMetaData().getMaxStatements()value. If less than zero, use the meta data value. Optional, default is to use the meta data.
- Since:
- LBS1.8
- Version:
- $Revision: 1.10.12.1 $
| Field Summary | |
private java.util.Date |
biggestPoolDate
Date at which the biggest pool size occured. |
private int |
biggestPoolSize
Maximum size the pool ever got to, regardless of generation. |
private int |
currentPoolSize
Current size of the pool; includes allocated connections. |
protected int |
generation
Generation number. |
private com.lutris.logging.LogChannel |
log
The log channel. |
protected com.lutris.appserver.server.sql.LogicalDatabase |
logicalDatabase
Reference to the logical database for easy access to the connection pool. |
private int |
maxPoolSize
Maximum number of connections in the pool. |
protected int |
maxPreparedStatements
Maximum number of prepared statements to use; if less-than zero, then JDBC is queried for this value. |
protected long |
numRequests
Number of queries or transactions on this logical database. |
protected java.lang.String |
password
SQL password.. |
private java.util.Stack |
pool
The actual pool of DBConnection objects. |
protected int |
queryTimeOut
Maximum amount of time in seconds to block on a query. |
protected boolean |
sqlLogging
Indicates if logging is enabled. |
private int |
timeOut
Maximum amount of time in milliseconds to wait for a connection. |
protected int |
transactionTimeOut
Maximum amount of time in seconds to block on a transaction. |
protected java.lang.String |
url
JDBC URL of database. |
protected java.lang.String |
user
SQL user name. |
| Constructor Summary | |
protected |
StandardConnectionAllocator(com.lutris.appserver.server.sql.LogicalDatabase logicalDatabase,
com.lutris.util.Config conConfig)
Initialize the connection allocator object. |
| Method Summary | |
com.lutris.appserver.server.sql.DBConnection |
allocate()
Allocate a connection to a thread. |
protected com.lutris.appserver.server.sql.DBConnection |
createConnection()
Create a new connection in the pool. |
void |
drop(com.lutris.appserver.server.sql.DBConnection dbConnection)
Called when a connection in this pool has an SQL error. |
void |
dropAllNow()
Called when the database manager is shutting down: Close all connections immediately. |
protected void |
finalize()
Finalizer. |
int |
getActiveCount()
Return the number of currently active connections. |
int |
getMaxCount()
Return the maximum number of connections active at one time. |
java.util.Date |
getMaxCountDate()
Return the time when the maximum connection count occured. |
long |
getRequestCount()
Return the number of database requests. |
void |
release(com.lutris.appserver.server.sql.DBConnection dbConnection)
Return a connection to the pool. |
void |
resetMaxCount()
Reset the maximum connection count and date. |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
logicalDatabase
protected com.lutris.appserver.server.sql.LogicalDatabase logicalDatabase
- Reference to the logical database for easy access to the
connection pool.
url
protected java.lang.String url
- JDBC URL of database.
user
protected java.lang.String user
- SQL user name.
password
protected java.lang.String password
- SQL password..
maxPoolSize
private int maxPoolSize
- Maximum number of connections in the pool.
If this value is <= zero, then create as many
connections as possible.
currentPoolSize
private int currentPoolSize
- Current size of the pool; includes allocated connections.
biggestPoolSize
private int biggestPoolSize
- Maximum size the pool ever got to, regardless of generation.
biggestPoolDate
private java.util.Date biggestPoolDate
- Date at which the biggest pool size occured.
numRequests
protected long numRequests
- Number of queries or transactions on this logical database.
pool
private java.util.Stack pool
- The actual pool of DBConnection objects.
sqlLogging
protected boolean sqlLogging
- Indicates if logging is enabled.
timeOut
private int timeOut
- Maximum amount of time in milliseconds to wait for a connection.
queryTimeOut
protected int queryTimeOut
- Maximum amount of time in seconds to block on a query. The
DBQuery object will retrieve this value from the connection.
transactionTimeOut
protected int transactionTimeOut
- Maximum amount of time in seconds to block on a transaction. The
DBTransaction object will retrieve this value from the connection.
maxPreparedStatements
protected int maxPreparedStatements
- Maximum number of prepared statements to use; if less-than zero,
then JDBC is queried for this value.
generation
protected int generation
- Generation number. When an SQL error occurs, all objects of the
same generation or earlier are dropped.
log
private com.lutris.logging.LogChannel log
- The log channel.
| Constructor Detail |
StandardConnectionAllocator
protected StandardConnectionAllocator(com.lutris.appserver.server.sql.LogicalDatabase logicalDatabase, com.lutris.util.Config conConfig) throws com.lutris.util.ConfigException
- Initialize the connection allocator object. Connections are
opened on demand and stored in a pool.
| Method Detail |
createConnection
protected com.lutris.appserver.server.sql.DBConnection createConnection() throws java.sql.SQLException
- Create a new connection in the pool.
allocate
public com.lutris.appserver.server.sql.DBConnection allocate() throws java.sql.SQLException
- Allocate a connection to a thread. If none are available, grow the
pool. If the pool is alredy its maximum size, then the thread waits.
- Specified by:
allocatein interfacecom.lutris.appserver.server.sql.ConnectionAllocator
release
public void release(com.lutris.appserver.server.sql.DBConnection dbConnection)
- Return a connection to the pool. If it is of an old generation,
close and drop.
- Specified by:
releasein interfacecom.lutris.appserver.server.sql.ConnectionAllocator
drop
public void drop(com.lutris.appserver.server.sql.DBConnection dbConnection)
- Called when a connection in this pool has an SQL error.
All unallocated connections in the pool are dropped if
they have a generation number less
than or equal to the error connection.
If the current generation number
is the same as this generation number, increment it.
This way so that all outstanding connections
(including the one passed in) of the same generation
are dropped when returned.
- Specified by:
dropin interfacecom.lutris.appserver.server.sql.ConnectionAllocator
dropAllNow
public void dropAllNow()
- Called when the database manager is shutting down:
Close all connections immediately.
- Specified by:
dropAllNowin interfacecom.lutris.appserver.server.sql.ConnectionAllocator
getActiveCount
public int getActiveCount()
- Return the number of currently active connections.
- Specified by:
getActiveCountin interfacecom.lutris.appserver.server.sql.ConnectionAllocator
getMaxCount
public int getMaxCount()
- Return the maximum number of connections active at one time.
- Specified by:
getMaxCountin interfacecom.lutris.appserver.server.sql.ConnectionAllocator
getMaxCountDate
public java.util.Date getMaxCountDate()
- Return the time when the maximum connection count occured.
- Specified by:
getMaxCountDatein interfacecom.lutris.appserver.server.sql.ConnectionAllocator
resetMaxCount
public void resetMaxCount()
- Reset the maximum connection count and date.
- Specified by:
resetMaxCountin interfacecom.lutris.appserver.server.sql.ConnectionAllocator
getRequestCount
public long getRequestCount()
- Return the number of database requests.
- Specified by:
getRequestCountin interfacecom.lutris.appserver.server.sql.ConnectionAllocator
finalize
protected void finalize()
- Finalizer.
If any connections allocated by this object have not been closed,
this method ensures that garbage collection does so.
|
|||||||||
| Home >> All >> com >> lutris >> appserver >> server >> sql >> [ standard overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.lutris.appserver.server.sql.standard.StandardConnectionAllocator