It's also worth noting that for the "leader" concept there is no election.
It's simply the node with the lowest address with some additional rules
around membership status and unreachability. That means that there can be
more than one "leader" at the same time, e.g. one for each side of a
network partition.

Cluster singleton is more strict and ensures that there will not be more
than one active singleton at any time.

/Patrik
fre 19 aug. 2016 kl. 11:41 skrev Akka Team <akka.offic...@gmail.com>:

> HI Yutao,
>
> On Mon, Aug 15, 2016 at 2:26 PM, Yutao Shuai <szqs...@gmail.com> wrote:
>
>>
>> <https://lh3.googleusercontent.com/-3MgMU_DY9KM/V7G02f_dlUI/AAAAAAAAAME/yM4Pje9ZAMAUpV7A0vy091WUjUS1AKOYQCLcB/s1600/TT%25E6%2588%25AA%25E5%259B%25BE%25E6%259C%25AA%25E5%2591%25BD%25E5%2590%258D22.jpg>
>> Thanks for your help Konrad. So the return value of this function is the
>> leader of the cluster? But I read the DiffRolesLeader function in the
>> ClusterEvent.scala where call the roleLeader function. This function
>> traverse all roles and call the roleLeader function, What this mean? All
>> nodes with specfic roles have its own leader? What difference between this
>> leader and cluster leader ?
>>
>
> The cluster leader does certain responsibilities in the cluster,
> internally. If you want to also hook into this leader election, then you
> can since we expose via the API the leader. In certain cases it might be
> useful to be able to select a leader among a subset of cluster members
> though, in that case you can use the role leader functionality. By default
> the cluster does nothing with this, it is only an exposed API if someone
> needs this for building new functionality on top of this leader election
> protocol.
>
> It is *NOT *recommended to use these features directly, as in 99.9% of
> the cases you really want the cluster Singleton pattern instead:
> http://doc.akka.io/docs/akka/2.4/scala/cluster-singleton.html
> For example, the leader election protocol selects a new leader whenever a
> new node *added not just when the leader is removed.* This is not an
> issue for Akka itself, as the role of the leader is stateless, and this
> transition is cheap. On the other hand, with most user Singletons you want
> to usually have state and therefore prefer a more stable location. The
> Singleton pattern solve this for you.
>
> In general, I would avoid touching the internal leader election altogether
> and use Singletons instead.
>
> -Endre
>
>
>>
>>
>> 在 2016年8月15日星期一 UTC+8下午5:27:22,Konrad Malawski写道:
>>>
>>> Hi Yutao,
>>> look at the return type – Option, so it's a single element.
>>> It returns the leader of a given role (role == multiple nodes, 1 of them
>>> is the leader).
>>> I.e. it would host the the Singleton if it were constrained to this role.
>>>
>>> --
>>> Konrad `ktoso` Malawski
>>> Akka <http://akka.io> @ Lightbend <http://lightbend.com>
>>>
>>> On 15 August 2016 at 04:23:26, Yutao Shuai (szq...@gmail.com) wrote:
>>>
>>>
>>> <https://lh3.googleusercontent.com/-tZtLqoK9VUY/V7EnCA2ZVKI/AAAAAAAAAL0/Gm66R8FjZqIZOmBWrT8b29IL8PdUJboCwCLcB/s1600/TT%25E6%2588%25AA%25E5%259B%25BE%25E6%259C%25AA%25E5%2591%25BD1%25E5%2590%258D.jpg>
>>>
>>> What this function means? Select a nodes with specfic roles as the
>>> cluster leader or every roles has its leader?
>>> --
>>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>>> >>>>>>>>>> Check the FAQ:
>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>> >>>>>>>>>> Search the archives:
>>> https://groups.google.com/group/akka-user
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Akka User List" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to akka-user+...@googlegroups.com.
>>> To post to this group, send email to akka...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/akka-user.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>> --
>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>> >>>>>>>>>> Check the FAQ:
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Akka User List" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to akka-user+unsubscr...@googlegroups.com.
>> To post to this group, send email to akka-user@googlegroups.com.
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Akka Team
> Lightbend <http://www.lightbend.com/> - Reactive apps on the JVM
> Twitter: @akkateam
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to