mesos-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald Laidlaw <donlaid...@me.com>
Subject Re: Java detector for mess masters and leader
Date Wed, 08 Jul 2015 17:48:51 GMT
@ Nicolaos
I really don’t think that will work.

When you use this code, it creates a node under /mesos named like: _c_e7007a30-1eaf-4826-bb99-011e8a33ac111-lock-0000000099
because it is gaining leadership. It does not create nodes like mesos does, with names like
info_0000000123. It therefore does not play well with mesos.

I don’t think the Curator code matches the mesos code in exactly how it does leadership
election.

I’ll just scan the mesos-created children of /mesos, they all begin with the string “info”
and are ephemeral sequence nodes. Their contents contains the info I need, which I can parse
using the mesos protocol buffer definition for MasterInfo. Although I think your substring
method would work just as well. At least it will until 0.24 when the content is changed to
a JSON string.

Best regards,
-Don


> On Jul 8, 2015, at 11:49 AM, Ken Sipe <kensipe@gmail.com> wrote:
> 
> awesome sharing of code!
> 
> I’ll add that if you are using Mesos-DNS, that the dns name master.mesos will resolve
to the masters and leader.mesos will resolve to the leader.
> 
> if you are looking to resolve to marathon leader you would have to use the code below
against zk at the moment.
> 
> - ken
> 
>> On Jul 8, 2015, at 9:42 AM, Nikolaos Ballas neXus <nikolaos.ballas@nexusgroup.com
<mailto:nikolaos.ballas@nexusgroup.com>> wrote:
>> 
>> Don…the bellow code will return leader node for mesos & marathon framework.
>> 
>> import …
>> public class SomeClass {
>>         CuratorFramework client;
>> public void init(){
>>  client = CuratorFrameworkFactory.newClient(connectionString, new ExponentialBackoffRetry(1000,
3))
>>         }
>> public String getMasterNodeIP(){
>> if(client!=null){
>>         client.start();
>>         LeaderSelectorListener listener = new LeaderSelectorListenerAdapter() {
>>             public void takeLeadership(CuratorFramework client) throws Exception
{
>>             }
>>         };
>> 
>>         LeaderSelector selector = new LeaderSelector(client, path, listener);
>>         selector.autoRequeue();
>>         selector.start();
>> 
>>         Participant participant = selector.getLeader();
>>         String id = participant.getId().substring(participant.getId().indexOf("@")
+ 1, participant.getId().indexOf("*"));
>>         masterNode.add(id);
>>     }
>> } catch (Exception e) {
>>     logger.error("Failed find out master node", e.getCause());
>> }
>> 
>>         }
>> }
>> Nikolaos Ballas  |  Software Development Manager 
>> 
>> Technology Nexus S.a.r.l.
>> 2-4 Rue Eugene Rupert
>> 2453 Luxembourg
>> Delivery address: 2-3 Rue Eugene Rupert,Vertigo Polaris Building
>> Tel: + 3522619113580
>> contact@nexusgroup.com <mailto:contact.de@nexusgroup.com> | nexusgroup.com
<http://www.nexusgroup.com/> 
>> LinkedIn.com <http://www.linkedin.com/company/nexus-technology> | Twitter <http://www.twitter.com/technologynexus>
| Facebook.com <https://www.facebook.com/pages/Technology-Nexus/133756470003189>
>> 
>> 
>> <C5B06FBE-74F4-416B-9BCE-F914341A2E0B_4_.png>
>> 
>>> On 08 Jul 2015, at 16:27, Donald Laidlaw <donlaidlaw@me.com <mailto:donlaidlaw@me.com>>
wrote:
>>> 
>>> @Nikolaos Ballas neXus
>>> I can see no way to instantiate the Curator LeaderSelector without actually becoming
a participant in leader election. If I do instantiate that class, it does not accept a null
value for the LeaderSelectorListener and so anything instantiating LeaderSelector must also
become a participant.
>>> 
>>> Even then, that class provides no way to listen for leadership change. The only
listening it does is to discover when it itself becomes the leader. I suppose it would be
possible to participate in the leadership election, but immediately relinquish leadership
causing a real mesos master to become the leader, but that seems a little too invasive to
do.
>>> 
>>> The only solution I can see is to monitor the children of the mesos leader node,
and parse through the contents of the ones whose name begins with “info” as per @Marco
Massenzio.
>>> 
>>> Best regards,
>>> -Don
>>> 
>>>> On Jul 7, 2015, at 12:16 PM, Donald Laidlaw <donlaidlaw@me.com <mailto:donlaidlaw@me.com>>
wrote:
>>>> 
>>>> Thank you all.
>>>> 
>>>> I will use the Curator recipe, since I already use Curator for a bunch of
other things. 
>>>> 
>>>> If curator can find the leader and the participants that is good enough.
Otherwise I will parse the protocol buffer contents, and provide a way to parse the future
son contents when that happens.
>>>> 
>>>> I’ll reply again with the results of using the Curator recipe to get the
leader and participants.
>>>> 
>>>> Best regards,
>>>> -Don
>>>> 
>>>>> On Jul 7, 2015, at 11:04 AM, Dick Davies <dick@hellooperator.net <mailto:dick@hellooperator.net>>
wrote:
>>>>> 
>>>>> The active master has a flag set in  /metrics/snapshot  :
>>>>> "master/elected" which is 1 for the active
>>>>> master and 0 otherwise, so it's easy enough to only load the metrics
>>>>> from the active master.
>>>>> 
>>>>> (I use the collectd plugin and push data rather than poll, but the
>>>>> same principle should apply).
>>>>> 
>>>>> On 7 July 2015 at 14:02, Donald Laidlaw <donlaidlaw@me.com <mailto:donlaidlaw@me.com>>
wrote:
>>>>>> Has anyone ever developed Java code to detect the mesos masters and
leader, given a zookeeper connection?
>>>>>> 
>>>>>> The reason I ask is because I would like to monitor mesos to report
various metrics reported by the master. This requires detecting and tracking the leading master
to query its /metrics/snapshot REST endpoint.
>>>>>> 
>>>>>> Thanks,
>>>>>> -Don
>>>> 
>>> 
>> 
> 


Mime
View raw message