You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fh...@apache.org on 2003/11/15 01:58:20 UTC

cvs commit: jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp ReplicationValve.java SimpleTcpCluster.java

fhanik      2003/11/14 16:58:20

  Modified:    modules/cluster/src/share/org/apache/catalina/cluster/session
                        DeltaSession.java SimpleTcpReplicationManager.java
               modules/cluster/src/share/org/apache/catalina/cluster/tcp
                        ReplicationValve.java SimpleTcpCluster.java
  Added:       modules/cluster/src/share/org/apache/catalina/cluster
                        ClusterManager.java ClusterSession.java
                        SessionMessage.java
  Removed:     modules/cluster/src/share/org/apache/catalina/cluster/session
                        ClusterManager.java ClusterSession.java
                        SessionMessage.java
  Log:
  refactored files to be used in a better way, more intuitive to extend,implement and configure
  
  Revision  Changes    Path
  1.1                  jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/ClusterManager.java
  
  Index: ClusterManager.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/ClusterManager.java,v 1.1 2003/11/15 00:58:20 fhanik Exp $
   * $Revision: 1.1 $
   * $Date: 2003/11/15 00:58:20 $
   *
   * ====================================================================
   *
   * 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 apache@apache.org.
   *
   * 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;
  
  /**
   * 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/ClusterSession.java
  
  Index: ClusterSession.java
  ===================================================================
  package org.apache.catalina.cluster;
  
  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);
  
  }
  
  
  1.3       +115 -154  jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/SessionMessage.java
  
  
  
  
  1.3       +5 -4      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DeltaSession.java	15 Nov 2003 00:49:43 -0000	1.2
  +++ DeltaSession.java	15 Nov 2003 00:58:20 -0000	1.3
  @@ -100,6 +100,7 @@
   
   import org.apache.catalina.session.ManagerBase;
   import org.apache.catalina.session.Constants;
  +import org.apache.catalina.cluster.ClusterSession;
   
   /**
    *
  
  
  
  1.15      +4 -3      jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/SimpleTcpReplicationManager.java
  
  Index: SimpleTcpReplicationManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/SimpleTcpReplicationManager.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- SimpleTcpReplicationManager.java	15 Oct 2003 18:11:49 -0000	1.14
  +++ SimpleTcpReplicationManager.java	15 Nov 2003 00:58:20 -0000	1.15
  @@ -74,6 +74,7 @@
   import org.apache.catalina.cluster.tcp.SocketSender;
   import org.apache.catalina.cluster.Member;
   import org.apache.catalina.cluster.tcp.SimpleTcpCluster;
  +import org.apache.catalina.cluster.SessionMessage;
   
   
   
  
  
  
  1.6       +10 -10    jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationValve.java
  
  Index: ReplicationValve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationValve.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ReplicationValve.java	9 Sep 2003 22:21:19 -0000	1.5
  +++ ReplicationValve.java	15 Nov 2003 00:58:20 -0000	1.6
  @@ -89,7 +89,7 @@
   import org.apache.catalina.util.StringManager;
   import org.apache.catalina.valves.*;
   import org.apache.catalina.cluster.session.SimpleTcpReplicationManager;
  -import org.apache.catalina.cluster.session.SessionMessage;
  +import org.apache.catalina.cluster.SessionMessage;
   import org.apache.catalina.cluster.tcp.SimpleTcpCluster;
   
   /**
  @@ -206,7 +206,7 @@
                       }
                   }
               }
  -            
  +
               String id = null;
               if ( session != null )
                   id = session.getId();
  @@ -220,7 +220,7 @@
                    (!(request.getContext().getManager() instanceof SimpleTcpReplicationManager)))
                   return;
   
  -            
  +
   
               String uri = hrequest.getDecodedRequestURI();
               boolean filterfound = false;
  @@ -234,15 +234,15 @@
                   return;
   
               if ( debug > 4 ) log("Invoking replication request on "+uri,4);
  -            
  +
               SessionMessage msg = manager.requestCompleted(id);
               if ( msg == null ) return;
   
  -            
  +
               cluster.send(msg);
               long stop = System.currentTimeMillis();
               addClusterSendTime(stop-start);
  -            
  +
           }catch (Exception x)
           {
               log("Unable to perform replication request.",x,2);
  
  
  
  1.17      +13 -13    jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java
  
  Index: SimpleTcpCluster.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- SimpleTcpCluster.java	14 Oct 2003 22:40:34 -0000	1.16
  +++ SimpleTcpCluster.java	15 Nov 2003 00:58:20 -0000	1.17
  @@ -94,7 +94,7 @@
   import org.apache.catalina.cluster.tcp.SocketSender;
   import org.apache.catalina.cluster.io.ListenCallback;
   
  -import org.apache.catalina.cluster.session.SessionMessage;
  +import org.apache.catalina.cluster.SessionMessage;
   import org.apache.catalina.cluster.session.ReplicationStream;
   import org.apache.catalina.cluster.session.SimpleTcpReplicationManager;
   import org.apache.catalina.cluster.Constants;
  @@ -247,7 +247,7 @@
   
   
       /**
  -     * The context name <-> manager association for distributed contexts. 
  +     * The context name <-> manager association for distributed contexts.
        */
       protected HashMap managers = new HashMap();
       /**
  @@ -260,7 +260,7 @@
        */
       protected long msgFrequency = 500;
       /**
  -     * java.nio.Channels.Selector.select timeout in case the JDK has a 
  +     * java.nio.Channels.Selector.select timeout in case the JDK has a
        * poor nio implementation
        */
       protected long tcpSelectorTimeout = 100;
  @@ -269,7 +269,7 @@
        * The channel configuration.
        */
       protected String protocol = null;
  -    
  +
       /**
        * The replication mode, can be either synchronous or asynchronous
        * defaults to synchronous
  @@ -324,9 +324,9 @@
               "asynchronous".equals(mode)) {
               log.debug("Setting replcation mode to "+mode);
               this.replicationMode = mode;
  -        } else 
  +        } else
               throw new IllegalArgumentException("Replication mode must be either synchronous or asynchronous");
  -        
  +
       }
       /**
        * Set the name of the cluster to join, if no cluster with
  @@ -503,8 +503,8 @@
   
   
       }
  -    
  -    
  +
  +
       public void send(SessionMessage msg, Member dest) {
           try
           {
  @@ -646,7 +646,7 @@
           this.tcpPort = port;
           svcproperties.setProperty("tcpListenPort",String.valueOf(port));
       }
  -    
  +
       public void setTcpSelectorTimeout(long timeout) {
           this.tcpSelectorTimeout = timeout;
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org