[jboss-cvs] JBossAS SVN: r92158 - trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/persistent.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Aug 7 21:01:23 EDT 2009
Author: bstansberry at jboss.com
Date: 2009-08-07 21:01:23 -0400 (Fri, 07 Aug 2009)
New Revision: 92158
Modified:
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/persistent/DriverManagerPersistentStore.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/persistent/PersistentStore.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/persistent/RDBMSStoreBase.java
Log:
[JBAS-7095] Stop using StringManager for msgs for now. Add some interface javadoc
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/persistent/DriverManagerPersistentStore.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/persistent/DriverManagerPersistentStore.java 2009-08-07 22:25:26 UTC (rev 92157)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/persistent/DriverManagerPersistentStore.java 2009-08-08 01:01:23 UTC (rev 92158)
@@ -88,7 +88,7 @@
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
- throw new RuntimeException(sm.getString(getStoreName() + ".InterruptedException"), e);
+ throw new RuntimeException("Interrupted while acquiring connection lock");
}
// Do nothing if there is a database connection already open
@@ -127,21 +127,14 @@
Class<?> clazz = Class.forName(driverName);
driver = (Driver) clazz.newInstance();
}
- catch (ClassNotFoundException ex)
+ catch (RuntimeException ex)
{
- getLogger().error(
- sm.getString(getStoreName() + ".checkConnectionClassNotFoundException", ex.toString()));
+ throw ex;
}
- catch (InstantiationException ex)
+ catch (Exception ex)
{
- getLogger().error(
- sm.getString(getStoreName() + ".checkConnectionClassNotFoundException", ex.toString()));
+ throw new RuntimeException("Caught exception creating driver of class " + driverName, ex);
}
- catch (IllegalAccessException ex)
- {
- getLogger().error(
- sm.getString(getStoreName() + ".checkConnectionClassNotFoundException", ex.toString()));
- }
try
{
@@ -150,7 +143,7 @@
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
- throw new RuntimeException(sm.getString(getStoreName() + ".startStoreInterruptedException", e.toString()));
+ throw new RuntimeException("Interrupted while acquiring connection lock");
}
try
@@ -159,7 +152,7 @@
}
catch (SQLException e)
{
- throw new RuntimeException(sm.getString(getStoreName() + ".startStoreSqlException", e.toString()));
+ throw new RuntimeException("Caught SQLException while opening database connection -- " + e.toString());
}
finally
{
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/persistent/PersistentStore.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/persistent/PersistentStore.java 2009-08-07 22:25:26 UTC (rev 92157)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/persistent/PersistentStore.java 2009-08-08 01:01:23 UTC (rev 92158)
@@ -9,21 +9,84 @@
import org.jboss.web.tomcat.service.session.distributedcache.spi.OutgoingSessionGranularitySessionData;
/**
+ * Interface exposed by a cluster-wide store for distributable web sessions.
*
- *
* @author Brian Stansberry
*
* @version $Revision: $
*/
public interface PersistentStore
{
+ /** Gets ids of session associated with the application that are in the store. */
Set<String> getSessionIds();
+
+ /**
+ * Gets the stored information about a particular session.
+ *
+ * @param realId the portion of the session id that is consistent across the
+ * lifetime of the session, i.e. with mutable elements like an
+ * appended jvmRoute removed.
+ *
+ * @param includeAttributes <code>true</code> if the returned data needs to
+ * include the session attribute map; <code>false</code>
+ * if that is unnecessary
+ *
+ * @return data about the session, or <code>null</code> if no data exists
+ * in the store
+ */
IncomingDistributableSessionData getSessionData(String realId, boolean includeAttributes);
+
+ /**
+ * Gets the last accessed timestamp for the session with the given id
+ * @param realId the portion of the session id that is consistent across the
+ * lifetime of the session, i.e. with mutable elements like an
+ * appended jvmRoute removed.
+ *
+ * @return the timestamp, or <code>null</code> if the session is not stored
+ */
Long getSessionTimestamp(String realId);
+
+ /**
+ * Gets the session version for the session with the given id
+ *
+ * @param realId the portion of the session id that is consistent across the
+ * lifetime of the session, i.e. with mutable elements like an
+ * appended jvmRoute removed.
+ *
+ * @return the version, or <code>null</code> if the session is not stored
+ */
Integer getSessionVersion(String realId);
+
+ /**
+ * Stores this session in the persistent store.
+ *
+ * @param sessionData the data to store
+ */
void storeSessionData(OutgoingSessionGranularitySessionData sessionData);
- void remove(String id);
+
+ /**
+ * Removes any information about this session from the persistent store.
+ *
+ * @param realId the portion of the session id that is consistent across the
+ * lifetime of the session, i.e. with mutable elements like an
+ * appended jvmRoute removed.
+ */
+ void remove(String realId);
+
+ /**
+ * Perform processing to remove outdated sessions from the store.
+ */
void processExpires();
+
+ /**
+ * Brings the store to the state where it is able to handle invocations of
+ * the other methods in this interface.
+ */
void start();
+
+ /**
+ * Removes the store from the state where it is able to handle invocations of
+ * the other methods in this interface, performs any needed cleanup work.
+ */
void stop();
}
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/persistent/RDBMSStoreBase.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/persistent/RDBMSStoreBase.java 2009-08-07 22:25:26 UTC (rev 92157)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/session/persistent/RDBMSStoreBase.java 2009-08-08 01:01:23 UTC (rev 92158)
@@ -23,8 +23,6 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-import org.apache.catalina.session.Constants;
-import org.apache.catalina.util.StringManager;
import org.jboss.ha.framework.server.SimpleCachableMarshalledValue;
import org.jboss.logging.Logger;
import org.jboss.web.tomcat.service.session.distributedcache.spi.DistributableSessionMetadata;
@@ -72,7 +70,7 @@
/**
* The string manager for this package.
*/
- protected final StringManager sm = StringManager.getManager(Constants.Package);
+// protected final StringManager sm = StringManager.getManager(Constants.Package);
/**
* Context name associated with this Store
@@ -557,7 +555,7 @@
{
if (exception == null)
{
- exception = new RuntimeException(sm.getString(getStoreName() + ".SQLException", e));
+ exception = new RuntimeException("Caught SQLException executing store clear", e);
}
}
catch (RuntimeException e)
@@ -619,7 +617,7 @@
{
if (exception == null)
{
- exception = new RuntimeException(sm.getString(getStoreName() + ".SQLException", e), e);
+ exception = new RuntimeException("Caught SQLException getting store size", e);
}
}
catch (RuntimeException e)
@@ -695,7 +693,7 @@
{
if (exception == null)
{
- exception = new RuntimeException(sm.getString(getStoreName() + ".SQLException", e));
+ exception = new RuntimeException("Caught SQLException getting session ids", e);
}
}
catch (RuntimeException e)
@@ -761,7 +759,7 @@
{
if (getLogger().isTraceEnabled())
{
- getLogger().trace(sm.getString(getStoreName() + ".loading", realId, sessionTable));
+ getLogger().trace("Loading session " + maskId(realId));
}
DistributableSessionMetadata metadata = new DistributableSessionMetadata();
@@ -806,21 +804,21 @@
{
if (exception == null)
{
- exception = new RuntimeException(sm.getString(getStoreName() + ".SQLException", e));
+ exception = new RuntimeException("Caught SQLException loading session " + maskId(realId), e);
}
}
catch (IOException e)
{
if (exception == null)
{
- exception = new RuntimeException(sm.getString(getStoreName() + ".IOException", e), e);
+ exception = new RuntimeException("Caught IOException loading session " + maskId(realId), e);
}
}
catch (ClassNotFoundException e)
{
if (exception == null)
{
- exception = new RuntimeException(sm.getString(getStoreName() + ".ClassNotFoundException", e), e);
+ exception = new RuntimeException("Caught ClassNotFoundException loading session " + maskId(realId), e);
}
}
catch (RuntimeException e)
@@ -874,11 +872,11 @@
return (incomingSession);
}
- public void remove(String id)
+ public void remove(String realId)
{
if (getLogger().isTraceEnabled())
{
- getLogger().trace(sm.getString(getStoreName() + ".removing", id, sessionTable));
+ getLogger().trace("Loading session " + maskId(realId));
}
RuntimeException exception = null;
@@ -889,7 +887,7 @@
boolean success = false;
try
{
- executeRemove(id, _conn);
+ executeRemove(realId, _conn);
_conn.commit();
success = true;
@@ -900,7 +898,7 @@
{
if (exception == null)
{
- exception = new RuntimeException(sm.getString(getStoreName() + ".SQLException", e));
+ exception = new RuntimeException("Caught SQLException removing session " + maskId(realId), e);
}
}
catch (RuntimeException e)
@@ -936,8 +934,7 @@
{
if (getLogger().isTraceEnabled())
{
- getLogger().trace(
- sm.getString(getStoreName() + ".saving", sessionData.getRealId(), sessionTable));
+ getLogger().trace("Storing session " + maskId(sessionData));
}
RuntimeException exception = null;
@@ -968,7 +965,7 @@
// See if this is due to pre-existing record
if (getLogger().isTraceEnabled())
{
- getLogger().trace(sm.getString(getStoreName() + ".insertSQLException", e));
+ getLogger().trace("Caught SQLException inserting session " + maskId(sessionData), e);
}
if (executeGetSessionVersion(_conn, sessionData.getRealId()) != null)
{
@@ -993,7 +990,7 @@
else
{
// Hmm, we don't have enough data for a full insert
- throw new IllegalStateException("Cannot insert session " + maskId(sessionData.getRealId()) + " as session metadata is not available");
+ throw new IllegalStateException("Cannot insert session " + maskId(sessionData) + " as session metadata is not available");
}
}
}
@@ -1007,14 +1004,14 @@
{
if (exception == null)
{
- exception = new RuntimeException("storeSessionData(): Caught exception storing session " + (maskId(sessionData.getRealId()) + " -- " + e.getLocalizedMessage()), e);
+ exception = new RuntimeException("Caught SQLException storing session " + maskId(sessionData), e);
}
}
catch (IOException e)
{
if (exception == null)
{
- exception = new RuntimeException(sm.getString(getStoreName() + ".IOException", e), e);
+ exception = new RuntimeException("Caught IOException storing session " + maskId(sessionData), e);
}
}
catch (RuntimeException e)
@@ -1056,8 +1053,14 @@
{
throw exception;
}
- }
+ }
+ private static String maskId(OutgoingSessionGranularitySessionData sessionData)
+ {
+ String realId = (sessionData == null ? null : sessionData.getRealId());
+ return maskId(realId);
+ }
+
private static String maskId(String realId)
{
if (realId == null)
@@ -1108,7 +1111,7 @@
{
if (exception == null)
{
- exception = new RuntimeException(sm.getString(getStoreName() + ".SQLException", e));
+ exception = new RuntimeException("Caught SQLException getting timestamp for session " + maskId(realId), e);
}
}
catch (RuntimeException e)
@@ -1175,7 +1178,7 @@
{
if (exception == null)
{
- exception = new RuntimeException(sm.getString(getStoreName() + ".SQLException", e));
+ exception = new RuntimeException("Caught SQLException getting version for session " + maskId(realId), e);
}
}
catch (RuntimeException e)
@@ -1243,14 +1246,10 @@
lastCleanup = now;
success = true;
}
- catch (SQLException e)
+ catch (Exception e)
{
- getLogger().error(sm.getString(getStoreName() + ".SQLException", e));
+ getLogger().error("Caught exception cleaning out expired sessions", e);
}
- catch (RuntimeException e)
- {
- getLogger().error(sm.getString(getStoreName() + ".SQLException", e));
- }
finally
{
try
@@ -1272,7 +1271,7 @@
{
// Validate and update our current component state
if (started)
- throw new IllegalStateException(sm.getString(getStoreName() + ".alreadyStarted"));
+ throw new IllegalStateException(getStoreName() + " is already started");
getName();
@@ -1288,7 +1287,7 @@
// Validate and update our current component state
if (!started)
{
- throw new IllegalStateException(sm.getString(getStoreName() + ".notStarted"));
+ throw new IllegalStateException(getStoreName() + " is not started");
}
started = false;
@@ -1341,7 +1340,7 @@
}
catch (SQLException e)
{
- getLogger().error(sm.getString(getStoreName() + ".closeResultSet", e.toString())); // Just log it here
+ getLogger().warn("Caught SQLException closing a result set -- " + e.getLocalizedMessage()); // Just log it here
}
}
@@ -1355,7 +1354,7 @@
{
if (getLogger().isTraceEnabled())
{
- getLogger().trace(sm.getString(getStoreName() + ".rollback", e.toString()));
+ getLogger().trace("Caught SQLException rolling back connection -- " + e.getLocalizedMessage(), e);
}
}
}
@@ -1369,9 +1368,9 @@
{
stmt.close();
}
- catch (Exception e)
+ catch (SQLException e)
{
- getLogger().debug(e.getLocalizedMessage());
+ getLogger().debug("Caught SQLException closing statement -- " + e.getLocalizedMessage());
}
}
}
@@ -1383,7 +1382,7 @@
}
catch (SQLException e)
{
- getLogger().error(sm.getString(getStoreName() + ".close", e.toString())); // Just log it here
+ getLogger().error("Caught SQLException closing connection -- " + e.getLocalizedMessage()); // Just log it here
}
}
}
@@ -1476,7 +1475,7 @@
DistributableSessionMetadata metadata = session.getMetadata();
if (metadata == null)
{
- throw new IllegalStateException(sm.getString(getStoreName() + ".insertMissingMetadataException"));
+ throw new IllegalStateException("Cannot insert session " + maskId(session) + " as session metadata is missing");
}
int size = obs.length;
@@ -1673,7 +1672,7 @@
}
catch (SQLException e)
{
- throw new RuntimeException(sm.getString(getStoreName() + ".getConnectionSqlException", e.toString()));
+ throw new RuntimeException("Caught SQLException getting a connection", e);
}
}
More information about the jboss-cvs-commits
mailing list