Dashboard > Jetty > ... > Jetty Documentation > Jetty Clustering with WADI
Jetty Clustering with WADI Log In | Sign Up   View a printable version of the current page.

Added by ngonzalez , last edited by Jan Bartel on May 01, 2007  (view change)
Labels: 
(None)

Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery

Clustering with Jetty and WADI

What is WADI?

WADI is an acronym of 'WADI Application Distribution Infrastructure'. WADI started life as a solution to the problems surrounding the distribution of state in clustered web tiers, but is becoming a more generalised distributed space service.

How to cluster your web application with Jetty and WADI

First, svn checkout jetty and then buid it by calling mvn install. Once it finishes, go to jetty.home/extras/wadi and mvn install that project. Besides compiling the java files and generating the jetty-wadi-session-manager jar file, this will copy all the dependencies into jetty.home/lib/wadi.

To cluster a webapp, you need to define the WadiSessionManager and create an instance of WadiSessionHandler (passing the WadiSessionManager object as a constructor parameter). Then set the WadiSessionHandler as your webapp's SessionHandler. You can do this in a context xml config file.

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">

<Configure class="org.mortbay.jetty.webapp.WebAppContext">
  <Set name="contextPath">/wadi</Set>
  <Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/test</Set>
  <Set name="extractWAR">false</Set>
  <Set name="copyWebDir">false</Set>
  <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>

  <Set name="SessionHandler">
    <New class="org.mortbay.jetty.servlet.wadi.WadiSessionHandler">
      <Arg>
	<New id="wadiSessionManager" class="org.mortbay.jetty.servlet.wadi.WadiSessionManager">
	  <Arg>CLUSTER</Arg>
	  <Arg>JETTY</Arg>
	  <Arg><SystemProperty name="node.name" default="red"/></Arg>
	  <Arg type="int">2</Arg>
	  <Arg>http://localhost:<SystemProperty name="jetty.port" default="8080"/>/test</Arg>
	  <Arg type="int">24</Arg>
	  <Arg type="int">360</Arg>
	</New>
      </Arg>
    </New>
  </Set>

</Configure>

This context xml config file is readily usable. After building the jetty.home/extras/wadi project, drop this config file into the jetty.home/contexts directory.  You can create a node in the cluster by calling "java -Dnode.name=nodename -Djetty.port=portnumber Djava.net.preferIPv4Stack=true -jar start.jar etc/jetty.xml" in the jetty home directory (where nodename=a distinct node name for this node, and portnumber=a distinct port number for this node).

For instance, if you want to create a cluster with three nodes, you can do so by calling the following: 

java -Djetty.port=7070 -Dnode.name=orange -Djava.net.preferIPv4Stack=true -jar start.jar etc/jetty-wadi-cluster.xml

java -Djetty.port=8080 -Dnode.name=red -Djava.net.preferIPv4Stack=true -jar start.jar etc/jetty-wadi-cluster.xml

java -Djetty.port=9090 -Dnode.name=blue -Djava.net.preferIPv4Stack=true -jar start.jar etc/jetty-wadi-cluster.xml 

Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery
Site running on a free Atlassian Confluence Open Source Project License granted to The Codehaus. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.6.2 Build:#919 Nov 26, 2007) - Bug/feature request - Contact Administrators