ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "slava.koptilin" <slava.kopti...@gmail.com>
Subject Re: Re: Where can we get the partition assignment of a Cache after the cluster changed?
Date Tue, 24 Oct 2017 10:39:27 GMT
Hi Aaron,

Please check that CACHE_REBALANCE events are registered in
IgniteConfiguration via xml or java code (by default, all these events are
disabled).

<property name="includeEventTypes">
    <list>
        <util:constant
static-field="org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_STARTED"/>
        <util:constant
static-field="org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_STOPPED"/>
        <util:constant
static-field="org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_PART_LOADED"/>
        <util:constant
static-field="org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_PART_UNLOADED"/>
        <util:constant
static-field="org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_OBJECT_LOADED"/>
        <util:constant
static-field="org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_OBJECT_UNLOADED"/>
        <util:constant
static-field="org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST"/>
    </list>
</property>

Could you try the following code?
        IgnitePredicate<Event> rebalanceEventLsnr = evt -> {
            System.out.println("Received event [evt=" + evt.name() + ",
evt=" + evt.toString());

            if (evt instanceof CacheRebalancingEvent) {
                CacheRebalancingEvent rebalancingEvt =
(CacheRebalancingEvent) evt;

                if (rebalancingEvt.cacheName().equals(IG_CACHE_NAME)) {
                    IgniteCache c = ignite.cache(IG_CACHE_NAME);
                    ClusterNode localNode = ignite.cluster().localNode();

                    int[] backups =
ignite.affinity(c.getName()).backupPartitions(localNode);
                    int[] primaries =
ignite.affinity(c.getName()).primaryPartitions(localNode);

                    System.out.println("Local node : " + localNode.id());
                    System.out.println("\t primary: " +
Arrays.toString(primaries));
                    System.out.println("\t backups: " +
Arrays.toString(backups));
                   
System.out.println("-----------------------------------------");
                }
            }

            return true; // Continue listening.
        };
        ignite.events().localListen(rebalanceEventLsnr,
EventType.EVT_CACHE_REBALANCE_STOPPED);




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Mime
View raw message