[ 
https://issues.apache.org/jira/browse/IGNITE-8035?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16418951#comment-16418951
 ] 

Nikolay Izhikov commented on IGNITE-8035:
-----------------------------------------

[~ruslangm] 

The issue with your code is following: RemoteFilter returns different values 
when executed on one or another node.
This is wrong due to the contract of ContinuousQuery.
To resolve your issue you should use Affinity to check if specific node will be 
primary for a specific entry.
This can be done with following filter:
{code:java}

    @IgniteAsyncCallback
    public static class RemoteFactory implements 
Factory<CacheEntryEventFilter<String, Long>> {
        private final ClusterNode node;

        public RemoteFactory(ClusterNode node) {
            this.node = node;
        }

        @Override
        public CacheEntryEventFilter<String, Long> create() {
            return new CacheEntryEventFilter<String, Long>() {
                @IgniteInstanceResource
                private Ignite ignite;

                @Override
                public boolean evaluate(CacheEntryEvent<? extends String, ? 
extends Long> cacheEntryEvent) {
                    Affinity<String> aff = ignite.affinity("myCache");

                    ClusterNode primary = 
aff.mapKeyToNode(cacheEntryEvent.getKey());

                    return primary.id().equals(node.id());
                }
            };
        }
    }
{code}

> Duplicated events with type CREATED in ContinuousQuery's Events Listener 
> -------------------------------------------------------------------------
>
>                 Key: IGNITE-8035
>                 URL: https://issues.apache.org/jira/browse/IGNITE-8035
>             Project: Ignite
>          Issue Type: Bug
>          Components: cache
>    Affects Versions: 2.4
>            Reporter: Ruslan Gilemzyanov
>            Assignee: Nikolay Izhikov
>            Priority: Major
>
> We faced with bug in ContinuousQuery's EventListener work in Ignite. I wrote 
> sample project to demonstrate it.
> We started 2 server nodes connected to the one cache.
> Topology snapshot became [ver=2, servers=2, clients=0, CPUs=4, heap=3.6GB]
> I have put elements in cache (about 50 elements). Elements were distributed 
> between two nodes approxiamtely in the same amount.
> After pushing every element to cache we waited 100ms (to ensure that Listener 
> did his work) and deleted element from cache. 
> Then we stopped one node. (Topology snapshot became [ver=3, servers=1, 
> clients=0, CPUs=4, heap=1.8GB])
> And then some absolutely randomly chosen (deleted from cache to this moment) 
> events came to other working node with status CREATED (Remind you that we 
> deleted them from cache to this moment). In our case it was 5 events.
> I think this is direct violation of Continuous Query's "exactly once 
> delivery" contract. 
> Source code is here: [https://github.com/ruslangm/ignite-sample]
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to