Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@apache.org Received: (qmail 66675 invoked from network); 23 May 2003 10:52:31 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 23 May 2003 10:52:31 -0000 Received: (qmail 18450 invoked by uid 97); 23 May 2003 10:54:39 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-dev@nagoya.betaversion.org Received: (qmail 18443 invoked from network); 23 May 2003 10:54:38 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 23 May 2003 10:54:38 -0000 Received: (qmail 65788 invoked by uid 500); 23 May 2003 10:52:21 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Developers List" Reply-To: "Tomcat Developers List" Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 65774 invoked by uid 500); 23 May 2003 10:52:21 -0000 Received: (qmail 65771 invoked from network); 23 May 2003 10:52:20 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 23 May 2003 10:52:20 -0000 Received: (qmail 43922 invoked by uid 1135); 23 May 2003 10:52:20 -0000 Date: 23 May 2003 10:52:20 -0000 Message-ID: <20030523105220.43920.qmail@icarus.apache.org> From: remm@apache.org To: jakarta-tomcat-catalina-cvs@apache.org Subject: cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/session StandardManager.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N remm 2003/05/23 03:52:20 Modified: catalina/src/share/org/apache/catalina/session StandardManager.java Log: - Apply missing commit (sorry). - Refactor the host deployer, session manager, webapp reloading threads into one (potentially) thread at the engine level. - The thread code is in StandardEngine, but can be refactored into StandardServer, in case we want to be able to have one thread for the whole server. The main adavantage of putting the code in container is that additional threads can be associated to branches of the container tree (ex: associate one thread per host, one thread for a specific context, etc ...). - The container's CL (if present) will be set as the context classloader before invoking the execute method, and will be restored afterwards. - I couldn't come up with good neams for the new field and the thread name. Can you help ? - By default, the engine will have a thread with a 10s delay. Revision Changes Path 1.9 +10 -136 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/session/StandardManager.java Index: StandardManager.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/session/StandardManager.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- StandardManager.java 25 Apr 2003 22:20:07 -0000 1.8 +++ StandardManager.java 23 May 2003 10:52:20 -0000 1.9 @@ -110,8 +110,7 @@ public class StandardManager extends ManagerBase - implements Lifecycle, PropertyChangeListener, Runnable - { + implements Lifecycle, PropertyChangeListener { // ---------------------------------------------------- Security Classes private class PrivilegedDoLoad @@ -144,12 +143,6 @@ /** - * The interval (in seconds) between checks for expired sessions. - */ - private int checkInterval = 60; - - - /** * The descriptive information about this implementation. */ private static final String info = "StandardManager/1.0"; @@ -189,54 +182,13 @@ */ private boolean started = false; - /** - * The background thread. - */ - private Thread thread = null; - - - /** - * The background thread completion semaphore. - */ - private boolean threadDone = false; - - - /** - * Name to register for the background thread. - */ - private String threadName = "StandardManager"; int rejectedSessions=0; int expiredSessions=0; long processingTime=0; - // ------------------------------------------------------------- Properties - - - /** - * Return the check interval (in seconds) for this Manager. - */ - public int getCheckInterval() { - - return (this.checkInterval); - - } - - - /** - * Set the check interval (in seconds) for this Manager. - * - * @param checkInterval The new check interval - */ - public void setCheckInterval(int checkInterval) { - - int oldCheckInterval = this.checkInterval; - this.checkInterval = checkInterval; - support.firePropertyChange("checkInterval", - new Integer(oldCheckInterval), - new Integer(this.checkInterval)); - } + // ------------------------------------------------------------- Properties /** @@ -742,9 +694,6 @@ log.error(sm.getString("standardManager.managerLoad"), t); } - // Start the background reaper thread - threadStart(); - } @@ -768,9 +717,6 @@ lifecycle.fireLifecycleEvent(STOP_EVENT, null); started = false; - // Stop the background reaper thread - threadStop(); - // Write out sessions try { unload(); @@ -861,7 +807,7 @@ /** * Invalidate all sessions that have expired. */ - private void processExpires() { + public void processExpires() { long timeNow = System.currentTimeMillis(); Session sessions[] = findSessions(); @@ -880,87 +826,15 @@ expiredSessions++; session.expire(); } catch (Throwable t) { - log.error(sm.getString("standardManager.expireException"), t); + log.error(sm.getString + ("standardManager.expireException"), t); } } } - long timeEnd=System.currentTimeMillis(); + long timeEnd = System.currentTimeMillis(); processingTime += ( timeEnd - timeNow ); } - /** - * Sleep for the duration specified by the checkInterval - * property. - */ - private void threadSleep() { - - try { - Thread.sleep(checkInterval * 1000L); - } catch (InterruptedException e) { - ; - } - - } - - - /** - * Start the background thread that will periodically check for - * session timeouts. - */ - private void threadStart() { - - if (thread != null) - return; - - threadDone = false; - threadName = "StandardManager[" + container.getName() + "]"; - thread = new Thread(this, threadName); - thread.setDaemon(true); - thread.setContextClassLoader(container.getLoader().getClassLoader()); - thread.start(); - - } - - - /** - * Stop the background thread that is periodically checking for - * session timeouts. - */ - private void threadStop() { - - if (thread == null) - return; - - threadDone = true; - thread.interrupt(); - try { - thread.join(); - } catch (InterruptedException e) { - ; - } - - thread = null; - - } - - - // ------------------------------------------------------ Background Thread - - - /** - * The background thread that checks for session timeouts and shutdown. - */ - public void run() { - - // Loop until the termination semaphore is set - while (!threadDone) { - threadSleep(); - processExpires(); - } - - } - - } --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org