tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@locus.apache.org
Subject cvs commit: jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session package.html LocalStrings.properties ManagerBase.java StandardManager.java
Date Thu, 27 Jul 2000 03:20:02 GMT
craigmcc    00/07/26 20:20:02

  Modified:    proposals/catalina/src/share/org/apache/tomcat/session
                        LocalStrings.properties ManagerBase.java
                        StandardManager.java
  Added:       proposals/catalina/src/share/org/apache/tomcat/session
                        package.html
  Log:
  Tune the standard session manager's use of collection classes to
  improve performance.  Add a Javadoc package documentation file.
  
  Revision  Changes    Path
  1.7       +4 -0      jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/LocalStrings.properties,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- LocalStrings.properties	2000/05/23 21:44:57	1.6
  +++ LocalStrings.properties	2000/07/27 03:20:01	1.7
  @@ -2,7 +2,11 @@
   applicationSession.value.iae=null value
   fileStore.alreadyStarted=File Store has already been started
   fileStore.notStarted=File Store has not yet been started
  +managerBase.complete=Seeding of random number generator has been completed
  +managerBase.getting=Getting message digest component for algorithm {0}
  +managerBase.gotten=Completed getting message digest component
   managerBase.random=Exception initializing random number generator of class {0}
  +managerBase.seeding=Seeding random number generator class {0}
   serverSession.value.iae=null value
   standardManager.alreadyStarted=Manager has already been started
   standardManager.createSession.ise=createSession: Too many active sessions
  
  
  
  1.8       +66 -29    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/ManagerBase.java
  
  Index: ManagerBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/ManagerBase.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ManagerBase.java	2000/07/11 00:46:51	1.7
  +++ ManagerBase.java	2000/07/27 03:20:01	1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/ManagerBase.java,v
1.7 2000/07/11 00:46:51 craigmcc Exp $
  - * $Revision: 1.7 $
  - * $Date: 2000/07/11 00:46:51 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/ManagerBase.java,v
1.8 2000/07/27 03:20:01 craigmcc Exp $
  + * $Revision: 1.8 $
  + * $Date: 2000/07/27 03:20:01 $
    *
    * ====================================================================
    *
  @@ -70,10 +70,9 @@
   import java.io.IOException;
   import java.security.MessageDigest;
   import java.security.NoSuchAlgorithmException;
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  +import java.util.ArrayList;
  +import java.util.HashMap;
   import java.util.Random;
  -import java.util.Vector;
   import org.apache.tomcat.Container;
   import org.apache.tomcat.Logger;
   import org.apache.tomcat.Manager;
  @@ -87,7 +86,7 @@
    * be subclassed to create more sophisticated Manager implementations.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.7 $ $Date: 2000/07/11 00:46:51 $
  + * @version $Revision: 1.8 $ $Date: 2000/07/27 03:20:01 $
    */
   
   public abstract class ManagerBase implements Manager {
  @@ -125,6 +124,12 @@
   
   
       /**
  +     * The debugging detail level for this component.
  +     */
  +    protected int debug = 0;
  +
  +
  +    /**
        * Return the MessageDigest implementation to be used when
        * creating session identifiers.
        */
  @@ -175,14 +180,14 @@
       /**
        * The set of previously recycled Sessions for this Manager.
        */
  -    protected Vector recycled = new Vector();
  +    protected ArrayList recycled = new ArrayList();
   
   
       /**
        * The set of currently active Sessions for this Manager, keyed by
        * session identifier.
        */
  -    protected Hashtable sessions = new Hashtable();
  +    protected HashMap sessions = new HashMap();
   
   
       /**
  @@ -250,6 +255,28 @@
   
   
       /**
  +     * Return the debugging detail level for this component.
  +     */
  +    public int getDebug() {
  +
  +	return (this.debug);
  +
  +    }
  +
  +
  +    /**
  +     * Set the debugging detail level for this component.
  +     *
  +     * @param debug The new debugging detail level
  +     */
  +    public void setDebug(int debug) {
  +
  +	this.debug = debug;
  +
  +    }
  +
  +
  +    /**
        * Return the MessageDigest object to be used for calculating
        * session identifiers.  If none has been created yet, initialize
        * one the first time this method is called.
  @@ -257,6 +284,8 @@
       public synchronized MessageDigest getDigest() {
   
   	if (this.digest == null) {
  +	    if (debug >= 1)
  +		log(sm.getString("managerBase.getting", algorithm));
   	    try {
   		this.digest = MessageDigest.getInstance(algorithm);
   	    } catch (NoSuchAlgorithmException e) {
  @@ -269,6 +298,8 @@
   		    this.digest = null;
   		}
   	    }
  +	    if (debug >= 1)
  +		log(sm.getString("managerBase.gotten"));
   	}
   
   	return (this.digest);
  @@ -382,6 +413,7 @@
       public synchronized Random getRandom() {
   
   	if (this.random == null) {
  +	    log(sm.getString("managerBase.seeding", randomClass));
   	    try {
   		Class clazz = Class.forName(randomClass);
   		this.random = (Random) clazz.newInstance();
  @@ -395,6 +427,7 @@
   		log(sm.getString("managerBase.random", randomClass), e);
   		this.random = new java.util.Random();
   	    }
  +	    log(sm.getString("managerBase.complete", randomClass));
   	}
   
   	return (this.random);
  @@ -459,8 +492,8 @@
   	synchronized (recycled) {
   	    int size = recycled.size();
   	    if (size > 0) {
  -		session = (StandardSession) recycled.elementAt(size - 1);
  -		recycled.removeElementAt(size - 1);
  +		session = (StandardSession) recycled.get(size - 1);
  +		recycled.remove(size - 1);
   	    }
   	}
   	if (session == null)
  @@ -472,8 +505,12 @@
   	session.setCreationTime(System.currentTimeMillis());
   	session.setMaxInactiveInterval(this.maxInactiveInterval);
   	String sessionId = generateSessionId();
  -	while (sessions.get(sessionId) != null)	// Guarantee uniqueness
  -	    sessionId = generateSessionId();
  +	/*
  +	synchronized (sessions) {
  +	    while (sessions.get(sessionId) != null)	// Guarantee uniqueness
  +		sessionId = generateSessionId();
  +	}
  +	*/
   	session.setId(sessionId);
   
   	return (session);
  @@ -496,7 +533,9 @@
   
   	if (id == null)
   	    return (null);
  -	return ((Session) sessions.get(id));
  +	synchronized (sessions) {
  +	    return ((Session) sessions.get(id));
  +	}
   
       }
   
  @@ -507,20 +546,12 @@
        */
       public Session[] findSessions() {
   
  +	Session results[] = null;
   	synchronized (sessions) {
  -	    Vector keys = new Vector();
  -	    Enumeration ids = sessions.keys();
  -	    while (ids.hasMoreElements()) {
  -		String id = (String) ids.nextElement();
  -		keys.addElement(id);
  -	    }
  -	    Session results[] = new Session[keys.size()];
  -	    for (int i = 0; i < results.length; i++) {
  -		String key = (String) keys.elementAt(i);
  -		results[i] = (Session) sessions.get(key);
  -	    }
  -	    return (results);
  +	    results = new Session[sessions.size()];
  +	    results = (Session[]) sessions.values().toArray(results);
   	}
  +	return (results);
   
       }
   
  @@ -580,7 +611,9 @@
        */
       void add(StandardSession session) {
   
  -	sessions.put(session.getId(), session);
  +	synchronized (sessions) {
  +	    sessions.put(session.getId(), session);
  +	}
   
       }
   
  @@ -642,7 +675,9 @@
        */
       void recycle(StandardSession session) {
   
  -	recycled.addElement(session);
  +	synchronized (recycled) {
  +	    recycled.add(session);
  +	}
   
       }
   
  @@ -654,7 +689,9 @@
        */
       void remove(StandardSession session) {
   
  -	sessions.remove(session.getId());
  +	synchronized (sessions) {
  +	    sessions.remove(session.getId());
  +	}
   
       }
   
  
  
  
  1.20      +9 -39     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardManager.java
  
  Index: StandardManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardManager.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- StandardManager.java	2000/07/15 03:15:37	1.19
  +++ StandardManager.java	2000/07/27 03:20:01	1.20
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardManager.java,v
1.19 2000/07/15 03:15:37 craigmcc Exp $
  - * $Revision: 1.19 $
  - * $Date: 2000/07/15 03:15:37 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardManager.java,v
1.20 2000/07/27 03:20:01 craigmcc Exp $
  + * $Revision: 1.20 $
  + * $Date: 2000/07/27 03:20:01 $
    *
    * ====================================================================
    *
  @@ -78,9 +78,7 @@
   import java.io.ObjectInputStream;
   import java.io.ObjectOutputStream;
   import java.io.ObjectStreamClass;
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -import java.util.Vector;
  +import java.util.Iterator;
   import javax.servlet.ServletContext;
   import org.apache.tomcat.Container;
   import org.apache.tomcat.Context;
  @@ -105,7 +103,7 @@
    * <code>stop()</code> methods of this class at the correct times.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.19 $ $Date: 2000/07/15 03:15:37 $
  + * @version $Revision: 1.20 $ $Date: 2000/07/27 03:20:01 $
    */
   
   public final class StandardManager
  @@ -123,12 +121,6 @@
   
   
       /**
  -     * The debugging detail level for this component.
  -     */
  -    private int debug = 2;
  -
  -
  -    /**
        * The descriptive information about this implementation.
        */
       private static final String info = "StandardManager/1.0";
  @@ -238,28 +230,6 @@
   
   
       /**
  -     * Return the debugging detail level for this component.
  -     */
  -    public int getDebug() {
  -
  -	return (this.debug);
  -
  -    }
  -
  -
  -    /**
  -     * Set the debugging detail level for this component.
  -     *
  -     * @param debug The new debugging detail level
  -     */
  -    public void setDebug(int debug) {
  -
  -	this.debug = debug;
  -
  -    }
  -
  -
  -    /**
        * Return descriptive information about this Manager implementation and
        * the corresponding version number, in the format
        * <code>&lt;description&gt;/&lt;version&gt;</code>.
  @@ -510,7 +480,7 @@
       private void load() throws LifecycleException {
   
   	// Initialize our internal data structures
  -	recycled.removeAllElements();
  +	recycled.clear();
   	sessions.clear();
   
   	// Open an input stream to the specified pathname, if any
  @@ -650,9 +620,9 @@
   	synchronized (sessions) {
   	    try {
   		oos.writeObject(new Integer(sessions.size()));
  -		Enumeration elements = sessions.elements();
  -		while (elements.hasMoreElements()) {
  -		    Session session = (Session) elements.nextElement();
  +		Iterator elements = sessions.values().iterator();
  +		while (elements.hasNext()) {
  +		    Session session = (Session) elements.next();
   		    oos.writeObject(session);
   		}
   	    } catch (IOException e) {
  
  
  
  1.1                  jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/package.html
  
  Index: package.html
  ===================================================================
  <body>
  
  <p>This package contains the standard <code>Manager</code> and
  <code>Session</code> implementations that represent the collection of
  active sessions and the individual sessions themselves, respectively,
  that are associated with a <code>Context</code>.  Additional implementations
  of the <code>Manager</code> interface can be based upon the supplied
  convenience base class (<code>ManagerBase</code>), if desired.  Different
  implementations of <code>Session</code> are possible, but a need for
  functionality beyond what is provided by the standard implementation
  (<code>StandardSession</code>) is not expected.</p>
  
  <p>The convenience <code>ManagerBase</code> base class is configured by
  setting the following properties:</p>
  <ul>
  <li><b>algorithm</b> - Message digest algorithm to be used when
      generating session identifiers.  This must be the name of an
      algorithm supported by the <code>java.security.MessageDigest</code>
      class on your platform.  [DEFAULT_ALGORITHM]</li>
  <li><b>debug</b> - Debugging detail level for this component. [0]</li>
  <li><b>distributable</b> - Has the web application we are associated with
      been marked as "distributable"?  If it has, attempts to add or replace
      a session attribute object that does not implement the
      <code>java.io.Serializable</code> interface will be rejected.
      [false]</li>
  <li><b>entropy</b> - A string initialization parameter that is used to
      increase the entropy of the seeding of the random number generator
      used in creation of session identifiers.  [NONE]</li>
  <li><b>maxInactiveInterval</b> - The default maximum inactive interval,
      in minutes, for sessions created by this Manager.  The standard
      implementation automatically updates this value based on the configuration
      settings in the web application deployment descriptor.  [60]</li>
  <li><b>randomClass</b> - The Java class name of the random number generator
      to be used when creating session identifiers for this Manager.
      [java.security.SecureRandom]</li>
  </ul>
  
  <p>The standard implementation of the <code>Manager</code> interface
  (<code>StandardManager</code>) supports the following additional configuration
  properties:</p>
  <ul>
  <li><b>checkInterval</b> - The interval, in seconds, between checks for
      sessions that have expired and should be invalidated.  [60]</li>
  <li><b>maxActiveSessions</b> - The maximum number of active sessions that
      will be allowed, or -1 for no limit.  [-1]</li>
  <li><b>pathname</b> - Pathname to the file that is used to store session
      data persistently across container restarts.  If this pathname is relative,
      it is resolved against the temporary working directory provided by our
      associated Context, if any.  ["sessions.ser"]</li>
  </ul>
  
  </body>
  
  
  

Mime
View raw message