ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anton Vinogradov <avinogra...@gridgain.com>
Subject Re: BinaryObject
Date Wed, 03 May 2017 09:20:52 GMT
Anil,

This seems to be fixed at https://issues.apache.org/jira/browse/IGNITE-4891,
please check.


On Wed, May 3, 2017 at 12:08 PM, Anil <anilklce@gmail.com> wrote:

> HI Team,
>
> Did you get a chance to look into it ? thanks.
>
> Thanks
>
> On 2 May 2017 at 11:19, Anil <anilklce@gmail.com> 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<Affinity<String>, BinaryObject> cache =
>> ignite.cache(CacheManager.CACHE).withKeepBinary();
>> IgniteCache<Affinity<String>, BinaryObject> lCache =
>> ignite.cache(CacheManager.LOCK_CACHE).withKeepBinary();
>> ScanQuery<Affinity<String>, BinaryObject> scanQuery = new
>> ScanQuery<Affinity<String>, BinaryObject>();
>> scanQuery.setLocal(true);
>> scanQuery.setPartition(1);
>>
>> Iterator<Entry<Affinity<String>, BinaryObject>> iterator =
>> cache.query(scanQuery).iterator();
>> Integer oldStat = null, newStat = null;
>> boolean changed = false;
>> Entry<Affinity<String>, BinaryObject> row = null;
>> while (iterator.hasNext()) {
>> try {
>> row = iterator.next();
>> BinaryObject itrVal = row.getValue();
>> String id = itrVal.<String>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.<Integer>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
>>
>>
>

Mime
View raw message