fhanik      2003/11/14 16:49:43

  Modified:    modules/cluster/src/share/org/apache/catalina/cluster/session
                        DeltaSession.java
  Added:       modules/cluster/src/share/org/apache/catalina/cluster/session
                        ClusterManager.java ClusterSession.java
  Log:
  adding interfaces to make clustering more configurable.
  Also, realized that only a primary session can expire by inactive time,
  the other nodes (slave sessions) will expire when the primary does
  
  Revision  Changes    Path
  1.2       +32 -6     
jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaSession.java
  
  Index: DeltaSession.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaSession.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DeltaSession.java 14 Nov 2003 20:07:52 -0000      1.1
  +++ DeltaSession.java 15 Nov 2003 00:49:43 -0000      1.2
  @@ -125,7 +125,8 @@
    */
   
   public class DeltaSession
  -    implements HttpSession, Session, Serializable {
  +    implements HttpSession, Session, Serializable,
  +               ClusterSession {
   
   
       // ----------------------------------------------------------- Constructors
  @@ -245,7 +246,7 @@
       /**
        * The Manager with which this Session is associated.
        */
  -    private Manager manager = null;
  +    private transient Manager manager = null;
   
   
       /**
  @@ -311,8 +312,33 @@
       private long thisAccessedTime = creationTime;
   
   
  +    /**
  +     * only the primary session will expire, or be able to
  +     * expire due to inactivity. This is set to false
  +     * as soon as I receive this session over the wire in
  +     * a session message. That means that someone else has
  +     * made a request on another server.
  +     */
  +    private transient boolean isPrimarySession = true;
  +
       // ----------------------------------------------------- Session Properties
   
  +    /**
  +     * returns true if this session is the primary session, if that is the
  +     * case, the manager can expire it upon timeout.
  +     * @return
  +     */
  +    public boolean isPrimarySession() {
  +       return isPrimarySession;
  +    }
  +
  +    /**
  +     * Sets whether this is the primary session or not.
  +     * @param primarySession
  +     */
  +    public void setPrimarySession(boolean primarySession) {
  +       this.isPrimarySession=primarySession;
  +    }
   
       /**
        * Return the authentication type used to authenticate our cached
  
  
  
  1.1                  
jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/ClusterManager.java
  
  Index: ClusterManager.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/ClusterManager.java,v
 1.1 2003/11/15 00:49:43 fhanik Exp $
   * $Revision: 1.1 $
   * $Date: 2003/11/15 00:49:43 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */
  
  package org.apache.catalina.cluster.session;
  
  /**
   * The common interface used by all cluster manager.
   * This is so that we can have a more pluggable way
   * of swapping session managers for different algorithms.
   *
   * @author Filip Hanik
  
   */
  
  import org.apache.catalina.Manager;
  
  public interface ClusterManager extends Manager {
  
     /**
      * A message was received from another node, this
      * is the callback method to implement if you are interested in
      * receiving replication messages.
      * @param msg - the message received.
      */
     public void messageDataReceived(SessionMessage msg);
  
     /**
      * When the request has been completed, the replication valve
      * will notify the manager, and the manager will decide whether
      * any replication is needed or not.
      * If there is a need for replication, the manager will
      * create a session message and that will be replicated.
      * The cluster determines where it gets sent.
      * @param sessionId - the sessionId that just completed.
      * @return a SessionMessage to be sent,
      */
     public SessionMessage requestCompleted(String sessionId);
  
     /**
      * When the manager expires session not tied to a request.
      * The cluster will periodically ask for a list of sessions
      * that should expire and that should be sent across the wire.
      * @return
      */
     public String[] getInvalidatedSessions();
  
  }
  
  
  
  1.1                  
jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/ClusterSession.java
  
  Index: ClusterSession.java
  ===================================================================
  package org.apache.catalina.cluster.session;
  
  import org.apache.catalina.Session;
  
  public interface ClusterSession extends Session {
     /**
      * returns true if this session is the primary session, if that is the
      * case, the manager can expire it upon timeout.
      * @return
      */
     public boolean isPrimarySession();
  
     /**
      * Sets whether this is the primary session or not.
      * @param primarySession
      */
     public void setPrimarySession(boolean primarySession);
  
  }
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to