Java Reference
In-Depth Information
application, you first download the distribution. The distribution provides utility scripts, as well as jars.
You may download Terracotta from http://www.terracotta.org .
For Terracotta to work, you need to provide it with a configuration file. This file is an XML file that
we'll review shortly. You start Terracotta as follows:
$TERRACOTTA_HOME/bin/start-tc-server.sh -f $PATH_TO_TERRACOTTA_CONFIGURATION
For all virtual machine clients that you want to “see” and share that state, start it with a customized
bootclasspath parameter when starting java. The arguments for this vary per operating system, so
Terracotta provides a handy script for determining the correct arguments, dso-env.sh . When provided
with the host and port of the Terracotta server, it can ensure that all configuration data for each client
virtual machine is loaded dynamically from the server. As you might imagine, this greatly eases
deployment over a grid of any substantive size! Here's how to use the script:
$TERRACOTTA_HOME/bin/dso-env.sh $HOST:$PORT
Replace $TERRACOTTA_HOME with the Terracotta's installation directory, and replace $HOST and $PORT
with the host and port of the server instance. When run, it will print out the correct arguments, which
you then need to feed into each client virtual machine's invocation scripts, for example in the
$JAVA_OPTS section for Tomcat or any standard java invocation.
$ dso-env.sh localhost:9510
When executed, this will produce something like the following, which you need to ensure is used in
your invocation of the java command:
-Xbootclasspath/p:c:\dev\terracotta-3.0.0\lib\dso-boot\dso-boot
hotspot_win32_160_14-ea.jar -Dtc.install-root=c:\dev\terracotta-3.0.0
How to Build a Terracotta XML Configuration File
The XML for the Terracotta configuration is verbose but self evident. Terracotta is a 99% code-incursion-
free solution. Because Terracotta works at such a low level, you don't need to know about it when
programming. The only thing of concern may be the introduction of threading issues, which you would
not have to deal with in strictly serialized execution. There are no annotations, and no APIs, to direct
Terracotta. Instead, Terracotta gets its information from the XML configuration file that you provide it.
Our example XML file ( tc-customerconsole-wo-spring.xml ) is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<tc:tc-config xmlns:tc=" http://www.terracotta.org/config"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.terracotta.org/schema/terracotta-4.xsd" >
<servers>
<server host="%i" name="server1">
<dso-port>9510</dso-port>
<jmx-port>9520</jmx-port>
<data>target/terracotta/server/data</data>
<logs>target/terracotta/server/logs</logs>
<statistics>target/terracotta/server/statistics</statistics>
</server>
Search WWH ::




Custom Search