[Proxool-cvs] proxool/src/java/org/logicalcobwebs/proxool ConnectionListenerIF.java, 1.7, 1.8 Comp
UNMAINTAINED!
Brought to you by:
billhorsman
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5577/src/java/org/logicalcobwebs/proxool Modified Files: ConnectionListenerIF.java CompositeConnectionListener.java ConnectionPool.java HouseKeeper.java Log Message: New onAboutToDie event for ConnectionListenerIF that gets called if the maximum-active-time is exceeded. Index: ConnectionListenerIF.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/ConnectionListenerIF.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ConnectionListenerIF.java 3 Mar 2003 11:11:57 -0000 1.7 --- ConnectionListenerIF.java 25 Jan 2007 00:10:24 -0000 1.8 *************** *** 30,33 **** --- 30,41 ---- /** + * We are killing a connection because the + * {@link ConnectionPoolDefinitionIF#getMaximumActiveTime() maximum-active-time} + * has been exceeded. + * @see #onAboutToDie(java.sql.Connection, int) + */ + static final int LIFETIME_EXPIRED = 0; + + /** * Happens everytime we create a new connection. You can use this * to allocate resources to a connection that might be useful during *************** *** 69,72 **** --- 77,88 ---- void onFail(String command, Exception exception); + /** + * Happens if we are deliberately killing a connection. It gets called + * just before the call to {@link #onDeath(java.sql.Connection)} + * @param connection the connection that is about to expire + * @param reason why it is being killed: {@link + * @throws SQLException if anything goes wrong (which will then be logged but ignored) + */ + void onAboutToDie(Connection connection, int reason) throws SQLException; } *************** *** 74,77 **** --- 90,96 ---- Revision history: $Log$ + Revision 1.8 2007/01/25 00:10:24 billhorsman + New onAboutToDie event for ConnectionListenerIF that gets called if the maximum-active-time is exceeded. + Revision 1.7 2003/03/03 11:11:57 billhorsman fixed licence Index: CompositeConnectionListener.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/CompositeConnectionListener.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CompositeConnectionListener.java 18 Jan 2006 14:40:01 -0000 1.6 --- CompositeConnectionListener.java 25 Jan 2007 00:10:24 -0000 1.7 *************** *** 6,16 **** package org.logicalcobwebs.proxool; - import java.sql.Connection; - import java.sql.SQLException; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.logicalcobwebs.proxool.util.AbstractListenerContainer; /** * A {@link ConnectionListenerIF} that keeps a list of <code>ConnectionListenerIF</code>s --- 6,16 ---- package org.logicalcobwebs.proxool; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.logicalcobwebs.proxool.util.AbstractListenerContainer; + import java.sql.Connection; + import java.sql.SQLException; + /** * A {@link ConnectionListenerIF} that keeps a list of <code>ConnectionListenerIF</code>s *************** *** 74,77 **** --- 74,99 ---- /** + * @see ConnectionListenerIF#onAboutToDie(java.sql.Connection, int) + */ + public void onAboutToDie(Connection connection, int reason) throws SQLException + { + Object[] listeners = getListeners(); + + for(int i=0; i<listeners.length; i++) { + try { + ConnectionListenerIF connectionListener = (ConnectionListenerIF) listeners[i]; + connectionListener.onAboutToDie(connection, reason); + } + catch (RuntimeException re) { + LOG.warn("RuntimeException received from listener "+listeners[i]+" when dispatching onAboutToDie event", re); + } + catch(SQLException se) { + LOG.warn("SQLException received from listener "+listeners[i]+" when dispatching onAboutToDie event - event dispatching cancelled"); + throw se; + } + } + } + + /** * @see ConnectionListenerIF#onExecute(String, long) */ *************** *** 113,116 **** --- 135,141 ---- Revision history: $Log$ + Revision 1.7 2007/01/25 00:10:24 billhorsman + New onAboutToDie event for ConnectionListenerIF that gets called if the maximum-active-time is exceeded. + Revision 1.6 2006/01/18 14:40:01 billhorsman Unbundled Jakarta's Commons Logging. Index: ConnectionPool.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/ConnectionPool.java,v retrieving revision 1.84 retrieving revision 1.85 diff -C2 -d -r1.84 -r1.85 *** ConnectionPool.java 23 Mar 2006 11:44:57 -0000 1.84 --- ConnectionPool.java 25 Jan 2007 00:10:24 -0000 1.85 *************** *** 6,26 **** package org.logicalcobwebs.proxool; - import java.sql.Connection; - import java.sql.SQLException; - import java.util.Collection; - import java.util.Date; - import java.util.HashSet; - import java.util.Iterator; - import java.util.List; - import java.util.Set; - import java.util.TreeSet; - - import org.logicalcobwebs.concurrent.ReaderPreferenceReadWriteLock; - import org.logicalcobwebs.concurrent.WriterPreferenceReadWriteLock; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.logicalcobwebs.proxool.admin.Admin; import org.logicalcobwebs.proxool.util.FastArrayList; /** * This is where most things happen. (In fact, probably too many things happen in this one --- 6,20 ---- package org.logicalcobwebs.proxool; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.logicalcobwebs.concurrent.ReaderPreferenceReadWriteLock; + import org.logicalcobwebs.concurrent.WriterPreferenceReadWriteLock; import org.logicalcobwebs.proxool.admin.Admin; import org.logicalcobwebs.proxool.util.FastArrayList; + import java.sql.Connection; + import java.sql.SQLException; + import java.util.*; + /** * This is where most things happen. (In fact, probably too many things happen in this one *************** *** 795,798 **** --- 789,797 ---- } + /** Call the onAboutToDie() method on each StateListenerIF . */ + protected void onAboutToDie(Connection connection, int reason) throws SQLException { + this.compositeConnectionListener.onAboutToDie(connection, reason); + } + /** Call the onExecute() method on each StateListenerIF . */ protected void onExecute(String command, long elapsedTime, Exception exception) throws SQLException { *************** *** 1117,1120 **** --- 1116,1122 ---- Revision history: $Log$ + Revision 1.85 2007/01/25 00:10:24 billhorsman + New onAboutToDie event for ConnectionListenerIF that gets called if the maximum-active-time is exceeded. + Revision 1.84 2006/03/23 11:44:57 billhorsman More information when quickly refusing Index: HouseKeeper.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/HouseKeeper.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** HouseKeeper.java 18 Jan 2006 14:40:01 -0000 1.5 --- HouseKeeper.java 25 Jan 2007 00:10:25 -0000 1.6 *************** *** 11,14 **** --- 11,15 ---- import java.sql.Connection; import java.sql.Statement; + import java.sql.SQLException; /** *************** *** 137,140 **** --- 138,146 ---- // This connection has been active for way too long. We're // going to kill it :) + try { + connectionPool.onAboutToDie(proxyConnection.getConnection(), ConnectionListenerIF.LIFETIME_EXPIRED); + } catch (SQLException e) { + log.error("Problem during onAboutToDie (ignored)", e); + } connectionPool.removeProxyConnection(proxyConnection, "it has been active for too long", ConnectionPool.FORCE_EXPIRY, true); *************** *** 260,263 **** --- 266,272 ---- Revision history: $Log$ + Revision 1.6 2007/01/25 00:10:25 billhorsman + New onAboutToDie event for ConnectionListenerIF that gets called if the maximum-active-time is exceeded. + Revision 1.5 2006/01/18 14:40:01 billhorsman Unbundled Jakarta's Commons Logging. |