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/04/16 20:49:22 UTC

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

fhanik      2003/04/16 11:49:22

  Modified:    modules/cluster/src/share/org/apache/catalina/cluster/session
                        ReplicatedSession.java
                        SimpleTcpReplicationManager.java
               modules/cluster/src/share/org/apache/catalina/cluster/tcp
                        ReplicationValve.java
  Log:
  fixed a bug in deserialization of sessions, also improved logging a little bit
  
  Revision  Changes    Path
  1.5       +10 -7     jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/ReplicatedSession.java
  
  Index: ReplicatedSession.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/ReplicatedSession.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ReplicatedSession.java	4 Apr 2003 19:43:47 -0000	1.4
  +++ ReplicatedSession.java	16 Apr 2003 18:49:22 -0000	1.5
  @@ -238,13 +238,16 @@
       }
   
       public String toString() {
  -        StringBuffer buf = new StringBuffer("[ReplicatedSession] Id").append(getId());        java.util.Enumeration e = getAttributeNames();
  +        StringBuffer buf = new StringBuffer("ReplicatedSession id=");
  +        buf.append(getId()).append(" ref=").append(super.toString()).append("\n");
  +        java.util.Enumeration e = getAttributeNames();
           while ( e.hasMoreElements() ) {
               String name = (String)e.nextElement();
  -            Object value = this.getAttribute(name);
  -            buf.append("\n\t"+name+"="+value);
  +            Object value = getAttribute(name);
  +            buf.append("\tname=").append(name).append("; value=").append(value).append("\n");
           }
  +        buf.append("\tLastAccess=").append(getLastAccessedTime()).append("\n");
           return buf.toString();
  -
       }
  +
   }
  
  
  
  1.7       +21 -5     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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SimpleTcpReplicationManager.java	16 Apr 2003 04:07:49 -0000	1.6
  +++ SimpleTcpReplicationManager.java	16 Apr 2003 18:49:22 -0000	1.7
  @@ -204,7 +204,7 @@
   
       public void setDebug(int debug) {
           this.debug = debug;
  -        super.setDebug(debug);
  +        //super.setDebug(debug);
       }
       /**
        * Creates a HTTP session.
  @@ -317,6 +317,11 @@
                   //return immediately if the session is not dirty
                   if ( useDirtyFlag && (!session.isDirty())) return null;
                   session.setIsDirty(false);
  +                if (getDebug()>5) {
  +                    try {
  +                        log.debug("Sending session to cluster="+session);
  +                    }catch ( Exception ignore) {}
  +                }
                   SessionMessage msg = new SessionMessage(name,SessionMessage.EVT_SESSION_CREATED,
                       writeSession(session),
                       session.getId());
  @@ -376,7 +381,15 @@
           {
               java.io.ByteArrayInputStream session_data = new java.io.ByteArrayInputStream(data);
               ReplicationStream session_in = new ReplicationStream(session_data,container.getLoader().getClassLoader());
  +            
               Session session = sessionId!=null?this.findSession(sessionId):null;
  +            //clear the old values from the existing session
  +            if ( session!=null ) {
  +                ReplicatedSession rs = (ReplicatedSession)session;
  +                rs.expire(false);
  +                session = null;
  +            }//end if
  +            
               if (session==null) session = createSession(false,false);
               boolean hasPrincipal = session_in.readBoolean();
               SerializablePrincipal p = null;
  @@ -524,6 +537,9 @@
                       Session session = this.readSession(msg.getSession(),msg.getSessionID());
                       session.setManager(this);
                       add(session);
  +                    session.setValid(true);
  +                    session.access();
  +                    if ( getDebug()  > 5 ) log("Received replicated session="+session);
                       break;
                   }
                   default:  {
  @@ -534,7 +550,7 @@
           }
           catch ( Exception x )
           {
  -            log("Unable to receive message through javagroups channel",x,1);
  +            log("Unable to receive message through TCP channel",x,1);
           }
       }
   
  
  
  
  1.3       +6 -19     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ReplicationValve.java	20 Mar 2003 20:46:14 -0000	1.2
  +++ ReplicationValve.java	16 Apr 2003 18:49:22 -0000	1.3
  @@ -263,13 +263,7 @@
        */
       protected void log(String message,int level) {
           if ( debug < level ) return;
  -        Logger logger = null;
  -        if ( container != null ) logger = container.getLogger();
  -        if (logger != null)
  -            logger.log(this.toString() + ": " + message);
  -        else
  -            System.out.println(this.toString() + ": " + message);
  -
  +        log.debug(message);
       }
   
   
  @@ -281,14 +275,7 @@
        */
       protected void log(String message, Throwable throwable,int level) {
           if ( debug < level ) return;
  -        Logger logger = null;
  -        if ( container != null ) logger = container.getLogger();
  -        if (logger != null)
  -            logger.log(this.toString() + ": " + message, throwable);
  -        else {
  -            log.warn(message,throwable);
  -        }
  -
  +        log.debug(message,throwable);
       }
   
   
  
  
  

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