I think a slightly simpler (and less racy) implementation would look something 
like this:

ignite.events().localListen(new IgnitePredicate<DiscoveryEvent>() {
    @Override public boolean apply(DiscoveryEvent event) {
        if (event.topologyNodes().size() >= 10) {
            // GO!
        }
 
        return true;
    }
}, EventType.EVT_NODE_JOINED);Also, I believe EventType.EVT_NODE_JOINED events 
must be enabled in the configuration:

IgniteConfiguration.setIncludeEventTypes(new int[]{EventType.EVT_NODE_JOINED});

Regards
Andrey

> Date: Fri, 19 Feb 2016 14:06:38 -0800
> From: [email protected]
> To: [email protected]
> Subject: Re: Wait for nodes to join the cluster
> 
> Hi Paolo,
> 
> You can register a discovery event listener and check the topology size
> there:
> 
> ignite.events().localListen(new IgnitePredicate<Event>() {
>     @Override public boolean apply(Event event) {
>         if (ignite.cluster().nodes().size() >= 10) {
>             // GO!
>         }
> 
>         return true;
>     }
> }, EventType.EVT_NODE_JOINED);
> 
> Note that it's better to run execution asynchronously in this case, not to
> block the Ignite's internal thread that processes events.
> 
> Let me know if this helps.
> 
> -Val
> 
> 
> 
> --
> View this message in context: 
> http://apache-ignite-users.70518.x6.nabble.com/Wait-for-nodes-to-join-the-cluster-tp3103p3104.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
                                          

Reply via email to