mpoeschl 2003/05/27 15:38:35
Modified: src/java/org/apache/torque/pool Tag: TORQUE_3_0_BRANCH
ConnectionPool.java TorqueClassicDataSource.java
Log:
cleanup
Revision Changes Path
No revision
No revision
1.14.2.2 +23 -8 db-torque/src/java/org/apache/torque/pool/ConnectionPool.java
Index: ConnectionPool.java
===================================================================
RCS file: /home/cvs/db-torque/src/java/org/apache/torque/pool/ConnectionPool.java,v
retrieving revision 1.14.2.1
retrieving revision 1.14.2.2
diff -u -r1.14.2.1 -r1.14.2.2
--- ConnectionPool.java 22 May 2003 19:53:19 -0000 1.14.2.1
+++ ConnectionPool.java 27 May 2003 22:38:35 -0000 1.14.2.2
@@ -122,7 +122,10 @@
*/
private int waitCount = 0;
+ /** Interval (in seconds) that the monitor thread reports the pool state */
private int logInterval;
+
+ /** Monitor thread reporting the pool state */
private Monitor monitor;
/**
@@ -210,7 +213,7 @@
* @param username The name of the database user.
* @param password The password of the database user.
* @return A database connection.
- * @exception SQLException
+ * @exception SQLException if there is aproblem with the db connection
*/
final synchronized PooledConnection getConnection(String username,
String password)
@@ -247,7 +250,7 @@
* <code>password</code>.
*
* @return A database connection.
- * @exception SQLException
+ * @exception SQLException if there is aproblem with the db connection
*/
private PooledConnection getNewConnection()
throws SQLException
@@ -319,7 +322,7 @@
* creating a new connection.
*
* @return An existing or new database connection.
- * @exception Exception
+ * @throws Exception if the pool is empty
*/
private PooledConnection popConnection()
throws Exception
@@ -485,6 +488,11 @@
notify();
}
+ /**
+ * Get the name of the pool
+ *
+ * @return the name of the pool
+ */
String getPoolName()
{
return toString();
@@ -607,18 +615,22 @@
*/
protected class Monitor extends Thread
{
+ /** true if the monot is running */
private boolean isRun = true;
+ /**
+ * run method for the monitor thread
+ */
public void run()
{
StringBuffer buf = new StringBuffer();
while (logInterval > 0 && isRun)
{
buf.setLength(0);
- buf.append(getPoolName()).append(" (in + out = total): ")
- .append(getNbrAvailable()).append(" + ")
- .append(getNbrCheckedOut()).append(" = ")
- .append(getTotalCount());
+ buf.append(getPoolName());
+ buf.append(" avail: ").append(getNbrAvailable());
+ buf.append(" in use: ").append(getNbrCheckedOut());
+ buf.append(" total: ").append(getTotalCount());
log(buf.toString());
// Wait for a bit.
@@ -632,6 +644,9 @@
}
}
+ /**
+ * Shut down the monitor
+ */
public void shutdown()
{
isRun = false;
1.5.2.1 +44 -13
db-torque/src/java/org/apache/torque/pool/TorqueClassicDataSource.java
Index: TorqueClassicDataSource.java
===================================================================
RCS file:
/home/cvs/db-torque/src/java/org/apache/torque/pool/TorqueClassicDataSource.java,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- TorqueClassicDataSource.java 26 Nov 2002 23:46:56 -0000 1.5
+++ TorqueClassicDataSource.java 27 May 2003 22:38:35 -0000 1.5.2.1
@@ -87,16 +87,20 @@
{
/** Pools keyed by username. */
private static Map pools = new HashMap();
+
+ /** Counter used to create an internal unique name od the Data Source */
private static int cpdsCounter;
/** DataSource Name used to find the ConnectionPoolDataSource */
private String dataSourceName;
+
/** Description */
private String description;
/** Login TimeOut in seconds */
private int loginTimeout;
+ /** Pool Data Source that is used to fetch connections */
private ConnectionPoolDataSource cpds;
/** Log stream */
@@ -105,12 +109,31 @@
/** Environment that may be used to set up a jndi initial context. */
private Properties jndiEnvironment;
+ /** Maximum Number of Connections cached in this Data Source */
private int defaultMaxConnections;
+
+ /**
+ * Maximum Number of Connections for a specified User in this Data
+ * Source
+ */
private Properties perUserMaxConnections;
+
+ /** Maximum lifetime of a database connection */
private int maxExpiryTime;
+
+ /**
+ * time to wait when initiating a connection
+ * for the database to respond
+ */
private int connectionWaitTimeout;
+
+ /** Interval (in seconds) that the monitor thread reports the pool state */
private int logInterval;
+
+ /** Do connections from this pool are auto-committing? */
private boolean defaultAutoCommit;
+
+ /** Are connections from this pool read-only? */
private boolean defaultReadOnly;
/**
@@ -147,7 +170,6 @@
this.defaultMaxConnections = v;
}
-
/**
* Get the number of database connections to cache per user. The keys
* are usernames and the value is the maximum connections. Any username
@@ -172,7 +194,6 @@
this.perUserMaxConnections = v;
}
-
/**
* Get the amount of time (in seconds) that database connections
* will be cached. The default is 3600 (1 hour).
@@ -195,7 +216,6 @@
this.maxExpiryTime = v;
}
-
/**
* Get the amount of time (in seconds) a connection request will
* have to wait before a time out occurs and an error is thrown.
@@ -220,7 +240,6 @@
this.connectionWaitTimeout = v;
}
-
/**
* Get the interval (in seconds) between which the ConnectionPool logs
* the status of it's Connections. Default is 0 which indicates no
@@ -407,8 +426,7 @@
*
* @param v Value to assign to connectionPoolDataSource.
*/
- public void
- setConnectionPoolDataSource(ConnectionPoolDataSource v)
+ public void setConnectionPoolDataSource(ConnectionPoolDataSource v)
{
if (v == null)
{
@@ -430,6 +448,7 @@
/**
* Attempt to establish a database connection.
*
+ * @return A database connection.
* @throws SQLException
*/
public Connection getConnection() throws SQLException
@@ -440,11 +459,12 @@
/**
* Attempt to establish a database connection.
*
- * @param username
- * @param password
+ * @param username The name of the database user.
+ * @param password The password of the database user.
+ * @return A database connection.
* @throws SQLException
*/
- synchronized public Connection getConnection(String username,
+ public synchronized Connection getConnection(String username,
String password)
throws SQLException
{
@@ -492,8 +512,8 @@
/**
*
- * @param username
- * @param password
+ * @param username The name of the database user.
+ * @param password The password of the database user.
* @throws javax.naming.NamingException
*/
synchronized private void registerPool(String username, String password)
@@ -542,6 +562,8 @@
/**
* Gets the maximum time in seconds that this data source can wait
* while attempting to connect to a database.
+ *
+ * @return the login timeout
*/
public int getLoginTimeout()
{
@@ -550,6 +572,8 @@
/**
* Get the log writer for this data source.
+ *
+ * @return the log writer
*/
public PrintWriter getLogWriter()
{
@@ -563,6 +587,8 @@
/**
* Sets the maximum time in seconds that this data source will wait
* while attempting to connect to a database. NOT USED.
+ *
+ * @param seconds the login timeout
*/
public void setLoginTimeout(int seconds)
{
@@ -571,6 +597,8 @@
/**
* Set the log writer for this data source.
+ *
+ * @param out the log writer to use
*/
public void setLogWriter(java.io.PrintWriter out)
{
@@ -579,6 +607,9 @@
/**
* <CODE>Referenceable</CODE> implementation.
+ *
+ * @return a reference
+ * @throws NamingException
*/
public Reference getReference() throws NamingException
{
@@ -623,7 +654,7 @@
* @param name
* @param context
* @param env
- * @return
+ * @return an instance of this class
* @throws Exception
*/
public Object getObjectInstance(Object refObj, Name name,
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]