On Tue, Apr 1, 2014 at 2:59 PM, Tommaso Paba <[email protected]> wrote:
> Hi, > > we're using Akka 2.3.0. In our tests with clustering, we noticed that it > can happen that, after the node has received the MemberUp event, if we > check the members variable of the Cluster.state object immediately > afterwards, sometimes the member list is empty. This happens quite often > (about 50% of the times), meaning that probably we access the variable when > the members has not been added yet, even though we have already received > the MemberUp event. > > We're just starting the first node of the cluster (with no other nodes > running), and we tried to access the member list both in the > registerOnMemberUp callback and when we receive the MemberUp event, with > the same results in both cases: sometimes it's empty, while some other > times it correctly contains the node itself. > > If we check cluster.state.leader, this is always correctly set with the > current node address, even when the member list is empty. So the state > appears to be inconsistent (i.e. it appears to have a leader but no > members!). > > We also tried to call Cluster.sendCurrentClusterState(self). In the > message that we receive afterwards, the members variable always contains > the current node, so this seems the correct way to access cluster state > information, though we don't know if this happens just because some time > has elapsed. > > Is this by design? Which is the safe way to know which members a cluster > has when a node comes up? The documentation does not mention any > limitations to using the Cluster.state object. Actually, it looks like > should be the intended way to access cluster state information. > >From the documentation: Instead of subscribing to cluster events it can sometimes be convenient to only get the full membership state with Cluster(system).state. Note that this state is not necessarily in sync with the events published to a cluster subscription. I would not use the state getter together with membership event listeners. If you already listen to the membership events you can build up the state as demonstrated in several samples in the documentation. > Another thing we noticed is that the registerOnMemberUp callback and the > MemberUp event are executed concurrently. So we were wondering which is the > purpose of registerOnMemberUp compared to processing the MemberUp event. > It can be useful if you want to startup something when the node has been accepted in the cluster. You can do the same thing with listening to MemberUp event, but that requires an actor that can receive the MemberUp event. /Patrik > > Thanks to anyone that will help. > Tommaso. > > -- > >>>>>>>>>> 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > -- Patrik Nordwall Typesafe <http://typesafe.com/> - Reactive apps on the JVM Twitter: @patriknw JOIN US. REGISTER TODAY! <http://www.scaladays.org/> Scala <http://www.scaladays.org/> Days <http://www.scaladays.org/> June 16th-18th, <http://www.scaladays.org/> Berlin <http://www.scaladays.org/> -- >>>>>>>>>> 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
