tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1382850 - in /tomcat/sandbox/trunk-resources: ./ java/org/apache/catalina/ java/org/apache/catalina/session/ java/org/apache/catalina/startup/ webapps/manager/WEB-INF/
Date Mon, 10 Sep 2012 13:56:41 GMT
Author: markt
Date: Mon Sep 10 13:56:41 2012
New Revision: 1382850

URL: http://svn.apache.org/viewvc?rev=1382850&view=rev
Log:
Merge changes from trunk

Modified:
    tomcat/sandbox/trunk-resources/   (props changed)
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/DistributedManager.java
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/StoreManager.java
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/session/LocalStrings.properties
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/session/PersistentManagerBase.java
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/startup/HostConfig.java
    tomcat/sandbox/trunk-resources/webapps/manager/WEB-INF/web.xml

Propchange: tomcat/sandbox/trunk-resources/
------------------------------------------------------------------------------
    svn:mergeinfo = /tomcat/trunk:1382517-1382847

Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/DistributedManager.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/DistributedManager.java?rev=1382850&r1=1382849&r2=1382850&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/DistributedManager.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/DistributedManager.java Mon Sep
10 13:56:41 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/sandbox/trunk-resources/java/org/apache/catalina/StoreManager.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/StoreManager.java?rev=1382850&r1=1382849&r2=1382850&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/StoreManager.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/StoreManager.java Mon Sep 10 13:56:41
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/sandbox/trunk-resources/java/org/apache/catalina/session/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/session/LocalStrings.properties?rev=1382850&r1=1382849&r2=1382850&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/session/LocalStrings.properties
(original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/session/LocalStrings.properties
Mon Sep 10 13:56:41 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/sandbox/trunk-resources/java/org/apache/catalina/session/PersistentManagerBase.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/session/PersistentManagerBase.java?rev=1382850&r1=1382849&r2=1382850&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/session/PersistentManagerBase.java
(original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/session/PersistentManagerBase.java
Mon Sep 10 13:56:41 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/sandbox/trunk-resources/java/org/apache/catalina/startup/HostConfig.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/startup/HostConfig.java?rev=1382850&r1=1382849&r2=1382850&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/startup/HostConfig.java (original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/startup/HostConfig.java Mon Sep
10 13:56:41 2012
@@ -47,6 +47,7 @@ import javax.management.ObjectName;
 
 import org.apache.catalina.Container;
 import org.apache.catalina.Context;
+import org.apache.catalina.DistributedManager;
 import org.apache.catalina.Host;
 import org.apache.catalina.Lifecycle;
 import org.apache.catalina.LifecycleEvent;
@@ -1429,21 +1430,31 @@ public class HostConfig
                         currentContext.getState().isAvailable() &&
                         !isServiced(previous.getName())) {
                     Manager manager = previousContext.getManager();
-                    if (manager != null && manager.getActiveSessions() == 0) {
-                        if (log.isInfoEnabled()) {
-                            log.info(sm.getString("hostConfig.undeployVersion",
-                                    previous.getName()));
+                    if (manager != null) {
+                        int sessionCount;
+                        if (manager instanceof DistributedManager) {
+                            sessionCount = ((DistributedManager)
+                                    manager).getActiveSessionsFull();
+                        } else {
+                            sessionCount = manager.getActiveSessions();
+                        }
+                        if (sessionCount == 0) {
+                            if (log.isInfoEnabled()) {
+                                log.info(sm.getString(
+                                        "hostConfig.undeployVersion",
+                                        previous.getName()));
+                            }
+                            DeployedApplication app =
+                                    deployed.get(previous.getName());
+                            String[] resources =
+                                    app.redeployResources.keySet().toArray(
+                                            new String[0]);
+                            // Version is unused - undeploy it completely
+                            // The -1 is a 'trick' to ensure all redeploy
+                            // resources are removed
+                            deleteRedeployResources(app, resources, -1,
+                                    true);
                         }
-                        DeployedApplication app =
-                                deployed.get(previous.getName());
-                        String[] resources =
-                                app.redeployResources.keySet().toArray(
-                                        new String[0]);
-                        // Version is unused - undeploy it completely
-                        // The -1 is a 'trick' to ensure all redeploy resources
-                        // are removed
-                        deleteRedeployResources(app, resources, -1,
-                                true);
                     }
                 }
             }

Modified: tomcat/sandbox/trunk-resources/webapps/manager/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/webapps/manager/WEB-INF/web.xml?rev=1382850&r1=1382849&r2=1382850&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/webapps/manager/WEB-INF/web.xml (original)
+++ tomcat/sandbox/trunk-resources/webapps/manager/WEB-INF/web.xml Mon Sep 10 13:56:41 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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message