Hi I took the new J2EEDescriptorsStore with your patch for connection renewal. Also made the similar changes to the J2EEContentStore(Patch yet to be submitted). I could find any noticable differences in the overall performances.
-----Original Message----- From: GARTRELL,MIKE (HP-Corvallis,ex1) [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 05, 2002 4:29 PM To: 'Slide Developers List' Subject: RE: cvs commit: jakarta-slide/src/stores/slidestore/j2ee J2EEDescriptorsStore.java I've observed a substantial performance hit when using this version of J2EEDescriptorsStore as compared to the previous version. PROPFIND requests take approximately 5 times longer to complete. Any idea why these changes to J2EEDescriptorsStore would cause this? Has anyone else observed this? -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Monday, February 04, 2002 8:07 PM To: [EMAIL PROTECTED] Subject: cvs commit: jakarta-slide/src/stores/slidestore/j2ee J2EEDescriptorsStore.java msmith 02/02/04 20:07:12 Modified: src/stores/slidestore/j2ee J2EEDescriptorsStore.java Log: Add the database test statements and calls to connectIfNeededAndPossible() to the J2EEDescriptorStore as well - now the store will reconnect to the database if the connection stops working (if, for example, the socket times out or is otherwise invalidated). Revision Changes Path 1.2 +62 -9 jakarta-slide/src/stores/slidestore/j2ee/J2EEDescriptorsStore.java Index: J2EEDescriptorsStore.java =================================================================== RCS file: /home/cvs/jakarta-slide/src/stores/slidestore/j2ee/J2EEDescriptorsStore. java ,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- J2EEDescriptorsStore.java 24 Dec 2001 22:08:13 -0000 1.1 +++ J2EEDescriptorsStore.java 5 Feb 2002 04:07:12 -0000 1.2 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-slide/src/stores/slidestore/j2ee/J2EEDescriptorsStore. java ,v 1.1 2001/12/24 22:08:13 remm Exp $ - * $Revision: 1.1 $ - * $Date: 2001/12/24 22:08:13 $ + * $Header: /home/cvs/jakarta-slide/src/stores/slidestore/j2ee/J2EEDescriptorsStore. java ,v 1.2 2002/02/05 04:07:12 msmith Exp $ + * $Revision: 1.2 $ + * $Date: 2002/02/05 04:07:12 $ * * ==================================================================== * @@ -91,7 +91,7 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a> * @author Ashok Kumar - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public class J2EEDescriptorsStore @@ -256,6 +256,11 @@ return statements; } + + protected String getDatabaseConnectionTestStatement() + { + return "select 1 from objects where uri is null"; + } /** * Initializes the data source with a set of parameters. @@ -289,6 +294,9 @@ getLogger().log(e.toString(),LOG_CHANNEL,Logger.ERROR); throw new ServiceConnectionFailedException(this, e); } + catch(NullPointerException e) { + e.printStackTrace(System.err); + } // all updates must be done inside a transaction, no auto commits try { @@ -335,8 +343,19 @@ throw new ServiceDisconnectionFailedException(this, e); } } - - + + /** + * Tries to reconnect if needed but doesn't report failure. + */ + protected synchronized void connectIfNeededAndPossible() { + try { + connectIfNeeded(); + } + catch (Throwable ex) { + // ignore + } + } + /** * Initializes data source. * <p/> @@ -449,7 +468,18 @@ public boolean isConnected() throws ServiceAccessException { try { - return ((connection != null) && (!connection.isClosed())); + if ((connection == null) || (connection.isClosed())) { + return false; + } + + PreparedStatement statement = + connection.prepareStatement(getDatabaseConnectionTestStatement()); + statement.executeQuery(); + statement.close(); + + // testStatement executed without throwing an exception + return true; + } catch (SQLException e) { throw new ServiceAccessException(this, e); } @@ -501,10 +531,14 @@ if (!alreadyEnlisted) { try { -// getLogger().log("start",LOG_CHANNEL,Logger.DEBUG); + // getLogger().log("start",LOG_CHANNEL,Logger.DEBUG); + + // test connection + connectIfNeeded(); + // discard changes made outside a tranaction connection.rollback(); - } catch (SQLException e) { + } catch (Exception e) { throw new XAException(XAException.XAER_RMERR); } alreadyEnlisted=true; @@ -620,6 +654,7 @@ } catch (SQLException e) { getLogger().log(e,LOG_CHANNEL,Logger.ERROR); + connectIfNeededAndPossible(); throw new ServiceAccessException(this, e); } finally { closeStatement(statement); @@ -706,6 +741,7 @@ } catch (SQLException e) { getLogger().log(e,LOG_CHANNEL,Logger.ERROR); + connectIfNeededAndPossible(); throw new ServiceAccessException(this, e); } finally { closeStatement(statement); @@ -791,6 +827,7 @@ } catch (SQLException e) { getLogger().log(e,LOG_CHANNEL,Logger.ERROR); + connectIfNeededAndPossible(); throw new ServiceAccessException(this, e); } finally { closeStatement(statement); @@ -842,6 +879,7 @@ } catch (SQLException e) { getLogger().log(e,LOG_CHANNEL,Logger.ERROR); + connectIfNeededAndPossible(); throw new ServiceAccessException(this, e); } } @@ -884,6 +922,7 @@ statement.execute(); } catch (SQLException e) { getLogger().log(e,LOG_CHANNEL,Logger.ERROR); + connectIfNeededAndPossible(); throw new ServiceAccessException(this, e); } finally { closeStatement(statement); @@ -924,6 +963,7 @@ statement.execute(); } catch (SQLException e) { getLogger().log(e,LOG_CHANNEL,Logger.ERROR); + connectIfNeededAndPossible(); throw new ServiceAccessException(this, e); } finally { closeStatement(statement); @@ -951,6 +991,7 @@ statement.execute(); } catch (SQLException e) { getLogger().log(e,LOG_CHANNEL,Logger.ERROR); + connectIfNeededAndPossible(); throw new ServiceAccessException(this, e); } finally { closeStatement(statement); @@ -999,6 +1040,7 @@ } catch (SQLException e) { getLogger().log(e,LOG_CHANNEL,Logger.ERROR); + connectIfNeededAndPossible(); throw new ServiceAccessException(this, e); } finally { closeStatement(statement); @@ -1043,6 +1085,7 @@ statement.execute(); } catch (SQLException e) { getLogger().log(e,LOG_CHANNEL,Logger.ERROR); + connectIfNeededAndPossible(); throw new ServiceAccessException(this, e); } finally { closeStatement(statement); @@ -1095,6 +1138,7 @@ } catch (SQLException e) { getLogger().log(e,LOG_CHANNEL,Logger.ERROR); + connectIfNeededAndPossible(); throw new ServiceAccessException(this, e); } finally { closeStatement(statement); @@ -1131,6 +1175,7 @@ } catch (SQLException e) { getLogger().log(e,LOG_CHANNEL,Logger.ERROR); + connectIfNeededAndPossible(); throw new ServiceAccessException(this, e); } finally { closeStatement(statement); @@ -1197,6 +1242,7 @@ } catch (SQLException e) { getLogger().log(e,LOG_CHANNEL,Logger.ERROR); + connectIfNeededAndPossible(); throw new ServiceAccessException(this, e); } finally { closeStatement(statement); @@ -1305,6 +1351,7 @@ } catch (SQLException e) { getLogger().log(e,LOG_CHANNEL,Logger.ERROR); + connectIfNeededAndPossible(); throw new ServiceAccessException(this, e); } finally { closeStatement(statement); @@ -1372,6 +1419,7 @@ } catch (SQLException e) { getLogger().log(e,LOG_CHANNEL,Logger.ERROR); + connectIfNeededAndPossible(); throw new ServiceAccessException(this, e); } finally { closeStatement(statement); @@ -1438,6 +1486,7 @@ } catch (SQLException e) { getLogger().log(e,LOG_CHANNEL,Logger.ERROR); + connectIfNeededAndPossible(); throw new ServiceAccessException(this, e); } finally { closeStatement(statement); @@ -1527,6 +1576,7 @@ } catch (SQLException e) { getLogger().log(e,LOG_CHANNEL,Logger.ERROR); + connectIfNeededAndPossible(); throw new ServiceAccessException(this, e); } finally { closeStatement(statement); @@ -1606,6 +1656,7 @@ } catch (SQLException e) { getLogger().log(e,LOG_CHANNEL,Logger.ERROR); + connectIfNeededAndPossible(); throw new ServiceAccessException(this, e); } finally { closeStatement(statement); @@ -1672,6 +1723,7 @@ } catch (SQLException e) { getLogger().log(e,LOG_CHANNEL,Logger.ERROR); + connectIfNeededAndPossible(); throw new ServiceAccessException(this, e); } finally { closeStatement(statement); @@ -1691,6 +1743,7 @@ try { statement.close(); } catch (SQLException e) { + connectIfNeededAndPossible(); } } } -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
