Author: markt
Date: Mon Sep 10 13:36:12 2012
New Revision: 1382832

URL: http://svn.apache.org/viewvc?rev=1382832&view=rev
Log:
Make sessions in the session Store visible via the Manager web application if 
showProxySessions is enabled

Modified:
    tomcat/trunk/java/org/apache/catalina/DistributedManager.java
    tomcat/trunk/java/org/apache/catalina/StoreManager.java
    tomcat/trunk/java/org/apache/catalina/session/LocalStrings.properties
    tomcat/trunk/java/org/apache/catalina/session/PersistentManagerBase.java
    tomcat/trunk/webapps/manager/WEB-INF/web.xml

Modified: tomcat/trunk/java/org/apache/catalina/DistributedManager.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/DistributedManager.java?rev=1382832&r1=1382831&r2=1382832&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/DistributedManager.java (original)
+++ tomcat/trunk/java/org/apache/catalina/DistributedManager.java Mon Sep 10 
13:36:12 2012
@@ -21,11 +21,17 @@ import java.util.Set;
 
 /**
  * Interface implemented by session managers that do not keep a complete copy
- * of all sessions on the local node but do know where every session is. The
- * BackupManager is an example of such a Manager. Sessions can be primary
- * (master copy on this node), backup (backup copy on this node) or proxy (only
- * the session ID on this node). The identity of the primary and backup nodes
- * are known for all sessions, including proxy sessions.
+ * of all sessions in memory but do know where every session is. The
+ * BackupManager is an example of such a Manager as are implementations of the
+ * StoreManager interface.
+ * <p>
+ * With the BackupManager, sessions can be primary (master copy on this node),
+ * backup (backup copy on this node) or proxy (only the session ID on this
+ * node). The identity of the primary and backup nodes are known for all
+ * sessions, including proxy sessions.
+ * <p>
+ * With StoreManager implementations, sessions can be primary (session is in
+ * memory) or proxy (session is in the Store).
  */
 public interface DistributedManager {
 

Modified: tomcat/trunk/java/org/apache/catalina/StoreManager.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/StoreManager.java?rev=1382832&r1=1382831&r2=1382832&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/StoreManager.java (original)
+++ tomcat/trunk/java/org/apache/catalina/StoreManager.java Mon Sep 10 13:36:12 
2012
@@ -20,7 +20,7 @@ package org.apache.catalina;
  * PersistentManager would have been a better name but that would have clashed
  * with the implementation name.
  */
-public interface StoreManager {
+public interface StoreManager extends DistributedManager {
 
     /**
      * Return the Store object which manages persistent Session

Modified: tomcat/trunk/java/org/apache/catalina/session/LocalStrings.properties
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/LocalStrings.properties?rev=1382832&r1=1382831&r2=1382832&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/session/LocalStrings.properties 
(original)
+++ tomcat/trunk/java/org/apache/catalina/session/LocalStrings.properties Mon 
Sep 10 13:36:12 2012
@@ -69,4 +69,6 @@ persistentManager.tooManyActive=Too many
 persistentManager.swapTooManyActive=Swapping out session {0}, idle for {1} 
seconds too many sessions active
 persistentManager.swapIn=Swapping session {0} in from Store
 persistentManager.swapInException=Exception in the Store during swapIn: {0}
-persistentManager.swapInInvalid=Swapped session {0} is invalid
\ No newline at end of file
+persistentManager.swapInInvalid=Swapped session {0} is invalid
+persistentManager.storeKeysException=Unable to determine the list of session 
IDs for sessions in the session store, assuming that the store is empty
+persistentManager.storeSizeException=Unable to determine the number of 
sessions in the session store, assuming that the store is empty
\ No newline at end of file

Modified: 
tomcat/trunk/java/org/apache/catalina/session/PersistentManagerBase.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/PersistentManagerBase.java?rev=1382832&r1=1382831&r2=1382832&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/session/PersistentManagerBase.java 
(original)
+++ tomcat/trunk/java/org/apache/catalina/session/PersistentManagerBase.java 
Mon Sep 10 13:36:12 2012
@@ -23,7 +23,9 @@ import java.security.AccessController;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.catalina.Lifecycle;
 import org.apache.catalina.LifecycleException;
@@ -629,8 +631,40 @@ public abstract class PersistentManagerB
     }
 
 
-    // ------------------------------------------------------ Protected Methods
+    @Override
+    public int getActiveSessionsFull() {
+        // In memory session count
+        int result = getActiveSessions();
+        try {
+            // Store session count
+            result += getStore().getSize();
+        } catch (IOException ioe) {
+            log.warn(sm.getString("persistentManager.storeSizeException"));
+        }
+        return result;
+    }
+
 
+    @Override
+    public Set<String> getSessionIdsFull() {
+        Set<String> sessionIds = new HashSet<>();
+        // In memory session ID list
+        sessionIds.addAll(sessions.keySet());
+        // Store session ID list
+        String[] storeKeys;
+        try {
+            storeKeys = getStore().keys();
+            for (String storeKey : storeKeys) {
+                sessionIds.add(storeKey);
+            }
+        } catch (IOException e) {
+            log.warn(sm.getString("persistentManager.storeKeysException"));
+        }
+        return sessionIds;
+    }
+
+
+    // ------------------------------------------------------ Protected Methods
 
     /**
      * Look for a session in the Store and, if found, restore

Modified: tomcat/trunk/webapps/manager/WEB-INF/web.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/manager/WEB-INF/web.xml?rev=1382832&r1=1382831&r2=1382832&view=diff
==============================================================================
--- tomcat/trunk/webapps/manager/WEB-INF/web.xml (original)
+++ tomcat/trunk/webapps/manager/WEB-INF/web.xml Mon Sep 10 13:36:12 2012
@@ -44,8 +44,8 @@
       <param-name>debug</param-name>
       <param-value>2</param-value>
     </init-param>
-    <!-- Uncomment this to show proxy sessions from the Backup manager in the
-         sessions list for an application
+    <!-- Uncomment this to show proxy sessions from the Backup manager or a
+         StoreManager in the sessions list for an application
     <init-param>
       <param-name>showProxySessions</param-name>
       <param-value>true</param-value>



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

Reply via email to