[jboss-cvs] JBossAS SVN: r105599 - in trunk: testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jun 2 17:11:03 EDT 2010


Author: pferraro
Date: 2010-06-02 17:11:03 -0400 (Wed, 02 Jun 2010)
New Revision: 105599

Added:
   trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/ClusteringDefaultsTestCase.java
Modified:
   trunk/testsuite/imports/sections/cluster.xml
   trunk/tomcat/src/main/java/org/jboss/web/tomcat/service/session/JBossManager.java
   trunk/tomcat/src/main/java/org/jboss/web/tomcat/service/session/JvmRouteValve.java
   trunk/tomcat/src/resources/war-deployers-jboss-beans.xml
Log:
[JBAS-8052] Install JvmRouteValve into context pipeline by default in JBossCacheManager
Change default replication-config/use-jk to true.
JvmRouteValve no longer throws exception if no jvmRoute was defined.

Modified: trunk/testsuite/imports/sections/cluster.xml
===================================================================
--- trunk/testsuite/imports/sections/cluster.xml	2010-06-02 21:07:04 UTC (rev 105598)
+++ trunk/testsuite/imports/sections/cluster.xml	2010-06-02 21:11:03 UTC (rev 105599)
@@ -170,6 +170,18 @@
          </classes>
       </war>
 
+   	<!-- build http-default.war (copy of http-sr, w/out jboss-web.xml) -->
+    <war warfile="${build.lib}/http-default.war"
+         webxml="${build.resources}/cluster/http/http-sr/WEB-INF/web.xml">
+       <fileset dir="${build.resources}/cluster/http">
+          <include name="*.jsp"/>
+       </fileset>
+       <classes dir="${build.classes}">
+          <include name="org/jboss/test/cluster/web/BindingListener.class"/>
+          <include name="org/jboss/test/cluster/web/CacheHelper*"/>
+       </classes>
+    </war>
+   	
       <!-- build http-jk.jar -->
       <war warfile="${build.lib}/http-jk.war"
          webxml="${build.resources}/cluster/http/http-jk/WEB-INF/web.xml">

Added: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/ClusteringDefaultsTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/ClusteringDefaultsTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/ClusteringDefaultsTestCase.java	2010-06-02 21:11:03 UTC (rev 105599)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.cluster.defaultcfg.web.test;
+
+import java.util.List;
+
+import javax.management.Attribute;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import junit.framework.Assert;
+import junit.framework.Test;
+
+import org.jboss.metadata.web.jboss.ReplicationGranularity;
+import org.jboss.metadata.web.jboss.ReplicationTrigger;
+import org.jboss.metadata.web.jboss.SnapshotMode;
+import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.web.tomcat.service.deployers.ClusteringDefaultsDeployer;
+
+/**
+ * @author Paul Ferraro
+ *
+ */
+public class ClusteringDefaultsTestCase extends JBossClusteredTestCase
+{
+   public static Test suite() throws Exception
+   {
+      return JBossClusteredTestCase.getDeploySetup(ClusteringDefaultsTestCase.class, "http-default.war");
+   }
+
+   public ClusteringDefaultsTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testDefaults() throws Exception
+   {
+      ObjectName name = ObjectName.getInstance("jboss.web:type=Manager,host=localhost,path=/http-default");
+      MBeanServerConnection server = this.getServer();
+      
+      String[] names = new String[] {
+            "CacheConfigName",
+            "UseJK",
+            "ReplicationGranularity",
+            "ReplicationTrigger",
+            "SnapshotMode",
+            "SnapshotInterval",
+            "MaxUnreplicatedInterval",
+            "PassivationEnabled",
+            "PassivationMaxIdleTime",
+            "PassivationMinIdleTime"
+      };
+      
+      List<Attribute> attributes = server.getAttributes(name, names).asList();
+      
+      this.assertEquals(attributes.get(0), "CacheConfigName", "standard-session-cache");
+      this.assertEquals(attributes.get(1), "UseJK", Boolean.TRUE);
+      this.assertEquals(attributes.get(2), "ReplicationGranularity", ReplicationGranularity.SESSION);
+      this.assertEquals(attributes.get(3), "ReplicationTrigger", ReplicationTrigger.SET_AND_NON_PRIMITIVE_GET);
+      this.assertEquals(attributes.get(4), "SnapshotMode", SnapshotMode.INSTANT);
+      this.assertEquals(attributes.get(5), "SnapshotInterval", Integer.valueOf(1000));
+      this.assertEquals(attributes.get(6), "MaxUnreplicatedInterval", Integer.valueOf(60));
+      this.assertEquals(attributes.get(7), "PassivationEnabled", Boolean.FALSE);
+      this.assertEquals(attributes.get(8), "PassivationMaxIdleTime", Long.valueOf(ClusteringDefaultsDeployer.IGNORED));
+      this.assertEquals(attributes.get(9), "PassivationMinIdleTime", Long.valueOf(ClusteringDefaultsDeployer.IGNORED));
+   }
+   
+   private void assertEquals(Attribute attribute, String name, Object value)
+   {
+      Assert.assertEquals(name, attribute.getName());
+      Assert.assertEquals(name, value, attribute.getValue());
+   }
+}

Modified: trunk/tomcat/src/main/java/org/jboss/web/tomcat/service/session/JBossManager.java
===================================================================
--- trunk/tomcat/src/main/java/org/jboss/web/tomcat/service/session/JBossManager.java	2010-06-02 21:07:04 UTC (rev 105598)
+++ trunk/tomcat/src/main/java/org/jboss/web/tomcat/service/session/JBossManager.java	2010-06-02 21:11:03 UTC (rev 105599)
@@ -187,8 +187,8 @@
    /** Generates ids for new sessions */
    protected SessionIDGenerator sessionIDGenerator_= new SessionIDGenerator();;
 
-   /** Our containing engine's jvmRoute (if it has one) */
-   protected String jvmRoute_;
+   /** A reference to our engine, for obtaining jvmRoute */
+   protected Engine engine;
 
    /** Our JMX Server */
    protected MBeanServer mserver_ = null;
@@ -300,12 +300,7 @@
     */
    public String getJvmRoute()
    {
-      if (jvmRoute_ == null)
-      {
-         Engine e = getEngine();
-         jvmRoute_= (e == null ? null : e.getJvmRoute());
-      }
-      return jvmRoute_;
+      return (this.engine != null) ? this.engine.getJvmRoute() : null;
    }
 
    /**
@@ -456,6 +451,8 @@
             (((Context) this.container_).getSessionTimeout() * 60);
          this.container_.addPropertyChangeListener(this);
       }
+      
+      this.engine = getEngine();
    }
 
    /**

Modified: trunk/tomcat/src/main/java/org/jboss/web/tomcat/service/session/JvmRouteValve.java
===================================================================
--- trunk/tomcat/src/main/java/org/jboss/web/tomcat/service/session/JvmRouteValve.java	2010-06-02 21:07:04 UTC (rev 105598)
+++ trunk/tomcat/src/main/java/org/jboss/web/tomcat/service/session/JvmRouteValve.java	2010-06-02 21:11:03 UTC (rev 105599)
@@ -96,26 +96,20 @@
       if (session != null)
       {
          String sessionId = session.getId();
-
-         // Obtain JvmRoute
-         // FIXME do this once in constructor
          String jvmRoute = manager_.getJvmRoute();
+         
          if (log_.isTraceEnabled())
          {
             log_.trace("checkJvmRoute(): check if need to re-route based on JvmRoute. Session id: " +
                sessionId + " jvmRoute: " + jvmRoute);
          }
          
-         // FIXME do this once in the session manager's start()
-         if (jvmRoute == null)
+         if (jvmRoute != null)
          {
-            throw new RuntimeException("JvmRouteValve.checkJvmRoute(): Tomcat JvmRoute is null. " +
-               "Need to assign a value in Tomcat server.xml for load balancing.");
+            // Check if incoming session id has JvmRoute appended. If not, append it.
+            boolean setCookie = !req.isRequestedSessionIdFromURL();
+            handleJvmRoute(requestedId, sessionId, jvmRoute, res, setCookie);
          }
-
-         // Check if incoming session id has JvmRoute appended. If not, append it.
-         boolean setCookie = !req.isRequestedSessionIdFromURL();
-         handleJvmRoute(requestedId, sessionId, jvmRoute, res, setCookie);
       }
    }
 
@@ -210,8 +204,7 @@
    private void resetSessionId(String oldId, String newId)
          throws IOException
    {
-      @SuppressWarnings("unchecked")
-      ClusteredSession<? extends OutgoingDistributableSessionData> session = (ClusteredSession) manager_.findSession(oldId);
+      ClusteredSession<? extends OutgoingDistributableSessionData> session = (ClusteredSession<?>) manager_.findSession(oldId);
       // change session id with the new one using local jvmRoute.
       if( session != null )
       {

Modified: trunk/tomcat/src/resources/war-deployers-jboss-beans.xml
===================================================================
--- trunk/tomcat/src/resources/war-deployers-jboss-beans.xml	2010-06-02 21:07:04 UTC (rev 105598)
+++ trunk/tomcat/src/resources/war-deployers-jboss-beans.xml	2010-06-02 21:11:03 UTC (rev 105599)
@@ -115,9 +115,8 @@
       to configure this overall default is to set it to 'false' and thus force
       per webapp configuration.
       -->
+      <property name="useJK">true</property>
       <!-- 
-      <property name="useJK">false</property>
-      
       <property name="useSessionPassivation">false</property>
       <property name="passivationMaxIdleTime">-1</property>  
       <property name="passivationMinIdleTime">-1</property>




More information about the jboss-cvs-commits mailing list