ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkarachentsev <dkarachent...@gridgain.com>
Subject Re: Determine current number of Server Nodes
Date Mon, 10 Jul 2017 07:55:53 GMT
Hi Chris,

You understand correctly that you need to subscribe for node joined event.
Here is possible example of how to write it:

    private static class Listener implements IgnitePredicate<Event> {

        private Ignite ignite;

        @Override public boolean apply(Event evt) {
            int size = ignite.cluster().forServers().nodes().size(); //
check cluster size for servers only

            if (size == 10) {
                // Generate ready event only once
                if (ignite.cache("flags").putIfAbsent("gridReady", true))
                    System.out.println("Got expected size");

                // Unsubscribe
                return false;

            return true;

And configuration:

        Map<IgnitePredicate&lt;? extends Event>, int[]> listeners = new

        listeners.put(new Listener(), new int[]{EventType.EVT_NODE_JOINED});


        cfg.setCacheConfiguration(new CacheConfiguration("flags"));


View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Determine-current-number-of-Server-Nodes-tp14542p14550.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

View raw message