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.
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 -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 -jar start.jar etc/jetty-wadi-cluster.xml
java -Djetty.port=8080 -Dnode.name=red -jar start.jar etc/jetty-wadi-cluster.xml
java -Djetty.port=9090 -Dnode.name=blue -jar start.jar etc/jetty-wadi-cluster.xml