ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nikolay Izhikov <nizhi...@apache.org>
Subject Re: Continuous query - Exactly once based event across multiple nodes..
Date Mon, 07 May 2018 06:40:07 GMT
Hello, JP.

You should use target node in remote filter.

You should check "Is primary node for some record equal to target node?" in your filter.
Please, see code below.
You can find related discussion and full example here [1].

    @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());
                }
            };
        }
    }



[1] https://issues.apache.org/jira/browse/IGNITE-8035


В Вс, 06/05/2018 в 23:33 -0700, JP пишет:
> Using continuous query,
> 
> How to achieve event trigger for cache exactly only once per key even if
> continuous query is listening in multiple nodes or multiple listener.
> example:
> 1. Scenario 1:
>  Node A: Start Continuous query 
>  Node B: Start Continuous query 
>  Node C: Insert or Update or Delete record ex: number from 1 to 100
> 
> Expected Output should be as below
>  Node A - 1 ,2,3,4,5....50
>  Node B - 51, 52, 53, 54, ... 100
>  Above output is the expected output. Here, event per key should be
> triggered exactly once across nodes.
> 
> Actual Output should be as below
>  Node A - 1 ,2,3,4,5,....100
>  Node B - 1, 2, 3, 4,5 ... 100
>  
> If this is not possible in Continuous query, then is there any way to
> achieve this.
> 
> 2. Scenario 2:
> To achieve expected output,
>  I am using singleton service per Cluster.
>     Ex: Cluster A
>               - Singleton service with Continuous query for cache
>                 Here problem is, service is running in only one instance.
> How to achieve above output with multiple instance of service?
> 
> 
> 
> 
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Mime
View raw message