tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r451343 - in /tomcat/tc6.0.x/trunk: conf/ java/org/apache/catalina/ java/org/apache/catalina/core/ java/org/apache/catalina/ha/ java/org/apache/catalina/ha/session/ java/org/apache/catalina/ha/tcp/ java/org/apache/catalina/tribes/
Date Fri, 29 Sep 2006 16:32:33 GMT
Author: fhanik
Date: Fri Sep 29 09:32:32 2006
New Revision: 451343

URL: http://svn.apache.org/viewvc?view=rev&rev=451343
Log:
Update configurations options, this new feature allows a specific <Context> to overwrite
what cluster manager is used by specifying a <Manager> element inside the context element
and the cluster will be notified of it.
This allows for a cleaner config, as the cluster does no longer have to forward all manager
settings, and allows documentation to be much clearer on what settings are available.


Modified:
    tomcat/tc6.0.x/trunk/conf/server.xml
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/Cluster.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardContext.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterManager.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterRuleSet.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/BackupManager.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/SimpleTcpReplicationManager.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/MembershipListener.java

Modified: tomcat/tc6.0.x/trunk/conf/server.xml
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/conf/server.xml?view=diff&rev=451343&r1=451342&r2=451343
==============================================================================
--- tomcat/tc6.0.x/trunk/conf/server.xml (original)
+++ tomcat/tc6.0.x/trunk/conf/server.xml Fri Sep 29 09:32:32 2006
@@ -192,11 +192,11 @@
         -->
         
         <!--
-        <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
-	         managerClassName="org.apache.catalina.cluster.session.DeltaManager"
-                 expireSessionsOnShutdown="false"
-                 useDirtyFlag="true"
-                 notifyListenersOnReplication="true">
+        <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster">
+          <Manager className="org.apache.catalina.ha.session.DeltaManager"
+                   expireSessionsOnShutdown="false"
+                   notifyListenersOnReplication="true"/>
+        
           <Channel className="org.apache.catalina.tribes.group.GroupChannel">
             <Membership className="org.apache.catalina.tribes.membership.McastService"
                         mcastAddr="228.0.0.4"
@@ -215,7 +215,7 @@
             <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
             <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
             <Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>
-	  </Channel>
+          </Channel>
 
           <Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
                  filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"/>

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/Cluster.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/Cluster.java?view=diff&rev=451343&r1=451342&r2=451343
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/Cluster.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/Cluster.java Fri Sep 29 09:32:32 2006
@@ -100,6 +100,14 @@
      * associated
      */
     public Manager createManager(String name);
+    
+    /**
+     * Register a manager with the cluster. If the cluster is not responsible 
+     * for creating a manager, then the container will at least notify the 
+     * cluster that this mananger is participating in the cluster.
+     * @param manager Manager
+     */
+    public void registerManager(Manager manager);
 
     // --------------------------------------------------------- Cluster Wide Deployments
     

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardContext.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardContext.java?view=diff&rev=451343&r1=451342&r2=451343
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardContext.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardContext.java Fri Sep 29 09:32:32
2006
@@ -4193,6 +4193,10 @@
         	} else {
         		contextManager = new StandardManager();
         	}
+        } else if ((getCluster() != null) && distributable) {
+            //let the cluster know that there is a context that is distributable
+            //and that it has its own manager
+            getCluster().registerManager(manager);
         }
         
         

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterManager.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterManager.java?view=diff&rev=451343&r1=451342&r2=451343
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterManager.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterManager.java Fri Sep 29 09:32:32
2006
@@ -107,4 +107,5 @@
    
    public boolean isNotifyListenersOnReplication();
 
+   public ClusterManager cloneFromTemplate();
 }

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterRuleSet.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterRuleSet.java?view=diff&rev=451343&r1=451342&r2=451343
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterRuleSet.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterRuleSet.java Fri Sep 29 09:32:32
2006
@@ -85,7 +85,16 @@
      */
     public void addRuleInstances(Digester digester) {
         //Cluster configuration start
+        digester.addObjectCreate(prefix + "Manager",
+                                 null, // MUST be specified in the element
+                                 "className");
+        digester.addSetProperties(prefix + "Manager");
+        digester.addSetNext(prefix + "Manager",
+                            "setManagerTemplate",
+                            "org.apache.catalina.ha.ClusterManager");
         
+
+
         digester.addObjectCreate(prefix + "Channel",
                                  null, // MUST be specified in the element
                                  "className");

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/BackupManager.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/BackupManager.java?view=diff&rev=451343&r1=451342&r2=451343
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/BackupManager.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/BackupManager.java Fri Sep 29
09:32:32 2006
@@ -19,16 +19,14 @@
 import java.io.IOException;
 
 import org.apache.catalina.LifecycleException;
-import org.apache.catalina.Loader;
 import org.apache.catalina.Session;
 import org.apache.catalina.ha.CatalinaCluster;
 import org.apache.catalina.ha.ClusterManager;
 import org.apache.catalina.ha.ClusterMessage;
 import org.apache.catalina.session.StandardManager;
-import org.apache.catalina.tribes.Member;
+import org.apache.catalina.tribes.Channel;
 import org.apache.catalina.tribes.io.ReplicationStream;
 import org.apache.catalina.tribes.tipis.LazyReplicatedMap;
-import org.apache.catalina.tribes.Channel;
 
 /**
  *@author Filip Hanik
@@ -266,6 +264,16 @@
 
     public String[] getInvalidatedSessions() {
         return new String[0];
+    }
+    
+    public ClusterManager cloneFromTemplate() {
+        BackupManager result = new BackupManager();
+        result.mExpireSessionsOnShutdown = mExpireSessionsOnShutdown;
+        result.name = "Clone-from-"+name;
+        result.cluster = cluster;
+        result.notifyListenersOnReplication = notifyListenersOnReplication;
+        result.mapSendOptions = mapSendOptions;
+        return result;
     }
 
 }

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?view=diff&rev=451343&r1=451342&r2=451343
==============================================================================
--- 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 Fri Sep 29
09:32:32 2006
@@ -43,6 +43,7 @@
 import org.apache.catalina.tribes.io.ReplicationStream;
 import org.apache.catalina.util.LifecycleSupport;
 import org.apache.catalina.util.StringManager;
+import org.apache.catalina.ha.ClusterManager;
 
 /**
  * The DeltaManager manages replicated sessions by only replicating the deltas
@@ -1496,4 +1497,23 @@
         cluster.send(newmsg, sender);
     }
 
+    public ClusterManager cloneFromTemplate() {
+        DeltaManager result = new DeltaManager();
+        result.name = "Clone-from-"+name;
+        result.cluster = cluster;
+        result.replicationValve = replicationValve;
+        result.maxActiveSessions = maxActiveSessions;
+        result.expireSessionsOnShutdown = expireSessionsOnShutdown;
+        result.notifyListenersOnReplication = notifyListenersOnReplication;
+        result.notifySessionListenersOnReplication = notifySessionListenersOnReplication;
+        result.stateTransferTimeout = stateTransferTimeout;
+        result.sendAllSessions = sendAllSessions;
+        result.sendClusterDomainOnly = sendClusterDomainOnly ;
+        result.sendAllSessionsSize = sendAllSessionsSize;
+        result.sendAllSessionsWaitTime = sendAllSessionsWaitTime ; 
+        result.receiverQueue = receiverQueue ;
+        result.stateTimestampDrop = stateTimestampDrop ;
+        result.stateTransferCreateSendTime = stateTransferCreateSendTime; 
+        return result;
+    }
 }

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/SimpleTcpReplicationManager.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/SimpleTcpReplicationManager.java?view=diff&rev=451343&r1=451342&r2=451343
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/SimpleTcpReplicationManager.java
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/SimpleTcpReplicationManager.java
Fri Sep 29 09:32:32 2006
@@ -687,4 +687,8 @@
         return cluster;
     }
 
+    public ClusterManager cloneFromTemplate() {
+        throw new UnsupportedOperationException();
+    }
+
 }

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java?view=diff&rev=451343&r1=451342&r2=451343
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java Fri Sep 29
09:32:32 2006
@@ -37,18 +37,17 @@
 import org.apache.catalina.Manager;
 import org.apache.catalina.Valve;
 import org.apache.catalina.ha.CatalinaCluster;
-import org.apache.catalina.tribes.Channel;
-import org.apache.catalina.tribes.ChannelListener;
 import org.apache.catalina.ha.ClusterListener;
 import org.apache.catalina.ha.ClusterManager;
 import org.apache.catalina.ha.ClusterMessage;
 import org.apache.catalina.ha.ClusterValve;
+import org.apache.catalina.ha.session.DeltaManager;
+import org.apache.catalina.ha.util.IDynamicProperty;
+import org.apache.catalina.tribes.Channel;
+import org.apache.catalina.tribes.ChannelListener;
 import org.apache.catalina.tribes.Member;
 import org.apache.catalina.tribes.MembershipListener;
 import org.apache.catalina.tribes.group.GroupChannel;
-
-import org.apache.catalina.ha.session.DeltaManager;
-import org.apache.catalina.ha.util.IDynamicProperty;
 import org.apache.catalina.util.LifecycleSupport;
 import org.apache.catalina.util.StringManager;
 import org.apache.commons.logging.Log;
@@ -147,8 +146,7 @@
      */
     protected Map managers = new HashMap();
 
-    private String managerClassName = "org.apache.catalina.ha.session.DeltaManager";
-
+    protected ClusterManager managerTemplate = new DeltaManager();
 
     private List valves = new ArrayList();
 
@@ -252,14 +250,20 @@
                 this.notifyLifecycleListenerOnFailure);
     }
 
+    /**
+     * @deprecated use getManagerTemplate().getClass().getName() instead.
+     * @return String
+     */
     public String getManagerClassName() {
-        if(managerClassName != null)
-            return managerClassName;
-        return (String)getProperty("manager.className");
+        return managerTemplate.getClass().getName();
     }
 
+    /**
+     * @deprecated use nested &lt;Manager&gt; element inside the cluster config instead.
+     * @param managerClassName String
+     */
     public void setManagerClassName(String managerClassName) {
-        this.managerClassName = managerClassName;
+        log.warn("setManagerClassName is deprecated, use nested <Manager> element inside
the <Cluster> element instead, this request will be ignored.");
     }
 
     /**
@@ -337,6 +341,10 @@
         this.channel = channel;
     }
 
+    public void setManagerTemplate(ClusterManager managerTemplate) {
+        this.managerTemplate = managerTemplate;
+    }
+
     /**
      * has members
      */
@@ -465,6 +473,10 @@
         return channel;
     }
 
+    public ClusterManager getManagerTemplate() {
+        return managerTemplate;
+    }
+
     /**
      * Create new Manager without add to cluster (comes with start the manager)
      * 
@@ -477,26 +489,25 @@
     public synchronized Manager createManager(String name) {
         if (log.isDebugEnabled()) log.debug("Creating ClusterManager for context " + name
+ " using class " + getManagerClassName());
         Manager manager = null;
-        ClassLoader oldCtxLoader = Thread.currentThread().getContextClassLoader();
         try {
-            Thread.currentThread().setContextClassLoader(SimpleTcpCluster.class.getClassLoader());
-            manager = (Manager) getClass().getClassLoader().loadClass(getManagerClassName()).newInstance();
+            manager = managerTemplate.cloneFromTemplate();
         } catch (Exception x) {
-            log.error("Unable to load class for replication manager", x);
+            log.error("Unable to clone cluster manager, defaulting to org.apache.catalina.ha.session.DeltaManager",
x);
             manager = new org.apache.catalina.ha.session.DeltaManager();
         } finally {
-            Thread.currentThread().setContextClassLoader(oldCtxLoader);
-            if(manager != null) {
-                manager.setDistributable(true);
-                if (manager instanceof ClusterManager) {
-                    ClusterManager cmanager = (ClusterManager) manager ;
-                    cmanager.setDefaultMode(true);
-                    cmanager.setName(getManagerName(name,manager));
-                    cmanager.setCluster(this);
-                }
-            }
+            if(manager != null) registerManager(manager);
         }
         return manager;
+    }
+    
+    public void registerManager(Manager manager) {
+        manager.setDistributable(true);
+        if (manager instanceof ClusterManager) {
+            ClusterManager cmanager = (ClusterManager) manager ;
+            cmanager.setDefaultMode(true);
+            cmanager.setName(getManagerName(((ClusterManager)manager).getName(),manager));
+            cmanager.setCluster(this);
+        }
     }
 
     /**

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/MembershipListener.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/MembershipListener.java?view=diff&rev=451343&r1=451342&r2=451343
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/MembershipListener.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/MembershipListener.java Fri Sep 29
09:32:32 2006
@@ -35,7 +35,7 @@
     
     /**
      * A member was removed from the group<br>
-     * If the member left voluntarily, the payload will contain the Member.SHUTDOWN_PAYLOAD
data
+     * If the member left voluntarily, the Member.getCommand will contain the Member.SHUTDOWN_PAYLOAD
data
      * @param member Member
      * @see Member#SHUTDOWN_PAYLOAD
      */



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


Mime
View raw message