Re: cache update from .NET client to Java cluster
cool - i thought i'd tried that but perhaps screwed it up will have another look -- View this message in context: http://apache-ignite-users.70518.x6.nabble.com/cache-update-from-NET-client-to-Java-cluster-tp11217p11336.html Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: cache update from .NET client to Java cluster
I was able to run it and reproduce the problem. If you add "Console.WriteLine("Cache size: " + cache.GetSize());" to the end of C# program, you'll see that there are two entries in the cache, because keys from Java and C# are not considered equal. To fix the problem, override GetHashCode/Equals in C# in the same manner as in Java: public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; if (obj.GetType() != this.GetType()) return false; return Id == ((MyClassKey) obj).Id; } public override int GetHashCode() { return (int)(Id ^ (Id >> 32)); } This way I get expected result in Java log: CacheListener - UPDATED , object0 written from .NET On Tue, Mar 21, 2017 at 7:55 AM, kfeerick < kevin.feer...@ninemilefinancial.com> wrote: > Here you go - hopefully you can spin this up in your favoured Java / C# IDE > pretty easily. > > cache-duplicate-reproducer.zip > <http://apache-ignite-users.70518.x6.nabble.com/file/ > n11332/cache-duplicate-reproducer.zip> > > > > -- > View this message in context: http://apache-ignite-users. > 70518.x6.nabble.com/cache-update-from-NET-client-to- > Java-cluster-tp11217p11332.html > Sent from the Apache Ignite Users mailing list archive at Nabble.com. >
Re: cache update from .NET client to Java cluster
Here you go - hopefully you can spin this up in your favoured Java / C# IDE pretty easily. cache-duplicate-reproducer.zip <http://apache-ignite-users.70518.x6.nabble.com/file/n11332/cache-duplicate-reproducer.zip> -- View this message in context: http://apache-ignite-users.70518.x6.nabble.com/cache-update-from-NET-client-to-Java-cluster-tp11217p11332.html Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: cache update from .NET client to Java cluster
Please send a reproducer. Probably I still misunderstand the question. On Mon, Mar 20, 2017 at 10:00 AM, kfeerick < kevin.feer...@ninemilefinancial.com> wrote: > That's not the behaviour I am seeing. I can send through a reproduce if > required. > > Thanks, > kevin > > > > -- > View this message in context: http://apache-ignite-users. > 70518.x6.nabble.com/cache-update-from-NET-client-to- > Java-cluster-tp11217p11305.html > Sent from the Apache Ignite Users mailing list archive at Nabble.com. >
Re: cache update from .NET client to Java cluster
That's not the behaviour I am seeing. I can send through a reproduce if required. Thanks, kevin -- View this message in context: http://apache-ignite-users.70518.x6.nabble.com/cache-update-from-NET-client-to-Java-cluster-tp11217p11305.html Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: cache update from .NET client to Java cluster
Yes, existing entry will be updated. On Mon, Mar 20, 2017 at 1:07 AM, kfeerick < kevin.feer...@ninemilefinancial.com> wrote: > Thanks Pavel, > Perhaps some crossed wires here. Let me rephrase my question. > > In my code example should I expect cache.Put(entry.Key, row) on my .NET > process running in client mode to update an existing entry or create a new > entry? > > /1:var cache = Ignite.GetOrCreateCache<Key, Value>("my-cache"); > 2:var query = new SqlQuery(typeof(Value), "Id=?") {Arguments = > new[] {id}}; > 3:var cursor = cache.Query(query); > 4:var entry = cursor.First(); > 5:var row = entry.Value; > 6:row.Text = "ignite me"; > 7:row.LastUpdatedStamp = DateTime.Now; > 8:cache.Put(entry.Key, row); / > > > Even with serialisation of the key both ways my expectation is that the key > value passed back in cache.Put() (line 8) would be equivalent to the key in > the cache already as Ignite passed me that exact key from the result of my > query (line 4). > > > > -- > View this message in context: http://apache-ignite-users. > 70518.x6.nabble.com/cache-update-from-NET-client-to- > Java-cluster-tp11217p11297.html > Sent from the Apache Ignite Users mailing list archive at Nabble.com. >
Re: cache update from .NET client to Java cluster
Thanks Pavel, Perhaps some crossed wires here. Let me rephrase my question. In my code example should I expect cache.Put(entry.Key, row) on my .NET process running in client mode to update an existing entry or create a new entry? /1:var cache = Ignite.GetOrCreateCache<Key, Value>("my-cache"); 2:var query = new SqlQuery(typeof(Value), "Id=?") {Arguments = new[] {id}}; 3:var cursor = cache.Query(query); 4:var entry = cursor.First(); 5:var row = entry.Value; 6:row.Text = "ignite me"; 7:row.LastUpdatedStamp = DateTime.Now; 8:cache.Put(entry.Key, row); / Even with serialisation of the key both ways my expectation is that the key value passed back in cache.Put() (line 8) would be equivalent to the key in the cache already as Ignite passed me that exact key from the result of my query (line 4). -- View this message in context: http://apache-ignite-users.70518.x6.nabble.com/cache-update-from-NET-client-to-Java-cluster-tp11217p11297.html Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: cache update from .NET client to Java cluster
> new entry get created in the map Updating an entry in Ignite cache is not just updating some map; it is a distributed operation that may update multiple memory/disk locations on multiple machines, depending on cache mode, number of backups, swap storage, etc. Anyway, these are implementation details, and I'm not very familiar with this part of code. You can write to d...@ignite.apache.org and ask for technical details there. Or is there something from the user point of view that affects you? Because from public API pov, I don't think this matters. On Fri, Mar 17, 2017 at 4:19 AM, kfeerick < kevin.feer...@ninemilefinancial.com> wrote: > /When you update the entry and call cache.Put, it gets serialized and then > sent to the server node./ > > Thanks Pavel, > Perhaps I'm missing something here but I would expect the existing entry to > get updated do to key equivalence rather than a new entry get created in > the > map? > > > > -- > View this message in context: http://apache-ignite-users. > 70518.x6.nabble.com/cache-update-from-NET-client-to- > Java-cluster-tp11217p11261.html > Sent from the Apache Ignite Users mailing list archive at Nabble.com. >
Re: cache update from .NET client to Java cluster
/When you update the entry and call cache.Put, it gets serialized and then sent to the server node./ Thanks Pavel, Perhaps I'm missing something here but I would expect the existing entry to get updated do to key equivalence rather than a new entry get created in the map? -- View this message in context: http://apache-ignite-users.70518.x6.nabble.com/cache-update-from-NET-client-to-Java-cluster-tp11217p11261.html Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: cache update from .NET client to Java cluster
Hi Kevin, When you retrieve data from cache (with a query, ICache.Get, or by any other means), you always get a local copy of the cached data, because cache entries are stored in serialized form on server nodes. When you update the entry and call cache.Put, it gets serialized and then sent to the server node. Do you have some use case where this behavior is unwanted? Pavel On Thu, Mar 16, 2017 at 2:56 AM, kfeerick < kevin.feer...@ninemilefinancial.com> wrote: > Hello there, > We're using ignite data grid for the purposes of distributing data from a > shared distributed Java key value store to a .NET client for display and > update. The Java nodes are running in server mode and the client connected > in client mode. I see some interesting behaviour when i look to update data > in the k/v store from the .NET client. Querying for a single data item and > then immediately updating it appears to create a *new* entry in the cache > rather than updating the existing value (as I would expect). I suspect this > is to do with the binary notion of equivalence and I've tried supplying a > custom BinaryIdentityResolver but with no change in behaviour. Below is a > code snippet from the .NET side to illustrate. I can upload a complete > reproduction of the issue if that's required. > > Can someone let me know if my expectations or understanding of the features > of the data grid are incorrect. > > var cache = Ignite.GetOrCreateCache<Key, Value>("my-cache"); > var query = new SqlQuery(typeof(Value), "Id=?") {Arguments = > new[] {id}}; > var cursor = cache.Query(query); > var entry = cursor.First(); > var row = entry.Value; > row.Text = "ignite me"; > row.LastUpdatedStamp = DateTime.Now; > cache.Put(entry.Key, modelRow); > > Cheers > Kevin > > > > -- > View this message in context: http://apache-ignite-users. > 70518.x6.nabble.com/cache-update-from-NET-client-to- > Java-cluster-tp11217.html > Sent from the Apache Ignite Users mailing list archive at Nabble.com. >
cache update from .NET client to Java cluster
Hello there, We're using ignite data grid for the purposes of distributing data from a shared distributed Java key value store to a .NET client for display and update. The Java nodes are running in server mode and the client connected in client mode. I see some interesting behaviour when i look to update data in the k/v store from the .NET client. Querying for a single data item and then immediately updating it appears to create a *new* entry in the cache rather than updating the existing value (as I would expect). I suspect this is to do with the binary notion of equivalence and I've tried supplying a custom BinaryIdentityResolver but with no change in behaviour. Below is a code snippet from the .NET side to illustrate. I can upload a complete reproduction of the issue if that's required. Can someone let me know if my expectations or understanding of the features of the data grid are incorrect. var cache = Ignite.GetOrCreateCache<Key, Value>("my-cache"); var query = new SqlQuery(typeof(Value), "Id=?") {Arguments = new[] {id}}; var cursor = cache.Query(query); var entry = cursor.First(); var row = entry.Value; row.Text = "ignite me"; row.LastUpdatedStamp = DateTime.Now; cache.Put(entry.Key, modelRow); Cheers Kevin -- View this message in context: http://apache-ignite-users.70518.x6.nabble.com/cache-update-from-NET-client-to-Java-cluster-tp11217.html Sent from the Apache Ignite Users mailing list archive at Nabble.com.