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 5F5A3200C68 for ; Wed, 3 May 2017 11:08:55 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 5DD30160BB5; Wed, 3 May 2017 09:08:55 +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 56389160BAA for ; Wed, 3 May 2017 11:08:54 +0200 (CEST) Received: (qmail 3678 invoked by uid 500); 3 May 2017 09:08:53 -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 3668 invoked by uid 99); 3 May 2017 09:08:53 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 May 2017 09:08:53 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 0319C1AA967 for ; Wed, 3 May 2017 09:08:53 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.679 X-Spam-Level: * X-Spam-Status: No, score=1.679 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 4YfkrGsQcR3Y for ; Wed, 3 May 2017 09:08:51 +0000 (UTC) Received: from mail-it0-f53.google.com (mail-it0-f53.google.com [209.85.214.53]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 21F325FCD2 for ; Wed, 3 May 2017 09:08:50 +0000 (UTC) Received: by mail-it0-f53.google.com with SMTP id e65so32542086ita.1 for ; Wed, 03 May 2017 02:08:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=nD/mYE5Zuha4Y39cdBuUGCf7deDHsaTblG36NTfXKIE=; b=k6YBHG5VaT3JNWRH8HwOPIhYQeGfj0xTg1D8KjIOjGg118IBk91OPgUlfwTGP6zGYn DhMcpQjdH/fJM6GgnZhM0MnaVoIJ6zcIGbDDJg9m5drw2P1/9MkEW9VKG3Dx/KBVz7MU 4/bmjw7CBGyBMlt5SGQuKOkXSklJfoCms+E31yUBcRlllWBJtqCHLIWaOujWrd4XbEkV TaaqBUzedTMw6opiQPtKXUXVqj0924FbKJmfPwjLQt982STBXBmOGWy83wWlnZBe6TXi fHdOliLfaJMdqcrTJ3nBivJrrcW+iVj1C8XgZfPpBOrnNbi9ObPIVfzr8R2kG/TEIxXx fvng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=nD/mYE5Zuha4Y39cdBuUGCf7deDHsaTblG36NTfXKIE=; b=Btdu2Zzs4Tb8GcVkT8h5KDUzyaQ6ZM90heQAUqbqRBSTN1L6jSy8/ScNpJaq+IfyQQ w1DL6jaILxvblx6wrueo+hAipjZBBsxsaNymmKWGSXN/NnP0K62Y/xkZEysg8Nl24+6M 6PZsXosuw/ltdEG6NYmoAMH/YVKe0beRszux6Bsiwg9sCA2N10dJDjM0IdXPojNBJrSh XCZByNPpQjMb/chRVs+fLBkNqGOPlCG6QG/qMX8BKSpVHcbIkV+btksCB2cLTBB0t6Kb kkYLIhRh3mrMzap0mt34WUd3gHGcSFDdynpHvxyn5j9V9wFZwW7+NxqivXziviGp24bo pgZA== X-Gm-Message-State: AN3rC/7r+5aOyH8xLvGtGtQs8gBQjzqIkBC08EB8Db+QKs/PKqWpQoaz 2Wryo1hVcNTqhB5jGJOoWJ/RSHuuVg== X-Received: by 10.36.19.72 with SMTP id 69mr7349128itz.41.1493802528773; Wed, 03 May 2017 02:08:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.170.139 with HTTP; Wed, 3 May 2017 02:08:08 -0700 (PDT) In-Reply-To: References: From: Anil Date: Wed, 3 May 2017 14:38:08 +0530 Message-ID: Subject: Re: BinaryObject To: user@ignite.apache.org Content-Type: multipart/alternative; boundary=001a1144027617acec054e9b0193 archived-at: Wed, 03 May 2017 09:08:55 -0000 --001a1144027617acec054e9b0193 Content-Type: text/plain; charset=UTF-8 HI Team, Did you get a chance to look into it ? thanks. Thanks On 2 May 2017 at 11:19, Anil wrote: > Hi, > > java.lang.ClassCastException: org.apache.ignite.internal.binary.BinaryObjectImpl > cannot be cast to org.apache.ignite.cache.affinity.Affinity exception > thrown when a field updated using BinaryObject for a cache entry. and it is > intermittent. > > Following is the snippet i am using > > IgniteCache, BinaryObject> cache = > ignite.cache(CacheManager.CACHE).withKeepBinary(); > IgniteCache, BinaryObject> lCache = > ignite.cache(CacheManager.LOCK_CACHE).withKeepBinary(); > ScanQuery, BinaryObject> scanQuery = new > ScanQuery, BinaryObject>(); > scanQuery.setLocal(true); > scanQuery.setPartition(1); > > Iterator, BinaryObject>> iterator = > cache.query(scanQuery).iterator(); > Integer oldStat = null, newStat = null; > boolean changed = false; > Entry, BinaryObject> row = null; > while (iterator.hasNext()) { > try { > row = iterator.next(); > BinaryObject itrVal = row.getValue(); > String id = itrVal.field("id"); > Lock lock = lCache.lock(id); > try { > lock.lock(); > BinaryObject val = cache.get(row.getKey()); > if (null != val){ > BinaryObjectBuilder bldr = val.toBuilder(); > oldStat = val.field("stat"); > Status status = null ; // determine status > if (!CommonUtils.equalsObject(oldStat, newStat)){ > changed = true; > bldr.setField("stat", status.getStatus()); > bldr.setField("status", status.getDescription()); > } > > // update other > fields > if(changed){ > cache.put(row.getKey(), bldr.build()); > } > } > }catch (Exception ex){ > log.error("Failed to update the status of {} {} ", id, ex); > }finally { > lock.unlock(); > } > }catch (Exception ex){ > log.error("Failed to process and update status of {} {} ", row, ex); > } > } > > > Do you see any issue in the above snippet ? thanks. > > > Thanks > > --001a1144027617acec054e9b0193 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
HI Team,

Did you get a chance to look i= nto it ? thanks.

Thanks

On 2 May 2017 at 11:19, Anil <= anilklce@gmail.com> wrote:
=
Hi,

java.lang.ClassCastException: org.a= pache.ignite.internal.binary.BinaryObjectImpl cannot be cast to org.ap= ache.ignite.cache.affinity.Affinity =C2=A0exception thrown when a fiel= d updated using BinaryObject for a cache entry. and it is intermittent.

Following is the snippet i am using

IgniteCache<Affinity<String>, BinaryObject> cache =3D i= gnite.cache(CacheManager.CACHE).withKeepBinary();
IgniteCache<Affinity<String>, BinaryObject> lCac= he =3D ignite.cache(CacheManager.LOCK_CACHE).withKeepBinary();
ScanQuery<Affinity<String>, BinaryObje= ct> scanQuery =3D new ScanQuery<Affinity<String>, BinaryObject&= gt;();
scanQuery.setLocal(true);
scanQuery.setPartition(1);

=
Iterator<Entry<Affinity<String&= gt;, BinaryObject>> iterator =3D cache.query(scanQuery).iterator= ();
Integer oldStat =3D null, newStat = =3D null;=C2=A0
boolean changed =3D fals= e;
Entry<Affinity<String>, Bina= ryObject> row =3D null;
while (iterat= or.hasNext()) {
try {
row =3D iterator.next();
= BinaryObject itrVal =3D row.getValue();
= String id =3D itrVal.<String>field("id");
Lock lock =3D lCache.lock(id);
try {
lock.lock= ();
BinaryObject val =3D cache.get(ro= w.getKey());
if (null !=3D val){
BinaryObjectBuilder bldr =3D val.toBuild= er();
= oldStat =3D val.<Integer>field("stat");
Status status =3D null ; // determine status<= /div>
if (!CommonUtils.equalsObject(oldStat, newStat)){
changed =3D true;
= bldr.setField("stat", status.getStatus());
bldr.setField("status", status.getDescr= iption());
}

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 // update other fields
if(changed){
cache.put(row.getKey(= ), bldr.build());
}
}
= }catch (Exception ex){
log.e= rror("Failed to update the status of =C2=A0{} =C2=A0{} ", id, ex)= ;
}finally {
= lock.unlock();
}
}catch (Exception ex){
log.error("Failed to process and update status of =C2=A0{= } =C2=A0{} ", row, ex);
}
}=C2=A0


= Do you see any issue in the above snippet ? thanks.


Thanks


--001a1144027617acec054e9b0193--