tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject svn commit: r525783 - in /tomcat/container/tc5.5.x: modules/cluster/src/share/org/apache/catalina/cluster/session/ webapps/docs/
Date Thu, 05 Apr 2007 09:41:22 GMT
Author: pero
Date: Thu Apr  5 02:41:20 2007
New Revision: 525783

URL: http://svn.apache.org/viewvc?view=rev&rev=525783
Log:
Add better GET access session message support with new DeltaManager expireTolerance and updateActiveIntervall
attributes.
Fix DeltaRequest missing synchonized
Fix DeltaRequest better error report at readRequest.

Modified:
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaManager.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaRequest.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaSession.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/mbeans-descriptors.xml
    tomcat/container/tc5.5.x/webapps/docs/changelog.xml
    tomcat/container/tc5.5.x/webapps/docs/cluster-howto.xml

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaManager.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaManager.java?view=diff&rev=525783&r1=525782&r2=525783
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaManager.java
(original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaManager.java
Thu Apr  5 02:41:20 2007
@@ -144,6 +144,17 @@
      */
     private int sendAllSessionsWaitTime = 2 * 1000 ; 
 
+    /**
+     * Send session access message every updateActiveInterval sec 
+     */
+    private int updateActiveInterval = 60;
+
+    /**
+     * The default session maxInactiveInterval + tolerance time interval, in seconds, between
client requests before
+     * the servlet container may invalidate a backup session from other cluster node.
+     */
+    private int expireTolerance = 300;
+
     private ArrayList receivedMessageQueue = new ArrayList() ;
     
     private boolean receiverQueue = false ;
@@ -237,6 +248,22 @@
 
     }
 
+    public int getUpdateActiveInterval() {
+        return updateActiveInterval;
+    }
+
+    public void setUpdateActiveInterval(int updateActiveInterval) {
+        this.updateActiveInterval = updateActiveInterval;
+    }
+
+    public int getExpireTolerance() {
+        return expireTolerance;
+    }
+
+    public void setExpireTolerance(int expireTolerance) {
+        this.expireTolerance = expireTolerance;
+    }
+
     /**
      * @return Returns the counterSend_EVT_GET_ALL_SESSIONS.
      */
@@ -620,6 +647,7 @@
         }
 
         DeltaSession session = (DeltaSession) super.createSession(sessionId) ;
+        session.setExpireTolerance(this.expireTolerance);
         if (distribute) {
             sendCreateSession(session.getId(), session);
         }
@@ -933,6 +961,8 @@
         if (started) {
             return;
         }
+        if(log.isInfoEnabled())
+            log.info("Starting clustering manager...:"+getName());
         started = true;
         lifecycle.fireLifecycleEvent(START_EVENT, null);
 
@@ -1326,7 +1356,9 @@
             if ((msg == null)) {
                 long replDelta = System.currentTimeMillis()
                         - session.getLastTimeReplicated();
-                if (replDelta > (getMaxInactiveInterval() * 1000)) {
+                if (replDelta >= updateActiveInterval*1000 ||
+                    (getMaxInactiveInterval()>=0 &&
+                    replDelta >= getMaxInactiveInterval()*1000)) {
                     counterSend_EVT_SESSION_ACCESSED++;
                     msg = new SessionMessageImpl(getName(),
                             SessionMessage.EVT_SESSION_ACCESSED, null,
@@ -1493,7 +1525,7 @@
             if (log.isDebugEnabled())
                 log.debug(sm.getString("deltaManager.receiveMessage.eventType",
                         getName(), msg.getEventTypeString(), sender));
- 
+
             switch (msg.getEventType()) {
             case SessionMessage.EVT_GET_ALL_SESSIONS: {
                 handleGET_ALL_SESSIONS(msg,sender);
@@ -1632,6 +1664,7 @@
         session.setValid(true);
         session.setPrimarySession(false);
         session.setCreationTime(msg.getTimestamp());
+        session.setExpireTolerance(this.expireTolerance);
         session.access();
         if(notifySessionListenersOnReplication)
             session.setId(msg.getSessionID());

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaRequest.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaRequest.java?view=diff&rev=525783&r1=525782&r2=525783
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaRequest.java
(original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaRequest.java
Thu Apr  5 02:41:20 2007
@@ -208,7 +208,7 @@
             new Exception("Session Id is null for setSessionId").fillInStackTrace().printStackTrace();
         }
     }
-    public int getSize() {
+    public synchronized int getSize() {
         return actions.size();
     }
     
@@ -244,7 +244,12 @@
             else {
                 info = new AttributeInfo(-1,-1,null,null);
             }
-            info.readExternal(in);
+            try {
+                info.readExternal(in);
+            } catch (java.io.IOException e) {
+                log.error("Decode failure in delta request receiver: sid=" + sessionId +
", count=" + cnt + ", failure position=" + i);
+                throw e;
+            }
             actions.addLast(info);
         }//for
     }
@@ -335,8 +340,8 @@
             value = in.readObject();
         }
 
-        public synchronized void writeExternal(java.io.ObjectOutput out) throws java.io.
-            IOException {
+        public synchronized void writeExternal(java.io.ObjectOutput out) 
+           throws java.io.IOException {
             //type - int
             //action - int
             //name - String

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaSession.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaSession.java?view=diff&rev=525783&r1=525782&r2=525783
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaSession.java
(original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaSession.java
Thu Apr  5 02:41:20 2007
@@ -183,6 +183,12 @@
     private int maxInactiveInterval = -1;
 
     /**
+     * The maxInactiveInterval + tolerance time interval, in seconds, between client requests
before
+     * the servlet container may invalidate a backup session from other cluster node.
+     */
+    private int expireTolerance = 300;
+
+    /**
      * Flag indicating whether this session is new or not.
      */
     private boolean isNew = false;
@@ -609,7 +615,7 @@
                     expire(true);
                 }
             } else {
-                if (timeIdle >= (2 * maxInactiveInterval)) {
+                if (timeIdle >= (maxInactiveInterval+expireTolerance)) {
                 //if the session has been idle twice as long as allowed,
                 //the primary session has probably crashed, and no other
                 //requests are coming in. that is why we do this. otherwise
@@ -1655,6 +1661,14 @@
 
     protected int getAccessCount() {
         return accessCount;
+    }
+
+    protected void setExpireTolerance(int expireTolerance) {
+        this.expireTolerance = expireTolerance;
+      }
+    
+    protected int getExpireTolerance() {
+        return expireTolerance;
     }
 
 }

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/mbeans-descriptors.xml
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/mbeans-descriptors.xml?view=diff&rev=525783&r1=525782&r2=525783
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/mbeans-descriptors.xml
(original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/mbeans-descriptors.xml
Thu Apr  5 02:41:20 2007
@@ -255,6 +255,14 @@
     <attribute   name="sendAllSessionsWaitTime"
           description="wait time between send session block (default 2 sec)"
                  type="int" />
+                 
+    <attribute   name="expireTolerance"
+          description="Auto expire tolerance interval for backup sessions (default 300 sec)"
+                 type="int" />
+                 
+    <attribute   name="updateActiveIntervall"
+          description="Send session access to backup after this intervall (default 60 sec)"
+                 type="int" />     
 
     <operation   name="listSessionIds"
           description="Return the list of active session ids"
@@ -309,6 +317,7 @@
                impact="ACTION"
                returnType="void">
     </operation>
+    
 	<operation name="getAllClusterSessions"
                description="send to oldest cluster member that this node need all cluster
sessions (resync member)"
                impact="ACTION"

Modified: tomcat/container/tc5.5.x/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/docs/changelog.xml?view=diff&rev=525783&r1=525782&r2=525783
==============================================================================
--- tomcat/container/tc5.5.x/webapps/docs/changelog.xml (original)
+++ tomcat/container/tc5.5.x/webapps/docs/changelog.xml Thu Apr  5 02:41:20 2007
@@ -71,6 +71,19 @@
   <subsection name="Cluster">
     <changelog>
       <fix>
+        Receiver can also use tcpListenAddress with a hostname. (rjung, pero)
+      </fix>     
+      <fix>
+        DeltaRequest synchronized getSize() and show log message as 
+        readExternal() failure. (rjung, pero)
+      </fix>
+      <add>
+        Add DeltaManager expireTolerance attribute to quicker auto expire long backup sessions.
(rjung, pero)
+      </add>
+      <add>
+        Add DeltaManager updateActiveIntervall attribute to send every 60 sec a session access
message. (rjung, pero)
+      </add>
+      <fix>
         <bug>39866</bug> Duplicate names appended to cluster manager name. (yoavs)
       </fix>
     </changelog>

Modified: tomcat/container/tc5.5.x/webapps/docs/cluster-howto.xml
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/docs/cluster-howto.xml?view=diff&rev=525783&r1=525782&r2=525783
==============================================================================
--- tomcat/container/tc5.5.x/webapps/docs/cluster-howto.xml (original)
+++ tomcat/container/tc5.5.x/webapps/docs/cluster-howto.xml Thu Apr  5 02:41:20 2007
@@ -390,7 +390,7 @@
                   primaryIndicator="true" /&gt;
 	   &lt;Valve            className="org.apache.catalina.cluster.session.JvmRouteBinderValve"
 	                      enabled="true"  /&gt;
-&lt;Cluster/&gt;
+&lt;/Cluster&gt;
 </source> 
 </p>
 </section>
@@ -953,6 +953,18 @@
     Only other GET_ALL_SESSION events are handle with date before state transfer message.</td>
     <td><code>true</code></td>
   </tr>  
+  
+  <tr>
+    <td>updateActiveInterval</td>
+    <td>Send session access message every updateActiveInterval sec.</td>
+    <td><code>60</code></td>
+  </tr>  
+  
+  <tr>
+    <td>expireTolerance</td>
+    <td>Autoexpire backup session after MaxInactive + expireTolerance sec.</td>
+    <td><code>300</code></td>
+  </tr> 
   
 </table>
   



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


Mime
View raw message