fhanik 2004/05/27 08:11:22 Modified: modules/cluster/src/share/org/apache/catalina/cluster/session ReplicatedSession.java SimpleTcpReplicationManager.java modules/cluster/src/share/org/apache/catalina/cluster/util SmartQueue.java Log: Changes in standard session broke the simple clustering mechanism. Fixed some logging statements Revision Changes Path 1.13 +34 -0 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.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- ReplicatedSession.java 26 May 2004 16:37:51 -0000 1.12 +++ ReplicatedSession.java 27 May 2004 15:11:21 -0000 1.13 @@ -58,6 +58,7 @@ protected boolean isDirty = false; private transient long lastAccessWasDistributed = System.currentTimeMillis(); private boolean isPrimarySession=true; + public ReplicatedSession(Manager manager) { super(manager); @@ -193,6 +194,21 @@ super.writeObjectData(stream); } + + public void setId(String id, boolean tellNew) { + + if ((this.id != null) && (manager != null)) + manager.remove(this); + + this.id = id; + + if (manager != null) + manager.add(this); + if (tellNew) tellNew(); + } + + + @@ -252,6 +268,24 @@ } buf.append("\tLastAccess=").append(getLastAccessedTime()).append("\n"); return buf.toString(); + } + public int getAccessCount() { + return accessCount; + } + public void setAccessCount(int accessCount) { + this.accessCount = accessCount; + } + public long getLastAccessedTime() { + return lastAccessedTime; + } + public void setLastAccessedTime(long lastAccessedTime) { + this.lastAccessedTime = lastAccessedTime; + } + public long getThisAccessedTime() { + return thisAccessedTime; + } + public void setThisAccessedTime(long thisAccessedTime) { + this.thisAccessedTime = thisAccessedTime; } } 1.24 +26 -7 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.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- SimpleTcpReplicationManager.java 5 May 2004 16:36:13 -0000 1.23 +++ SimpleTcpReplicationManager.java 27 May 2004 15:11:21 -0000 1.24 @@ -383,14 +383,20 @@ ReplicationStream session_in = new ReplicationStream(session_data,container.getLoader().getClassLoader()); Session session = sessionId!=null?this.findSession(sessionId):null; + boolean isNew = (session==null); //clear the old values from the existing session if ( session!=null ) { ReplicatedSession rs = (ReplicatedSession)session; - rs.expire(false); + rs.expire(false); //cleans up the previous values, since we are not doing removes session = null; }//end if - if (session==null) session = createSession(false,false); + if (session==null) { + session = createSession(false, false); + sessions.remove(session.getId()); + } + + boolean hasPrincipal = session_in.readBoolean(); SerializablePrincipal p = null; if ( hasPrincipal ) @@ -398,6 +404,19 @@ ((ReplicatedSession)session).readObjectData(session_in); if ( hasPrincipal ) session.setPrincipal(p.getPrincipal(getContainer().getRealm())); + ((ReplicatedSession)session).setId(sessionId,isNew); + ReplicatedSession rsession = (ReplicatedSession)session; + rsession.setAccessCount(1); + session.setManager(this); + session.setValid(true); + rsession.setLastAccessedTime(System.currentTimeMillis()); + rsession.setThisAccessedTime(System.currentTimeMillis()); + ((ReplicatedSession)session).setAccessCount(0); + session.setNew(false); +// System.out.println("Session loaded id="+sessionId + +// " actualId="+session.getId()+ +// " exists="+this.sessions.containsKey(sessionId)+ +// " valid="+rsession.isValid()); return session; } @@ -558,11 +577,10 @@ } case SessionMessage.EVT_SESSION_CREATED: { 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); + if ( getDebug() > 5 ) { + log("Received replicated session=" + session + + " isValid=" + session.isValid()); + } break; } case SessionMessage.EVT_SESSION_EXPIRED: { @@ -577,6 +595,7 @@ Session session = findSession(msg.getSessionID()); if ( session != null ) { session.access(); + session.endAccess(); } break; } 1.6 +1 -1 jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/util/SmartQueue.java Index: SmartQueue.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/util/SmartQueue.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- SmartQueue.java 26 May 2004 16:39:01 -0000 1.5 +++ SmartQueue.java 27 May 2004 15:11:21 -0000 1.6 @@ -68,7 +68,7 @@ queueMap.put(entry.getKey(),entry); }else { /*the object has been queued, replace the value*/ - if ( debug != 0 ) System.out.print("["+Thread.currentThread().getName()+"][SmartQueue] Replacing old object="+current); + if ( debug != 0 ) log.debug("["+Thread.currentThread().getName()+"][SmartQueue] Replacing old object="+current); current.setValue(entry.getValue()); if ( debug != 0 ) log.debug("with new object="+current); }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]