You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by ki...@apache.org on 2013/05/09 03:27:18 UTC

svn commit: r1480516 [1/24] - in /incubator/helix/site-content: ./ apidocs/reference/org/apache/helix/ apidocs/reference/org/apache/helix/messaging/handling/ apidocs/reference/org/apache/helix/model/ apidocs/reference/org/apache/helix/participant/state...

Author: kishoreg
Date: Thu May  9 01:27:17 2013
New Revision: 1480516

URL: http://svn.apache.org/r1480516
Log:
Site checkin for project Apache Helix

Added:
    incubator/helix/site-content/ApiUsage.html
    incubator/helix/site-content/Sample_App.html
    incubator/helix/site-content/apidocs/reference/org/apache/helix/ConfigScope.ConfigScopeProperty.html
    incubator/helix/site-content/apidocs/reference/org/apache/helix/ConfigScope.html
    incubator/helix/site-content/apidocs/reference/org/apache/helix/ConfigScopeBuilder.html
    incubator/helix/site-content/apidocs/reference/org/apache/helix/messaging/handling/HelixTask.TimeoutCancelTask.html
    incubator/helix/site-content/apidocs/reference/org/apache/helix/model/ClusterConstraints.ConstraintItem.html
    incubator/helix/site-content/apidocs/reference/org/apache/helix/model/IdealState.AutoModeBuilder.html
    incubator/helix/site-content/apidocs/reference/org/apache/helix/model/IdealState.CustomBuilder.html
    incubator/helix/site-content/apidocs/reference/org/apache/helix/model/IdealState.SemiAutoBuilder.html
    incubator/helix/site-content/apidocs/reference/org/apache/helix/participant/statemachine/StateTransitionTableBuilder.html
    incubator/helix/site-content/apidocs/reference/org/apache/helix/tools/IdealStateCalculatorForStorageNode.html
    incubator/helix/site-content/apidocs/reference/org/apache/helix/tools/PropertiesReader.html
    incubator/helix/site-content/involved/release.html
    incubator/helix/site-content/xref-test/org/apache/helix/ExternalCommand.html
    incubator/helix/site-content/xref-test/org/apache/helix/integration/TestGroupMessage.html
    incubator/helix/site-content/xref-test/org/apache/helix/integration/TestMessageThrottle2.html
    incubator/helix/site-content/xref/org/apache/helix/ConfigScope.html
    incubator/helix/site-content/xref/org/apache/helix/ConfigScopeBuilder.html
    incubator/helix/site-content/xref/org/apache/helix/participant/statemachine/StateTransitionTableBuilder.html
    incubator/helix/site-content/xref/org/apache/helix/tools/IdealStateCalculatorForStorageNode.html
    incubator/helix/site-content/xref/org/apache/helix/tools/PropertiesReader.html
Modified:
    incubator/helix/site-content/checkstyle-aggregate.html
    incubator/helix/site-content/checkstyle.rss
    incubator/helix/site-content/distribution-management.html
    incubator/helix/site-content/helix-admin-webapp/dependencies.html
    incubator/helix/site-content/helix-admin-webapp/distribution-management.html
    incubator/helix/site-content/helix-agent/dependencies.html
    incubator/helix/site-content/helix-agent/distribution-management.html
    incubator/helix/site-content/helix-core/dependencies.html
    incubator/helix/site-content/helix-core/distribution-management.html
    incubator/helix/site-content/index.html
    incubator/helix/site-content/mockservice/dependencies.html
    incubator/helix/site-content/mockservice/distribution-management.html
    incubator/helix/site-content/recipes/distributed-lock-manager/dependencies.html
    incubator/helix/site-content/recipes/distributed-lock-manager/distribution-management.html
    incubator/helix/site-content/recipes/distribution-management.html
    incubator/helix/site-content/recipes/rabbitmq-consumer-group/dependencies.html
    incubator/helix/site-content/recipes/rabbitmq-consumer-group/distribution-management.html
    incubator/helix/site-content/recipes/rsync-replicated-file-system/dependencies.html
    incubator/helix/site-content/recipes/rsync-replicated-file-system/distribution-management.html
    incubator/helix/site-content/recipes/service-discovery/dependencies.html
    incubator/helix/site-content/recipes/service-discovery/distribution-management.html
    incubator/helix/site-content/recipes/task-execution/dependencies.html
    incubator/helix/site-content/recipes/task-execution/distribution-management.html
    incubator/helix/site-content/releasing.html
    incubator/helix/site-content/xref-test/allclasses-frame.html
    incubator/helix/site-content/xref-test/org/apache/helix/integration/TestAutoRebalance.html
    incubator/helix/site-content/xref-test/org/apache/helix/integration/TestMessagingService.html
    incubator/helix/site-content/xref-test/org/apache/helix/integration/package-frame.html
    incubator/helix/site-content/xref-test/org/apache/helix/integration/package-summary.html
    incubator/helix/site-content/xref-test/org/apache/helix/messaging/TestAsyncCallback.html
    incubator/helix/site-content/xref-test/org/apache/helix/messaging/TestAsyncCallbackSvc.html
    incubator/helix/site-content/xref-test/org/apache/helix/messaging/package-frame.html
    incubator/helix/site-content/xref-test/org/apache/helix/messaging/package-summary.html
    incubator/helix/site-content/xref/allclasses-frame.html
    incubator/helix/site-content/xref/org/apache/helix/NotificationContext.html
    incubator/helix/site-content/xref/org/apache/helix/PropertyType.html
    incubator/helix/site-content/xref/org/apache/helix/messaging/handling/HelixTaskExecutor.html
    incubator/helix/site-content/xref/org/apache/helix/model/AlertStatus.html
    incubator/helix/site-content/xref/org/apache/helix/model/Alerts.html
    incubator/helix/site-content/xref/org/apache/helix/model/package-frame.html
    incubator/helix/site-content/xref/org/apache/helix/model/package-summary.html
    incubator/helix/site-content/xref/org/apache/helix/package-frame.html
    incubator/helix/site-content/xref/org/apache/helix/package-summary.html

Added: incubator/helix/site-content/ApiUsage.html
URL: http://svn.apache.org/viewvc/incubator/helix/site-content/ApiUsage.html?rev=1480516&view=auto
==============================================================================
--- incubator/helix/site-content/ApiUsage.html (added)
+++ incubator/helix/site-content/ApiUsage.html Thu May  9 01:27:17 2013
@@ -0,0 +1,659 @@
+<!DOCTYPE html>
+<!--
+ | Generated by Apache Maven Doxia at Jan 25, 2013
+ | Rendered using Apache Maven Fluido Skin 1.3.0
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+  <head>
+    <meta charset="UTF-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <meta name="Date-Revision-yyyymmdd" content="20130125" />
+    <meta http-equiv="Content-Language" content="en" />
+    <title>Apache Helix - </title>
+    <link rel="stylesheet" href="./css/apache-maven-fluido-1.3.0.min.css" />
+    <link rel="stylesheet" href="./css/site.css" />
+    <link rel="stylesheet" href="./css/print.css" media="print" />
+
+      
+    <script type="text/javascript" src="./js/apache-maven-fluido-1.3.0.min.js"></script>
+
+    
+            </head>
+        <body class="topBarEnabled">
+          
+                
+                    
+                
+
+    <div id="topbar" class="navbar navbar-fixed-top ">
+      <div class="navbar-inner">
+                <div class="container-fluid">
+        <a data-target=".nav-collapse" data-toggle="collapse" class="btn btn-navbar">
+          <span class="icon-bar"></span>
+          <span class="icon-bar"></span>
+          <span class="icon-bar"></span>
+        </a>
+                
+                                <ul class="nav">
+                          <li class="dropdown">
+        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Helix <b class="caret"></b></a>
+        <ul class="dropdown-menu">
+        
+                      <li>      <a href="index.html"  title="About">About</a>
+</li>
+                  
+                      <li>      <a href="Quickstart.html"  title="Quick Start">Quick Start</a>
+</li>
+                  
+                      <li>      <a href="ApiUsage.html"  title="Api Usage">Api Usage</a>
+</li>
+                  
+                      <li>      <a href="Architecture.html"  title="Architecture">Architecture</a>
+</li>
+                  
+                      <li>      <a href="Features.html"  title="Features">Features</a>
+</li>
+                  
+                      <li>      <a href="releasenotes/release-0.6.0-incubating.html"  title="Current release 0.6.0-incubating">Current release 0.6.0-incubating</a>
+</li>
+                  
+                      <li>      <a href="jira-report.html"  title="Current Version Change Log">Current Version Change Log</a>
+</li>
+                          </ul>
+      </li>
+                <li class="dropdown">
+        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Recipes <b class="caret"></b></a>
+        <ul class="dropdown-menu">
+        
+                      <li>      <a href="recipes/lock_manager.html"  title="Distributed lock manager">Distributed lock manager</a>
+</li>
+                  
+                      <li>      <a href="recipes/rabbitmq_consumer_group.html"  title="Rabbit MQ consumer group">Rabbit MQ consumer group</a>
+</li>
+                  
+                      <li>      <a href="recipes/rsync_replicated_file_store.html"  title="Rsync replicated file store">Rsync replicated file store</a>
+</li>
+                          </ul>
+      </li>
+                <li class="dropdown">
+        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Get Involved <b class="caret"></b></a>
+        <ul class="dropdown-menu">
+        
+                      <li>      <a href="mail-lists.html"  title="Mailing Lists">Mailing Lists</a>
+</li>
+                  
+                      <li>      <a href="issue-tracking.html"  title="Issues">Issues</a>
+</li>
+                  
+                      <li>      <a href="team-list.html"  title="Team">Team</a>
+</li>
+                  
+                      <li>      <a href="source-repository.html"  title="Sources">Sources</a>
+</li>
+                  
+                      <li>      <a href="integration.html"  title="Continuous Integration">Continuous Integration</a>
+</li>
+                  
+                      <li>      <a href="involved/building.html"  title="Building Guide">Building Guide</a>
+</li>
+                  
+                      <li>      <a href="releasing.html"  title="Release Guide">Release Guide</a>
+</li>
+                          </ul>
+      </li>
+                <li class="dropdown">
+        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Project Documentation <b class="caret"></b></a>
+        <ul class="dropdown-menu">
+        
+                      <li class="dropdown-submenu">
+                                      <a href="project-info.html"  title="Project Information">Project Information</a>
+              <ul class="dropdown-menu">
+                                  <li>      <a href="index.html"  title="About">About</a>
+</li>
+                                  <li>      <a href="project-summary.html"  title="Project Summary">Project Summary</a>
+</li>
+                                  <li>      <a href="dependency-info.html"  title="Dependency Information">Dependency Information</a>
+</li>
+                                  <li>      <a href="modules.html"  title="Project Modules">Project Modules</a>
+</li>
+                                  <li>      <a href="license.html"  title="Project License">Project License</a>
+</li>
+                                  <li>      <a href="team-list.html"  title="Project Team">Project Team</a>
+</li>
+                                  <li>      <a href="source-repository.html"  title="Source Repository">Source Repository</a>
+</li>
+                                  <li>      <a href="issue-tracking.html"  title="Issue Tracking">Issue Tracking</a>
+</li>
+                                  <li>      <a href="mail-lists.html"  title="Mailing Lists">Mailing Lists</a>
+</li>
+                                  <li>      <a href="dependency-management.html"  title="Dependency Management">Dependency Management</a>
+</li>
+                                  <li>      <a href="dependencies.html"  title="Dependencies">Dependencies</a>
+</li>
+                                  <li>      <a href="dependency-convergence.html"  title="Dependency Convergence">Dependency Convergence</a>
+</li>
+                                  <li>      <a href="integration.html"  title="Continuous Integration">Continuous Integration</a>
+</li>
+                                  <li>      <a href="plugin-management.html"  title="Plugin Management">Plugin Management</a>
+</li>
+                                  <li>      <a href="plugins.html"  title="Project Plugins">Project Plugins</a>
+</li>
+                                  <li>      <a href="distribution-management.html"  title="Distribution Management">Distribution Management</a>
+</li>
+                              </ul>
+            </li>
+                  
+                      <li class="dropdown-submenu">
+                                      <a href="project-reports.html"  title="Project Reports">Project Reports</a>
+              <ul class="dropdown-menu">
+                                  <li>      <a href="jira-report.html"  title="JIRA Report">JIRA Report</a>
+</li>
+                                  <li>      <a href="xref/index.html"  title="Source Xref">Source Xref</a>
+</li>
+                                  <li>      <a href="xref-test/index.html"  title="Test Source Xref">Test Source Xref</a>
+</li>
+                                  <li>      <a href="apidocs/index.html"  title="JavaDocs">JavaDocs</a>
+</li>
+                                  <li>      <a href="checkstyle-aggregate.html"  title="Checkstyle">Checkstyle</a>
+</li>
+                                  <li>      <a href="sonar.html"  title="Sonar">Sonar</a>
+</li>
+                              </ul>
+            </li>
+                          </ul>
+      </li>
+                <li class="dropdown">
+        <a href="#" class="dropdown-toggle" data-toggle="dropdown">ASF <b class="caret"></b></a>
+        <ul class="dropdown-menu">
+        
+                      <li>      <a href="http://www.apache.org/foundation/how-it-works.html"  title="How Apache Works">How Apache Works</a>
+</li>
+                  
+                      <li>      <a href="http://www.apache.org/foundation/"  title="Foundation">Foundation</a>
+</li>
+                  
+                      <li>      <a href="http://www.apache.org/foundation/sponsorship.html"  title="Sponsoring Apache">Sponsoring Apache</a>
+</li>
+                  
+                      <li>      <a href="http://www.apache.org/foundation/thanks.html"  title="Thanks">Thanks</a>
+</li>
+                          </ul>
+      </li>
+                  </ul>
+          
+          
+          
+                   
+                      </div>
+          
+        </div>
+      </div>
+    </div>
+    
+        <div class="container-fluid">
+          <div id="banner">
+        <div class="pull-left">
+                                                  <a href="./" id="bannerLeft">
+                                                                                                <img src="images/helix-logo.jpg" />
+                </a>
+                      </div>
+        <div class="pull-right">                  <a href="http://incubator.apache.org/" id="bannerRight">
+                                                                                        <img src="http://incubator.apache.org/images/egg-logo.png" />
+                </a>
+      </div>
+        <div class="clear"><hr/></div>
+      </div>
+
+      <div id="breadcrumbs">
+        <ul class="breadcrumb">
+                
+                    
+                              <li class="">
+                    <a href="./" title="Apache Helix">
+        Apache Helix</a>
+        </li>
+      <li class="divider ">/</li>
+        <li class=""></li>
+        
+                
+                    
+                  <li id="publishDate" class="pull-right">Last Published: 2013-01-25</li> <li class="divider pull-right">|</li>
+              <li id="projectVersion" class="pull-right">Version: 0.6.1-incubating-SNAPSHOT</li>
+            
+                            </ul>
+      </div>
+
+            
+      <div class="row-fluid">
+        <div id="leftColumn" class="span3">
+          <div class="well sidebar-nav">
+                
+                    
+                <ul class="nav nav-list">
+                    <li class="nav-header">Helix</li>
+                                
+      <li>
+    
+                          <a href="index.html" title="About">
+          <i class="none"></i>
+        About</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="Quickstart.html" title="Quick Start">
+          <i class="none"></i>
+        Quick Start</a>
+            </li>
+                  
+      <li class="active">
+    
+            <a href="#"><i class="none"></i>Api Usage</a>
+          </li>
+                  
+      <li>
+    
+                          <a href="Architecture.html" title="Architecture">
+          <i class="none"></i>
+        Architecture</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="Features.html" title="Features">
+          <i class="none"></i>
+        Features</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="releasenotes/release-0.6.0-incubating.html" title="Current release 0.6.0-incubating">
+          <i class="none"></i>
+        Current release 0.6.0-incubating</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="jira-report.html" title="Current Version Change Log">
+          <i class="none"></i>
+        Current Version Change Log</a>
+            </li>
+                              <li class="nav-header">Recipes</li>
+                                
+      <li>
+    
+                          <a href="recipes/lock_manager.html" title="Distributed lock manager">
+          <i class="none"></i>
+        Distributed lock manager</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="recipes/rabbitmq_consumer_group.html" title="Rabbit MQ consumer group">
+          <i class="none"></i>
+        Rabbit MQ consumer group</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="recipes/rsync_replicated_file_store.html" title="Rsync replicated file store">
+          <i class="none"></i>
+        Rsync replicated file store</a>
+            </li>
+                              <li class="nav-header">Get Involved</li>
+                                
+      <li>
+    
+                          <a href="mail-lists.html" title="Mailing Lists">
+          <i class="none"></i>
+        Mailing Lists</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="issue-tracking.html" title="Issues">
+          <i class="none"></i>
+        Issues</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="team-list.html" title="Team">
+          <i class="none"></i>
+        Team</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="source-repository.html" title="Sources">
+          <i class="none"></i>
+        Sources</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="integration.html" title="Continuous Integration">
+          <i class="none"></i>
+        Continuous Integration</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="involved/building.html" title="Building Guide">
+          <i class="none"></i>
+        Building Guide</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="releasing.html" title="Release Guide">
+          <i class="none"></i>
+        Release Guide</a>
+            </li>
+                              <li class="nav-header">Project Documentation</li>
+                                                                                                                                                                                                                                                                                                                                                                
+      <li>
+    
+                          <a href="project-info.html" title="Project Information">
+          <i class="icon-chevron-right"></i>
+        Project Information</a>
+                  </li>
+                                                                                                                                                              
+      <li>
+    
+                          <a href="project-reports.html" title="Project Reports">
+          <i class="icon-chevron-right"></i>
+        Project Reports</a>
+                  </li>
+                              <li class="nav-header">ASF</li>
+                                
+      <li>
+    
+                          <a href="http://www.apache.org/foundation/how-it-works.html" class="externalLink" title="How Apache Works">
+          <i class="none"></i>
+        How Apache Works</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="http://www.apache.org/foundation/" class="externalLink" title="Foundation">
+          <i class="none"></i>
+        Foundation</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink" title="Sponsoring Apache">
+          <i class="none"></i>
+        Sponsoring Apache</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="http://www.apache.org/foundation/thanks.html" class="externalLink" title="Thanks">
+          <i class="none"></i>
+        Thanks</a>
+            </li>
+            </ul>
+                
+                    
+                            <form id="search-form" action="http://www.google.com/search" method="get" >
+    
+  <input value="helix.incubator.apache.org" name="sitesearch" type="hidden"/>
+  <input class="search-query" name="q" id="query" type="text" />
+</form>
+<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=search-form"></script>
+          
+          <hr class="divider" />
+
+           <div id="poweredBy">
+                            <div class="clear"></div>
+                            <div class="clear"></div>
+                            <div class="clear"></div>
+                             <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
+        <img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" />
+      </a>
+                  </div>
+          </div>
+        </div>
+        
+                
+        <div id="bodyColumn"  class="span9" >
+                                  
+            <!-- -
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License. --><h1>Create an instance of Manager</h1><p>The first step of using the Helix api will be creating a Helix manager instance. It requires the following parameters:</p>
+<ul>
+  <li>clusterName: A logical name to represent the group of nodes</li>
+  <li>instanceName: A logical name of the process creating the manager instance. Generally this is host:port.</li>
+  <li>instanceType: Type of the process. This can be one of the following types:
+  <ul>
+    <li>CONTROLLER: Process that controls the cluster, any number of controllers can be started but only one will be active at any given time.</li>
+    <li>PARTICIPANT: Process that performs the actual task in the distributed system.</li>
+    <li>SPECTATOR: Process that observes the changes in the cluster.</li>
+    <li>ADMIN: To carry out system admin actions.</li>
+  </ul></li>
+  <li>zkConnectString: Connection string to Zookeeper. This is of the form host1:port1,host2:port2,host3:port3.</li>
+</ul>
+<div class="source"><pre class="prettyprint">      manager = HelixManagerFactory.getZKHelixManager(clusterName,
+                                                      instanceName,
+                                                      instanceType,
+                                                      zkConnectString);
+</pre></div><h1>Setting up a cluster</h1><p>Initial setup of a cluster, involves creating appropriate znodes in the zookeeper. </p>
+<div class="source"><pre class="prettyprint">    //Create setuptool instance
+    ClusterSetupTool setupTool = new ClusterSetupTool(zkConnectString);
+    //Create cluster namespace in zookeeper
+    setupTool.addCluster(clusterName, true);
+    //Add six Participant instances, each instance must have a unique id. host:port is the standard convention
+    String instances[] = new String[6];
+    for (int i = 0; i &lt; storageInstanceInfoArray.length; i++)
+    {
+      instance[i] = &quot;localhost:&quot; + (8900 + i);
+    }
+    setupTool.addInstancesToCluster(clusterName, instances);
+    //add the resource with 10 partitions to the cluster. Using MasterSlave state model. 
+    //See the section on how to configure a application specific state model
+    setupTool.addResourceToCluster(clusterName, &quot;TestDB&quot;, 10, &quot;MasterSlave&quot;);
+    //This will do the assignment of partitions to instances. Assignment algorithm is based on consistent hashing and RUSH. 
+    //See how to do custom partition assignment
+    setupTool.rebalanceResource(clusterName, &quot;TestDB&quot;, 3);
+</pre></div><div class="section"><h2>Participant<a name="Participant"></a></h2><p>Starting up a participant is pretty straightforward. After the Helix manager instance is created, only thing that needs to be registered is the state model factory. The Methods on the State Model will be called when controller sends transitions to the Participant.</p>
+<div class="source"><pre class="prettyprint">      manager = HelixManagerFactory.getZKHelixManager(clusterName,
+                                                          instanceName,
+                                                          InstanceType.PARTICIPANT,
+                                                          zkConnectString);
+     StateMachineEngine stateMach = manager.getStateMachineEngine();
+     //create a stateModelFactory that returns a statemodel object for each partition. 
+     stateModelFactory = new OnlineOfflineStateModelFactory();     
+     stateMach.registerStateModelFactory(stateModelType, stateModelFactory);
+     manager.connect();
+</pre></div>
+<div class="source"><pre class="prettyprint">public class OnlineOfflineStateModelFactory extends
+		StateModelFactory&lt;StateModel&gt; {
+	@Override
+	public StateModel createNewStateModel(String stateUnitKey) {
+		OnlineOfflineStateModel stateModel = new OnlineOfflineStateModel();
+		return stateModel;
+	}
+	@StateModelInfo(states = &quot;{'OFFLINE','ONLINE'}&quot;, initialState = &quot;OFFINE&quot;)
+	public static class OnlineOfflineStateModel extends StateModel {
+        @Transition(from = &quot;OFFLINE&quot;, to = &quot;ONLINE&quot;)
+		public void onBecomeOnlineFromOffline(Message message,
+				NotificationContext context) {
+			System.out
+					.println(&quot;OnlineOfflineStateModel.onBecomeOnlineFromOffline()&quot;);
+			//Application logic to handle transition 
+		}
+        @Transition(from = &quot;ONLINE&quot;, to = &quot;OFFLINE&quot;)
+		public void onBecomeOfflineFromOnline(Message message,
+				NotificationContext context) {
+			System.out
+						.println(&quot;OnlineOfflineStateModel.onBecomeOfflineFromOnline()&quot;);
+			//Application logic to handle transition
+		}
+	}
+}
+</pre></div></div><div class="section"><h2>Controller Code<a name="Controller_Code"></a></h2><p>Controller needs to know about all changes in the cluster. Helix comes with default implementation to handle all changes in the cluster. If you have a need to add additional functionality, see GenericHelixController on how to configure the pipeline.</p>
+<div class="source"><pre class="prettyprint">      manager = HelixManagerFactory.getZKHelixManager(clusterName,
+                                                          instanceName,
+                                                          InstanceType.CONTROLLER,
+                                                          zkConnectString);
+     manager.connect();
+     GenericHelixController controller = new GenericHelixController();
+     manager.addConfigChangeListener(controller);
+     manager.addLiveInstanceChangeListener(controller);
+     manager.addIdealStateChangeListener(controller);
+     manager.addExternalViewChangeListener(controller);
+     manager.addControllerListener(controller);
+</pre></div><p>This above snippet shows how the controller is started. You can also start the controller using command line interface.</p>
+<div class="source"><pre class="prettyprint">cd helix
+mvn clean install -Dmaven.test.skip=true
+cd helix-core/target/helix-core-pkg/bin
+chmod +x *
+./run-helix-controller.sh --zkSvr &lt;ZookeeperServerAddress(Required)&gt;  --cluster &lt;Cluster name (Required)&gt;
+</pre></div></div><div class="section"><h2>Spectator Code<a name="Spectator_Code"></a></h2><p>A spectator simply observes all cluster is notified when the state of the system changes. Helix consolidates the state of entire cluster in one Znode called ExternalView. Helix provides a default implementation RoutingTableProvider that caches the cluster state and updates it when there is a change in the cluster</p>
+<div class="source"><pre class="prettyprint">manager = HelixManagerFactory.getZKHelixManager(clusterName,
+                                                          instanceName,
+                                                          InstanceType.PARTICIPANT,
+                                                          zkConnectString);
+manager.connect();
+RoutingTableProvider routingTableProvider = new RoutingTableProvider();
+manager.addExternalViewChangeListener(routingTableProvider);
+
+</pre></div><p>In order to figure out who is serving a partition, here are the apis</p>
+<div class="source"><pre class="prettyprint">instances = routingTableProvider.getInstances(&quot;DBNAME&quot;, &quot;PARITION_NAME&quot;, &quot;PARTITION_STATE&quot;);
+</pre></div></div><div class="section"><h2>Helix Admin operations<a name="Helix_Admin_operations"></a></h2><p>Helix provides multiple ways to administer the cluster. It has a command line interface and also a REST interface.</p>
+<div class="source"><pre class="prettyprint">cd helix
+mvn clean install -Dmaven.test.skip=true
+cd helix-core/target/helix-core-pkg/bin
+chmod +x *
+./helix-admin.sh --help
+Provide zookeeper address. Required for all commands  
+   --zkSvr &lt;ZookeeperServerAddress(Required)&gt;       
+
+Add a new cluster                                                          
+   --addCluster &lt;clusterName&gt;                              
+
+Add a new Instance to a cluster                                    
+   --addNode &lt;clusterName InstanceAddress(host:port)&gt;                                      
+
+Add a State model to a cluster                                     
+   --addStateModelDef &lt;clusterName &lt;filename&gt;&gt;    
+
+Add a resource to a cluster            
+   --addResource &lt;clusterName resourceName partitionNum stateModelRef &lt;mode(AUTO_REBALANCE|AUTO|CUSTOM)&gt;&gt;      
+
+Upload an IdealState(Partition to Node Mapping)                                         
+   --addIdealState &lt;clusterName resourceName &lt;filename&gt;&gt;            
+
+Delete a cluster
+   --dropCluster &lt;clusterName&gt;                                                                         
+
+Delete a resource
+   --dropResource &lt;clusterName resourceName&gt;                                                           Drop an existing resource from a cluster
+
+Drop an existing Instance from a cluster    
+   --dropNode &lt;clusterName InstanceAddress(host:port)&gt;                    
+
+Enable/disable the entire cluster, this will basically pause the controller which means no transitions will be trigger, but the existing node sin the cluster continue to function 
+   --enableCluster &lt;clusterName&gt;
+
+Enable/disable a Instance. Useful to take a faulty node out of the cluster.
+   --enableInstance &lt;clusterName InstanceName true/false&gt;
+
+Enable/disable a partition
+   --enablePartition &lt;clusterName instanceName resourceName partitionName true/false&gt;
+
+
+   --listClusterInfo &lt;clusterName&gt;                                                                     Query info of a cluster
+   --listClusters                                                                                      List existing clusters
+   --listInstanceInfo &lt;clusterName InstanceName&gt;                                                       Query info of a Instance in a cluster
+   --listInstances &lt;clusterName&gt;                                                                       List Instances in a cluster
+   --listPartitionInfo &lt;clusterName resourceName partitionName&gt;                                        Query info of a partition
+   --listResourceInfo &lt;clusterName resourceName&gt;                                                       Query info of a resource
+   --listResources &lt;clusterName&gt;                                                                       List resources hosted in a cluster
+   --listStateModel &lt;clusterName stateModelName&gt;                                                       Query info of a state model in a cluster
+   --listStateModels &lt;clusterName&gt;                                                                     Query info of state models in a cluster
+
+</pre></div></div><div class="section"><h2>Idealstate modes and configuration<a name="Idealstate_modes_and_configuration"></a></h2>
+<ul>
+  <li>AUTO mode: Partition to Node assignment is pre-generated using consistent hashing</li>
+</ul>
+<div class="source"><pre class="prettyprint">  setupTool.addResourceToCluster(clusterName, resourceName, partitionNumber, &quot;MasterSlave&quot;)
+  setupTool.rebalanceStorageCluster(clusterName, resourceName, replicas)
+</pre></div>
+<ul>
+  <li>AUTO_REBALANCE mode: Partition to Node assignment is generated dynamically by cluster manager based on the nodes that are currently up and running</li>
+</ul>
+<div class="source"><pre class="prettyprint"> setupTool.addResourceToCluster(clusterName, resourceName, partitionNumber, &quot;MasterSlave&quot;, &quot;AUTO_REBALANCE&quot;)
+ setupTool.rebalanceStorageCluster(clusterName, resourceName, replicas)
+</pre></div>
+<ul>
+  <li>CUSTOMIZED mode: Allows one to set the is pre-generated from a JSON format file</li>
+</ul><p><tt>
+ setupTool.addIdealState(clusterName, resourceName, idealStateJsonFile)
+</tt></p></div><div class="section"><h2>Configuring state model<a name="Configuring_state_model"></a></h2>
+<div class="source"><pre class="prettyprint">StateModelConfigGenerator generator = new StateModelConfigGenerator();
+ZnRecord stateModelConfig = generator.generateConfigForOnlineOffline();
+StateModelDefinition stateModelDef = new StateModelDefinition(stateModelConfig);
+ClusterSetup setupTool = new ClusterSetup(zkConnectString);
+setupTool.addStateModelDef(cluster,stateModelName,stateModelDef);
+</pre></div><p>See StateModelConfigGenerator to get more info on creating custom state model.</p></div><div class="section"><h2>Messaging Api usage<a name="Messaging_Api_usage"></a></h2><p>See BootstrapProcess.java in examples package to see how Participants can exchange messages with each other.</p>
+<div class="source"><pre class="prettyprint">      ClusterMessagingService messagingService = manager.getMessagingService();
+      //CONSTRUCT THE MESSAGE
+      Message requestBackupUriRequest = new Message(
+          MessageType.USER_DEFINE_MSG, UUID.randomUUID().toString());
+      requestBackupUriRequest
+          .setMsgSubType(BootstrapProcess.REQUEST_BOOTSTRAP_URL);
+      requestBackupUriRequest.setMsgState(MessageState.NEW);
+      //SET THE RECIPIENT CRITERIA, All nodes that satisfy the criteria will receive the message
+      Criteria recipientCriteria = new Criteria();
+      recipientCriteria.setInstanceName(&quot;*&quot;);
+      recipientCriteria.setRecipientInstanceType(InstanceType.PARTICIPANT);
+      recipientCriteria.setResource(&quot;MyDB&quot;);
+      recipientCriteria.setPartition(&quot;&quot;);
+      //Should be processed only the process that is active at the time of sending the message. 
+      //This means if the recipient is restarted after message is sent, it will not be processed.
+      recipientCriteria.setSessionSpecific(true);
+      // wait for 30 seconds
+      int timeout = 30000;
+      //The handler that will be invoked when any recipient responds to the message.
+      BootstrapReplyHandler responseHandler = new BootstrapReplyHandler();
+      //This will return only after all recipients respond or after timeout.
+      int sentMessageCount = messagingService.sendAndWait(recipientCriteria,
+          requestBackupUriRequest, responseHandler, timeout);
+</pre></div><p>For more details on MessagingService see ClusterMessagingService</p></div>
+                  </div>
+            </div>
+          </div>
+
+    <hr/>
+
+    <footer>
+            <div class="container-fluid">
+              <div class="row span12">Copyright &copy;                    2013
+                        <a href="http://www.apache.org/">The Apache Software Foundation</a>.
+            All Rights Reserved.      
+                    
+      </div>
+
+        
+        
+                </div>
+    </footer>
+  </body>
+</html>
\ No newline at end of file

Added: incubator/helix/site-content/Sample_App.html
URL: http://svn.apache.org/viewvc/incubator/helix/site-content/Sample_App.html?rev=1480516&view=auto
==============================================================================
--- incubator/helix/site-content/Sample_App.html (added)
+++ incubator/helix/site-content/Sample_App.html Thu May  9 01:27:17 2013
@@ -0,0 +1,369 @@
+<!DOCTYPE html>
+<!--
+ | Generated by Apache Maven Doxia at Dec 11, 2012
+ | Rendered using Apache Maven Fluido Skin 1.3.0
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+  <head>
+    <meta charset="UTF-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <meta name="Date-Revision-yyyymmdd" content="20121211" />
+    <meta http-equiv="Content-Language" content="en" />
+    <title>Apache Helix - </title>
+    <link rel="stylesheet" href="./css/apache-maven-fluido-1.3.0.min.css" />
+    <link rel="stylesheet" href="./css/site.css" />
+    <link rel="stylesheet" href="./css/print.css" media="print" />
+
+      
+    <script type="text/javascript" src="./js/apache-maven-fluido-1.3.0.min.js"></script>
+
+    
+            </head>
+        <body class="topBarEnabled">
+          
+                        
+                    
+                
+
+    <div id="topbar" class="navbar navbar-fixed-top ">
+      <div class="navbar-inner">
+                                  <div class="container"><div class="nav-collapse">
+            
+                
+                                <ul class="nav">
+                          <li class="dropdown">
+        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Helix <b class="caret"></b></a>
+        <ul class="dropdown-menu">
+        
+                      <li>      <a href="index.html"  title="About">About</a>
+</li>
+                  
+                      <li>      <a href="Quickstart.html"  title="Quick Start">Quick Start</a>
+</li>
+                  
+                      <li>      <a href="ApiUsage.html"  title="Api Usage">Api Usage</a>
+</li>
+                  
+                      <li>      <a href="Architecture.html"  title="Architecture">Architecture</a>
+</li>
+                  
+                      <li>      <a href="Features.html"  title="Features">Features</a>
+</li>
+                  
+                      <li>      <a href="Sample_App.html"  title="Sample App">Sample App</a>
+</li>
+                  
+                      <li>      <a href="UseCases.html"  title="Use Cases">Use Cases</a>
+</li>
+                          </ul>
+      </li>
+                <li class="dropdown">
+        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Get Involved <b class="caret"></b></a>
+        <ul class="dropdown-menu">
+        
+                      <li>      <a href="mail-lists.html"  title="Mailing Lists">Mailing Lists</a>
+</li>
+                  
+                      <li>      <a href="issue-tracking.html"  title="Issues">Issues</a>
+</li>
+                  
+                      <li>      <a href="team-list.html"  title="Team">Team</a>
+</li>
+                  
+                      <li>      <a href="source-repository.html"  title="Sources">Sources</a>
+</li>
+                  
+                      <li>      <a href="integration.html"  title="Continuous Integration">Continuous Integration</a>
+</li>
+                  
+                      <li>      <a href="involved/building.html"  title="Building Guide">Building Guide</a>
+</li>
+                  
+                      <li>      <a href="involved/release.html"  title="Release Guide">Release Guide</a>
+</li>
+                          </ul>
+      </li>
+                <li class="dropdown">
+        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Project Documentation <b class="caret"></b></a>
+        <ul class="dropdown-menu">
+        
+                      <li class="dropdown-submenu">
+                                      <a href="project-info.html"  title="Project Information">Project Information</a>
+              <ul class="dropdown-menu">
+                                  <li>      <a href="index.html"  title="About">About</a>
+</li>
+                                  <li>      <a href="project-summary.html"  title="Project Summary">Project Summary</a>
+</li>
+                                  <li>      <a href="dependency-info.html"  title="Dependency Information">Dependency Information</a>
+</li>
+                                  <li>      <a href="modules.html"  title="Project Modules">Project Modules</a>
+</li>
+                                  <li>      <a href="license.html"  title="Project License">Project License</a>
+</li>
+                                  <li>      <a href="team-list.html"  title="Project Team">Project Team</a>
+</li>
+                                  <li>      <a href="source-repository.html"  title="Source Repository">Source Repository</a>
+</li>
+                                  <li>      <a href="issue-tracking.html"  title="Issue Tracking">Issue Tracking</a>
+</li>
+                                  <li>      <a href="mail-lists.html"  title="Mailing Lists">Mailing Lists</a>
+</li>
+                                  <li>      <a href="dependency-management.html"  title="Dependency Management">Dependency Management</a>
+</li>
+                                  <li>      <a href="dependencies.html"  title="Dependencies">Dependencies</a>
+</li>
+                                  <li>      <a href="dependency-convergence.html"  title="Dependency Convergence">Dependency Convergence</a>
+</li>
+                                  <li>      <a href="integration.html"  title="Continuous Integration">Continuous Integration</a>
+</li>
+                                  <li>      <a href="plugin-management.html"  title="Plugin Management">Plugin Management</a>
+</li>
+                                  <li>      <a href="plugins.html"  title="Project Plugins">Project Plugins</a>
+</li>
+                                  <li>      <a href="distribution-management.html"  title="Distribution Management">Distribution Management</a>
+</li>
+                              </ul>
+            </li>
+                  
+                      <li class="dropdown-submenu">
+                                      <a href="project-reports.html"  title="Project Reports">Project Reports</a>
+              <ul class="dropdown-menu">
+                                  <li>      <a href="xref/index.html"  title="Source Xref">Source Xref</a>
+</li>
+                                  <li>      <a href="xref-test/index.html"  title="Test Source Xref">Test Source Xref</a>
+</li>
+                                  <li>      <a href="apidocs/index.html"  title="JavaDocs">JavaDocs</a>
+</li>
+                                  <li>      <a href="checkstyle-aggregate.html"  title="Checkstyle">Checkstyle</a>
+</li>
+                                  <li>      <a href="sonar.html"  title="Sonar">Sonar</a>
+</li>
+                              </ul>
+            </li>
+                          </ul>
+      </li>
+                <li class="dropdown">
+        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Modules <b class="caret"></b></a>
+        <ul class="dropdown-menu">
+        
+                      <li>      <a href="helix-core/index.html"  title="Apache Helix :: Core">Apache Helix :: Core</a>
+</li>
+                  
+                      <li>      <a href="helix-admin-webapp/index.html"  title="Apache Helix :: Admin Webapp">Apache Helix :: Admin Webapp</a>
+</li>
+                  
+                      <li>      <a href="mockservice/index.html"  title="Helix :: Mockservice">Helix :: Mockservice</a>
+</li>
+                  
+                      <li>      <a href="recipes/index.html"  title="Helix :: Recipes">Helix :: Recipes</a>
+</li>
+                          </ul>
+      </li>
+                <li class="dropdown">
+        <a href="#" class="dropdown-toggle" data-toggle="dropdown">ASF <b class="caret"></b></a>
+        <ul class="dropdown-menu">
+        
+                      <li>      <a href="http://www.apache.org/foundation/how-it-works.html"  title="How Apache Works">How Apache Works</a>
+</li>
+                  
+                      <li>      <a href="http://www.apache.org/foundation/"  title="Foundation">Foundation</a>
+</li>
+                  
+                      <li>      <a href="http://www.apache.org/foundation/sponsorship.html"  title="Sponsoring Apache">Sponsoring Apache</a>
+</li>
+                  
+                      <li>      <a href="http://www.apache.org/foundation/thanks.html"  title="Thanks">Thanks</a>
+</li>
+                          </ul>
+      </li>
+                  </ul>
+          
+                      <form id="search-form" action="http://www.google.com/search" method="get"  class="navbar-search pull-right" >
+    
+  <input value="helix.incubator.apache.org" name="sitesearch" type="hidden"/>
+  <input class="search-query" name="q" id="query" type="text" />
+</form>
+<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=search-form"></script>
+          
+                                                              
+                   
+                      </div>
+          
+        </div>
+      </div>
+    </div>
+    
+        <div class="container">
+          <div id="banner">
+        <div class="pull-left">
+                                <div id="bannerLeft">
+                <h2>Apache Helix</h2>
+                </div>
+                      </div>
+        <div class="pull-right">                  <a href="http://incubator.apache.org/" id="bannerRight">
+                                                                                        <img src="http://incubator.apache.org/images/egg-logo.png" />
+                </a>
+      </div>
+        <div class="clear"><hr/></div>
+      </div>
+
+      <div id="breadcrumbs">
+        <ul class="breadcrumb">
+                
+                    
+                              <li class="">
+                    <a href="./" title="Apache Helix">
+        Apache Helix</a>
+        </li>
+      <li class="divider ">/</li>
+        <li class=""></li>
+        
+                
+                    
+                  <li id="publishDate" class="pull-right">Last Published: 2012-12-11</li> <li class="divider pull-right">|</li>
+              <li id="projectVersion" class="pull-right">Version: 0.6-incubating-SNAPSHOT</li>
+            
+                            </ul>
+      </div>
+
+      
+                
+        <div id="bodyColumn" >
+                                  
+            <!-- -
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License. --><h1>RabbitMQ Consumer Group</h1><p><a class="externalLink" href="http://www.rabbitmq.com/">RabbitMQ</a> is a well known Open source software the provides robust messaging for applications.</p><p>One of the commonly implemented recipes using this software is a work queue. <a class="externalLink" href="http://www.rabbitmq.com/tutorials/tutorial-four-java.html">http://www.rabbitmq.com/tutorials/tutorial-four-java.html</a> describes the use case where</p>
+<ul>
+  <li>A producer sends a message with a routing key.</li>
+  <li>The message goes to the queues whose binding key exactly matches the routing key of the message.</li>
+  <li>There are multiple consumers and each consumer is interested in processing only a subset of the messages by binding to the interested keys</li>
+</ul><p>The example provided <a class="externalLink" href="http://www.rabbitmq.com/tutorials/tutorial-four-java.html">here</a> describes how multiple consumers can be started to process all the tasks.</p><p>While this works, in production systems one needs the following * Ability to handle failures: when a consumers fails another consumer must be started or the other consumers must start processing these messages that should have been processed by the failed consumer. * When the existing consumers cannot keep up with the task generation rate, new consumers will be added. The tasks must be redistributed among all the consumers. </p><p>In this sample app, we explain how these set of consumers can be grouped together and handle consumer failures and expansion automatically.</p><p>Mapping this usecase to Helix is pretty easy as the binding key/routing key is equivalent to a partition. </p><p>Lets take a real example. Lets say a topic has 6 partitions, and we have 2 consumers to 
 process all the queues. What we want is all 6 queues to be evenly divided among 2 consumers. Eventually when the system scales, we add more consumers to keep up. This will make each consumer process tasks from 2 queues. Now lets say that a consumer fails and that the number of active consumers is now reduced to 2. This means each consumer must process 3 queues.</p><p>We showcase how such a dynamic App can be developed using Helix. </p><h1>Try it</h1><p>Before getting into the details on how to develop such an App using Helix, you can try the following steps to get a feel of it.</p>
+<div class="source"><pre class="prettyprint">git clone git@github.com:linkedin/helix.git
+cd helix
+./build
+export HELIX_PKG_ROOT=`pwd`/helix-core/target/helix-core-pkg
+</pre></div><p>OR Download the latest 0.5.28 release tar ball from <a class="externalLink" href="http://linkedin.github.com/helix/download/release-0.5.28//helix-core-pkg-0.5.28.tar.gz">here</a> <tt>
+tar -xzvf helix-core-pkg-0.5.28.tar.gz
+export HELIX_PKG_ROOT=`pwd`/helix-core-pkg
+</tt></p><p>Download the rabbitmq-consumer-group recipe from <a class="externalLink" href="http://linkedin.github.com/helix/download/release-0.5.28/rabbitmq-consumer-group-0.5.28.tar.gz">here</a> <tt>
+tar -xzvf rabbitmq-consumer-group-0.5.28.tar.gz
+export HELIX_RABBITMQ_ROOT=`pwd`/rabbitmq-consumer-group/
+</tt> <tt>
+chmod +x $HELIX_PKG_ROOT/bin/*
+chmod +x $HELIX_RABBITMQ_ROOT/bin/*
+</tt></p><div class="section"><h2>Install Rabbit MQ<a name="Install_Rabbit_MQ"></a></h2><p>Setting up RabbitMQ on a local box is straightforward. You can find the instructions here <a class="externalLink" href="http://www.rabbitmq.com/download.html">http://www.rabbitmq.com/download.html</a></p></div><div class="section"><h2>Start ZK<a name="Start_ZK"></a></h2><p>Start zookeeper at port 2199 <tt>
+$HELIX_PKG_ROOT/bin/start-standalone-zookeeper 2199
+</tt></p></div><div class="section"><h2>Setup the consumer group cluster<a name="Setup_the_consumer_group_cluster"></a></h2><p>This will setup the cluster by creating a rabbitmq-consumer-group cluster and adds a topic resource with 6 queues. <tt>
+$HELIX_RABBITMQ_ROOT/bin/setup-cluster.sh localhost:2199 
+</tt></p></div><div class="section"><h2>Add consumers<a name="Add_consumers"></a></h2><p>Start 2 consumers in 2 different terminals. Each consumer is given a unique id. ``` //start-consumer.sh zookeeperAddress (e.g. localhost:2181) consumerId , rabbitmqServer (e.g. localhost) $HELIX_RABBITMQ_ROOT/bin/start-consumer.sh localhost:2199 0 localhost $HELIX_RABBITMQ_ROOT/bin/start-consumer.sh localhost:2199 1 localhost </p>
+<div class="source"><pre class="prettyprint">Start HelixController
+--------------------
+Now start a Helix controller that starts managing the &quot;rabbitmq-consumer-group&quot; cluster.
+</pre></div><p>$HELIX_RABBITMQ_ROOT/bin/start-cluster-manager.sh localhost:2199 ```</p></div><div class="section"><h2>Send messages to the Topic<a name="Send_messages_to_the_Topic"></a></h2><p>Start sending messages to the topic. This script randomly selects a routing key (1-6) and sends the message to topic. Based on the key, messages gets routed to the appropriate queue.</p>
+<div class="source"><pre class="prettyprint">$HELIX_RABBITMQ_ROOT/bin/send-message.sh localhost 20
+</pre></div><p>After running this, you should see all 20 messages being processed by 2 consumers. </p></div><div class="section"><h2>Add another consumer<a name="Add_another_consumer"></a></h2><p>Once a new consumer is started, helix detects it. In order to balance the load between 3 consumers, it deallocates 1 partition from the existing consumers and allocates it to the new consumer. We see that each consumer is now processing only 2 queues. Helix makes sure that old nodes are asked to stop consuming before the new consumer is asked to start consuming for a given partition. But the transitions for each partition can happen in parallel. <tt>
+$HELIX_RABBITMQ_ROOT/bin/start-consumer.sh localhost:2199 2 localhost
+</tt></p><p>Send messages again to the topic. <tt>
+$HELIX_RABBITMQ_ROOT/bin/send-message.sh localhost 100
+</tt> You should see that messages are now received by all 3 consumers.</p></div><div class="section"><h2>Stop a consumer<a name="Stop_a_consumer"></a></h2><p>In any terminal press CTRL^C and notice that Helix detects the consumer failure and distributes the 2 partitions that were processed by failed consumer to the remaining 2 active consumers.</p><h1>How does it work</h1><p>Find the entire code <a class="externalLink" href="https://github.com/linkedin/helix/tree/master/recipes/rabbitmq-consumer-group/src/main/java/com/linkedin/helix/recipes/rabbitmq">here</a>. </p></div><div class="section"><h2>Cluster setup<a name="Cluster_setup"></a></h2><p>This step creates znode on zookeeper for the cluster and adds the state model. We use online offline state model since there is no need for other states. The consumer is either processing a queue or it is not.</p><p>It creates a resource called rabbitmq-consumer-group with 6 partitions. The execution mode is set to AUTO_REBALANCE. Thi
 s means that the Helix controls the assignment of partition to consumers and automatically distributes the partitions evenly among the active consumers. When a consumer is added or removed, it ensures that a minimum number of partitions are shuffled.</p>
+<div class="source"><pre class="prettyprint">      zkclient = new ZkClient(zkAddr, ZkClient.DEFAULT_SESSION_TIMEOUT,
+          ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
+      ZKHelixAdmin admin = new ZKHelixAdmin(zkclient);
+      
+      // add cluster
+      admin.addCluster(clusterName, true);
+
+      // add state model definition
+      StateModelConfigGenerator generator = new StateModelConfigGenerator();
+      admin.addStateModelDef(clusterName, &quot;OnlineOffline&quot;,
+          new StateModelDefinition(generator.generateConfigForOnlineOffline()));
+
+      // add resource &quot;topic&quot; which has 6 partitions
+      String resourceName = &quot;rabbitmq-consumer-group&quot;;
+      admin.addResource(clusterName, resourceName, 6, &quot;OnlineOffline&quot;, &quot;AUTO_REBALANCE&quot;);
+</pre></div></div><div class="section"><h2>Starting the consumers<a name="Starting_the_consumers"></a></h2><p>The only thing consumers need to know is the zkaddress, cluster name and consumer id. It does not need to know anything else.</p>
+<div class="source"><pre class="prettyprint">   _manager =
+          HelixManagerFactory.getZKHelixManager(_clusterName,
+                                                _consumerId,
+                                                InstanceType.PARTICIPANT,
+                                                _zkAddr);
+
+      StateMachineEngine stateMach = _manager.getStateMachineEngine();
+      ConsumerStateModelFactory modelFactory =
+          new ConsumerStateModelFactory(_consumerId, _mqServer);
+      stateMach.registerStateModelFactory(&quot;OnlineOffline&quot;, modelFactory);
+
+      _manager.connect();
+
+</pre></div><p>Once the consumer has registered the statemodel and the controller is started, the consumer starts getting callbacks (onBecomeOnlineFromOffline) for the partition it needs to host. All it needs to do as part of the callback is to start consuming messages from the appropriate queue. Similarly, when the controller deallocates a partitions from a consumer, it fires onBecomeOfflineFromOnline for the same partition. As a part of this transition, the consumer will stop consuming from a that queue.</p>
+<div class="source"><pre class="prettyprint"> @Transition(to = &quot;ONLINE&quot;, from = &quot;OFFLINE&quot;)
+  public void onBecomeOnlineFromOffline(Message message, NotificationContext context)
+  {
+    LOG.debug(_consumerId + &quot; becomes ONLINE from OFFLINE for &quot; + _partition);
+
+    if (_thread == null)
+    {
+      LOG.debug(&quot;Starting ConsumerThread for &quot; + _partition + &quot;...&quot;);
+      _thread = new ConsumerThread(_partition, _mqServer, _consumerId);
+      _thread.start();
+      LOG.debug(&quot;Starting ConsumerThread for &quot; + _partition + &quot; done&quot;);
+
+    }
+  }
+
+  @Transition(to = &quot;OFFLINE&quot;, from = &quot;ONLINE&quot;)
+  public void onBecomeOfflineFromOnline(Message message, NotificationContext context)
+      throws InterruptedException
+  {
+    LOG.debug(_consumerId + &quot; becomes OFFLINE from ONLINE for &quot; + _partition);
+
+    if (_thread != null)
+    {
+      LOG.debug(&quot;Stopping &quot; + _consumerId + &quot; for &quot; + _partition + &quot;...&quot;);
+
+      _thread.interrupt();
+      _thread.join(2000);
+      _thread = null;
+      LOG.debug(&quot;Stopping &quot; +  _consumerId + &quot; for &quot; + _partition + &quot; done&quot;);
+
+    }
+  }
+</pre></div></div>
+                  </div>
+          </div>
+
+    <hr/>
+
+    <footer>
+            <div class="container">
+              <div class="row span12">Copyright &copy;                    2012
+                        <a href="http://www.apache.org/">The Apache Software Foundation</a>.
+            All Rights Reserved.      
+                    
+      </div>
+
+        
+                <p id="poweredBy" class="pull-right">
+                          <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
+        <img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" />
+      </a>
+              </p>
+        
+                </div>
+    </footer>
+  </body>
+</html>
\ No newline at end of file