Hi,

I was using REBALANCE_STOPPED event to recognize which primary partitions
are assigned to local with Ignite v1.5.
As the REBALANCE_STOPPED event occurs a couple of times when a server node
has been failed,
I made my code to check discoveryEvent of received events because I want my
code be executed only once per a node failed or joined.

It worked well but after upgrade to Ignite v1.6 my code does not perform
correctly.
I found the partitions are not rebalanced yet, although the event listener
received a REBALANCE_STOPPED event.

Here is my code.
How do I fix my code? I need your advice.

-------------------------------------------------------------------------------------------------------------
                Ignite ignite = IgniteUtil.getIgnite();
                
                IgnitePredicate<EventAdapter> locLsnr = new
IgnitePredicate<EventAdapter>() {
                        @Override
                        public boolean apply(EventAdapter evt) {
                                Boolean isClient = null;

                                switch (evt.type()) {
                                case EventType.EVT_CACHE_REBALANCE_STOPPED:
                                        if (evt instanceof 
CacheRebalancingEvent) {
                                                CacheRebalancingEvent cacheEvt 
= (CacheRebalancingEvent) evt;
                                                isClient =
cacheEvt.discoveryNode().attribute(IgniteNodeAttributes.ATTR_CLIENT_MODE);
                                                if (isClient != null && 
!isClient
                                                                && 
cacheEvt.cacheName().equals(CacheConfig.messageCache().getName())
                                                                && 
(cacheEvt.discoveryEventType() == EventType.EVT_NODE_JOINED
                                                                                
|| cacheEvt.discoveryEventType() == EventType.EVT_NODE_LEFT 
                                                                                
|| cacheEvt.discoveryEventType() == EventType.EVT_NODE_FAILED)) {
                                                        
                                                        //Rebalance finished
                                                        Affinity aff = 
ignite.affinity(CacheConfig.messageCache().getName());
                                                        int[] partitions =
aff.primaryPartitions(ignite.cluster().localNode());
                                                        
                                                }
                                        }
                                        break;
                                default:
                                        break;
                                }

                                return true;
                        }
        };
        
        ignite.events().localListen(locLsnr,
EventType.EVT_CACHE_REBALANCE_STOPPED);
-------------------------------------------------------------------------------------------------------------

Sincerely,
Andrew.         



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/How-do-I-know-the-cache-rebalance-is-finished-tp5219.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Reply via email to