[jboss-cvs] JBossAS SVN: r93488 - projects/docs/enterprise/5.0/Administration_And_Configuration_Guide/en-US.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Sep 14 12:47:04 EDT 2009


Author: pferraro
Date: 2009-09-14 12:47:04 -0400 (Mon, 14 Sep 2009)
New Revision: 93488

Removed:
   projects/docs/enterprise/5.0/Administration_And_Configuration_Guide/en-US/Clustering_Guide_HASingleton.xml
Log:
Clustering_Guide_HASingleton.xml made obsolete by Clustering_Guide_Deployment.xml

Deleted: projects/docs/enterprise/5.0/Administration_And_Configuration_Guide/en-US/Clustering_Guide_HASingleton.xml
===================================================================
--- projects/docs/enterprise/5.0/Administration_And_Configuration_Guide/en-US/Clustering_Guide_HASingleton.xml	2009-09-14 16:45:01 UTC (rev 93487)
+++ projects/docs/enterprise/5.0/Administration_And_Configuration_Guide/en-US/Clustering_Guide_HASingleton.xml	2009-09-14 16:47:04 UTC (rev 93488)
@@ -1,377 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
-
-<chapter id="clustering-hasingleton">
-
-  <title>Clustered Singleton Services</title>
-  <section>
-    <title>Introduction</title>
-    <para>
-      A clustered singleton service (also known as an HA singleton)
-      is a service that is deployed on multiple nodes in a cluster, but
-      is providing its service on only one of the nodes. The node
-      running the singleton service is typically called the master node.
-      When the master fails or is shut down, another master is selected
-      from the remaining nodes and the service is restarted on the new
-      master. Thus, other than a brief interval when one master has
-      stopped and another has yet to take over, the service is always
-      being provided by one but only one node.
-    </para>
-    <figure id="master_node_fail.fig">
-      <title>Topology after the Master Node fails</title>
-      <mediaobject>
-        <imageobject>
-          <imagedata align="center" fileref="images/master_node_fail.png" />
-        </imageobject>
-      </mediaobject>
-    </figure>
-  </section>
-
-  <section>
-    <title>Deployment Options</title>
-    <para>
-      The JBoss Enterprise Application Platform provides support for a number of
-      strategies for helping you deploy clustered singleton services. In
-      this section we will explore the different strategies. All of the
-      strategies are built on top of the HAPartition service described
-      in the introduction. They rely on the <literal>HAPartition</literal>
-      to provide notifications when different nodes in the cluster start
-      and stop; based on those notifications each node in the cluster
-      can independently (but consistently) determine if it is now the
-      master node and needs to begin providing a service.
-    </para>
-
-
-    <section>
-      <title>HASingletonDeployer service</title>
-      <para>
-        The simplest and most commonly used strategy for deploying an HA
-        singleton is to take an ordinary deployment (war, ear, jar,
-        whatever you would normally put in deploy) and deploy it in the
-        <literal>$JBOSS_HOME/server/all/deploy-hasingleton</literal>
-        directory instead of in <literal>deploy</literal>. The
-        <literal>deploy-hasingleton</literal> directory does not lie under
-        deploy or farm, so its contents are not automatically deployed 
-        when an AS instance starts. Instead, deploying the contents of this
-        directory is the responsibility of a special service, the
-        <literal>jboss.ha:service=HASingletonDeployer</literal>
-        MBean (which itself is deployed via the
-        deploy/deploy-hasingleton-service.xml file.) The
-        HASingletonDeployer service is itself an HA Singleton, one whose
-        provided service when it becomes master is to deploy the
-        contents of deploy-hasingleton and whose service when it stops
-        being the master (typically at server shutdown) is to undeploy
-        the contents of <literal>deploy-hasingleton</literal>.
-      </para>
-      <para>
-        So, by placing your deployments in <literal>deploy-hasingleton</literal>
-        you know that they will be deployed only on the master node in
-        the cluster. If the master node cleanly shuts down, they will be
-        cleanly undeployed as part of shutdown. If the master node fails
-        or is shut down, they will be deployed on whatever node takes
-        over as master.
-      </para>
-      <para>
-        Using deploy-hasingleton is very simple, but it does
-        have two drawbacks:
-      </para>
-      <itemizedlist>
-        <listitem>
-          <para>
-            There is no hot-deployment feature for services in
-            <literal>deploy-hasingleton</literal>
-            . Redeploying a service that has been deployed to
-            <literal>deploy-hasingleton</literal>
-            requires a server restart.
-          </para>
-        </listitem>
-        <listitem>
-          <para>
-            If the master node fails and another node takes over
-            as master, your singleton service needs to go through the
-            entire deployment process before it will be providing
-            services. Depending on how complex the deployment of your
-            service is and what sorts of startup activities it engages
-            in, this could take a while, during which time the service
-            is not being provided.
-          </para>
-        </listitem>
-      </itemizedlist>
-    </section>
-
-    <section>
-      <title>Mbean deployments using HASingletonController</title>
-      <para>
-        If your service is an Mbean (i.e., not a J2EE deployment like an ear
-        or war or jar), you can deploy it along with a service called an
-        HASingletonController in order to turn it into an HA singleton.
-        It is the job of the HASingletonController to work with the
-        HAPartition service to monitor the cluster and determine if it
-        is now the master node for its service. If it determines it has
-        become the master node, it invokes a method on your service
-        telling it to begin providing service. If it determines it is no
-        longer the master node, it invokes a method on your service
-        telling it to stop providing service. Let's walk through an
-        illustration.
-      </para>
-      <para>
-        First, we have an MBean service that we want to make
-        an HA singleton. The only thing special about it is it needs to
-        expose in its MBean interface a method that can be called when
-        it should begin providing service, and another that can be
-        called when it should stop providing service:
-      </para>
-
-      <programlisting><![CDATA[ 
-public class HASingletonExample implements HASingletonExampleMBean
-{
-   private boolean isMasterNode = false; 
-
-   public void startSingleton()
-   { 
-     isMasterNode = true;
-   }
-
-   public boolean isMasterNode()
-   {
-      return isMasterNode; 
-   }
-
-   public void stopSingleton()
-   {
-      isMasterNode = false; 
-   }
-}
-]]></programlisting>
-
-      <para>
-        We used <literal>startSingleton</literal> and <literal>stopSingleton</literal>
-        in the above example, but you could name the methods anything.
-      </para>
-      <para>
-        Next, we deploy our service, along with an HASingletonController
-        to control it, most likely packaged in a .sar file, with the
-        following <literal>META-INF/jboss-service.xml</literal>:
-      </para>
-      <programlisting><![CDATA[
-<server> 
-  <!-- This MBean is an example of a clustered singleton -->
-  <mbean code="org.jboss.ha.examples.HASingletonExample" 
-         name=“jboss:service=HASingletonExample"/>
-          
-  <!-- This HASingletonController manages the cluster Singleton --> 
-  <mbean code="org.jboss.ha.singleton.HASingletonController" 
-         name="jboss:service=ExampleHASingletonController">
-         
-    <!-- Inject a ref to the HAPartition -->
-    <depends optional-attribute-name="ClusterPartition" proxy-type="attribute">
-      jboss:service=${jboss.partition.name:DefaultPartition}
-    </depends>
-    <!-- Inject a ref to the service being controlled -->
-    <depends optional-attribute-name="TargetName">jboss:service=HASingletonExample</depends>
-    
-    <!-- Methods to invoke when become master / stop being master -->
-    <attribute name="TargetStartMethod">startSingleton</attribute> 
-    <attribute name="TargetStopMethod">stopSingleton</attribute> 
-  </mbean> 
-</server>
-]]></programlisting>
-
-      <para>A clustered singleton service.</para>
-      <para>
-        The obvious downside to this approach is it only works for
-        MBeans. Upsides are that the above example can be placed in
-        <literal>deploy</literal> or <literal>farm</literal>
-        and thus can be hot deployed and farmed deployed. Also, if our
-        example service had complex, time-consuming startup
-        requirements, those could potentially be implemented in create()
-        or start() methods. JBoss will invoke create() and start() as
-        soon as the service is deployed; it doesn't wait until the node
-        becomes the master node. So, the service could be primed and
-        ready to go, just waiting for the controller to implement
-        startSingleton() at which point it can immediately provide
-        service.
-      </para>
-      <para>
-        The jboss.ha:service=HASingletonDeployer service discussed above
-        is itself an interesting example of using an
-        HASingletonController. Here is its deployment descriptor
-        (extracted from the <literal>deploy/deploy-hasingleton-service.xml</literal>
-        file):
-      </para>
-      <programlisting><![CDATA[ 
-<mbean code="org.jboss.ha.singleton.HASingletonController" 
-       name="jboss.ha:service=HASingletonDeployer"> 
-  <depends optional-attribute-name="ClusterPartition" proxy-type="attribute">
-    jboss:service=${jboss.partition.name:DefaultPartition}
-  </depends>  
-  <depends optional-attributeame="TargetName">
-    jboss.system:service=MainDeployer
-  </depends> 
-  <attribute name="TargetStartMethod">deploy</attribute> 
-  <attribute name="TargetStartMethodArgument">
-    ${jboss.server.home.url}/deploy-hasingleton
-  </attribute> 
-  <attribute name="TargetStopMethod">undeploy</attribute> 
-  <attribute name="TargetStopMethodArgument">
-    ${jboss.server.home.url}/deploy-hasingleton
- </attribute> 
-</mbean>
-]]></programlisting>
-
-      <para>
-        A few interesting things here. First the service being
-        controlled is the <literal>MainDeployer</literal>
-        service, which is the core deployment service in JBoss. That is,
-        it's a service that wasn't written with an intent that it be
-        controlled by an <literal>HASingletonController</literal>.
-        But it still works! Second, the target start and stop methods
-        are <literal>deploy</literal> and <literal>undeploy</literal>.
-        No requirement that they have particular names, or even that they
-        logically have <emphasis>start</emphasis> and <emphasis>stop</emphasis>
-        functionality. Here the functionality of the invoked methods is more like
-        <emphasis>do</emphasis> and <emphasis>undo</emphasis>. Finally, note the
-        <literal>TargetStart(Stop)MethodArgument</literal> attributes.
-        Your singleton service's start/stop methods can take an argument,
-        in this case the location of the directory the <literal>MainDeployer</literal>
-        should deploy/undeploy.
-      </para>
-    </section>
-
-    <section>
-      <title>HASingleton deployments using a Barrier</title>
-      <para>
-        Services deployed normally inside deploy or farm
-        that want to be started/stopped whenever the content of
-        deploy-hasingleton gets deployed/undeployed, (i.e., whenever the
-        current node becomes the master), need only specify a dependency
-        on the Barrier mbean: 
-      </para>
-      <programlisting><![CDATA[
-<depends>jboss.ha:service=HASingletonDeployer,type=Barrier</depends>
-]]></programlisting>
-
-      <para>
-        The way it works is that a BarrierController is deployed along with the
-        jboss.ha:service=HASingletonDeployer MBean and listens for JMX
-        notifications from it. A BarrierController is a relatively
-        simple Mbean that can subscribe to receive any JMX notification
-        in the system. It uses the received notifications to control the
-        lifecycle of a dynamically created Mbean called the Barrier.The
-        Barrier is instantiated, registered and brought to the CREATE
-        state when the BarrierController is deployed. After that, the
-        BarrierController starts and stops the Barrier when matching JMX
-        notifications are received. Thus, other services need only
-        depend on the Barrier MBean using the usual &lt;depends&gt; tag, and
-        they will be started and stopped in tandem with the Barrier.
-        When the BarrierController is undeployed the Barrier is destroyed too. 
-      </para>
-      <para>
-        This provides an alternative to the deploy-hasingleton approach in that we can use
-        farming to distribute the service, while content in deploy-hasingleton must be copied
-        manually on all nodes.
-      </para>
-      <para>
-        On the other hand, the barrier-dependent service will be instantiated/created (i.e., any create() method invoked) on all nodes, but only started on the master node. This is different with the deploy-hasingleton approach that will only deploy (instantiate/create/start) the contents of the deploy-hasingleton directory on one of the nodes. 
-      </para>
-      <para>
-        So services depending on the barrier will need to make sure they do minimal or no work inside their create() step, rather they should use start() to do the work. 
-      </para>
-      <note>
-        <title>Note</title>
-        <para>
-          The Barrier controls the start/stop of dependent services, but not their destruction,
-          which happens only when the <literal>BarrierController</literal> is itself destroyed/undeployed.
-          Thus using the <literal>Barrier</literal> to control services that need to be "destroyed" as part of their normal “undeploy” operation (like, for example, an <literal>EJBContainer</literal>) will not have the desired effect. 
-        </para>
-      </note>
-    </section>
-  </section>      
-
-  <section>
-    <title>Determining the master node</title>
-    <para>
-      The various clustered singleton management strategies all depend on the fact that each node in the cluster can independently react to changes in cluster membership and correctly decide whether it is now the “master node”. How is this done?
-    </para>
-    <para>
- <!--     Prior to JBoss AS 4.2.0, the methodology for this was fixed and simple. -->
-      For each member of the cluster, the HAPartition mbean maintains an attribute called the CurrentView, which is basically an ordered list of the current members of the cluster.
-      As nodes join and leave the cluster, JGroups ensures that each surviving member of the cluster gets an updated view.
-      You can see the current view by going into the JMX console, and looking at the CurrentView attribute in the <literal>jboss:service=DefaultPartition</literal> mbean.
-      Every member of the cluster will have the same view, with the members in the same order.  
-    </para>
-    <para>
-      Let's say, for example, that we have a 4 node cluster, nodes A through D, and the current view can be expressed as {A, B, C, D}.
-      Generally speaking, the order of nodes in the view will reflect the order in which they joined the cluster (although this is not always the case, and should not be assumed to be the case).
-    </para>
-    <para>
-      To further our example, let's say there is a singleton service (i.e. an <literal>HASingletonController</literal>) named Foo that's deployed around the cluster, except, for whatever reason, on B.
-      The <literal>HAPartition</literal> service maintains across the cluster a registry of what services are deployed where, in view order.
-      So, on every node in the cluster, the <literal>HAPartition</literal> service knows that the view with respect to the Foo service is {A, C, D} (no B).
-    </para>
-    <para>
-      Whenever there is a change in the cluster topology of the Foo service, the <literal>HAPartition</literal> service invokes a callback on Foo notifying it of the new topology.
-      So, for example, when Foo started on D, the Foo service running on A, C and D all got callbacks telling them the new view for Foo was {A, C, D}.
-      That callback gives each node enough information to independently decide if it is now the master.
-      The Foo service on each node does this by checking if they are the first member of the view – if they are, they are the master; if not, they're not.
-      Simple as that.
-    </para>
-    <para>
-      If A were to fail or shutdown, Foo on C and D would get a callback with a new view for Foo of {C, D}.
-      C would then become the master.
-      If A restarted, A, C and D would get a callback with a new view for Foo of {C, D, A}.
-      C would remain the master – there's nothing magic about A that would cause it to become the master again just because it was before.
-    </para>
-
-    <section>
-      <title>HA singleton election policy</title>
-      <para>
-        The <literal>HASingletonElectionPolicy</literal> object is responsible for electing a master node from a list of available nodes, on behalf of an HA singleton, following a change in cluster topology.
-      </para>
-      <programlisting><![CDATA[
-public interface HASingletonElectionPolicy
-{
-   ClusterNode elect(List<ClusterNode> nodes);
-}
-]]></programlisting>
-      <para>
-        JBoss ships with 2 election policies:
-      </para>
-      <variablelist>
-        <varlistentry>
-          <term><literal>HASingletonElectionPolicySimple</literal></term>
-          <listitem>
-            <para>
-              This policy selects a master node based relative age.
-              The desired age is configured via the <literal>position</literal> property, which corresponds to the index in the list of available nodes.
-              <literal>position = 0</literal>, the default, refers to the oldest node; <literal>position = 1</literal>, refers to the 2nd oldest; etc.
-              <literal>position</literal> can also be negative to indicate youngness; imagine the list of available nodes as a circular linked list.
-              <literal>position = -1</literal>, refers to the youngest node; <literal>position = -2</literal>, refers to the 2nd youngest node; etc.
-            </para>
-            <programlisting><![CDATA[
-<bean class="org.jboss.ha.singleton.HASingletonElectionPolicySimple">
-  <property name="position">-1</property>
-</bean>
-]]></programlisting>
-          </listitem>
-        </varlistentry>
-        <varlistentry>
-          <term><literal>PreferredMasterElectionPolicy</literal></term>
-          <listitem>
-            <para>
-              This policy extends <literal>HASingletonElectionPolicySimple</literal>, allowing the configuration of a preferred node.
-              The <literal>preferredMaster</literal> property, specified as <emphasis>host:port</emphasis> or <emphasis>address:port</emphasis>, identifies a specific node that should become master, if available.
-              If the preferred node is not available, the election policy will behave as described above.
-            </para>
-            <programlisting><![CDATA[
-<bean class="org.jboss.ha.singleton.PreferredMasterElectionPolicy">
-  <property name="preferredMaster">server1:12345</property>
-</bean>
-]]></programlisting>
-          </listitem>
-        </varlistentry>
-      </variablelist>
-    </section>
-  </section>
-</chapter>
-    




More information about the jboss-cvs-commits mailing list