Added: helix/site-content/1.0.5-docs/tutorial_rebalance.html URL: http://svn.apache.org/viewvc/helix/site-content/1.0.5-docs/tutorial_rebalance.html?rev=1900823&view=auto ============================================================================== --- helix/site-content/1.0.5-docs/tutorial_rebalance.html (added) +++ helix/site-content/1.0.5-docs/tutorial_rebalance.html Thu May 12 05:29:03 2022 @@ -0,0 +1,400 @@ + +<!DOCTYPE html> + + + + + + +<!-- + Generated by Apache Maven Doxia at 2022-05-11 Rendered using Reflow Maven Skin 2.0.0 (https://olamy.github.io/reflow-maven-skin) +--> +<html xml:lang="en" lang="en"> + + <head> + <meta charset="UTF-8" /> + <title>Apache Helix – Tutorial - Rebalancing Algorithms</title> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <meta name="description" content="" /> + <meta http-equiv="content-language" content="en" /> + + <link href="./css/bootstrap.min.css" rel="stylesheet" /> + <link href="./css/bootstrap-responsive.min.css" rel="stylesheet" /> + <link href="./css/docs.css" rel="stylesheet" /> + <link href="./css/reflow-skin.css" rel="stylesheet" /> + + + <link href="./css/lightbox.css" rel="stylesheet" /> + + <link href="./css/site.css" rel="stylesheet" /> + <link href="./css/print.css" rel="stylesheet" media="print" /> + + <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements --> + <!--[if lt IE 9]> + <script src="./js/html5.js"></script> + <![endif]--> + + + + + + +<!-- Matomo --> +<script> + var _paq = window._paq = window._paq || []; + _paq.push(['disableCookies']); + _paq.push(['trackPageView']); + _paq.push(['enableLinkTracking']); + + (function() { + var u="https://analytics.apache.org"; + _paq.push(['setTrackerUrl', u+'/matomo.php']); + _paq.push(['setSiteId', '15']); + var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; + g.async=true; g.src=u+'/matomo.js'; s.parentNode.insertBefore(g,s); + })(); +</script> +<!-- End Matomo Code --> + </head> + + <body class="page-tutorial_rebalance project-105-docs" data-spy="scroll" data-offset="60" data-target="#toc-scroll-target"> + + + <div class="navbar navbar-fixed-top"> + <div class="navbar-inner"> + <div class="container"> + <a class="btn btn-navbar" data-toggle="collapse" data-target="#top-nav-collapse"> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </a> + <a class="brand" href="http://helix.apache.org">Apache Helix</a> + <div class="nav-collapse collapse" id="top-nav-collapse"> + <ul class="nav pull-right"> + <li ><a href="index.html" title="Helix 1.0.4">Helix 1.0.4</a></li> + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Get Helix <b class="caret"></b></a> + <ul class="dropdown-menu"> + <li ><a href="download.html" title="Download">Download</a></li> + <li ><a href="Building.html" title="Building">Building</a></li> + <li ><a href="releasenotes/release-1.0.4.html" title="Release Notes">Release Notes</a></li> + </ul> + </li> + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Hands-On <b class="caret"></b></a> + <ul class="dropdown-menu"> + <li ><a href="Quickstart.html" title="Quick Start">Quick Start</a></li> + <li ><a href="Tutorial.html" title="Tutorial">Tutorial</a></li> + <li ><a href="../javadocs/1.0.4" title="Javadocs">Javadocs</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> + <li ><a href="recipes/service_discovery.html" title="Service discovery">Service discovery</a></li> + <li ><a href="recipes/task_dag_execution.html" title="Distributed task DAG execution">Distributed task DAG execution</a></li> + </ul> + </li> + </ul> + </div><!--/.nav-collapse --> + </div> + </div> + </div> + + <div class="container"> + + <!-- Masthead + ================================================== --> + + <header> + <div class="jumbotron subhead"> + <div class="row" id="banner"> + <div class="span12"> + <div class="pull-left"> + <a href="http://helix.apache.org/" id="bannerLeft"><img src="../images/helix-logo.jpg" alt='"''"' /></a> + <p class="lead">A cluster management framework for partitioned and replicated distributed resources</p> + </div> + <div class="pull-right"> + <a href="http://www.apache.org/" id="bannerRight"><img src="../images/feather_small.gif" alt='"''"' /></a> + </div> + </div> + </div> + </div> + <div> + <ul class="breadcrumb"> + <li><a href="http://helix.apache.org/" title="Apache Helix" class="externalLink">Apache Helix</a></li> + <li class="divider">/</li> + <li><a href="../" title="Apache Helix">Apache Helix</a></li> + <li class="divider">/</li> + <li><a href="../1.0.4-docs/" title="Release 1.0.4">Release 1.0.4</a></li> + <li class="divider">/</li> + <li>Tutorial - Rebalancing Algorithms</li> + <li class="publishDate version-date pull-right">Last Published: 2022-05-11</li> + </ul> + </div> + </header> + + <div class="main-body"> + <div class="row"> + <div class="span12"> + <div class="body-content"> +<!-- +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. +--> +<section> + <div class="page-header"> + <h2 id="Helix_Tutorial:_Rebalancing_Algorithms"><a href="./Tutorial.html">Helix Tutorial</a>: Rebalancing Algorithms</h2> + </div> + <p>The placement of partitions in a distributed system is essential for the reliability and scalability of the system. For example, when a node fails, it is important that the partitions hosted on that node are reallocated evenly among the remaining nodes. Consistent hashing is one such algorithm that can satisfy this guarantee. Helix provides a variant of consistent hashing based on the RUSH algorithm, among others.</p> + <p>This means given a number of partitions, replicas and number of nodes, Helix does the automatic assignment of partition to nodes such that:</p> + <ul> + <li>Each node has the same number of partitions</li> + <li>Replicas of the same partition do not stay on the same node</li> + <li>When a node fails, the partitions will be equally distributed among the remaining nodes</li> + <li>When new nodes are added, the number of partitions moved will be minimized along with satisfying the above criteria</li> + </ul> + <p>Helix employs a rebalancing algorithm to compute the <i>ideal state</i> of the system. When the <i>current state</i> differs from the <i>ideal state</i>, Helix uses it as the target state of the system and computes the appropriate transitions needed to bring it to the <i>ideal state</i>.</p> + <p>Helix makes it easy to perform this operation, while giving you control over the algorithm. In this section, we'll see how to implement the desired behavior.</p> + <p>Helix has four options for rebalancing, in increasing order of customization by the system builder:</p> + <ul> + <li>FULL_AUTO</li> + <li>SEMI_AUTO</li> + <li>CUSTOMIZED</li> + <li>USER_DEFINED</li> + </ul> + <div class="source"> + <pre><code> |FULL_AUTO | SEMI_AUTO | CUSTOMIZED| USER_DEFINED | + ---------------------------------------------------------| + LOCATION | HELIX | APP | APP | APP | + ---------------------------------------------------------| + STATE | HELIX | HELIX | APP | APP | + ---------------------------------------------------------- +</code></pre> + </div> + <section> + <h3 id="FULL_AUTO">FULL_AUTO</h3> + <p>When the rebalance mode is set to FULL_AUTO, Helix controls both the location of the replica along with the state. This option is useful for applications where creation of a replica is not expensive.</p> + <p>For example, consider this system that uses a LeaderStandby state model, with 3 partitions and 2 replicas in the ideal state.</p> + <div class="source"> + <pre><code>{ + "id" : "MyResource", + "simpleFields" : { + "REBALANCE_MODE" : "FULL_AUTO", + "NUM_PARTITIONS" : "3", + "REPLICAS" : "2", + "STATE_MODEL_DEF_REF" : "LeaderStandby", + } + "listFields" : { + "MyResource_0" : [], + "MyResource_1" : [], + "MyResource_2" : [] + }, + "mapFields" : { + } +} +</code></pre> + </div> + <p>If there are 3 nodes in the cluster, then Helix will balance the leaders and standbys equally. The ideal state is therefore:</p> + <div class="source"> + <pre><code>{ + "id" : "MyResource", + "simpleFields" : { + "NUM_PARTITIONS" : "3", + "REPLICAS" : "2", + "STATE_MODEL_DEF_REF" : "LeaderStandby", + }, + "mapFields" : { + "MyResource_0" : { + "N1" : "LEADER", + "N2" : "STANDBY", + }, + "MyResource_1" : { + "N2" : "LEADER", + "N3" : "STANDBY", + }, + "MyResource_2" : { + "N3" : "LEADER", + "N1" : "STANDBY", + } + } +} +</code></pre> + </div> + <p>Another typical example is evenly distributing a group of tasks among the currently healthy processes. For example, if there are 60 tasks and 4 nodes, Helix assigns 15 tasks to each node. When one node fails, Helix redistributes its 15 tasks to the remaining 3 nodes, resulting in a balanced 20 tasks per node. Similarly, if a node is added, Helix re-allocates 3 tasks from each of the 4 nodes to the 5th node, resulting in a balanced distribution of 12 tasks per node..</p> + </section> + <section> + <h3 id="SEMI_AUTO">SEMI_AUTO</h3> + <p>When the application needs to control the placement of the replicas, use the SEMI_AUTO rebalance mode.</p> + <p>Example: In the ideal state below, the partition 'MyResource_0' is constrained to be placed only on node1 or node2. The choice of <i>state</i> is still controlled by Helix. That means MyResource_0.LEADER could be on node1 and MyResource_0.STANDBY on node2, or vice-versa but neither would be placed on node3.</p> + <div class="source"> + <pre><code>{ + "id" : "MyResource", + "simpleFields" : { + "REBALANCE_MODE" : "SEMI_AUTO", + "NUM_PARTITIONS" : "3", + "REPLICAS" : "2", + "STATE_MODEL_DEF_REF" : "LeaderStandby", + } + "listFields" : { + "MyResource_0" : [node1, node2], + "MyResource_1" : [node2, node3], + "MyResource_2" : [node3, node1] + }, + "mapFields" : { + } +} +</code></pre> + </div> + <p>The LeaderStandby state model requires that a partition has exactly one LEADER at all times, and the other replicas should be STANDBYs. In this simple example with 2 replicas per partition, there would be one LEADER and one STANDBY. Upon failover, a STANDBY has to assume leadership, and a new STANDBY will be generated.</p> + <p>In this mode when node1 fails, unlike in FULL_AUTO mode the partition is <i>not</i> moved from node1 to node3. Instead, Helix will decide to change the state of MyResource_0 on node2 from STANDBY to LEADER, based on the system constraints.</p> + </section> + <section> + <h3 id="CUSTOMIZED">CUSTOMIZED</h3> + <p>Helix offers a third mode called CUSTOMIZED, in which the application controls the placement <i>and</i> state of each replica. The application needs to implement a callback interface that Helix invokes when the cluster state changes. Within this callback, the application can recompute the idealstate. Helix will then issue appropriate transitions such that <i>Idealstate</i> and <i>Currentstate</i> converges.</p> + <p>Here's an example, again with 3 partitions, 2 replicas per partition, and the LeaderStandby state model:</p> + <div class="source"> + <pre><code>{ + "id" : "MyResource", + "simpleFields" : { + "REBALANCE_MODE" : "CUSTOMIZED", + "NUM_PARTITIONS" : "3", + "REPLICAS" : "2", + "STATE_MODEL_DEF_REF" : "LeaderStandby", + }, + "mapFields" : { + "MyResource_0" : { + "N1" : "LEADER", + "N2" : "STANDBY", + }, + "MyResource_1" : { + "N2" : "LEADER", + "N3" : "STANDBY", + }, + "MyResource_2" : { + "N3" : "LEADER", + "N1" : "STANDBY", + } + } +} +</code></pre> + </div> + <p>Suppose the current state of the system is âMyResource_0â -> {N1:LEADER, N2:STANDBY} and the application changes the ideal state to âMyResource_0â -> {N1:STANDBY,N2:LEADER}. While the application decides which node is LEADER and which is STANDBY, Helix will not blindly issue LEADER-->STANDBY to N1 and STANDBY-->LEADER to N2 in parallel, since that might result in a transient state where both N1 and N2 are leaders, which violates the LeaderStandby constraint that there is exactly one LEADER at a time. Helix will first issue LEADER-->STANDBY to N1 and after it is completed, it will issue STANDBY-->LEADER to N2.</p> + </section> + <section> + <h3 id="USER_DEFINED">USER_DEFINED</h3> + <p>For maximum flexibility, Helix exposes an interface that can allow applications to plug in custom rebalancing logic. By providing the name of a class that implements the Rebalancer interface, Helix will automatically call the contained method whenever there is a change to the live participants in the cluster. For more, see <a href="./tutorial_user_def_rebalancer.html">User-Defined Rebalancer</a>.</p> + </section> + <section> + <h3 id="Backwards_Compatibility">Backwards Compatibility</h3> + <p>In previous versions, FULL_AUTO was called AUTO_REBALANCE and SEMI_AUTO was called AUTO. Furthermore, they were presented as the IDEAL_STATE_MODE. Helix supports both IDEAL_STATE_MODE and REBALANCE_MODE, but IDEAL_STATE_MODE is now deprecated and may be phased out in future versions.</p> + </section> +</section> + </div> + </div> + </div> + </div> + + </div><!-- /container --> + + <!-- Footer + ================================================== --> + <footer class="well"> + <div class="container"> + <div class="row"> + <div class="span3 bottom-nav"> + <ul class="nav nav-list"> + <li class="nav-header">Get Helix</li> + <li > + <a href="download.html" title="Download">Download</a> + </li> + <li > + <a href="Building.html" title="Building">Building</a> + </li> + <li > + <a href="releasenotes/release-1.0.4.html" title="Release Notes">Release Notes</a> + </li> + </ul> + </div> + <div class="span3 bottom-nav"> + <ul class="nav nav-list"> + <li class="nav-header">Hands-On</li> + <li > + <a href="Quickstart.html" title="Quick Start">Quick Start</a> + </li> + <li > + <a href="Tutorial.html" title="Tutorial">Tutorial</a> + </li> + <li > + <a href="../javadocs/1.0.4" title="Javadocs">Javadocs</a> + </li> + </ul> + </div> + <div class="span3 bottom-nav"> + <ul class="nav nav-list"> + <li class="nav-header">Recipes</li> + <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> + <li > + <a href="recipes/service_discovery.html" title="Service discovery">Service discovery</a> + </li> + <li > + <a href="recipes/task_dag_execution.html" title="Distributed task DAG execution">Distributed task DAG execution</a> + </li> + </ul> + </div> + </div> + </div> + </footer> + + <div class="container subfooter"> + <div class="row"> + <div class="span12"> + <p class="pull-right"><a href="#">Back to top</a></p> + <p class="copyright">Copyright ©2022 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All Rights Reserved.</p> + <p><a href="https://github.com/olamy/reflow-maven-skin" title="Reflow Maven skin">Reflow Maven skin</a> maintained by <a href="https://twitter.com/olamy" target="_blank" title="Olivier Lamy">Olivier Lamy</a>.</p> + <div class="row span16"><div>Apache Helix, Apache, the Apache feather logo, and the Apache Helix project logos are trademarks of The Apache Software Foundation. + All other marks mentioned may be trademarks or registered trademarks of their respective owners.</div> + <a href="https://helix.apache.org/1.0.5-docs/privacy-policy.html">Privacy Policy</a> + </div> + </div> + </div> + </div> + + <!-- Le javascript + ================================================== --> + <!-- Placed at the end of the document so the pages load faster --> + <script src="./js/jquery.min.js"></script> + + <script src="./js/bootstrap.min.js"></script> + <script src="./js/lightbox.min.js"></script> + <script src="./js/reflow-scroll.js"></script> + + <script src="./js/reflow-skin.js"></script> + + </body> +</html> \ No newline at end of file
Added: helix/site-content/1.0.5-docs/tutorial_rest_service.html URL: http://svn.apache.org/viewvc/helix/site-content/1.0.5-docs/tutorial_rest_service.html?rev=1900823&view=auto ============================================================================== --- helix/site-content/1.0.5-docs/tutorial_rest_service.html (added) +++ helix/site-content/1.0.5-docs/tutorial_rest_service.html Thu May 12 05:29:03 2022 @@ -0,0 +1,1234 @@ + +<!DOCTYPE html> + + + + + + +<!-- + Generated by Apache Maven Doxia at 2022-05-11 Rendered using Reflow Maven Skin 2.0.0 (https://olamy.github.io/reflow-maven-skin) +--> +<html xml:lang="en" lang="en"> + + <head> + <meta charset="UTF-8" /> + <title>Apache Helix – Tutorial - REST Service 2.0</title> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <meta name="description" content="" /> + <meta http-equiv="content-language" content="en" /> + + <link href="./css/bootstrap.min.css" rel="stylesheet" /> + <link href="./css/bootstrap-responsive.min.css" rel="stylesheet" /> + <link href="./css/docs.css" rel="stylesheet" /> + <link href="./css/reflow-skin.css" rel="stylesheet" /> + + + <link href="./css/lightbox.css" rel="stylesheet" /> + + <link href="./css/site.css" rel="stylesheet" /> + <link href="./css/print.css" rel="stylesheet" media="print" /> + + <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements --> + <!--[if lt IE 9]> + <script src="./js/html5.js"></script> + <![endif]--> + + + + + + +<!-- Matomo --> +<script> + var _paq = window._paq = window._paq || []; + _paq.push(['disableCookies']); + _paq.push(['trackPageView']); + _paq.push(['enableLinkTracking']); + + (function() { + var u="https://analytics.apache.org"; + _paq.push(['setTrackerUrl', u+'/matomo.php']); + _paq.push(['setSiteId', '15']); + var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; + g.async=true; g.src=u+'/matomo.js'; s.parentNode.insertBefore(g,s); + })(); +</script> +<!-- End Matomo Code --> + </head> + + <body class="page-tutorial_rest_service project-105-docs" data-spy="scroll" data-offset="60" data-target="#toc-scroll-target"> + + + <div class="navbar navbar-fixed-top"> + <div class="navbar-inner"> + <div class="container"> + <a class="btn btn-navbar" data-toggle="collapse" data-target="#top-nav-collapse"> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </a> + <a class="brand" href="http://helix.apache.org">Apache Helix</a> + <div class="nav-collapse collapse" id="top-nav-collapse"> + <ul class="nav pull-right"> + <li ><a href="index.html" title="Helix 1.0.4">Helix 1.0.4</a></li> + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Get Helix <b class="caret"></b></a> + <ul class="dropdown-menu"> + <li ><a href="download.html" title="Download">Download</a></li> + <li ><a href="Building.html" title="Building">Building</a></li> + <li ><a href="releasenotes/release-1.0.4.html" title="Release Notes">Release Notes</a></li> + </ul> + </li> + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Hands-On <b class="caret"></b></a> + <ul class="dropdown-menu"> + <li ><a href="Quickstart.html" title="Quick Start">Quick Start</a></li> + <li ><a href="Tutorial.html" title="Tutorial">Tutorial</a></li> + <li ><a href="../javadocs/1.0.4" title="Javadocs">Javadocs</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> + <li ><a href="recipes/service_discovery.html" title="Service discovery">Service discovery</a></li> + <li ><a href="recipes/task_dag_execution.html" title="Distributed task DAG execution">Distributed task DAG execution</a></li> + </ul> + </li> + </ul> + </div><!--/.nav-collapse --> + </div> + </div> + </div> + + <div class="container"> + + <!-- Masthead + ================================================== --> + + <header> + <div class="jumbotron subhead"> + <div class="row" id="banner"> + <div class="span12"> + <div class="pull-left"> + <a href="http://helix.apache.org/" id="bannerLeft"><img src="../images/helix-logo.jpg" alt='"''"' /></a> + <p class="lead">A cluster management framework for partitioned and replicated distributed resources</p> + </div> + <div class="pull-right"> + <a href="http://www.apache.org/" id="bannerRight"><img src="../images/feather_small.gif" alt='"''"' /></a> + </div> + </div> + </div> + </div> + <div> + <ul class="breadcrumb"> + <li><a href="http://helix.apache.org/" title="Apache Helix" class="externalLink">Apache Helix</a></li> + <li class="divider">/</li> + <li><a href="../" title="Apache Helix">Apache Helix</a></li> + <li class="divider">/</li> + <li><a href="../1.0.4-docs/" title="Release 1.0.4">Release 1.0.4</a></li> + <li class="divider">/</li> + <li>Tutorial - REST Service 2.0</li> + <li class="publishDate version-date pull-right">Last Published: 2022-05-11</li> + </ul> + </div> + </header> + + <div class="main-body"> + <div class="row"> + <div class="span12"> + <div class="body-content"> +<!-- +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. +--> +<section> + <div class="page-header"> + <h2 id="Helix_Tutorial:_REST_Service_2.0"><a href="./Tutorial.html">Helix Tutorial</a>: REST Service 2.0</h2> + </div> + <p>New Helix REST service supported features:</p> + <ul> + <li>Expose all admin operations via restful API. + <ul> + <li>All of Helix admin operations, include these defined in HelixAdmin.java and ConfigAccessor.java, etc, are exposed via rest API.</li> + </ul> </li> + <li>Support all task framework API via restful.Current task framework operations are supported from rest API too.</li> + <li>More standard Restful API + <ul> + <li>Use the standard HTTP methods if possible, GET, POST, PUT, DELETE, instead of customized command as it today.</li> + <li>Customized command will be used if there is no corresponding HTTP methods, for example, rebalance a resource, disable an instance, etc.</li> + </ul> </li> + <li>Make Helix restful service an separately deployable service.</li> + <li>Enable Access/Audit log for all write access.</li> + </ul> + <section> + <h3 id="Installation">Installation</h3> + <p>The command line tool comes with helix-core package:</p> + <p>Get the command line tool:</p> + <div class="source"> + <pre><code>git clone https://git-wip-us.apache.org/repos/asf/helix.git +cd helix +git checkout tags/helix-1.0.4 +./build +cd helix-rest/target/helix-rest-pkg/bin +chmod +x *.sh +</code></pre> + </div> + <p>Get help:</p> + <div class="source"> + <pre><code>./run-rest-admin.sh --help +</code></pre> + </div> + <p>Start the REST server</p> + <div class="source"> + <pre><code>./run-rest-admin.sh --port 1234 --zkSvr localhost:2121 +</code></pre> + </div> + </section> + <section> + <h3 id="Helix_REST_2.0_Endpoint">Helix REST 2.0 Endpoint</h3> + <p>Helix REST 2.0 endpoint will start with /admin/v2 prefix, and the rest will mostly follow the current URL convention. This allows us to support v2.0 endpoint at the same time with the current Helix web interface. Some sample v2.0 endpoints would look like the following:</p> + <div class="source"> + <pre><code>curl -X GET http://localhost:12345/admin/v2/clusters +curl -X POST http://localhost:12345/admin/v2/clusters/myCluster +curl -X POST http://localhost:12345/admin/v2/clusters/myCluster?command=activate&supercluster=controler_cluster +curl http://localhost:12345/admin/v2/clusters/myCluster/resources/myResource/IdealState +</code></pre> + </div> + </section> + <section> + <h3 id="REST_Endpoints_and_Supported_Operations">REST Endpoints and Supported Operations</h3> + <section> + <h4 id="Operations_on_Helix_Cluster">Operations on Helix Cluster</h4> + <ul> + <li> <p><b>â/clustersâ</b></p> + <ul> + <li>Represents all helix managed clusters connected to given zookeeper</li> + <li><b>GET</b> â List all Helix managed clusters. Example: curl <a class="externalLink" href="http://localhost:1234/admin/v2/clusters">http://localhost:1234/admin/v2/clusters</a></li> + </ul> + <div class="source"> + <pre><code>$curl http://localhost:1234/admin/v2/clusters +{ + "clusters" : [ "cluster1", "cluster2", "cluster3"] +} +</code></pre> + </div> </li> + <li> <p><b>â/clusters/{clusterName}â</b></p> + <ul> + <li> <p>Represents a helix cluster with name {clusterName}</p> </li> + <li> <p><b>GET</b> â return the cluster info. Example: curl <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/myCluster">http://localhost:1234/admin/v2/clusters/myCluster</a></p> + <div class="source"> + <pre><code>$curl http://localhost:1234/admin/v2/clusters/myCluster +{ + "id" : "myCluster", + "paused" : true, + "disabled" : true, + "controller" : "helix.apache.org:1234", + "instances" : [ "aaa.helix.apache.org:1234", "bbb.helix.apache.org:1234" ], + "liveInstances" : ["aaa.helix.apache.org:1234"], + "resources" : [ "resource1", "resource2", "resource3" ], + "stateModelDefs" : [ "MasterSlave", "LeaderStandby", "OnlineOffline" ] +} +</code></pre> + </div> </li> + <li> <p><b>PUT</b> â create a new cluster with {clusterName}, it returns 200 if the cluster already exists. Example: curl -X PUT <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/myCluster">http://localhost:1234/admin/v2/clusters/myCluster</a></p> </li> + <li> <p><b>DELETE</b> â delete this cluster. Example: curl -X DELETE <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/myCluster">http://localhost:1234/admin/v2/clusters/myCluster</a></p> </li> + <li> <p><b>activate</b> â Link this cluster to a Helix super (controller) cluster, i.e, add the cluster as a resource to the super cluster. Example: curl -X POST <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/myCluster?command=activate&superCluster=myCluster">http://localhost:1234/admin/v2/clusters/myCluster?command=activate&superCluster=myCluster</a></p> </li> + <li> <p><b>expand</b> â In the case that a set of new node is added in the cluster, use this command to balance the resources on the existing instances to new added instances. Example: curl -X POST <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/myCluster?command=expand">http://localhost:1234/admin/v2/clusters/myCluster?command=expand</a></p> </li> + <li> <p><b>enable</b> â enable/resume the cluster. Example: curl -X POST <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/myCluster?command=enable">http://localhost:1234/admin/v2/clusters/myCluster?command=enable</a></p> </li> + <li> <p><b>disable</b> â disable/pause the cluster. Example: curl -X POST <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/myCluster?command=disable">http://localhost:1234/admin/v2/clusters/myCluster?command=disable</a></p> </li> + </ul> </li> + <li> <p><b>â/clusters/{clusterName}/configsâ</b></p> + <ul> + <li>Represents cluster level configs for cluster with {clusterName}</li> + <li><b>GET</b>: get all configs.</li> + </ul> + <div class="source"> + <pre><code>$curl http://localhost:1234/admin/v2/clusters/myCluster/configs +{ + "id" : "myCluster", + "simpleFields" : { + "PERSIST_BEST_POSSIBLE_ASSIGNMENT" : "true" + }, + "listFields" : { + }, + "mapFields" : { + } +} +</code></pre> + </div> + <ul> + <li><b>POST</b>: update or delete one/some config entries.<br> update â Update the entries included in the input.</li> + </ul> + <div class="source"> + <pre><code>$curl -X POST -H "Content-Type: application/json" http://localhost:1234/admin/v2/clusters/myCluster/configs?command=update -d ' +{ + "id" : "myCluster", + "simpleFields" : { + "PERSIST_BEST_POSSIBLE_ASSIGNMENT" : "true" + }, + "listFields" : { + "disabledPartition" : ["p1", "p2", "p3"] + }, + "mapFields" : { + } +}' +</code></pre> + </div> + <div class="source"> + <pre><code>delete -- Remove the entries included in the input from current config. +</code></pre> + </div> + <div class="source"> + <pre><code>$curl -X POST -H "Content-Type: application/json" http://localhost:1234/admin/v2/clusters/myCluster/configs?command=update -d ' +{ + "id" : "myCluster", + "simpleFields" : { + }, + "listFields" : { + "disabledPartition" : ["p1", "p3"] + }, + "mapFields" : { + } +}' +</code></pre> + </div> </li> + <li> <p><b>â/clusters/{clusterName}/controllerâ</b></p> + <ul> + <li>Represents the controller for cluster {clusterName}.</li> + <li><b>GET</b> â return controller information</li> + </ul> + <div class="source"> + <pre><code>$curl http://localhost:1234/admin/v2/clusters/myCluster/controller +{ + "id" : "myCluster", + "controller" : "test.helix.apache.org:1234", + "HELIX_VERSION":"1.0.4", + "LIVE_INSTANCE":"[email protected]:1234", + "SESSION_ID":"35ab496aba54c99" +} +</code></pre> + </div> </li> + <li> <p><b>â/clusters/{clusterName}/controller/errorsâ</b></p> + <ul> + <li>Represents error information for the controller of cluster {clusterName}. This is new endpoint in v2.0.</li> + <li><b>GET</b> â get all error information.</li> + <li><b>DELETE</b> â clean up all error logs.</li> + </ul> </li> + <li> <p><b>â/clusters/{clusterName}/controller/historyâ</b></p> + <ul> + <li>Represents the change history of leader controller of cluster {clusterName}. This is new endpoint in v2.0.</li> + <li><b>GET</b> â get the leader controller history.</li> + </ul> + <div class="source"> + <pre><code>$curl http://localhost:1234/admin/v2/clusters/myCluster/controller/history +{ + "id" : "myCluster", + "history" [ + "{DATE=2017-03-21-16:57:14, CONTROLLER=test1.helix.apache.org:1234, TIME=1490115434248}", + "{DATE=2017-03-27-22:35:16, CONTROLLER=test3.helix.apache.org:1234, TIME=1490654116484}", + "{DATE=2017-03-27-22:35:24, CONTROLLER=test2.helix.apache.org:1234, TIME=1490654124926}" + ] +} +</code></pre> + </div> </li> + <li> <p><b>/clusters/{clusterName}/controller/messages"</b></p> + <ul> + <li>Represents all uncompleted messages currently received by the controller of cluster {clusterName}. This is new endpoint in v2.0.</li> + <li><b>GET</b> â list all uncompleted messages received by the controller.</li> + </ul> + <div class="source"> + <pre><code>$curl http://localhost:1234/admin/v2/clusters/myCluster/controller/messages +{ + "id" : "myCluster", + "count" : 5, + "messages" [ + "0b8df4f2-776c-4325-96e7-8fad07bd9048", + "13a8c0af-b77e-4f5c-81a9-24fedb62cf58" + ] +} +</code></pre> + </div> </li> + <li> <p><b>â/clusters/{clusterName}/controller/messages/{messageId}â</b></p> + <ul> + <li>Represents the messages currently received by the controller of cluster {clusterName} with id {messageId}. This is new endpoint in v2.0.</li> + <li><b>GET</b> - get the message with {messageId} received by the controller.</li> + <li><b>DELETE</b> - delete the message with {messageId}</li> + </ul> </li> + <li> <p><b>â/clusters/{clusterName}/statemodeldefs/â</b></p> + <ul> + <li>Represents all the state model definitions defined in cluster {clusterName}. This is new endpoint in v2.0.</li> + <li><b>GET</b> - get all the state model definition in the cluster.</li> + </ul> + <div class="source"> + <pre><code>$curl -X POST -H "Content-Type: application/json" http://localhost:1234/admin/v2/clusters/myCluster/statemodeldefs +{ + "id" : "myCluster", + "stateModelDefs" : [ "MasterSlave", "LeaderStandby", "OnlineOffline" ] +} +</code></pre> + </div> </li> + <li> <p><b>â/clusters/{clusterName}/statemodeldefs/{statemodeldef}â</b></p> + <ul> + <li>Represents the state model definition {statemodeldef} defined in cluster {clusterName}. This is new endpoint in v2.0.</li> + <li><b>GET</b> - get the state model definition</li> + </ul> + <div class="source"> + <pre><code>$curl -X POST -H "Content-Type: application/json" http://localhost:1234/admin/v2/clusters/myCluster/statemodeldefs/LeaderStandby +{ + "id" : "STANDBY", + "simpleFields" : { + "INITIAL_STATE" : "OFFLINE" + }, + "mapFields" : { + "DROPPED.meta" : { + "count" : "-1" + }, + "ERROR.meta" : { + "count" : "-1" + }, + "ERROR.next" : { + "DROPPED" : "DROPPED", + "OFFLINE" : "OFFLINE" + }, + "LEADER.meta" : { + "count" : "1" + }, + "LEADER.next" : { + "STANDBY" : "STANDBY", + "DROPPED" : "STANDBY", + "OFFLINE" : "STANDBY" + }, + "OFFLINE.meta" : { + "count" : "-1" + }, + "OFFLINE.next" : { + "STANDBY" : "STANDBY", + "LEADER" : "STANDBY", + "DROPPED" : "DROPPED" + }, + "STANDBY.meta" : { + "count" : "R" + }, + "STANDBY.next" : { + "LEADER" : "LEADER", + "DROPPED" : "OFFLINE", + "OFFLINE" : "OFFLINE" + } + }, + "listFields" : { + "STATE_PRIORITY_LIST" : [ "LEADER", "STANDBY", "OFFLINE", "DROPPED", "ERROR" ], + "STATE_TRANSITION_PRIORITYLIST" : [ "LEADER-STANDBY", "STANDBY-LEADER", "OFFLINE-STANDBY", "STANDBY-OFFLINE", "OFFLINE-DROPPED" ] + } +} +</code></pre> + </div> + <ul> + <li><b>POST</b> - add a new state model definition with {statemodeldef}</li> + <li><b>DELETE</b> - delete the state model definition</li> + </ul> </li> + </ul> + </section> + <section> + <h4 id="Helix_.E2.80.9CResource.E2.80.9D_and_its_sub-resources">Helix âResourceâ and its sub-resources</h4> + <ul> + <li> <p><b>â/clusters/{clusterName}/resourcesâ</b></p> + <ul> + <li>Represents all resources in a cluster.</li> + <li><b>GET</b> - list all resources with their IdealStates and ExternViews.</li> + </ul> + <div class="source"> + <pre><code>$curl http://localhost:1234/admin/v2/clusters/myCluster/resources +{ + "id" : "myCluster", + "idealstates" : [ "idealstate1", "idealstate2", "idealstate3" ], + "externalviews" : [ "idealstate1", "idealstate3" ] +} +</code></pre> + </div> </li> + <li> <p><b>â/clusters/{clusterName}/resources/{resourceName}â</b></p> + <ul> + <li>Represents a resource in cluster {clusterName} with name {resourceName}</li> + <li><b>GET</b> - get resource info</li> + </ul> + <div class="source"> + <pre><code>$curl http://localhost:1234/admin/v2/clusters/myCluster/resources/resource1 +{ + "id" : "resource1", + "resourceConfig" : {}, + "idealState" : {}, + "externalView" : {} +} +</code></pre> + </div> + <ul> + <li><b>PUT</b> - add a resource with {resourceName}</li> + </ul> + <div class="source"> + <pre><code>$curl -X PUT -H "Content-Type: application/json" http://localhost:1234/admin/v2/clusters/myCluster/resources/myResource -d ' +{ + "id":"myResource", + "simpleFields":{ + "STATE_MODEL_FACTORY_NAME":"DEFAULT" + ,"EXTERNAL_VIEW_DISABLED":"true" + ,"NUM_PARTITIONS":"1" + ,"REBALANCE_MODE":"TASK" + ,"REPLICAS":"1" + ,"IDEAL_STATE_MODE":"AUTO" + ,"STATE_MODEL_DEF_REF":"Task" + ,"REBALANCER_CLASS_NAME":"org.apache.helix.task.WorkflowRebalancer" + } +}' +</code></pre> + </div> + <ul> + <li><b>DELETE</b> - delete a resource. Example: curl -X DELETE <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/myCluster/resources/myResource">http://localhost:1234/admin/v2/clusters/myCluster/resources/myResource</a></li> + <li><b>enable</b> enable the resource. Example: curl -X POST <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/myCluster/resources/myResource?command=enable">http://localhost:1234/admin/v2/clusters/myCluster/resources/myResource?command=enable</a></li> + <li><b>disable</b> - disable the resource. Example: curl -X POST <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/myCluster/resources/myResource?command=disable">http://localhost:1234/admin/v2/clusters/myCluster/resources/myResource?command=disable</a></li> + <li><b>rebalance</b> - rebalance the resource. Example: curl -X POST <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/myCluster/resources/myResource?command=rebalance">http://localhost:1234/admin/v2/clusters/myCluster/resources/myResource?command=rebalance</a></li> + </ul> </li> + <li> <p><b>â/clusters/{clusterName}/resources/{resourceName}/idealStateâ</b></p> + <ul> + <li>Represents the ideal state of a resource with name {resourceName} in cluster {clusterName}. This is new endpoint in v2.0.</li> + <li><b>GET</b> - get idealstate.</li> + </ul> + <div class="source"> + <pre><code>$curl http://localhost:1234/admin/v2/clusters/myCluster/resources/myResource/idealState +{ + "id":"myResource" + ,"simpleFields":{ + "IDEAL_STATE_MODE":"AUTO" + ,"NUM_PARTITIONS":"2" + ,"REBALANCE_MODE":"SEMI_AUTO" + ,"REPLICAS":"2" + ,"STATE_MODEL_DEF_REF":"STANDBY" + } + ,"listFields":{ + "myResource_0":["host1", "host2"] + ,"myResource_1":["host2", "host1"] + } + ,"mapFields":{ + "myResource_0":{ + "host1":"LEADER" + ,"host2":"STANDBY" + } + ,"myResource_1":{ + "host1":"STANDBY" + ,"host2":"LEADER" + } + } +} +</code></pre> + </div> </li> + <li> <p><b>â/clusters/{clusterName}/resources/{resourceName}/externalViewâ</b></p> + <ul> + <li>Represents the external view of a resource with name {resourceName} in cluster {clusterName}</li> + <li><b>GET</b> - get the externview</li> + </ul> + <div class="source"> + <pre><code>$curl http://localhost:1234/admin/v2/clusters/myCluster/resources/myResource/externalView +{ + "id":"myResource" + ,"simpleFields":{ + "IDEAL_STATE_MODE":"AUTO" + ,"NUM_PARTITIONS":"2" + ,"REBALANCE_MODE":"SEMI_AUTO" + ,"REPLICAS":"2" + ,"STATE_MODEL_DEF_REF":"STANDBY" + } + ,"listFields":{ + "myResource_0":["host1", "host2"] + ,"myResource_1":["host2", "host1"] + } + ,"mapFields":{ + "myResource_0":{ + "host1":"LEADER" + ,"host2":"OFFLINE" + } + ,"myResource_1":{ + "host1":"STANDBY" + ,"host2":"LEADER" + } + } +} +</code></pre> + </div> </li> + <li> <p><b>â/clusters/{clusterName}/resources/{resourceName}/configsâ</b></p> + <ul> + <li>Represents resource level of configs for resource with name {resourceName} in cluster {clusterName}. This is new endpoint in v2.0.</li> + <li><b>GET</b> - get resource configs.</li> + </ul> + <div class="source"> + <pre><code>$curl http://localhost:1234/admin/v2/clusters/myCluster/resources/myResource/configs +{ + "id":"myDB" + "UserDefinedProperty" : "property" +} +</code></pre> + </div> </li> + </ul> + </section> + <section> + <h4 id="Helix_Instance_and_its_sub-resources">Helix Instance and its sub-resources</h4> + <ul> + <li> <p><b>â/clusters/{clusterName}/instancesâ</b></p> + <ul> + <li>Represents all instances in a cluster {clusterName}</li> + <li><b>GET</b> - list all instances in this cluster.</li> + </ul> + <div class="source"> + <pre><code>$curl http://localhost:1234/admin/v2/clusters/myCluster/instances +{ + "id" : "myCluster", + "instances" : [ "host1", "host2", "host3", "host4"], + "online" : ["host1", "host4"], + "disabled" : ["host2"] +} +</code></pre> + </div> + <ul> + <li><b>POST</b> - enable/disable instances.</li> + </ul> + <div class="source"> + <pre><code>$curl -X POST -H "Content-Type: application/json" http://localhost:1234/admin/v2/clusters/myCluster/instances/command=enable -d +{ + "instances" : [ "host1", "host3" ] +} +$curl -X POST -H "Content-Type: application/json" http://localhost:1234/admin/v2/clusters/myCluster/instances/command=disable -d +{ + "instances" : [ "host2", "host4" ] +} +</code></pre> + </div> </li> + <li> <p><b>â/clusters/{clusterName}/instances/{instanceName}â</b></p> + <ul> + <li>Represents a instance in cluster {clusterName} with name {instanceName}</li> + <li><b>GET</b> - get instance information.</li> + </ul> + <div class="source"> + <pre><code>$curl http://localhost:1234/admin/v2/clusters/myCluster/instances/host_1234 +{ + "id" : "host_1234", + "configs" : { + "HELIX_ENABLED" : "true", + "HELIX_HOST" : "host", + "HELIX_PORT" : "1234", + "HELIX_DISABLED_PARTITION" : [ ] + } + "liveInstance" : { + "HELIX_VERSION":"0.6.6.3", + "LIVE_INSTANCE":"4526@host", + "SESSION_ID":"359619c2d7efc14" + } +} +</code></pre> + </div> + <ul> + <li><b>PUT</b> - add a new instance with {instanceName}</li> + </ul> + <div class="source"> + <pre><code>$curl -X PUT -H "Content-Type: application/json" http://localhost:1234/admin/v2/clusters/myCluster/instances/host_1234 -d ' +{ + "id" : "host_1234", + "simpleFields" : { + "HELIX_ENABLED" : "true", + "HELIX_HOST" : "host", + "HELIX_PORT" : "1234", + } +}' +</code></pre> + </div> <p>There's one important restriction for this operation: the {instanceName} should match exactly HELIX_HOST + â_â + HELIX_PORT. For example, if host is localhost, and port is 1234, the instance name should be localhost_1234. Otherwise, the response won't contain any error but the configurations are not able to be filled in.</p> + <ul> + <li> <p><b>DELETE</b> - delete the instance. Example: curl -X DELETE <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/myCluster/instances/host_1234">http://localhost:1234/admin/v2/clusters/myCluster/instances/host_1234</a></p> </li> + <li> <p><b>enable</b> - enable the instance. Example: curl -X POST <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/myCluster/instances/host_1234?command=enable">http://localhost:1234/admin/v2/clusters/myCluster/instances/host_1234?command=enable</a></p> </li> + <li> <p><b>disable</b> - disable the instance. Example: curl -X POST <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/myCluster/instances/host_1234?command=disable">http://localhost:1234/admin/v2/clusters/myCluster/instances/host_1234?command=disable</a></p> </li> + <li> <p><b>addInstanceTag</b> - add tags to this instance.</p> </li> + </ul> + <div class="source"> + <pre><code>$curl -X POST -H "Content-Type: application/json" http://localhost:1234/admin/v2/clusters/myCluster/instances/host_1234?command=addInstanceTag -d ' +{ + "id" : "host_1234", + "instanceTags" : [ "tag_1", "tag_2, "tag_3" ] +}' +</code></pre> + </div> + <ul> + <li><b>removeInstanceTag</b> - remove a tag from this instance.</li> + </ul> + <div class="source"> + <pre><code>$curl -X POST -H "Content-Type: application/json" http://localhost:1234/admin/v2/clusters/myCluster/instances/host_1234?command=removeInstanceTag -d ' +{ + "id" : "host_1234", + "instanceTags" : [ "tag_1", "tag_2, "tag_3" ] +}' +</code></pre> + </div> </li> + <li> <p><b>â/clusters/{clusterName}/instances/{instanceName}/resourcesâ</b></p> + <ul> + <li>Represents all resources and their partitions locating on the instance in cluster {clusterName} with name {instanceName}. This is new endpoint in v2.0.</li> + <li><b>GET</b> - return all resources that have partitions in the instance.</li> + </ul> + <div class="source"> + <pre><code>$curl http://localhost:1234/admin/v2/clusters/myCluster/instances/host_1234/resources +{ + "id" : "host_1234", + "resources" [ "myResource1", "myResource2", "myResource3"] +} +</code></pre> + </div> </li> + <li> <p><b>â/clusters/{clusterName}/instances/{instanceName}/resources/{resource}â</b></p> + <ul> + <li>Represents all partitions of the {resource} locating on the instance in cluster {clusterName} with name {instanceName}. This is new endpoint in v2.0.</li> + <li><b>GET</b> - return all partitions of the resource in the instance.</li> + </ul> + <div class="source"> + <pre><code>$curl http://localhost:1234/admin/v2/clusters/myCluster/instances/localhost_1234/resources/myResource1 +{ + "id":"myResource1" + ,"simpleFields":{ + "STATE_MODEL_DEF":"STANDBY" + ,"STATE_MODEL_FACTORY_NAME":"DEFAULT" + ,"BUCKET_SIZE":"0" + ,"SESSION_ID":"359619c2d7f109b" + } + ,"listFields":{ + } + ,"mapFields":{ + "myResource1_2":{ + "CURRENT_STATE":"STANDBY" + ,"INFO":"" + } + ,"myResource1_3":{ + "CURRENT_STATE":"LEADER" + ,"INFO":"" + } + ,"myResource1_0":{ + "CURRENT_STATE":"LEADER" + ,"INFO":"" + } + ,"myResource1_1":{ + "CURRENT_STATE":"STANDBY" + ,"INFO":"" + } + } +} +</code></pre> + </div> </li> + <li> <p><b>â/clusters/{clusterName}/instances/{instanceName}/configsâ</b></p> + <ul> + <li>Represents instance configs in cluster {clusterName} with name {instanceName}. This is new endpoint in v2.0.</li> + <li><b>GET</b> - return configs for the instance.</li> + </ul> + <div class="source"> + <pre><code>$curl http://localhost:1234/admin/v2/clusters/myCluster/instances/host_1234/configs +{ + "id":"host_1234" + "configs" : { + "HELIX_ENABLED" : "true", + "HELIX_HOST" : "host" + "HELIX_PORT" : "1234", + "HELIX_DISABLED_PARTITION" : [ ] +} +</code></pre> + </div> + <ul> + <li><b>PUT</b> - PLEASE NOTE THAT THIS PUT IS FULLY OVERRIDE THE INSTANCE CONFIG</li> + </ul> + <div class="source"> + <pre><code>$curl -X PUT -H "Content-Type: application/json" http://localhost:1234/admin/v2/clusters/myCluster/instances/host_1234/configs +{ + "id":"host_1234" + "configs" : { + "HELIX_ENABLED" : "true", + "HELIX_HOST" : "host" + "HELIX_PORT" : "1234", + "HELIX_DISABLED_PARTITION" : [ ] +} +</code></pre> + </div> </li> + <li> <p><b>â/clusters/{clusterName}/instances/{instanceName}/errorsâ</b></p> + <ul> + <li>List all the mapping of sessionId to partitions of resources. This is new endpoint in v2.0.</li> + <li><b>GET</b> - get mapping</li> + </ul> + <div class="source"> + <pre><code>$curl http://localhost:1234/admin/v2/clusters/myCluster/instances/host_1234/errors +{ + "id":"host_1234" + "errors":{ + "35sfgewngwese":{ + "resource1":["p1","p2","p5"], + "resource2":["p2","p7"] + } + } +} +</code></pre> + </div> + <ul> + <li><b>DELETE</b> - clean up all error information from Helix.</li> + </ul> </li> + <li> <p><b>â/clusters/{clusterName}/instances/{instanceName}/errors/{sessionId}/{resourceName}/{partitionName}â</b></p> + <ul> + <li>Represents error information for the partition {partitionName} of the resource {resourceName} under session {sessionId} in instance with {instanceName} in cluster {clusterName}. This is new endpoint in v2.0.</li> + <li><b>GET</b> - get all error information.</li> + </ul> + <div class="source"> + <pre><code>$curl http://localhost:1234/admin/v2/clusters/myCluster/instances/host_1234/errors/35sfgewngwese/resource1/p1 +{ + "id":"35sfgewngwese_resource1" + ,"simpleFields":{ + } + ,"listFields":{ + } + ,"mapFields":{ + "HELIX_ERROR 20170521-070822.000561 STATE_TRANSITION b819a34d-41b5-4b42-b497-1577501eeecb":{ + "AdditionalInfo":"Exception while executing a state transition task ..." + ,"MSG_ID":"4af79e51-5f83-4892-a271-cfadacb0906f" + ,"Message state":"READ" + } + } +} +</code></pre> + </div> </li> + <li> <p><b>â/clusters/{clusterName}/instances/{instanceName}/historyâ</b></p> + <ul> + <li>Represents instance session change history for the instance with {instanceName} in cluster {clusterName}. This is new endpoint in v2.0.</li> + <li><b>GET</b> - get the instance change history.</li> + </ul> + <div class="source"> + <pre><code>$curl http://localhost:1234/admin/v2/clusters/myCluster/instances/host_1234/history +{ + "id": "host_1234", + "LAST_OFFLINE_TIME": "183948792", + "HISTORY": [ + "{DATE=2017-03-02T19:25:18:915, SESSION=459014c82ef3f5b, TIME=1488482718915}", + "{DATE=2017-03-10T22:24:53:246, SESSION=15982390e5d5c91, TIME=1489184693246}", + "{DATE=2017-03-11T02:03:52:776, SESSION=15982390e5d5d85, TIME=1489197832776}", + "{DATE=2017-03-13T18:15:00:778, SESSION=15982390e5d678d, TIME=1489428900778}", + "{DATE=2017-03-21T02:47:57:281, SESSION=459014c82effa82, TIME=1490064477281}", + "{DATE=2017-03-27T14:51:06:802, SESSION=459014c82f01a07, TIME=1490626266802}", + "{DATE=2017-03-30T00:05:08:321, SESSION=5590151804e2c78, TIME=1490832308321}", + "{DATE=2017-03-30T01:17:34:339, SESSION=2591d53b0421864, TIME=1490836654339}", + "{DATE=2017-03-30T17:31:09:880, SESSION=2591d53b0421b2a, TIME=1490895069880}", + "{DATE=2017-03-30T18:05:38:220, SESSION=359619c2d7f109b, TIME=1490897138220}" + ] +} +</code></pre> + </div> </li> + <li> <p><b>â/clusters/{clusterName}/instances/{instanceName}/messagesâ</b></p> + <ul> + <li>Represents all uncompleted messages currently received by the instance. This is new endpoint in v2.0.</li> + <li><b>GET</b> - list all uncompleted messages received by the controller.</li> + </ul> + <div class="source"> + <pre><code>$curl http://localhost:1234/admin/v2/clusters/myCluster/instances/host_1234/messages +{ + "id": "host_1234", + "new_messages": ["0b8df4f2-776c-4325-96e7-8fad07bd9048", "13a8c0af-b77e-4f5c-81a9-24fedb62cf58"], + "read_messages": ["19887b07-e9b8-4fa6-8369-64146226c454"] + "total_message_count" : 100, + "read_message_count" : 50 +} +</code></pre> + </div> </li> + <li> <p><b>"/clusters/{clusterName}/instances/{instanceName}/messages/{messageId}</b></p> + <ul> + <li>Represents the messages currently received by by the instance with message given message id. This is new endpoint in v2.0.</li> + <li><b>GET</b> - get the message content with {messageId} received by the instance.</li> + </ul> + <div class="source"> + <pre><code>$curl http://localhost:1234/admin/v2/clusters/myCluster/instances/localhost_1234/messages/0b8df4f2-776c-4325-96e7-8fad07bd9048 +{ + "id": "0b8df4f2-776c-4325-96e7-8fad07bd9048", + "CREATE_TIMESTAMP":"1489997469400", + "ClusterEventName":"messageChange", + "FROM_STATE":"OFFLINE", + "MSG_ID":"0b8df4f2-776c-4325-96e7-8fad07bd9048", + "MSG_STATE":"new", + "MSG_TYPE":"STATE_TRANSITION", + "PARTITION_NAME":"Resource1_243", + "RESOURCE_NAME":"Resource1", + "SRC_NAME":"controller_1234", + "SRC_SESSION_ID":"15982390e5d5a76", + "STATE_MODEL_DEF":"LeaderStandby", + "STATE_MODEL_FACTORY_NAME":"myFactory", + "TGT_NAME":"host_1234", + "TGT_SESSION_ID":"459014c82efed9b", + "TO_STATE":"DROPPED" +} +</code></pre> + </div> + <ul> + <li><b>DELETE</b> - delete the message with {messageId}. Example: $curl -X DELETE <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/myCluster/instances/host_1234/messages/0b8df4f2-776c-4325-96e7-8fad07bd9048">http://localhost:1234/admin/v2/clusters/myCluster/instances/host_1234/messages/0b8df4f2-776c-4325-96e7-8fad07bd9048</a></li> + </ul> </li> + <li> <p><b>â/clusters/{clusterName}/instances/{instanceName}/healthreportsâ</b></p> + <ul> + <li>Represents all health reports in the instance in cluster {clusterName} with name {instanceName}. This is new endpoint in v2.0.</li> + <li><b>GET</b> - return the name of health reports collected from the instance.</li> + </ul> + <div class="source"> + <pre><code>$curl http://localhost:1234/admin/v2/clusters/myCluster/instances/host_1234/healthreports +{ + "id" : "host_1234", + "healthreports" [ "report1", "report2", "report3" ] +} +</code></pre> + </div> </li> + <li> <p><b>â/clusters/{clusterName}/instances/{instanceName}/healthreports/{reportName}â</b></p> + <ul> + <li>Represents the health report with {reportName} in the instance in cluster {clusterName} with name {instanceName}. This is new endpoint in v2.0.</li> + <li><b>GET</b> - return the content of health report collected from the instance.</li> + </ul> + <div class="source"> + <pre><code>$curl http://localhost:1234/admin/v2/clusters/myCluster/instances/host_1234/healthreports/ClusterStateStats +{ + "id":"ClusterStateStats" + ,"simpleFields":{ + "CREATE_TIMESTAMP":"1466753504476" + ,"TimeStamp":"1466753504476" + } + ,"listFields":{ + } + ,"mapFields":{ + "UserDefinedData":{ + "Data1":"0" + ,"Data2":"0.0" + } + } +} +</code></pre> + </div> </li> + </ul> + </section> + <section> + <h4 id="Helix_Workflow_and_its_sub-resources">Helix Workflow and its sub-resources</h4> + <ul> + <li> <p><b>â/clusters/{clusterName}/workflowsâ</b></p> + <ul> + <li>Represents all workflows in cluster {clusterName}</li> + <li><b>GET</b> - list all workflows in this cluster. Example : curl <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/TestCluster/workflows">http://localhost:1234/admin/v2/clusters/TestCluster/workflows</a></li> + </ul> + <div class="source"> + <pre><code>{ + "Workflows" : [ "Workflow1", "Workflow2" ] +} +</code></pre> + </div> </li> + <li> <p><b>â/clusters/{clusterName}/workflows/{workflowName}â</b></p> + <ul> + <li>Represents workflow with name {workflowName} in cluster {clusterName}</li> + <li><b>GET</b> - return workflow information. Example : curl <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1">http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1</a></li> + </ul> + <div class="source"> + <pre><code>{ + "id" : "Workflow1", + "WorkflowConfig" : { + "Expiry" : "43200000", + "FailureThreshold" : "0", + "IsJobQueue" : "true", + "LAST_PURGE_TIME" : "1490820801831", + "LAST_SCHEDULED_WORKFLOW" : "Workflow1_20170329T000000", + "ParallelJobs" : "1", + "RecurrenceInterval" : "1", + "RecurrenceUnit" : "DAYS", + "START_TIME" : "1482176880535", + "STATE" : "STOPPED", + "StartTime" : "12-19-2016 00:00:00", + "TargetState" : "START", + "Terminable" : "false", + "capacity" : "500" + }, + "WorkflowContext" : { + "JOB_STATES": { + "Job1": "COMPLETED", + "Job2": "COMPLETED" + }, + "StartTime": { + "Job1": "1490741582339", + "Job2": "1490741580204" + }, + "FINISH_TIME": "1490741659135", + "START_TIME": "1490741580196", + "STATE": "COMPLETED" + }, + "Jobs" : ["Job1","Job2","Job3"], + "ParentJobs" : { + "Job1":["Job2", "Job3"], + "Job2":["Job3"] + } +} +</code></pre> + </div> + <ul> + <li><b>PUT</b> - create a workflow with {workflowName}. Example : curl -X PUT -H âContent-Type: application/jsonâ -d <a href="./WorkflowExample.json">WorkflowExample.json</a> <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1">http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1</a></li> + <li><b>DELETE</b> - delete the workflow. Example : curl -X DELETE <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1">http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1</a></li> + <li><b>start</b> - start the workflow. Example : curl -X POST -H âContent-Type: application/jsonâ <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1?command=start">http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1?command=start</a></li> + <li><b>stop</b> - pause the workflow. Example : curl -X POST -H âContent-Type: application/jsonâ <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1?command=stop">http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1?command=stop</a></li> + <li><b>resume</b> - resume the workflow. Example : curl -X POST -H âContent-Type: application/jsonâ <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1?command=resume">http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1?command=resume</a></li> + <li><b>cleanup</b> - cleanup all expired jobs in the workflow, this operation is only allowed if the workflow is a JobQueue. Example : curl -X POST -H âContent-Type: application/jsonâ <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1?command=clean">http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1?command=clean</a></li> + </ul> </li> + <li> <p><b>â/clusters/{clusterName}/workflows/{workflowName}/configsâ</b></p> + <ul> + <li>Represents workflow config with name {workflowName} in cluster {clusterName}. This is new endpoint in v2.0.</li> + <li><b>GET</b> - return workflow configs. Example : curl <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1/configs">http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1/configs</a></li> + </ul> + <div class="source"> + <pre><code>{ + "id": "Workflow1", + "Expiry" : "43200000", + "FailureThreshold" : "0", + "IsJobQueue" : "true", + "START_TIME" : "1482176880535", + "StartTime" : "12-19-2016 00:00:00", + "TargetState" : "START", + "Terminable" : "false", + "capacity" : "500" +} +</code></pre> + </div> </li> + <li> <p><b>â/clusters/{clusterName}/workflows/{workflowName}/contextâ</b></p> + <ul> + <li>Represents workflow runtime information with name {workflowName} in cluster {clusterName}. This is new endpoint in v2.0.</li> + <li><b>GET</b> - return workflow runtime information. Example : curl <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1/context">http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1/context</a></li> + </ul> + <div class="source"> + <pre><code>{ + "id": "WorkflowContext", + "JOB_STATES": { + "Job1": "COMPLETED", + "Job2": "COMPLETED" + }, + "StartTime": { + "Job1": "1490741582339", + "Job2": "1490741580204" + }, + "FINISH_TIME": "1490741659135", + "START_TIME": "1490741580196", + "STATE": "COMPLETED" +} +</code></pre> + </div> </li> + </ul> + </section> + <section> + <h4 id="Helix_Job_and_its_sub-resources">Helix Job and its sub-resources</h4> + <ul> + <li> <p><b>â/clusters/{clusterName}/workflows/{workflowName}/jobsâ</b></p> + <ul> + <li>Represents all jobs in workflow {workflowName} in cluster {clusterName}</li> + <li><b>GET</b> return all job names in this workflow. Example : curl <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1/jobs">http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1/jobs</a></li> + </ul> + <div class="source"> + <pre><code>{ + "id":"Jobs" + "Jobs":["Job1","Job2","Job3"] +} +</code></pre> + </div> </li> + <li> <p><b>â/clusters/{clusterName}/workflows/{workflowName}/jobs/{jobName}â</b></p> + <ul> + <li>Represents job with {jobName} within {workflowName} in cluster {clusterName}</li> + <li><b>GET</b> return job information. Example : curl <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1/jobs/Job1">http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1/jobs/Job1</a></li> + </ul> + <div class="source"> + <pre><code>{ + "id":"Job1" + "JobConfig":{ + "WorkflowID":"Workflow1", + "IgnoreDependentJobFailure":"false", + "MaxForcedReassignmentsPerTask":"3" + }, + "JobContext":{ + "START_TIME":"1491005863291", + "FINISH_TIME":"1491005902612", + "Tasks":[ + { + "id":"0", + "ASSIGNED_PARTICIPANT":"P1", + "FINISH_TIME":"1491005898905" + "INFO":"" + "NUM_ATTEMPTS":"1" + "START_TIME":"1491005863307" + "STATE":"COMPLETED" + "TARGET":"DB_0" + }, + { + "id":"1", + "ASSIGNED_PARTICIPANT":"P5", + "FINISH_TIME":"1491005895443" + "INFO":"" + "NUM_ATTEMPTS":"1" + "START_TIME":"1491005863307" + "STATE":"COMPLETED" + "TARGET":"DB_1" + } + ] + } +} +</code></pre> + </div> + <ul> + <li><b>PUT</b> - insert a job with {jobName} into the workflow, this operation is only allowed if the workflow is a JobQueue.<br> Example : curl -X PUT -H âContent-Type: application/jsonâ -d <a href="./JobExample.json">JobExample.json</a> <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1/jobs/Job1">http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1/jobs/Job1</a></li> + <li><b>DELETE</b> - delete the job from the workflow, this operation is only allowed if the workflow is a JobQueue.<br> Example : curl -X DELETE <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1/jobs/Job1">http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1/jobs/Job1</a></li> + </ul> </li> + <li> <p><b>â/clusters/{clusterName}/workflows/{workflowName}/jobs/{jobName}/configsâ</b></p> + <ul> + <li>Represents job config for {jobName} within workflow {workflowName} in cluster {clusterName}. This is new endpoint in v2.0.</li> + <li><b>GET</b> - return job config. Example : curl <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1/jobs/Job1/configs">http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1/jobs/Job1/configs</a></li> + </ul> + <div class="source"> + <pre><code>{ + "id":"JobConfig" + "WorkflowID":"Workflow1", + "IgnoreDependentJobFailure":"false", + "MaxForcedReassignmentsPerTask":"3" +} +</code></pre> + </div> </li> + <li> <p><b>â/clusters/{clusterName}/workflows/{workflowName}/jobs/{jobName}/contextâ</b></p> + <ul> + <li>Represents job runtime information with {jobName} in {workflowName} in cluster {clusterName}. This is new endpoint in v2.0.</li> + <li><b>GET</b> - return job runtime information. Example : curl <a class="externalLink" href="http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1/jobs/Job1/context">http://localhost:1234/admin/v2/clusters/TestCluster/workflows/Workflow1/jobs/Job1/context</a></li> + </ul> + <div class="source"> + <pre><code>{ + "id":"JobContext": + "START_TIME":"1491005863291", + "FINISH_TIME":"1491005902612", + "Tasks":[ + { + "id":"0", + "ASSIGNED_PARTICIPANT":"P1", + "FINISH_TIME":"1491005898905" + "INFO":"" + "NUM_ATTEMPTS":"1" + "START_TIME":"1491005863307" + "STATE":"COMPLETED" + "TARGET":"DB_0" + }, + { + "id":"1", + "ASSIGNED_PARTICIPANT":"P5", + "FINISH_TIME":"1491005895443" + "INFO":"" + "NUM_ATTEMPTS":"1" + "START_TIME":"1491005863307" + "STATE":"COMPLETED" + "TARGET":"DB_1" + } + ] +} +</code></pre> + </div> </li> + </ul> + </section> + </section> +</section> + </div> + </div> + </div> + </div> + + </div><!-- /container --> + + <!-- Footer + ================================================== --> + <footer class="well"> + <div class="container"> + <div class="row"> + <div class="span3 bottom-nav"> + <ul class="nav nav-list"> + <li class="nav-header">Get Helix</li> + <li > + <a href="download.html" title="Download">Download</a> + </li> + <li > + <a href="Building.html" title="Building">Building</a> + </li> + <li > + <a href="releasenotes/release-1.0.4.html" title="Release Notes">Release Notes</a> + </li> + </ul> + </div> + <div class="span3 bottom-nav"> + <ul class="nav nav-list"> + <li class="nav-header">Hands-On</li> + <li > + <a href="Quickstart.html" title="Quick Start">Quick Start</a> + </li> + <li > + <a href="Tutorial.html" title="Tutorial">Tutorial</a> + </li> + <li > + <a href="../javadocs/1.0.4" title="Javadocs">Javadocs</a> + </li> + </ul> + </div> + <div class="span3 bottom-nav"> + <ul class="nav nav-list"> + <li class="nav-header">Recipes</li> + <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> + <li > + <a href="recipes/service_discovery.html" title="Service discovery">Service discovery</a> + </li> + <li > + <a href="recipes/task_dag_execution.html" title="Distributed task DAG execution">Distributed task DAG execution</a> + </li> + </ul> + </div> + </div> + </div> + </footer> + + <div class="container subfooter"> + <div class="row"> + <div class="span12"> + <p class="pull-right"><a href="#">Back to top</a></p> + <p class="copyright">Copyright ©2022 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All Rights Reserved.</p> + <p><a href="https://github.com/olamy/reflow-maven-skin" title="Reflow Maven skin">Reflow Maven skin</a> maintained by <a href="https://twitter.com/olamy" target="_blank" title="Olivier Lamy">Olivier Lamy</a>.</p> + <div class="row span16"><div>Apache Helix, Apache, the Apache feather logo, and the Apache Helix project logos are trademarks of The Apache Software Foundation. + All other marks mentioned may be trademarks or registered trademarks of their respective owners.</div> + <a href="https://helix.apache.org/1.0.5-docs/privacy-policy.html">Privacy Policy</a> + </div> + </div> + </div> + </div> + + <!-- Le javascript + ================================================== --> + <!-- Placed at the end of the document so the pages load faster --> + <script src="./js/jquery.min.js"></script> + + <script src="./js/bootstrap.min.js"></script> + <script src="./js/lightbox.min.js"></script> + <script src="./js/reflow-scroll.js"></script> + + <script src="./js/reflow-skin.js"></script> + + </body> +</html> \ No newline at end of file Added: helix/site-content/1.0.5-docs/tutorial_spectator.html URL: http://svn.apache.org/viewvc/helix/site-content/1.0.5-docs/tutorial_spectator.html?rev=1900823&view=auto ============================================================================== --- helix/site-content/1.0.5-docs/tutorial_spectator.html (added) +++ helix/site-content/1.0.5-docs/tutorial_spectator.html Thu May 12 05:29:03 2022 @@ -0,0 +1,305 @@ + +<!DOCTYPE html> + + + + + + +<!-- + Generated by Apache Maven Doxia at 2022-05-11 Rendered using Reflow Maven Skin 2.0.0 (https://olamy.github.io/reflow-maven-skin) +--> +<html xml:lang="en" lang="en"> + + <head> + <meta charset="UTF-8" /> + <title>Apache Helix – Tutorial - Spectator</title> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <meta name="description" content="" /> + <meta http-equiv="content-language" content="en" /> + + <link href="./css/bootstrap.min.css" rel="stylesheet" /> + <link href="./css/bootstrap-responsive.min.css" rel="stylesheet" /> + <link href="./css/docs.css" rel="stylesheet" /> + <link href="./css/reflow-skin.css" rel="stylesheet" /> + + + <link href="./css/lightbox.css" rel="stylesheet" /> + + <link href="./css/site.css" rel="stylesheet" /> + <link href="./css/print.css" rel="stylesheet" media="print" /> + + <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements --> + <!--[if lt IE 9]> + <script src="./js/html5.js"></script> + <![endif]--> + + + + + + +<!-- Matomo --> +<script> + var _paq = window._paq = window._paq || []; + _paq.push(['disableCookies']); + _paq.push(['trackPageView']); + _paq.push(['enableLinkTracking']); + + (function() { + var u="https://analytics.apache.org"; + _paq.push(['setTrackerUrl', u+'/matomo.php']); + _paq.push(['setSiteId', '15']); + var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; + g.async=true; g.src=u+'/matomo.js'; s.parentNode.insertBefore(g,s); + })(); +</script> +<!-- End Matomo Code --> + </head> + + <body class="page-tutorial_spectator project-105-docs" data-spy="scroll" data-offset="60" data-target="#toc-scroll-target"> + + + <div class="navbar navbar-fixed-top"> + <div class="navbar-inner"> + <div class="container"> + <a class="btn btn-navbar" data-toggle="collapse" data-target="#top-nav-collapse"> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </a> + <a class="brand" href="http://helix.apache.org">Apache Helix</a> + <div class="nav-collapse collapse" id="top-nav-collapse"> + <ul class="nav pull-right"> + <li ><a href="index.html" title="Helix 1.0.4">Helix 1.0.4</a></li> + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Get Helix <b class="caret"></b></a> + <ul class="dropdown-menu"> + <li ><a href="download.html" title="Download">Download</a></li> + <li ><a href="Building.html" title="Building">Building</a></li> + <li ><a href="releasenotes/release-1.0.4.html" title="Release Notes">Release Notes</a></li> + </ul> + </li> + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Hands-On <b class="caret"></b></a> + <ul class="dropdown-menu"> + <li ><a href="Quickstart.html" title="Quick Start">Quick Start</a></li> + <li ><a href="Tutorial.html" title="Tutorial">Tutorial</a></li> + <li ><a href="../javadocs/1.0.4" title="Javadocs">Javadocs</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> + <li ><a href="recipes/service_discovery.html" title="Service discovery">Service discovery</a></li> + <li ><a href="recipes/task_dag_execution.html" title="Distributed task DAG execution">Distributed task DAG execution</a></li> + </ul> + </li> + </ul> + </div><!--/.nav-collapse --> + </div> + </div> + </div> + + <div class="container"> + + <!-- Masthead + ================================================== --> + + <header> + <div class="jumbotron subhead"> + <div class="row" id="banner"> + <div class="span12"> + <div class="pull-left"> + <a href="http://helix.apache.org/" id="bannerLeft"><img src="../images/helix-logo.jpg" alt='"''"' /></a> + <p class="lead">A cluster management framework for partitioned and replicated distributed resources</p> + </div> + <div class="pull-right"> + <a href="http://www.apache.org/" id="bannerRight"><img src="../images/feather_small.gif" alt='"''"' /></a> + </div> + </div> + </div> + </div> + <div> + <ul class="breadcrumb"> + <li><a href="http://helix.apache.org/" title="Apache Helix" class="externalLink">Apache Helix</a></li> + <li class="divider">/</li> + <li><a href="../" title="Apache Helix">Apache Helix</a></li> + <li class="divider">/</li> + <li><a href="../1.0.4-docs/" title="Release 1.0.4">Release 1.0.4</a></li> + <li class="divider">/</li> + <li>Tutorial - Spectator</li> + <li class="publishDate version-date pull-right">Last Published: 2022-05-11</li> + </ul> + </div> + </header> + + <div class="main-body"> + <div class="row"> + <div class="span12"> + <div class="body-content"> +<!-- +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. +--> +<section> + <div class="page-header"> + <h2 id="Helix_Tutorial:_Spectator"><a href="./Tutorial.html">Helix Tutorial</a>: Spectator</h2> + </div> + <p>Next, we'll learn how to implement a <b>spectator</b>. Typically, a spectator needs to react to changes within the distributed system. Examples: a client that needs to know where to send a request, a topic consumer in a consumer group. The spectator is automatically informed of changes in the <i>external state</i> of the cluster, but it does not have to add any code to keep track of other components in the system.</p> + <section> + <h3 id="Start_a_Connection">Start a Connection</h3> + <p>Same as for a participant, The Helix manager is the common component that connects each system component with the cluster.</p> + <p>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, in this case, use SPECTATOR: + <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> + <p>After the Helix manager instance is created, the only thing that needs to be registered is the listener. When the ExternalView changes, the listener is notified.</p> + <p>A spectator observes the cluster and 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><code>manager = HelixManagerFactory.getZKHelixManager(clusterName, + instanceName, + InstanceType.SPECTATOR, + zkConnectString); +manager.connect(); +RoutingTableProvider routingTableProvider = new RoutingTableProvider(); +manager.addExternalViewChangeListener(routingTableProvider); +</code></pre> + </div> + </section> + <section> + <h3 id="Spectator_Code">Spectator Code</h3> + <p>In the following code snippet, the application sends the request to a valid instance by interrogating the external view. Suppose the desired resource for this request is in the partition myDB_1.</p> + <div class="source"> + <pre><code>// instances = routingTableProvider.getInstances(, "PARTITION_NAME", "PARTITION_STATE"); +instances = routingTableProvider.getInstances("myDB", "myDB_1", "ONLINE"); + +//////////////////////////////////////////////////////////////////////////////////////////////// +// Application-specific code to send a request to one of the instances // +//////////////////////////////////////////////////////////////////////////////////////////////// + +theInstance = instances.get(0); // should choose an instance and throw an exception if none are available +result = theInstance.sendRequest(yourApplicationRequest, responseObject); + +</code></pre> + </div> + <p>When the external view changes, the application needs to react by sending requests to a different instance.</p> + </section> +</section> + </div> + </div> + </div> + </div> + + </div><!-- /container --> + + <!-- Footer + ================================================== --> + <footer class="well"> + <div class="container"> + <div class="row"> + <div class="span3 bottom-nav"> + <ul class="nav nav-list"> + <li class="nav-header">Get Helix</li> + <li > + <a href="download.html" title="Download">Download</a> + </li> + <li > + <a href="Building.html" title="Building">Building</a> + </li> + <li > + <a href="releasenotes/release-1.0.4.html" title="Release Notes">Release Notes</a> + </li> + </ul> + </div> + <div class="span3 bottom-nav"> + <ul class="nav nav-list"> + <li class="nav-header">Hands-On</li> + <li > + <a href="Quickstart.html" title="Quick Start">Quick Start</a> + </li> + <li > + <a href="Tutorial.html" title="Tutorial">Tutorial</a> + </li> + <li > + <a href="../javadocs/1.0.4" title="Javadocs">Javadocs</a> + </li> + </ul> + </div> + <div class="span3 bottom-nav"> + <ul class="nav nav-list"> + <li class="nav-header">Recipes</li> + <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> + <li > + <a href="recipes/service_discovery.html" title="Service discovery">Service discovery</a> + </li> + <li > + <a href="recipes/task_dag_execution.html" title="Distributed task DAG execution">Distributed task DAG execution</a> + </li> + </ul> + </div> + </div> + </div> + </footer> + + <div class="container subfooter"> + <div class="row"> + <div class="span12"> + <p class="pull-right"><a href="#">Back to top</a></p> + <p class="copyright">Copyright ©2022 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All Rights Reserved.</p> + <p><a href="https://github.com/olamy/reflow-maven-skin" title="Reflow Maven skin">Reflow Maven skin</a> maintained by <a href="https://twitter.com/olamy" target="_blank" title="Olivier Lamy">Olivier Lamy</a>.</p> + <div class="row span16"><div>Apache Helix, Apache, the Apache feather logo, and the Apache Helix project logos are trademarks of The Apache Software Foundation. + All other marks mentioned may be trademarks or registered trademarks of their respective owners.</div> + <a href="https://helix.apache.org/1.0.5-docs/privacy-policy.html">Privacy Policy</a> + </div> + </div> + </div> + </div> + + <!-- Le javascript + ================================================== --> + <!-- Placed at the end of the document so the pages load faster --> + <script src="./js/jquery.min.js"></script> + + <script src="./js/bootstrap.min.js"></script> + <script src="./js/lightbox.min.js"></script> + <script src="./js/reflow-scroll.js"></script> + + <script src="./js/reflow-skin.js"></script> + + </body> +</html> \ No newline at end of file
