shuber 2005/12/07 15:26:49 CET
Modified files:
core/src/java/org/jahia/hibernate/manager
SpringContextSingleton.java
core/src/webapp/WEB-INF/etc/config jahia.skeleton
core/src/webapp/WEB-INF/etc/spring
applicationcontext-basejahiaconfig.xml
applicationcontext-compass.xml
applicationcontext-dao.xml
applicationcontext-services.xml
core/src/webapp/html/startup howto_cluster.html
Log:
- Introducing the possibility to use values from jahia.properties in the
Spring configuration files, for example :
<property name="activated">
<value>${cluster.activated}</value>
</property>
Unfortunately this only works with property values, but it should already
help regroup configuration settings into one file.
- Moved part of the cluster configuration into the jahia.properties file
- Updated HOWTO documentation to reflect moved settings.
Revision Changes Path
1.14 +12 -1
jahia/core/src/java/org/jahia/hibernate/manager/SpringContextSingleton.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/hibernate/manager/SpringContextSingleton.java.diff?r1=1.13&r2=1.14&f=h
1.27 +21 -0 jahia/core/src/webapp/WEB-INF/etc/config/jahia.skeleton
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/webapp/WEB-INF/etc/config/jahia.skeleton.diff?r1=1.26&r2=1.27&f=h
1.8 +3 -6
jahia/core/src/webapp/WEB-INF/etc/spring/applicationcontext-basejahiaconfig.xml
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/webapp/WEB-INF/etc/spring/applicationcontext-basejahiaconfig.xml.diff?r1=1.7&r2=1.8&f=h
1.2 +0 -3
jahia/core/src/webapp/WEB-INF/etc/spring/applicationcontext-compass.xml
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/webapp/WEB-INF/etc/spring/applicationcontext-compass.xml.diff?r1=1.1&r2=1.2&f=h
1.10 +1 -1
jahia/core/src/webapp/WEB-INF/etc/spring/applicationcontext-dao.xml
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/webapp/WEB-INF/etc/spring/applicationcontext-dao.xml.diff?r1=1.9&r2=1.10&f=h
1.19 +3 -3
jahia/core/src/webapp/WEB-INF/etc/spring/applicationcontext-services.xml
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/webapp/WEB-INF/etc/spring/applicationcontext-services.xml.diff?r1=1.18&r2=1.19&f=h
1.19 +15 -24 jahia/core/src/webapp/html/startup/howto_cluster.html
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/webapp/html/startup/howto_cluster.html.diff?r1=1.18&r2=1.19&f=h
Index: SpringContextSingleton.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/hibernate/manager/SpringContextSingleton.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- SpringContextSingleton.java 2 Sep 2005 10:18:59 -0000 1.13
+++ SpringContextSingleton.java 7 Dec 2005 14:26:48 -0000 1.14
@@ -11,6 +11,9 @@
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
+import java.io.File;
+import java.io.IOException;
+
public class SpringContextSingleton {
private static SpringContextSingleton ourInstance = null;
@@ -37,11 +40,19 @@
}
public void init() {
+ final String springPath =
pathResolver.resolvePath(springRelativePath);
+ String relativeApplicationRoot = pathResolver.resolvePath("/");
+ try {
+ String absApplicationRoot = new
File(relativeApplicationRoot).getCanonicalPath();
+ System.setProperty("jahiaWebAppRoot", absApplicationRoot);
+ } catch (IOException ioe) {
+ logger.warn("Couldn't resolve jahiaWebAppRoot path, defaulting
to empty string (which will most probably cause errors) !");
+ System.setProperty("jahiaWebAppRoot", "");
+ }
GenericApplicationContext parentAppContext = new
GenericApplicationContext();
parentAppContext.getBeanFactory().registerSingleton("settingsBean",
settingsBean);
parentAppContext.refresh();
try {
- final String springPath =
pathResolver.resolvePath(springRelativePath);
String[] paths = {"file:" + springPath +
"/applicationcontext-*.xml"};
context = new FileSystemXmlApplicationContext(paths, true,
parentAppContext);
} catch (Throwable e) {
Index: jahia.skeleton
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/webapp/WEB-INF/etc/config/jahia.skeleton,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- jahia.skeleton 9 Nov 2005 11:18:05 -0000 1.26
+++ jahia.skeleton 7 Dec 2005 14:26:48 -0000 1.27
@@ -391,6 +391,27 @@
# The timeout value is in milliseconds.
siteServerNameTestConnectTimeout = 500
+### Cluster settings ################
+
+# Use this setting to activate most of the clustering communicating
+cluster.activated = false
+
+# the serverId MUST be different for each node of the cluster.
+cluster.node.serverId = jahiaServer1
+
+# The following settings may be changed in order to avoid conflicts with
+# existing multicast IP broadcasts on a network, or to change them to
+# address ranges that are properly routed by the network hardware. The
+# default values comply with the IANA address space
+# (http://www.iana.org/assignments/multicast-addresses).
+# Check out the assignement ranges to see if they may conflict with
+# something that might be present on your network.
+cluster.service.multicast.ip_address = 231.12.21.130
+cluster.service.multicast.port = 45000
+cluster.idgenerator.multicast.ip_address = 231.12.21.150
+cluster.idgenerator.multicast.port = 45020
+
+
### Jahia Services ##################
# You should never need to change these unless you are doing some
customizations
# to Jahia and want to replace a default service implementation.
Index: applicationcontext-basejahiaconfig.xml
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/webapp/WEB-INF/etc/spring/applicationcontext-basejahiaconfig.xml,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- applicationcontext-basejahiaconfig.xml 9 Nov 2005 11:00:36 -0000
1.7
+++ applicationcontext-basejahiaconfig.xml 7 Dec 2005 14:26:48 -0000
1.8
@@ -10,12 +10,10 @@
<!-- property placeholder post-processor -->
- <!--
- <bean id="placeholderConfig"
-
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <property name="location" value="/WEB-INF/etc/config/jahia.properties"/>
+ <!-- jahiaWebAppRoot is built by the SpringSingleton and passed as a
system property -->
+ <bean id="placeholderConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property
name="location"><value>file:///${jahiaWebAppRoot}/WEB-INF/etc/config/jahia.properties</value></property>
</bean>
- -->
<!-- configuration bean -->
<bean id="jahiaConfigBean" class="org.jahia.bin.JahiaConfig">
@@ -124,5 +122,4 @@
<bean id="org.jahia.gui.menuIdPropsBean"
class="org.jahia.gui.menuIdPropsBean" />
-
</beans>
Index: applicationcontext-compass.xml
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/webapp/WEB-INF/etc/spring/applicationcontext-compass.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- applicationcontext-compass.xml 30 Sep 2005 15:34:08 -0000 1.1
+++ applicationcontext-compass.xml 7 Dec 2005 14:26:48 -0000 1.2
@@ -3,9 +3,6 @@
<beans>
- <bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- </bean>
-
<!-- Compass -->
<bean id="compass" class="org.compassframework.spring.LocalCompassBean">
<property name="resourceLocations">
Index: applicationcontext-dao.xml
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/webapp/WEB-INF/etc/spring/applicationcontext-dao.xml,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- applicationcontext-dao.xml 1 Dec 2005 11:08:59 -0000 1.9
+++ applicationcontext-dao.xml 7 Dec 2005 14:26:48 -0000 1.10
@@ -222,7 +222,7 @@
<ref bean="sessionFactory"/>
</property>
<property name="clusterActivated">
- <value>false</value>
+ <value>${cluster.activated}</value>
</property>
<property name="clusterProperties">
<value>UDP(mcast_addr=231.12.21.150;mcast_port=45020;ip_ttl=32;mcast_send_buf_size=1000000;mcast_recv_buf_size=1000000):PING(timeout=2000;num_initial_members=2):MERGE2(min_interval=5000;max_interval=10000):FD_SOCK:VERIFY_SUSPECT(timeout=1500):pbcast.NAKACK(gc_lag=50;retransmit_timeout=300,600,1200,2400,4800):pbcast.STABLE(desired_avg_gossip=20000):UNICAST(timeout=5000):FRAG(frag_size=8096;down_thread=false;up_thread=false):pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;shun=false;print_local_addr=true):pbcast.STATE_TRANSFER(up_thread=false;down_thread=false)</value>
Index: applicationcontext-services.xml
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/webapp/WEB-INF/etc/spring/applicationcontext-services.xml,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- applicationcontext-services.xml 6 Dec 2005 12:12:19 -0000 1.18
+++ applicationcontext-services.xml 7 Dec 2005 14:26:48 -0000 1.19
@@ -18,7 +18,7 @@
<bean id="ClusterNodeSettings"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="properties">
<props>
- <prop key="serverId">jahiaServer1</prop>
+ <prop
key="serverId">${cluster.node.serverId}</prop>
</props>
</property>
</bean>
@@ -27,13 +27,13 @@
<property name="target">
<bean class="org.jahia.services.cluster.JGroupsClusterService"
parent="jahiaServiceTemplate">
<property name="activated">
- <value>false</value>
+ <value>${cluster.activated}</value>
</property>
<property name="channelGroupName">
<value>JahiaCluster</value>
</property>
<property name="channelProperties">
-
<value>UDP(mcast_addr=231.12.21.130;mcast_port=45000;ip_ttl=32;mcast_send_buf_size=1000000;mcast_recv_buf_size=1000000):PING(timeout=2000;num_initial_members=2):MERGE2(min_interval=5000;max_interval=10000):FD_SOCK:VERIFY_SUSPECT(timeout=1500):pbcast.NAKACK(gc_lag=50;retransmit_timeout=300,600,1200,2400,4800):pbcast.STABLE(desired_avg_gossip=20000):UNICAST(timeout=5000):FRAG(frag_size=8096;down_thread=false;up_thread=false):pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;shun=false;print_local_addr=true)</value>
+
<value>UDP(mcast_addr=${cluster.service.multicast.ip_address};mcast_port=${cluster.service.multicast.port};ip_ttl=32;mcast_send_buf_size=1000000;mcast_recv_buf_size=1000000):PING(timeout=2000;num_initial_members=2):MERGE2(min_interval=5000;max_interval=10000):FD_SOCK:VERIFY_SUSPECT(timeout=1500):pbcast.NAKACK(gc_lag=50;retransmit_timeout=300,600,1200,2400,4800):pbcast.STABLE(desired_avg_gossip=20000):UNICAST(timeout=5000):FRAG(frag_size=8096;down_thread=false;up_thread=false):pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;shun=false;print_local_addr=true)</value>
</property>
</bean>
</property>
Index: howto_cluster.html
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/webapp/html/startup/howto_cluster.html,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- howto_cluster.html 6 Dec 2005 12:13:57 -0000 1.18
+++ howto_cluster.html 7 Dec 2005 14:26:49 -0000 1.19
@@ -134,7 +134,7 @@
Messages sent between
nodes to synchronize the state of the cluster use time stamps, so if nodes are
not
precisely
time-synchronized, problems will occur.<br/>We recommend setting up an NTP
client with frequent updates
on each server or any
other mechanism to ensure the time is the same on all servers.</span>
- </p>
+ </p>
<h2>I - To activate in base content storage</h2>
To setup in base content storage, you
just have to select "in base storage" during the
configuration wizard, in the database
advanced configuration screen.<br/><br/>
@@ -160,8 +160,7 @@
<li>Install the first instance
as for a stand-alone configuration.<br/>
During the configuration
wizard, select "in base content storing" if you prefer to store all
data in the
database. After configuration wizard is completed and installaton successful,
shutdown this instance of
- Jahia.
- </li>
+ Jahia.
</li>
<li>Delete all the tables
created during the installation of the first instance of Jahia. Depending on
the database
used and if more
convenient, you may drop the database used and re-create an empty database with
the same name. When
doing this, make
sure that the database login used during the installation of the first instance
has the same rights to the
@@ -232,23 +231,13 @@
<p class="code"><attribute
name="CacheMode">LOCAL</attribute></p>
<p>with the line </p>
<p class="code"><attribute
name="CacheMode">REPL_ASYNC</attribute></p>
- </li><li>Modify the
<i>jahia/WEB-INF/etc/spring/applicationcontext-services.xml</i>
- and set the value of the
parameter <property name="activated"> to <b>true</b> in the
- <i>ClusterService</i> bean
<br/>(<i><bean id="ClusterService"
parent="txProxyTemplate"></i>).<br/><br/>
- A <b>different</b>
server ID is also required for each node of the cluster. This should also be
modified in the
-
<i>applicationcontext-services.xml</i> file :
-<pre class="code"><bean id="ClusterNodeSettings"
-
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
- <property name="properties">
- <props>
- <prop key="serverId"><span
class="red">jahiaServer1</span></prop>
- </props>
- </property>
-</bean></pre>
- Modify the
<i>jahia/WEB-INF/etc/spring/applicationcontext-dao.xml</i> and set the value of
the parameter <property name="clusterActivated"> to <b>true</b>
in the <i>idGeneratorDAO</i> bean <br/>
- (<i><bean
id="idGeneratorDAO"
class="org.jahia.hibernate.dao.IDGeneratorDAO"
init-method="start" destroy-method="stop"></i>).<br />
</li>
- <li>By default, the clustering
service uses UDP multicast to communicate with other instances of Jahia running
in the
+ <li>Modify the
<i>jahia/WEB-INF/etc/config/jahia.properties</i> and set the following :<br />
+ <p class="code">cluster.activated
= true</p>
+ A
<b>different</b> server ID is also required for each node of the cluster. In
the same file, change this setting :
+ <pre
class="code">cluster.node.serverId = <span class="red">jahiaServer</span></pre>
+ </li>
+ <li>By default, the clustering service uses
UDP multicast to communicate with other instances of Jahia running in the
same local network. This means
that <span class="red"> all Jahia installations in the same local network which
have the clustering
feature activated will try to
communicate with each other</span>, which may lead to some interferences or
unwanted
behaviours. To prevent this,
we suggest you change the multicast address and put the same value only
@@ -265,12 +254,14 @@
bridge, switch or hub
hardware between the Jahia installations that it does forward UDP multicast
packets.<br/>
<br/>
- ii) You also need to
modify the multicast IP in the
<i>jahia/WEB-INF/etc/spring/applicationcontext-services.xml</i> file. Still
- in the
<i>ClusterService</i> bean, modify the value of the <property
name="channelProperties"> parameter and
- replace
<i>mcast_addr=231.12.21.130</i> with another IP address. Make sure it is <span
class="red"><b>not</b></span> the same address as the
+ ii) You also need to
modify the multicast IP in the <i>jahia/WEB-INF/etc/config/jahia.properties</i>
file. Change this line : <br />
+ <p
class="code">cluster.service.multicast.ip_address =
231.12.21.130</p>
+ Make sure it is <span
class="red"><b>not</b></span> the same address as the
one in the
treecache.xml file.<br />
<br/>
- iii) Finally, in the
file jahia/WEB-INF/etc/spring/applicationcontext-dao.xml, change the multicast
IP address in the idGeneratorDAO "clusterProperties" that's set at
231.12.21.150 to something else. </li>
+ iii) Still in the
<i>jahia/WEB-INF/etc/config/jahia.properties</i>, also change the following IP
address to another unused setting : <br />
+ <p
class="code">cluster.idgenerator.multicast.ip_address =
231.12.21.150</p>
+ </li>
</ol>
If the clustering feature has been
activated, you should see the following line displayed three times with 3
different ports in
the output console when starting each
jahia node :<br/>
@@ -285,7 +276,7 @@
[org.jgroups.protocols.UDP]
ERROR - exception=java.net.BindException: Cannot assign requested address:
Datagram send failed, msg=[ds
1.12.21.133:45000, src:
192.168.2.130:1664 (2 headers), size = 0 bytes], mcast_addr=231.12.21.133:45000
</span>
- <h4>Sticky sessions</h4>
+ <h4>Sticky sessions</h4>
If you are using an
hardware or software loadbalancer in front of Jahia to handle distribution of
load amongst all Jahia nodes in
the cluster, you will
need to activate "sticky sessions" on Tomcat and the load balancer. This is
required to force an open session to
make all requests on
the same server for the time of the session.<br/>