tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kfuj...@apache.org
Subject svn commit: r1195848 - in /tomcat/tc6.0.x/trunk: java/org/apache/catalina/ha/session/ webapps/docs/
Date Tue, 01 Nov 2011 07:00:21 GMT
Author: kfujino
Date: Tue Nov  1 07:00:21 2011
New Revision: 1195848

URL: http://svn.apache.org/viewvc?rev=1195848&view=rev
Log:
When Context manager does not exist, no context manager message is replied in order to avoid
timeout (default 60 sec) of GET_ALL_SESSIONS sync phase.

Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/ClusterSessionListener.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaManager.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/LocalStrings.properties
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/SessionMessage.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/SessionMessageImpl.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/mbeans-descriptors.xml
    tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/ClusterSessionListener.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/ClusterSessionListener.java?rev=1195848&r1=1195847&r2=1195848&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/ClusterSessionListener.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/ClusterSessionListener.java Tue
Nov  1 07:00:21 2011
@@ -88,10 +88,21 @@ public class ClusterSessionListener exte
                 }
             } else {
                 ClusterManager mgr = (ClusterManager) managers.get(ctxname);
-                if (mgr != null)
+                if (mgr != null) {
                     mgr.messageDataReceived(msg);
-                else if (log.isWarnEnabled())
-                    log.warn("Context manager doesn't exist:" + ctxname);
+                } else {
+                    if (log.isWarnEnabled())
+                        log.warn("Context manager doesn't exist:" + ctxname);
+
+                    // A no context manager message is replied in order to avoid
+                    // timeout of GET_ALL_SESSIONS sync phase.
+                    if (msg.getEventType() == SessionMessage.EVT_GET_ALL_SESSIONS) {
+                        SessionMessage replymsg = new SessionMessageImpl(ctxname,
+                                SessionMessage.EVT_ALL_SESSION_NOCONTEXTMANAGER,
+                                null, "NO-CONTEXT-MANAGER","NO-CONTEXT-MANAGER-" + ctxname);
+                        cluster.send(replymsg, msg.getAddress());
+                    }
+                }
             }
         }
         return;

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaManager.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaManager.java?rev=1195848&r1=1195847&r2=1195848&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaManager.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaManager.java Tue Nov  1
07:00:21 2011
@@ -115,6 +115,7 @@ public class DeltaManager extends Cluste
     private boolean notifySessionListenersOnReplication = true;
     private boolean notifyContainerListenersOnReplication  = true;
     private volatile boolean stateTransfered = false ;
+    private volatile boolean noContextManagerReceived = false ;
     private int stateTransferTimeout = 60;
     private boolean sendAllSessions = true;
     private boolean sendClusterDomainOnly = true ;
@@ -142,6 +143,7 @@ public class DeltaManager extends Cluste
     private long counterReceive_EVT_SESSION_DELTA = 0;
     private int counterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE = 0 ;
     private long counterReceive_EVT_CHANGE_SESSION_ID = 0 ;
+    private long counterReceive_EVT_ALL_SESSION_NOCONTEXTMANAGER = 0 ;
     private long counterSend_EVT_GET_ALL_SESSIONS = 0 ;
     private long counterSend_EVT_ALL_SESSION_DATA = 0 ;
     private long counterSend_EVT_SESSION_CREATED = 0;
@@ -291,7 +293,14 @@ public class DeltaManager extends Cluste
     public long getCounterReceive_EVT_CHANGE_SESSION_ID() {
         return counterReceive_EVT_CHANGE_SESSION_ID;
     }
-    
+
+    /**
+     * @return Returns the counterReceive_EVT_ALL_SESSION_NOCONTEXTMANAGER.
+     */
+    public long getCounterReceive_EVT_ALL_SESSION_NOCONTEXTMANAGER() {
+        return counterReceive_EVT_ALL_SESSION_NOCONTEXTMANAGER;
+    }
+
     /**
      * @return Returns the processingTime.
      */
@@ -358,7 +367,15 @@ public class DeltaManager extends Cluste
     public void setStateTransfered(boolean stateTransfered) {
         this.stateTransfered = stateTransfered;
     }
-    
+
+    public boolean isNoContextManagerReceived() {
+        return noContextManagerReceived;
+    }
+
+    public void setNoContextManagerReceived(boolean noContextManagerReceived) {
+        this.noContextManagerReceived = noContextManagerReceived;
+    }
+
     /**
      * @return Returns the sendAllSessionsWaitTime in msec
      */
@@ -1055,7 +1072,7 @@ public class DeltaManager extends Cluste
                 }
                 reqNow = System.currentTimeMillis();
                 isTimeout = ((reqNow - reqStart) > (1000 * getStateTransferTimeout()));
-            } while ((!getStateTransfered()) && (!isTimeout));
+            } while ((!getStateTransfered()) && (!isTimeout) && (!isNoContextManagerReceived()));
         } else {
             if(getStateTransferTimeout() == -1) {
                 // wait that state is transfered
@@ -1064,16 +1081,19 @@ public class DeltaManager extends Cluste
                         Thread.sleep(100);
                     } catch (Exception sleep) {
                     }
-                } while ((!getStateTransfered()));
+                } while ((!getStateTransfered())&& (!isNoContextManagerReceived()));
                 reqNow = System.currentTimeMillis();
             }
         }
-        if (isTimeout || (!getStateTransfered())) {
+        if (isTimeout) {
             counterNoStateTransfered++ ;
-            log.error(sm.getString("deltaManager.noSessionState",getName(),new Date(beforeSendTime),new
Long(reqNow - beforeSendTime)));
+            log.error(sm.getString("deltaManager.noSessionState",getName(),new Date(beforeSendTime),Long.valueOf(reqNow
- beforeSendTime)));
+        } else if (isNoContextManagerReceived()) {
+            if (log.isWarnEnabled())
+                log.warn(sm.getString("deltaManager.noContextManager",getName(),new Date(beforeSendTime),Long.valueOf(reqNow
- beforeSendTime)));
         } else {
             if (log.isInfoEnabled())
-                log.info(sm.getString("deltaManager.sessionReceived",getName(), new Date(beforeSendTime),
new Long(reqNow - beforeSendTime)));
+                log.info(sm.getString("deltaManager.sessionReceived",getName(), new Date(beforeSendTime),
Long.valueOf(reqNow - beforeSendTime)));
         }
     }
 
@@ -1473,6 +1493,10 @@ public class DeltaManager extends Cluste
                     handleCHANGE_SESSION_ID(msg,sender);
                     break;
                  }
+                case SessionMessage.EVT_ALL_SESSION_NOCONTEXTMANAGER: {
+                    handleALL_SESSION_NOCONTEXTMANAGER(msg,sender);
+                    break;
+                 }
                 default: {
                     //we didn't recognize the message type, do nothing
                     break;
@@ -1661,6 +1685,18 @@ public class DeltaManager extends Cluste
     }
 
     /**
+     * handle receive no context manager.
+     * @param msg
+     * @param sender
+     */
+    protected void handleALL_SESSION_NOCONTEXTMANAGER(SessionMessage msg, Member sender)
{
+        counterReceive_EVT_ALL_SESSION_NOCONTEXTMANAGER++ ;
+        if (log.isDebugEnabled()) 
+            log.debug(sm.getString("deltaManager.receiveMessage.noContextManager",getName(),
sender.getHost(), Integer.valueOf(sender.getPort())));
+        noContextManagerReceived = true ;
+    }
+
+    /**
      * send a block of session to sender
      * @param sender
      * @param currentSessions

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/LocalStrings.properties?rev=1195848&r1=1195847&r2=1195848&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/LocalStrings.properties (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/LocalStrings.properties Tue Nov
 1 07:00:21 2011
@@ -34,6 +34,7 @@ deltaManager.noCluster=Starting... no cl
 deltaManager.noMasterMember=Starting... with no other member for context [{0}] at domain
[{1}]
 deltaManager.noMembers=Manager [{0}]: skipping state transfer. No members active in cluster
group.
 deltaManager.noSessionState=Manager [{0}]: No session state send at {1} received, timing
out after {2} ms.
+deltaManager.noContextManager=Manager [{0}]: No context manager send at {1} received in {2}
ms.
 deltaManager.notStarted=Manager has not yet been started
 deltaManager.sendMessage.newSession=Manager [{0}] send new session ({1})
 deltaManager.expireSessions=Manager [{0}] expiring sessions upon shutdown
@@ -44,6 +45,7 @@ deltaManager.receiveMessage.error=Manage
 deltaManager.receiveMessage.eventType=Manager [{0}]: Received SessionMessage of type=({1})
from [{2}]
 deltaManager.receiveMessage.expired=Manager [{0}]: received session [{1}] expired.
 deltaManager.receiveMessage.transfercomplete=Manager [{0}] received from node [{1}:{2}] session
state transfered.
+deltaManager.receiveMessage.noContextManager=Manager [{0}] received from node [{1}:{2}] no
context manager.
 deltaManager.receiveMessage.unloadingAfter=Manager [{0}]: unloading sessions complete
 deltaManager.receiveMessage.unloadingBegin=Manager [{0}]: start unloading sessions
 deltaManager.receiveMessage.allSessionDataAfter=Manager [{0}]: session state deserialized

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/SessionMessage.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/SessionMessage.java?rev=1195848&r1=1195847&r2=1195848&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/SessionMessage.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/SessionMessage.java Tue Nov 
1 07:00:21 2011
@@ -33,6 +33,7 @@ import org.apache.catalina.ha.ClusterMes
  *   <li><pre>public static final int EVT_ALL_SESSION_DATA</pre><li>
  *   <li><pre>public static final int EVT_ALL_SESSION_TRANSFERCOMPLETE</pre><li>
  *   <li><pre>public static final int EVT_CHANGE_SESSION_ID</pre><li>
+ *   <li><pre>public static final int EVT_ALL_SESSION_NOCONTEXTMANAGER</pre><li>
  * </ul>
  *
  */
@@ -82,7 +83,12 @@ public interface SessionMessage extends 
      */
     public static final int EVT_CHANGE_SESSION_ID = 15;
 
-    
+    /**
+     * Event type used when context manager doesn't exist.
+     * This is used when the manager which send a session state does not exist. 
+     */
+    public static final int EVT_ALL_SESSION_NOCONTEXTMANAGER = 16;
+
     public String getContextName();
     
     public String getEventTypeString();

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/SessionMessageImpl.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/SessionMessageImpl.java?rev=1195848&r1=1195847&r2=1195848&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/SessionMessageImpl.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/SessionMessageImpl.java Tue Nov
 1 07:00:21 2011
@@ -80,6 +80,9 @@ public class SessionMessageImpl extends 
      *    after GET_ALL_SESSION received from this sender.<BR>
      * <B>EVT_CHANGE_SESSION_ID</B><BR>
      *    send original sessionID and new sessionID.<BR>
+     * <B>EVT_ALL_SESSION_NOCONTEXTMANAGER</B><BR>
+     *    send that context manager does not exist
+     *    after GET_ALL_SESSION received from this sender.<BR>
      * @param contextName - the name of the context (application
      * @param eventtype - one of the 8 event type defined in this class
      * @param session - the serialized byte array of the session itself
@@ -142,6 +145,7 @@ public class SessionMessageImpl extends 
             case EVT_ALL_SESSION_DATA : return "ALL-SESSION-DATA";
             case EVT_ALL_SESSION_TRANSFERCOMPLETE : return "SESSION-STATE-TRANSFERED";
             case EVT_CHANGE_SESSION_ID : return "SESSION-ID-CHANGED";
+            case EVT_ALL_SESSION_NOCONTEXTMANAGER : return "NO-CONTEXT-MANAGER";
             default : return "UNKNOWN-EVENT-TYPE";
         }
     }

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/mbeans-descriptors.xml
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/mbeans-descriptors.xml?rev=1195848&r1=1195847&r2=1195848&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/mbeans-descriptors.xml (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/mbeans-descriptors.xml Tue Nov
 1 07:00:21 2011
@@ -172,6 +172,11 @@ created by this Manager"
       description="Number of sessions we rejected due to maxActive beeing reached"
       type="int"/>
     <attribute
+      name="noContextManagerReceived"
+      is="true"
+      description="Is no context manager message received? "
+      type="boolean"/>
+    <attribute
       name="expiredSessions"
       description="Number of sessions that expired ( doesn't include explicit invalidations
)"
       type="int"/>
@@ -226,7 +231,12 @@ created by this Manager"
       name="counterReceive_EVT_CHANGE_SESSION_ID"
       description="Count receive EVT_CHANGE_SESSION_ID messages"
       type="long"
-      writeable="false"/>  
+      writeable="false"/>
+    <attribute
+      name="counterReceive_EVT_ALL_SESSION_NOCONTEXTMANAGER"
+      description="Count receive EVT_ALL_SESSION_NOCONTEXTMANAGER messages"
+      type="long"
+      writeable="false"/>
     <attribute
       name="counterSend_EVT_GET_ALL_SESSIONS"
       description="Count send EVT_GET_ALL_SESSIONS messages"

Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=1195848&r1=1195847&r2=1195848&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Tue Nov  1 07:00:21 2011
@@ -166,6 +166,11 @@
         Fix unneeded duplicate <code>resetDeltaRequest()</code> call in
         <code>DeltaSession.setId(String)</code>. (kkolinko)
       </fix>
+      <add>
+        When Context manager does not exist, no context manager message is 
+        replied in order to avoid timeout (default 60 sec) of 
+        GET_ALL_SESSIONS sync phase. (kfujino)
+      </add>
     </changelog>
   </subsection>
   <subsection name="Webapps">



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


Mime
View raw message