Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 9F5BD200C4C for ; Tue, 21 Mar 2017 07:19:05 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 9DD17160B8F; Tue, 21 Mar 2017 06:19:05 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C1551160B76 for ; Tue, 21 Mar 2017 07:19:04 +0100 (CET) Received: (qmail 53963 invoked by uid 500); 21 Mar 2017 06:19:03 -0000 Mailing-List: contact user-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@ignite.apache.org Delivered-To: mailing list user@ignite.apache.org Received: (qmail 53954 invoked by uid 99); 21 Mar 2017 06:19:03 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Mar 2017 06:19:03 +0000 Received: from mail-oi0-f42.google.com (mail-oi0-f42.google.com [209.85.218.42]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id 61E141A0331 for ; Tue, 21 Mar 2017 06:19:03 +0000 (UTC) Received: by mail-oi0-f42.google.com with SMTP id r203so28375630oib.3 for ; Mon, 20 Mar 2017 23:19:03 -0700 (PDT) X-Gm-Message-State: AFeK/H1fsvq+ASq8HGzwCnrhtJ88wzDerd+z/sFIrkqbzMIeG7jEXbFuCEvSsiw2QR0AlECxgog7yz/9Geiympvp X-Received: by 10.202.84.150 with SMTP id i144mr8583122oib.53.1490077142741; Mon, 20 Mar 2017 23:19:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.46.47 with HTTP; Mon, 20 Mar 2017 23:18:32 -0700 (PDT) In-Reply-To: <1490072113837-11332.post@n6.nabble.com> References: <1489622170656-11217.post@n6.nabble.com> <1489713592374-11261.post@n6.nabble.com> <1489961245918-11297.post@n6.nabble.com> <1489993215761-11305.post@n6.nabble.com> <1490072113837-11332.post@n6.nabble.com> From: Pavel Tupitsyn Date: Tue, 21 Mar 2017 09:18:32 +0300 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: cache update from .NET client to Java cluster To: user@ignite.apache.org Content-Type: multipart/alternative; boundary=001a113df41ac80bf2054b379e29 archived-at: Tue, 21 Mar 2017 06:19:05 -0000 --001a113df41ac80bf2054b379e29 Content-Type: text/plain; charset=UTF-8 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.feerick@ninemilefinancial.com> wrote: > Here you go - hopefully you can spin this up in your favoured Java / C# IDE > pretty easily. > > cache-duplicate-reproducer.zip > 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. > --001a113df41ac80bf2054b379e29 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I was able to run it and reproduce the problem.
If you= add "Console.WriteLine("Cache size: " + cache.GetSize());&q= uot; 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 equa= l.

To fix the problem, override GetHashCode/Equals= in C# in the same manner as in Java:

public<=
/span>=C2=A0override=C2=A0bool=C2=A0Equals(object=C2=A0obj)
{
=C2=A0=C2=A0=C2=A0=C2=A0if=C2=A0(Referenc=
eEquals(null,=C2=A0obj))=C2=A0return=C2=A0false;
=C2=A0=C2=A0=C2=A0=C2=A0if=C2=A0(Referenc=
eEquals(this,=C2=A0obj))=C2=A0return=C2=A0true;
=C2=A0=C2=A0=C2=A0=C2=A0if=C2=A0(obj.GetT=
ype()=C2=A0!=3D=C2=A0this.GetType())=C2=
=A0return=C2=A0false;
=C2=A0=C2=A0=C2=A0=C2=A0return=C2=A0Id=C2=
=A0=3D=3D=C2=A0((MyClassKey)=
=C2=A0obj).Id;
}
=20
public=C2=A0ov=
erride=C2=A0int=C2=A0GetHashCode()
{
=C2=A0=C2=A0=C2=A0=C2=A0return=C2=A0(int)(Id=C2=A0^=C2=A0(Id=C2=A0>>=C2=A032=
));
}

This way I get expected result in Java log:
CacheListe= ner - UPDATED , object0 written from .NET


On Tue, Mar 21, 2017 at 7:= 55 AM, kfeerick <kevin.feerick@ninemilefinancial.com= > wrote:
Here you go - hopefull= y 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-duplica= te-reproducer.zip>



--
View this message in context: http://apache-ignite-users.705= 18.x6.nabble.com/cache-update-from-NET-client-to-Java-cluster-tp1= 1217p11332.html
Sent from the Apache Ignite Users m= ailing list archive at Nabble.com.

--001a113df41ac80bf2054b379e29--