Using IgniteSet as part of dynamic remote filter for Ignite's Continuous Query

Viewed 82

Has anyone ever tried using IgniteSet or similar data structures for setting remote filters on a continuous query? There is not much documentation on how IgniteSet works and hence this question. Basically my use case is as follows:

I have a distributed cache implemented using Ignite. A user is interested in real time updates from my cache based on some criteria. I will have more than one user subscribing to these updates. Rather than run n continuous queries, I intend to run one continuous query for n users with the remote filter backed by some distributed data structure.

I think IgniteSet could work for me. But I am not sure how this will affect the performance of my app server in production since I am not entirely sure how IgniteSet would work (due to minimal documentation on this topic). Basically, if I need to update the ignite set data structure, will it be dynamically updated for all remote nodes as well and will this mean I will start receiving updates for the filter that might be evaluated (to true) on these remote nodes?

    qry.setRemoteFilterFactory(new Factory<CacheEntryEventFilter<PersonKey, Person>>() {
            @Override public CacheEntryEventFilter<PersonKey, Person> create() {
                return new CacheEntryEventFilter<PersonKey, Person>() {
                    @Override public boolean evaluate(CacheEntryEvent<? extends PersonKey, ? extends Person> e) {

                        //IgniteSet maintained outside of filter
                        return igniteSet.contains(e.getKey().getCity());
                    }
                };
            }
        });

Sorry if I am missing something obvious here.

Any help would be greatly appreciated!

1 Answers

IgniteSet is backed by a cache, and like all Ignite caches, is designed to allow all nodes to see updates as soon as they are available.
see: https://ignite.apache.org/docs/latest/data-structures/queue-and-set for configuration settings.

The design you are proposing is subject to race conditions. A consumer of the continuous query could come in before the appropriate writer had a chance to update the given IgniteSet.

Use appropriate synchronization mechanisms to work out all edge conditions. Examples/Descriptions here: https://ignite.apache.org/features/datastructures.html

Related