Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49407
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 29 Jul 2010 18:32:58 +0000 (18:32 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 29 Jul 2010 18:32:58 +0000 (18:32 +0000)
Make BackupManager and DeltaManager handle primary and backup sessions consistently

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@980535 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/session/ManagerBase.java
java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
webapps/docs/changelog.xml

index 78299af..749bff0 100644 (file)
@@ -772,7 +772,7 @@ public abstract class ManagerBase extends LifecycleMBeanBase
     public void add(Session session) {
 
         sessions.put(session.getIdInternal(), session);
-        int size = sessions.size();
+        int size = getActiveSessions();
         if( size > maxActive ) {
             synchronized(maxActiveUpdateLock) {
                 if( size > maxActive ) {
@@ -811,7 +811,7 @@ public abstract class ManagerBase extends LifecycleMBeanBase
     public Session createSession(String sessionId) {
         
         if ((maxActiveSessions >= 0) &&
-                (sessions.size() >= maxActiveSessions)) {
+                (getActiveSessions() >= maxActiveSessions)) {
             rejectedSessions++;
             throw new IllegalStateException(
                     sm.getString("managerBase.createSession.ise"));
index b089dc7..b6d827a 100644 (file)
@@ -998,7 +998,7 @@ public abstract class AbstractReplicatedMap extends ConcurrentHashMap implements
                 while (i.hasNext()) {
                     Map.Entry<?,?> e = i.next();
                     MapEntry entry = (MapEntry) super.get(e.getKey());
-                    if (entry!=null && entry.isPrimary() && value.equals(entry.getValue())) return true;
+                    if (entry!=null && entry.isActive() && value.equals(entry.getValue())) return true;
                 }//while
                 return false;
             }//end if
@@ -1035,7 +1035,7 @@ public abstract class AbstractReplicatedMap extends ConcurrentHashMap implements
                 Map.Entry<?,?> e = i.next();
                 Object key = e.getKey();
                 MapEntry entry = (MapEntry)super.get(key);
-                if ( entry != null && entry.isPrimary() ) {
+                if ( entry != null && entry.isActive() ) {
                     set.add(new MapEntry(key, entry.getValue()));
                 }
             }
@@ -1052,7 +1052,7 @@ public abstract class AbstractReplicatedMap extends ConcurrentHashMap implements
                 Map.Entry<?,?> e = i.next();
                 Object key = e.getKey();
                 MapEntry entry = (MapEntry)super.get(key);
-                if ( entry!=null && entry.isPrimary() ) set.add(key);
+                if ( entry!=null && entry.isActive() ) set.add(key);
             }
             return Collections.unmodifiableSet(set);
 
@@ -1069,7 +1069,7 @@ public abstract class AbstractReplicatedMap extends ConcurrentHashMap implements
                 Map.Entry<?,?> e = it.next();
                 if ( e != null ) {
                     MapEntry entry = (MapEntry) super.get(e.getKey());
-                    if (entry!=null && entry.isPrimary() && entry.getValue() != null) counter++;
+                    if (entry!=null && entry.isActive() && entry.getValue() != null) counter++;
                 }
             }
             return counter;
@@ -1087,7 +1087,7 @@ public abstract class AbstractReplicatedMap extends ConcurrentHashMap implements
             while ( i.hasNext() ) {
                 Map.Entry<?,?> e = i.next();
                 MapEntry entry = (MapEntry)super.get(e.getKey());
-                if (entry!=null && entry.isPrimary() && entry.getValue()!=null) values.add(entry.getValue());
+                if (entry!=null && entry.isActive() && entry.getValue()!=null) values.add(entry.getValue());
             }
             return Collections.unmodifiableCollection(values);
         }
@@ -1135,9 +1135,13 @@ public abstract class AbstractReplicatedMap extends ConcurrentHashMap implements
         }
 
         public boolean isPrimary() {
-            return ( (!proxy) && (!backup));
+            return (!proxy && !backup);
         }
 
+        public boolean isActive() {
+            return !proxy;
+        }
+        
         public void setProxy(boolean proxy) {
             this.proxy = proxy;
         }
index ac012c5..a2c2ffa 100644 (file)
         <code>SimpleTcpReplicationManager.startInternal()</code>. (markt)
       </fix>
       <fix>
+        <bug>49407</bug>: Change the BackupManager so it is consistent with
+        DeltaManager and reports both primary and backup sessions when active
+        sessions are requested. (markt)
+      </fix>
+      <fix>
         <bug>49445</bug>: When session ID is changed after authentication,
         ensure the DeltaManager replicates the change in ID to the other nodes
         in the cluster. (kfujino)