Jetty has moved!
Jetty is a project at the Eclipse Foundation.
Homepage:http://www.eclipse.org/jetty
Downloads: http://download.eclipse.org/jetty/
Documentation:http://www.eclipse.org/jetty/documentation/current/
About:http://www.eclipse.org/jetty/about.php
Jetty Powered:http://www.eclipse.org/jetty/powered/
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
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

Session Clustering with Terracotta

Build Instructions

  1. Before you start, make sure you have installed release terracotta 2.4 or greater. We'll refer to the installation directory as <TC-HOME>.
  2. If you haven't already got a boot jar for terracotta for your jvm version, then make one now. On linux this is:
  3. Download and unzip a src bundle (6.1.4 onwards) or check out trunk or any tag from jetty-6.1.4 onwards. Here's how to do the checkout:
    We'll refer to the installation directory as <JETTY-HOME>.
  4. Build it if it isn't already:
  5. Go to the <JETTY_HOME>/contrib/terracotta directory and build it:
    Icon

    You'll need to have the terracotta tc.jar file installed in your local maven repository. If it isn't already, then maven will give you the exact instructions on what you need to do to put it there. It will look something like this:

  6. Copy the target/terracotta-sessions.jar you just built into <JETTY-HOME>/lib/ext.

Configuration

Configuring Jetty to use Terracotta consists of creating a single TerracottaSessionIdManager per jetty instance to generate unqiue session ids, and then setting up a special TerracottaSessionManager per webapp to be distributed.

We've provided sample config files to do both of these things, so if you don't want to read further, you can just use them. Here's how to start jetty with terracotta and deploy the sample webapps that come with the terracotta distribution:

  1. build, then copy the DepartmentTaskList.war, Cart.war and Townsend.war files from $TC-HOME/samples/sessions to $JETTY-HOME/webapps
  2. copy these jetty context deployer config files which match the sample webapps into $JETTY-HOME/contexts from $JETTY-HOME/contrib/terracotta/src/main/resources:
    • cart.xml
    • departmentTaskList.xml
    • townsend.xml
  3. skip down to the #Starting section to run jetty

Otherwise, let's continue with looking into the configuration files.

The TerracottaSessionIdManager

One TerracottaSessionIdManager is configured per jetty instance to generate unique session ids. These are the relevant lines from $JETTY-HOME/contrib/terracotta/src/main/resources/jetty.xml:

The workerName is a unqiue name for the jetty instance. In the example it is "fred" but you can use any naming scheme you'd like. We set the tcIdMgr object as a Server attribute so that we can reference it in other config files.

The TerracottaSessionManager

Each webapp whose sessions we want clustered must use a TerracottaSessionManager instead of the default HashSessionManager.

The easiest way to do this is to create individual context deployer config files for each webapp, and include these lines:

These lines ensure that a TerracottaSessionManager is established for each webapp, and has access to the jetty instance's unique session id generator we configured above.

Starting

  1. Start a terracotta server with a jetty configuration file. On linux this is $TC_HOME/bin/start-tc-server.sh -f $JETTY-HOME/contrib/terracotta/src/main/resources/tc-config-jetty.xml
  2. Set up the webapps that you want to use terracotta by following the instructions in the #Configuration section above.
  3. Start jetty:

You'll now have a jetty instance that is talking to terracotta to distribute sessions from your webapps. Rinse and repeat to create other jetty instances in the cluser. Don't forget to select a unique workerName for the other TerracottaSessionIdManagers. Also, if you just want to play around and run 2 jetty instances on the same machine, don't forget that you'll need to use port numbers for each!

  • No labels
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