Return-Path: X-Original-To: apmail-helix-user-archive@minotaur.apache.org Delivered-To: apmail-helix-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8D903115AE for ; Fri, 1 Aug 2014 00:46:27 +0000 (UTC) Received: (qmail 14263 invoked by uid 500); 1 Aug 2014 00:46:27 -0000 Delivered-To: apmail-helix-user-archive@helix.apache.org Received: (qmail 14215 invoked by uid 500); 1 Aug 2014 00:46:27 -0000 Mailing-List: contact user-help@helix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@helix.apache.org Delivered-To: mailing list user@helix.apache.org Received: (qmail 14203 invoked by uid 99); 1 Aug 2014 00:46:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Aug 2014 00:46:27 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of kanak.b@hotmail.com designates 65.54.190.27 as permitted sender) Received: from [65.54.190.27] (HELO BAY004-OMC1S16.hotmail.com) (65.54.190.27) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Aug 2014 00:46:24 +0000 Received: from BAY182-W26 ([65.54.190.60]) by BAY004-OMC1S16.hotmail.com with Microsoft SMTPSVC(7.5.7601.22712); Thu, 31 Jul 2014 17:45:58 -0700 X-TMN: [m7SZIdqb4alCzA8HZmSUZvBJgo75ywRC] X-Originating-Email: [kanak.b@hotmail.com] Message-ID: Content-Type: multipart/alternative; boundary="_37a3c822-d68b-4b54-ae0a-e15bf7cdd04f_" From: Kanak Biscuitwala To: "user@helix.apache.org" Subject: RE: Questions about custom helix rebalancer/controller/agent Date: Thu, 31 Jul 2014 17:45:58 -0700 Importance: Normal In-Reply-To: References: ,,, MIME-Version: 1.0 X-OriginalArrivalTime: 01 Aug 2014 00:45:58.0835 (UTC) FILETIME=[F5EA9030:01CFAD21] X-Virus-Checked: Checked by ClamAV on apache.org --_37a3c822-d68b-4b54-ae0a-e15bf7cdd04f_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable i.e. helixAdmin.enableCluster(clusterName=2C false)=3B From: kanak.b@hotmail.com To: user@helix.apache.org Subject: RE: Questions about custom helix rebalancer/controller/agent Date: Thu=2C 31 Jul 2014 17:44:40 -0700 =0A= =0A= =0A= Unfortunately HelixAdmin#rebalance is a misnomer=2C and it is a function of= all the configured instances and not the live instances. The closest you c= an get to that is to use the third option I listed related to CUSTOMIZED mo= de=2C where you write the mappings yourself based on what is live. Another thing you could do is pause the cluster controller and unpause it f= or a period every 30 minutes. That will essentially enforce that the contro= ller will not send transitions (or do anything else=2C really) during the t= ime it is paused. This sounds a little like a hack to me=2C but it may do w= hat you want. Kanak Date: Thu=2C 31 Jul 2014 17:39:40 -0700 Subject: Re: Questions about custom helix rebalancer/controller/agent From: varun@pinterest.com To: user@helix.apache.org Thanks Kanak=2C for your detailed response and this is really very helpful.= I was wondering if its possible for me do something like the following: List resourceList =3D helixAdmin.getResourceList()=3B=0A= for each resource: Compute target ideal state helixAdmin.rebalance(reso= urce)=3B Thread.sleep(30minutes)=3B So=2C the above happens inside a while loop thread and this is the only pla= ce where we do the rebalancing ?=0A= ThanksVarun On Thu=2C Jul 31=2C 2014 at 5:25 PM=2C Kanak Biscuitwala wrote: =0A= =0A= =0A= =0A= =0A= =0A= =0A= Hi Varun=2C Sorry for the delay. 1 and 3) There are a number of ways to do this=2C with various tradeoffs. - You can write a user-defined rebalancer. In helix 0.6.x=2C it involves im= plementing the following interface:=0A= https://github.com/apache/helix/blob/helix-0.6.x/helix-core/src/main/java/o= rg/apache/helix/controller/rebalancer/Rebalancer.java=0A= Essentially what it does is given an existing ideal state=2C compute a new = ideal state. For 0.6.x=2C this will read the preference lists in the output= ideal state and compute a state mapping based on them. If you need more co= ntrol=2C you can also implement:=0A= https://github.com/apache/helix/blob/helix-0.6.x/helix-core/src/main/java/o= rg/apache/helix/controller/rebalancer/internal/MappingCalculator.java=0A= which will allow you to create a mapping from partition to map of participa= nt and state. In 0.7.x=2C we consolidated these into a single method. Here is a tutorial on the user-defined rebalancer: http://helix.apache.org/= 0.6.3-docs/tutorial_user_def_rebalancer.html=0A= Now=2C running this every 30 minutes is tricky because by default the contr= oller responds to all cluster events (and really it needs to because it agg= regates all participant current states into the external view -- unless you= don't care about that).=0A= - Combined with the user-defined rebalancer (or not)=2C you can have a Gene= ricHelixController that doesn't listen on any events=2C but calls startReba= lancingTimer()=2C into which you can pass 30 minutes. The problem with this= is that the instructions at http://helix.apache.org/0.6.3-docs/tutorial_co= ntroller.html won't work as described because of a known issue. The workaro= und is to connect HelixManager as role ADMINISTRATOR instead of CONTROLLER.= =0A= However=2C if you connect as ADMINISTRATOR=2C you have to set up leader ele= ction yourself (assuming you want a fault-tolerant controller). See https:/= /github.com/apache/helix/blob/helix-0.6.x/helix-core/src/main/java/org/apac= he/helix/manager/zk/DistributedLeaderElection.java for a controller change = listener that can do leader election=2C but your version will have to be di= fferent=2C as you actually don't want to add listeners=2C but rather set up= a timer.=0A= This also gives you the benefit of plugging in your own logic into the cont= roller pipeline. See https://github.com/apache/helix/blob/helix-0.6.x/helix= -core/src/main/java/org/apache/helix/controller/GenericHelixController.java= createDefaultRegistry() for how to create an appropriate PipelineRegistry.= =0A= - You can take a completely different approach and put your ideal state in = CUSTOMIZED rebalance mode. Then you can have a meta-resource where one part= icipant is a leader and the others are followers (you can create an ideal s= tate in SEMI_AUTO mode=2C where the replica count and the replica count and= preference list of resourceName_0 is "ANY_LIVEINSTANCE". When one particip= ant is told to become leader=2C you can set a timer for 30 minutes and upda= te and write the map fields of the ideal state accordingly.=0A= 2) I'm not sure I understand the question. If you're in the JVM=2C you simp= ly need to connect as a PARTICIPANT for your callbacks=2C but that can just= be something you do at the beginning of your node startup. The rest of you= r code is more or less governed by your transitions=2C but if there are thi= ngs you need to do on the side=2C there is nothing in Helix preventing you = from doing so. See http://helix.apache.org/0.6.3-docs/tutorial_participant.= html for participant logic.=0A= 4) The current state is per-instance and is literally called CurrentState. = For a given participant=2C you can query a current state by doing something= like: HelixDataAccessor accessor =3D helixManager.getHelixDataAccessor()=3B=0A= CurrentState currentState =3D accessor.getProperty(accessor.keyBuilder().cu= rrentState(instanceName=2C sessionId=2C resourceName)=3B If you implement a user-defined rebalancer as above=2C we automatically agg= regate all these current states into a CurrentStateOutput object.=0A= 5) You can use a Helix spectator: http://helix.apache.org/0.6.3-docs/tutorial_spectator.html=0A= This basically gives you a live-updating routing table for the mappings of = the Helix-managed resource. However=2C it requires the external view to be = up to date=2C going back to my other point of perhaps separating the concep= t of changing mappings every 30 minutes from the frequency at which the con= troller runs.=0A= Hopefully this helps. Kanak Date: Thu=2C 31 Jul 2014 12:13:27 -0700 Subject: Questions about custom helix rebalancer/controller/agent From: varun@pinterest.com =0A= To: user@helix.apache.org Hi=2C=0A= =0A= I am trying to write a customized rebalancing algorithm. I would like to ru= n the rebalancer every 30 minutes inside a single thread. I would also like= to completely disable Helix triggering the rebalancer.=0A= =0A= I have a few questions:1) What's the best way to run the custom controller = ? Can I simply instantiate a ZKHelixAdmin object and then keep running my r= ebalancer inside a thread or do I need to do something more.=0A= =0A= Apart from rebalancing=2C I want to do other things inside the the controll= er=2C so it would be nice if I could simply fire up the controller through = code. I could not find this in the documentation.=0A= =0A= 2) Same question for the Helix agent. My Helix Agent is a JVM process which= does other things apart from exposing the callbacks for state transitions.= Is there a code sample for the same ?=0A= =0A= 3) How do I disable Helix triggered rebalancing once I am able to run the c= ustom controller ?=0A= =0A= 4) During my custom rebalance run=2C how I can get the current cluster stat= e - is it through ClusterDataCache.getIdealState() ?=0A= =0A= 5) For clients talking to the cluster=2C does helix provide an easy abstrac= tion to find the partition distribution for a helix resource ?=0A= =0A= Thanks=0A= =0A= = --_37a3c822-d68b-4b54-ae0a-e15bf7cdd04f_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
i.e. helixAdmin.enableCluster(cl= usterName=2C false)=3B


From: kanak.b@ho= tmail.com
To: user@helix.apache.org
Subject: RE: Questions about cust= om helix rebalancer/controller/agent
Date: Thu=2C 31 Jul 2014 17:44:40 -= 0700

=0A= =0A= =0A=
Unfortunately HelixAdmin#rebalance is a misnomer=2C and it= is a function of all the configured instances and not the live instances. = The closest you can get to that is to use the third option I listed related= to CUSTOMIZED mode=2C where you write the mappings yourself based on what = is live.

Another thing you could do is pause the cluster= controller and unpause it for a period every 30 minutes. That will essenti= ally enforce that the controller will not send transitions (or do anything = else=2C really) during the time it is paused. This sounds a little like a h= ack to me=2C but it may do what you want.

Kanak

Date: Thu=2C 31 Jul 2014 17:39:40 -070= 0
Subject: Re: Questions about custom helix rebalancer/controller/agent<= br>From: varun@pinterest.com
To: user@helix.apache.org

Thanks Kanak=2C for your detailed response and this is really very= helpful. I was wondering if its possible for me do something like the foll= owing:

List resourceList =3D helixAdmin.getResourceList(= )=3B
=0A=
for each resource:
 =3B  =3BCompute target ideal sta= te
 =3B  =3BhelixAdmin.rebalance(resource)=3B
<= br>
Thread.sleep(30minutes)=3B

So=2C the= above happens inside a while loop thread and this is the only place where = we do the rebalancing ?
=0A=

Thanks
Varun


On Thu=2C Jul 31=2C 2014 at = 5:25 PM=2C Kanak Biscuitwala <=3Bkanak.b@hotmail.com>=3B wrote:
=0A=
=0A= =0A= =0A=
=0A= =0A= =0A=
Hi Varun=2C

Sorry for the delay.

1 and 3) There are a number = of ways to do this=2C with various tradeoffs.

- Yo= u can write a user-defined rebalancer. In helix 0.6.x=2C it involves implem= enting the following interface:
=0A=

=0A=

Essentially what it does is given an existing ideal sta= te=2C compute a new ideal state. For 0.6.x=2C this will read the preference= lists in the output ideal state and compute a state mapping based on them.= If you need more control=2C you can also implement:
=0A=

=0A=

which will allow you to create a mapping from partition= to map of participant and state. In 0.7.x=2C we consolidated these into a = single method.

Here is a tutorial on the user-defi= ned rebalancer: =3B= http://helix.apache.org/0.6.3-docs/tutorial_user_def_rebalancer.html=0A=

Now=2C running this every 30 minutes is tricky because = by default the controller responds to all cluster events (and really it nee= ds to because it aggregates all participant current states into the externa= l view -- unless you don't care about that).
=0A=

- Combined with the user-defined rebalancer (or not)=2C= you can have a GenericHelixController that doesn't listen on any events=2C= but calls startRebalancingTimer()=2C into which you can pass 30 minutes. T= he problem with this is that the instructions at =3Bhttp://helix.apache.org/0.6.3-docs/tutorial_control= ler.html =3Bwon't work as described because of a known issue. The w= orkaround is to connect HelixManager as role ADMINISTRATOR instead of CONTR= OLLER.
=0A=

However=2C if you connect as ADMINISTRATOR=2C you have = to set up leader election yourself (assuming you want a fault-tolerant cont= roller). See =3Bhttps://github= .com/apache/helix/blob/helix-0.6.x/helix-core/src/main/java/org/apache/heli= x/manager/zk/DistributedLeaderElection.java =3Bfor a controller cha= nge listener that can do leader election=2C but your version will have to b= e different=2C as you actually don't want to add listeners=2C but rather se= t up a timer.
=0A=

This also gives you the benefit of plugging in your own= logic into the controller pipeline. See =3Bhttps://github.com/apache/helix/blob/helix-0.6.x/helix-core/src= /main/java/org/apache/helix/controller/GenericHelixController.java = =3BcreateDefaultRegistry() for how to create an appropriate PipelineRegistr= y.
=0A=

- You can take a completely different approach and put = your ideal state in CUSTOMIZED rebalance mode. Then you can have a meta-res= ource where one participant is a leader and the others are followers (you c= an create an ideal state in SEMI_AUTO mode=2C where the replica count and t= he replica count and preference list of resourceName_0 is "ANY_LIVEINSTANCE= ". When one participant is told to become leader=2C you can set a timer for= 30 minutes and update and write the map fields of the ideal state accordin= gly.
=0A=

2) I'm not sure I understand the question. If you're in= the JVM=2C you simply need to connect as a PARTICIPANT for your callbacks= =2C but that can just be something you do at the beginning of your node sta= rtup. The rest of your code is more or less governed by your transitions=2C= but if there are things you need to do on the side=2C there is nothing in = Helix preventing you from doing so. See =3Bhttp://helix.apache.org/0.6.3-docs/tutorial_participant.htm= l =3Bfor participant logic.
=0A=

4) The current state is per-instance and is literally c= alled CurrentState. For a given participant=2C you can query a current stat= e by doing something like:

HelixDataAccessor acces= sor =3D helixManager.getHelixDataAccessor()=3B
=0A=
CurrentState currentState =3D accessor.getProperty(accessor.keyBuilder= ().currentState(instanceName=2C sessionId=2C resourceName)=3B
If you implement a user-defined rebalancer as above=2C we autom= atically aggregate all these current states into a CurrentStateOutput objec= t.
=0A=

5) You can use a Helix spectator:

<= div>http://helix.apache.org/0.6.3-docs/tutorial_spectator.htm= l
=0A=

This basically gives you a live-updating routing table = for the mappings of the Helix-managed resource. However=2C it requires the = external view to be up to date=2C going back to my other point of perhaps s= eparating the concept of changing mappings every 30 minutes from the freque= ncy at which the controller runs.
=0A=

Hopefully this helps.

Kanak


Date: Thu=2C 31 Jul 2014 12:13:27 -0700
= Subject: Questions about custom helix rebalancer/controller/agent
From: = varun@pinterest.com
=0A= To: user@helix.apache.org


Hi=2C
=0A=
=0A= I am trying to write a customized rebalancing algorithm. I would like to ru= n the rebalancer every 30 minutes inside a single thread. I would also like= to completely disable Helix triggering the rebalancer.
=0A= =0A=
I have a few questions:
1) What's the best way= to run the custom controller ? Can I simply instantiate a ZKHelixAdmin obj= ect and then keep running my rebalancer inside a thread or do I need to do = something more.
=0A= =0A=

Apart from rebalancing=2C I want to do other things= inside the the controller=2C so it would be nice if I could simply fire up= the controller through code. I could not find this in the documentation.=0A= =0A=

2) Same question for the Helix agent. My Helix Agen= t is a JVM process which does other things apart from exposing the callback= s for state transitions. Is there a code sample for the same ?
=0A= =0A=

3) How do I disable Helix triggered rebalancing onc= e I am able to run the custom controller ?
=0A= =0A=

4) During my custom rebalance run=2C how I can get = the current cluster state - is it through ClusterDataCache.getIdealState() = ?
=0A= =0A=

5) For clients talking to the cluster=2C does helix= provide an easy abstraction to find the partition distribution for a helix= resource ?
=0A= =0A=

Thanks
=0A=
=0A=

=
= --_37a3c822-d68b-4b54-ae0a-e15bf7cdd04f_--