Terracotta

From Resin 3.0

(Difference between revisions)
Jump to: navigation, search
(checkpoint)
Line 4: Line 4:
 
'''WARNING: THE FOLLOWING IS INCOMPLETE AND IN PROGRESS!'''
 
'''WARNING: THE FOLLOWING IS INCOMPLETE AND IN PROGRESS!'''
  
 +
(The following has been tested with Resin 3.1.5 and Terracotta 2.5.4)
  
 
<ol>
 
<ol>
 
<li>Download Resin from http://www.caucho.com/download</li>
 
<li>Download Resin from http://www.caucho.com/download</li>
<li>Unzip Resin into <code>/usr/local/share/resin</code></li>
+
<li>Unzip Resin.  From now on, we'll refer to the location of the Resin root directory as $RESIN</li>
 
<li>Download Terracotta from http://www.terracotta.org</li>
 
<li>Download Terracotta from http://www.terracotta.org</li>
<li>Unzip Terracotta</li>
+
<li>Unzip Terracotta. From now on, we'll refer to the location of the Terracotta root directory as $TERRACOTTA</li>
<li>Create the Mule webapp directory structure:
+
<li>Create the example webapp directory structure:
<pre>mkdir -p /usr/local/share/resin/webapps/terracotta/WEB-INF/classes/example/
+
<pre>mkdir -p $RESIN/webapps/terracotta/WEB-INF/classes/example/</pre>
</pre>
+
 
</li>
 
</li>
<li>Create the configuration file <code>/usr/local/share/resin/webapps/mule/WEB-INF/resin-web.xml</code>
+
<li>Create the configuration file <code>$RESIN/webapps/terracotta/WEB-INF/resin-web.xml</code>
 
<pre><?xml version="1.0" encoding="UTF-8"?>
 
<pre><?xml version="1.0" encoding="UTF-8"?>
 
<web-app xmlns="http://caucho.com/ns/resin">
 
<web-app xmlns="http://caucho.com/ns/resin">
Line 24: Line 24:
 
</pre>
 
</pre>
 
</li>
 
</li>
<li>Create the configuration file <code>/usr/local/share/resin/tc-config.xml</code>
 
<pre><?xml version="1.0" encoding="UTF-8"?>
 
<tc:tc-config xmlns:tc="http://www.terracotta.org/config">
 
  <clients>
 
    <dso>
 
      <debugging>
 
        <instrumentation-logging>
 
          <class>true</class>
 
          <hierarchy>true</hierarchy>
 
          <locks>true</locks>
 
          <transient-root>true</transient-root>
 
          <roots>true</roots>
 
          <distributed-methods>true</distributed-methods>
 
        </instrumentation-logging>
 
        <runtime-logging>
 
          <lock-debug>true</lock-debug> 
 
          <field-change-debug>true</field-change-debug> 
 
          <wait-notify-debug>true</wait-notify-debug>
 
          <distributed-method-debug>true</distributed-method-debug>
 
          <new-object-debug>true</new-object-debug>
 
        </runtime-logging>
 
      </debugging>
 
    </dso>
 
  </clients>
 
 
  <application>
 
    <dso>
 
      <roots>
 
        <root>
 
          <field-name>example.HelloWorldServlet._accessTimes</field-name>
 
        </root>
 
      </roots>
 
      <locks>
 
        <autolock>
 
          <method-expression>* example.HelloWorldServlet*.*(..)</method-expression>
 
          <lock-level>write</lock-level>
 
        </autolock>
 
      </locks>
 
      <instrumented-classes>
 
        <include><class-expression>example..*</class-expression></include>
 
      </instrumented-classes>
 
      <additional-boot-jar-classes>
 
        <include>java.util.TimeZone</include>
 
        <include>sun.util.calendar.ZoneInfo</include>
 
      </additional-boot-jar-classes>
 
    </dso>
 
  </application>
 
</tc:tc-config>
 
</pre></li>
 
 
<li>Create the HelloWorld Servlet <code>/usr/local/share/resin/webapps/terracotta/WEB-INF/classes/example/HelloWorldServlet.java</code>
 
<li>Create the HelloWorld Servlet <code>/usr/local/share/resin/webapps/terracotta/WEB-INF/classes/example/HelloWorldServlet.java</code>
 
<pre>package example;
 
<pre>package example;
Line 113: Line 64:
 
}</pre>
 
}</pre>
 
</li>
 
</li>
<li>Create two copies of resin.conf, with different ports for the server and http.  Add these lines to both versions of resin.conf
+
<li>Create the Terracotta configuration file <code>$RESIN/tc-config.xml</code>
 +
<pre><?xml version="1.0" encoding="UTF-8"?>
 +
<tc:tc-config xmlns:tc="http://www.terracotta.org/config">
 +
  <application>
 +
    <dso>
 +
      <roots>
 +
        <root>
 +
          <field-name>example.HelloWorldServlet._accessTimes</field-name>
 +
        </root>
 +
      </roots>
 +
      <locks>
 +
        <autolock>
 +
          <method-expression>* example.HelloWorldServlet*.*(..)</method-expression>
 +
          <lock-level>write</lock-level>
 +
        </autolock>
 +
      </locks>
 +
      <instrumented-classes>
 +
        <include><class-expression>example..*</class-expression></include>
 +
      </instrumented-classes>
 +
      <additional-boot-jar-classes>
 +
        <include>java.util.TimeZone</include>
 +
        <include>sun.util.calendar.ZoneInfo</include>
 +
      </additional-boot-jar-classes>
 +
    </dso>
 +
  </application>
 +
</tc:tc-config>
 +
</pre></li>
 +
<li>Create the Terracotta boot jar:
 +
<pre>$TERRACOTTA/bin/make-boot-jar.sh -f $RESIN/tc-config.xml</pre>
 +
</li>
 +
<li>Edit resin.conf, adding the following .  Add these lines to both versions of resin.conf
 
<pre>
 
<pre>
 
<jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>
 
<jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>

Revision as of 17:20, 16 April 2008

Terracotta and Resin

WARNING: THE FOLLOWING IS INCOMPLETE AND IN PROGRESS!

(The following has been tested with Resin 3.1.5 and Terracotta 2.5.4)

  1. Download Resin from http://www.caucho.com/download
  2. Unzip Resin. From now on, we'll refer to the location of the Resin root directory as $RESIN
  3. Download Terracotta from http://www.terracotta.org
  4. Unzip Terracotta. From now on, we'll refer to the location of the Terracotta root directory as $TERRACOTTA
  5. Create the example webapp directory structure:
    mkdir -p $RESIN/webapps/terracotta/WEB-INF/classes/example/
  6. Create the configuration file $RESIN/webapps/terracotta/WEB-INF/resin-web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://caucho.com/ns/resin">
      <servlet servlet-name="hello-servlet"
               servlet-class="example.HelloWorldServlet"/>
    
      <servlet-mapping url-pattern="/*" servlet-name="hello-servlet"/>
    </web-app>
    
  7. Create the HelloWorld Servlet /usr/local/share/resin/webapps/terracotta/WEB-INF/classes/example/HelloWorldServlet.java
    package example;
    
    import java.io.*;
    import java.text.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    
    public class HelloWorldServlet extends HttpServlet {
      // this is the variable that Terracotta will distribute
      private ArrayList<Calendar> _accessTimes = new ArrayList<Calendar>();
    
      @Override
      public void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException
      {
        Calendar now = Calendar.getInstance();
    
        synchronized(_accessTimes) {
          _accessTimes.add((Calendar) now.clone());
          DateFormat format = new SimpleDateFormat("yyyy.MM.dd G 'at' HH:mm:ss z");
    
          resp.setContentType("text/html");
    
          PrintWriter out = resp.getWriter();
    
          out.println("<html>");
          out.println("<body>");
    
          for (Calendar calendar : _accessTimes) {
            out.println("<br/>" + format.format(calendar.getTime()));
          }
    
          out.println("</body>");
          out.println("</html>");
        }
      }
    }
  8. Create the Terracotta configuration file $RESIN/tc-config.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <tc:tc-config xmlns:tc="http://www.terracotta.org/config">
      <application>
        <dso>
          <roots>
            <root>
              <field-name>example.HelloWorldServlet._accessTimes</field-name>
            </root>
          </roots>
          <locks>
            <autolock>
              <method-expression>* example.HelloWorldServlet*.*(..)</method-expression>
              <lock-level>write</lock-level>
            </autolock>
          </locks>
          <instrumented-classes>
            <include><class-expression>example..*</class-expression></include>
          </instrumented-classes>
          <additional-boot-jar-classes>
            <include>java.util.TimeZone</include>
            <include>sun.util.calendar.ZoneInfo</include>
           </additional-boot-jar-classes>
        </dso>
      </application>
    </tc:tc-config>
    
  9. Create the Terracotta boot jar:
    $TERRACOTTA/bin/make-boot-jar.sh -f $RESIN/tc-config.xml
  10. Edit resin.conf, adding the following . Add these lines to both versions of resin.conf
    <jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>
    <jvm-arg>-Xbootclasspath/p:<path-to-terracotta>/lib/dso-boot/<dso-boot-jar></jvm-arg>
    <jvm-arg>-Dtc.install-root=<path-to-terracotta></jvm-arg>
    <jvm-arg>-Dtc.config=localhost:9510</jvm-arg>
    
  11. Invoke two Resin instances, using the two different resin.confs
Personal tools