How To Run ZK With Terracotta
From Documentation
| Categories |
|---|
| Small Talks |
|---|
|
Latest Small Talks : |
| Sort By : |
- Author
- Peter Kuo, Engineer, Potix Corporation
- Date
- Feb 4, 2010
- Version
- ZK5
Contents |
Introduction
As my first step to run ZK application with Terracotta(a clustering software for java). I tried a rather simple scenario. Two tomcats and one Terracotta server run at the same machine.
What is Terracotta
Terracotta is an open source JVM-level clustering software for Java. It delivers clustering as a runtime infrastructure service, which simplifies the task of clustering a Java application immensely, by effectively clustering the JVM underneath the application, instead of clustering the application itself.
Test Environment
- Tomcat 6
- ZK Demo with ZK5
- Terracotta 3.2.1 beta
- Windows 2003R2
- JDK 1.6
Demo
Two web applications share session data by terracotta.
Setup Steps
Follow the document from Terracotta official site Web Sessions Express Installation
Add following section to context.xml of Tomcat 6.
<Valve className="org.terracotta.session.TerracottaTomcat60xSessionValve" tcConfigUrl="localhost:9510"/>Add following section to catalina.bat of Tomcat 6 to prevent out of memory error.
set JAVA_OPTS="-XX:PermSize=512M"
Add following section to zk.xml to enable session serialization.
<system-config> <disable-event-thread/> <ui-factory-class>org.zkoss.zk.ui.http.SerializableUiFactory</ui-factory-class> </system-config>
Write a test zul to see if session data is shared by two tomcat.
<window title="Share same session in two tomcat" border="normal" width="300px"> <button label="set time in session" onClick='session.setAttribute("insession",(new Date()).toString());state.value="already set time"' /> <button label="get time in session" onClick='result.value=session.getAttribute("insession")' /> <vbox> <label id="state" value=""/> <label id="result" value=""/> </vbox> </window>
start terracotta server.
start application server.
Summary
Although this test environment is simple, it does show the ability that terracotta is an easy solution to make different application servers share session data. I have run ZK demo for ZK5 with terracotta successfully. But you can't tell if session is shared by 2 ZK demo application, therefore I wrote a simple testsession.zul to demo session is shared by 2 ZK applications.
See Also
- ZK Clustering -- from ZK forum
- How to Run ZK on Apache + Tomcat clustering, Part I
- How to Run ZK on Apache + Tomcat clustering, Part II
- Clustering Web Applications with Terracotta -- from Terracotta official site
- Web Sessions Express Installation -- from Terracotta official site
| Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License. |