You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Som Som <2a...@gmail.com> on 2018/02/07 15:01:25 UTC

continuous query - changes from local server only

hi.

I have a cache with cachemode = partitioned and 2 server nodes that share
parts of the cache data according to the affinity function. Then I run the
client node on one of the computers where the server node is located. How
to configure a continuous query on the client node to receive events only
from server nodes located on the same machine?

Re: continuous query - changes from local server only

Posted by Vinokurov Pavel <vi...@gmail.com>.
Som,

You could create the continuous query on each client node with the filter
described above.

2018-02-08 19:55 GMT+03:00 Som Som <2a...@gmail.com>:

> i've got both client and server nodes on each of 3 physical servers, that
> is my cluster. there is a partitioned cache, each server node stores only a
> part of keys. i start the application on my dev machine that app is also
> client of the cluster further i put new key into the cluster. i would like
> to see this change only in client which is located with server node which
> stores this new key.
>
> 8 февр. 2018 г. 11:41 ДП пользователь "dkarachentsev" <
> dkarachentsev@gridgain.com> написал:
>
> Hi,
>
> You may fuse filter for that, for example:
>
> ContinuousQuery<Integer, Integer> qry = new ContinuousQuery<>();
>
>         fine al Set<ClusterNode> nodes = new
> HashSet<>(client.cluster().forDataNodes("cache")
>             .forHost(client.cluster().localNode()).nodes());
>
>         qry.setRemoteFilterFactory(new
> Factory<CacheEntryEventFilter&lt;Integer, Integer>>() {
>             @Override public CacheEntryEventFilter<Integer, Integer>
> create() {
>                 return new CacheEntryEventFilter<Integer, Integer>() {
>                     @IgniteInstanceResource
>                     private Ignite ignite;
>
>                     @Override public boolean evaluate(
>                         CacheEntryEvent<? extends Integer, ? extends
> Integer> event) throws CacheEntryListenerException {
>                         // Server nodes on current host
>                         return nodes.contains(ignite.cluster(
> ).localNode());
>                     }
>                 };
>             }
>         });
>
> Thanks!
> -Dmitry
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>
>
>


-- 

Regards

Pavel Vinokurov

Re: continuous query - changes from local server only

Posted by Som Som <2a...@gmail.com>.
i've got both client and server nodes on each of 3 physical servers, that
is my cluster. there is a partitioned cache, each server node stores only a
part of keys. i start the application on my dev machine that app is also
client of the cluster further i put new key into the cluster. i would like
to see this change only in client which is located with server node which
stores this new key.

8 февр. 2018 г. 11:41 ДП пользователь "dkarachentsev" <
dkarachentsev@gridgain.com> написал:

Hi,

You may fuse filter for that, for example:

ContinuousQuery<Integer, Integer> qry = new ContinuousQuery<>();

        fine al Set<ClusterNode> nodes = new
HashSet<>(client.cluster().forDataNodes("cache")
            .forHost(client.cluster().localNode()).nodes());

        qry.setRemoteFilterFactory(new
Factory<CacheEntryEventFilter&lt;Integer, Integer>>() {
            @Override public CacheEntryEventFilter<Integer, Integer>
create() {
                return new CacheEntryEventFilter<Integer, Integer>() {
                    @IgniteInstanceResource
                    private Ignite ignite;

                    @Override public boolean evaluate(
                        CacheEntryEvent<? extends Integer, ? extends
Integer> event) throws CacheEntryListenerException {
                        // Server nodes on current host
                        return nodes.contains(ignite.cluster().localNode());
                    }
                };
            }
        });

Thanks!
-Dmitry



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

Re: continuous query - changes from local server only

Posted by dkarachentsev <dk...@gridgain.com>.
Hi,

You may fuse filter for that, for example:

ContinuousQuery<Integer, Integer> qry = new ContinuousQuery<>();

        final Set<ClusterNode> nodes = new
HashSet<>(client.cluster().forDataNodes("cache")
            .forHost(client.cluster().localNode()).nodes());

        qry.setRemoteFilterFactory(new
Factory<CacheEntryEventFilter&lt;Integer, Integer>>() {
            @Override public CacheEntryEventFilter<Integer, Integer>
create() {
                return new CacheEntryEventFilter<Integer, Integer>() {
                    @IgniteInstanceResource
                    private Ignite ignite;

                    @Override public boolean evaluate(
                        CacheEntryEvent<? extends Integer, ? extends
Integer> event) throws CacheEntryListenerException {
                        // Server nodes on current host
                        return nodes.contains(ignite.cluster().localNode());
                    }
                };
            }
        });

Thanks!
-Dmitry



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