You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by JP <jo...@gmail.com> on 2018/05/07 06:33:25 UTC
Continuous query - Exactly once based event across multiple nodes..
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/
Re: Continuous query - Exactly once based event across multiple
nodes..
Posted by vkulichenko <va...@gmail.com>.
JP,
Do you have a solution for this? Do you need any more help?
-Val
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Continuous query - Exactly once based event across multiple
nodes..
Posted by JP <jo...@gmail.com>.
Vkulichenko,
I want to update in multiple databases based on event triggered in the
ignite cache.
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Continuous query - Exactly once based event across multiple
nodes..
Posted by vkulichenko <va...@gmail.com>.
JP,
Can you please describe the business case behind this? What are you trying
to achieve on application level? What guarantees are needed and why?
-Val
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Continuous query - Exactly once based event across multiple nodes..
Posted by Nikolay Izhikov <ni...@apache.org>.
Hello, JP.
So what?
What is issue with multiple filter instance?
пн, 7 мая 2018 г., 12:47 JP <jo...@gmail.com>:
> Thanks... This solution worked but problem is, it creating multiple remote
> filter instance..
>
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>
Re: Continuous query - Exactly once based event across multiple
nodes..
Posted by JP <jo...@gmail.com>.
Thanks... This solution worked but problem is, it creating multiple remote
filter instance..
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
RE: Continuous query - Exactly once based event across multiple nodes..
Posted by Raymond Wilson <ra...@trimble.com>.
I another possibility to create a continuous query per node in your node
affinity set for the cache and have the continuous query return local
values, like this:
using (IContinuousQueryHandle<ICacheEntry<Key, Value>>
queryHandle = queueCache.QueryContinuous
(qry: new ContinuousQuery< Key, Value >(new LocalListener())
{ Local = true },
initialQry: new ScanQuery< Key, Value > { Local = true }))
(
// Perform the initial query to grab all existing elements
foreach (var item in queryHandle.GetInitialQueryCursor())
{
if (NodeIsPrimaryForThisKey(Key)) // Don’t let backups
get involved
handler.Add(item.Key);
}
// move into steady state management of arriving elements...
)
-----Original Message-----
From: Николай Ижиков [mailto:nizhikov.dev@gmail.com] On Behalf Of Nikolay
Izhikov
Sent: Monday, May 7, 2018 6:40 PM
To: user@ignite.apache.org
Cc: JP <jo...@gmail.com>
Subject: Re: Continuous query - Exactly once based event across multiple
nodes..
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/
Re: Continuous query - Exactly once based event across multiple
nodes..
Posted by Nikolay Izhikov <ni...@apache.org>.
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/