<?xml version="1.0" encoding="UTF-8"?>
<section version="5.0" xml:lang="en" xmlns="http://docbook.org/ns/docbook"
         xmlns:xlink="http://www.w3.org/1999/xlink"
         xmlns:xi="http://www.w3.org/2001/XInclude"
         xmlns:svg="http://www.w3.org/2000/svg"
         xmlns:mml="http://www.w3.org/1998/Math/MathML"
         xmlns:html="http://www.w3.org/1999/xhtml"
         xmlns:db="http://docbook.org/ns/docbook">
  <info>
    <title>sampleCluster3</title>
  </info>

  <para>This example is delivered with JOnAS in the
  <code>JONAS_ROOT/examples/cluster-javaee5</code> directory.</para>

  <section>
    <info>
      <title>Description</title>
    </info>

    <para>The sampleCluster3 application aims to demonstrate the JOnAS's
    clustering features in a <quote>pedagogical</quote> way for Java EE
    5.</para>

    <para>These features are:</para>

    <itemizedlist>
      <listitem>
        <para>Load balancing at Apache level using <link
        xlink:href="http://tomcat.apache.org/connectors-doc/">mod_jk</link></para>
      </listitem>

      <listitem>
        <para>Failover at the web level (HTTP session replication using <link
        xlink:href="http://tomcat.apache.org/">tomcat</link>).</para>
      </listitem>

      <listitem>
        <para>Load balancing at EJB level using CMI</para>
      </listitem>

      <listitem>
        <para>Failover at EJB level (Stateful EJB replication)</para>
      </listitem>
    </itemizedlist>

    <para>The application is composed of the following EJB3 components:</para>

    <itemizedlist>
      <listitem>
        <para>1 SLSB (MyStateless)</para>
      </listitem>

      <listitem>
        <para>2 SFSB (MyStateful and MyStatefulInner)</para>
      </listitem>

      <listitem>
        <para>1 EB (Node)</para>
      </listitem>
    </itemizedlist>

    <mediaobject>
      <imageobject>
        <imagedata align="center"
                   fileref="../../../../resources/images/clustering/sampleCluster3.png"
                   scalefit="1" width="80%"></imagedata>
      </imageobject>
    </mediaobject>
  </section>

  <section>
    <info>
      <title>Structure</title>
    </info>

    <itemizedlist>
      <listitem>
        <para><code>./bin-client</code>: scripts to launch clients,</para>
      </listitem>

      <listitem>
        <para><code>./etc</code>: configuration file,</para>
      </listitem>

      <listitem>
        <para><code>./example-config</code>: configuration example,</para>
      </listitem>

      <listitem>
        <para><code>./src</code>: source code,</para>
      </listitem>

      <listitem>
        <para><filename>./output</filename>: generated files.</para>
      </listitem>
    </itemizedlist>
  </section>

  <section>
    <title>Configuring the cluster</title>

    <para>First of all, configure the cluster using the
    <command>newjc</command> command. Please, refer to the newjc documentation
    and do not forget to install and configure apache2 as it's described in
    the Cluster Configuration Guide.</para>
  </section>

  <section>
    <info>
      <title>Compiling</title>
    </info>

    <para>To build the application, launch <command>ant</command> tool from
    <filename>$JONAS_ROOT/examples/cluster-javaee5</filename> root directory
    where (the build.xml file is located).</para>

    <para><itemizedlist>
        <listitem>
          <para><command>ant ear</command>. The application file
          <filename>sampleCluster3.ear</filename> is generated in
          <filename>./output/apps</filename> folder.</para>
        </listitem>
      </itemizedlist></para>
  </section>

  <section>
    <info>
      <title>Running</title>
    </info>

    <section>
      <info>
        <title>Launching the cluster</title>
      </info>

      <para>To start and halt the cluster, use the <command>jcl4sc</command>
      (<command>jcl4sc.bat</command>) command generated by
      <command>newjc</command> in the root of the <phrase
      xml:id="appserver">JOnAS</phrase> bases.</para>

      <para><command>jcl4sc -c start</command> allows to start the cluster,
      included the cluster daemon, the db node, the master node and the jbx
      nodes.</para>

      <para><command>jcl4sc halt</command> allows to halt the cluster.</para>

      <para>You may type <command>jcl4sc -help</command> to get the usage of
      the command.</para>
    </section>

    <section>
      <info>
        <title>Deploying</title>
      </info>

      <para>The sampleCluster3 application is automatically deployed on the
      cluster if you have previously build it, before using the
      <command>jcl4sc</command> command.</para>
    </section>

    <section>
      <info>
        <title>Using</title>
      </info>

      <para>The application is available at
      <code>http://&lt;hostname&gt;:&lt;apache-port&gt;/sampleCluster3.
      </code></para>

      <para>Example: <code>http://localhost:80/sampleCluster3</code></para>
    </section>
  </section>
</section>