Re: Conditional data Preloading from third party persistence

2021-06-22 Thread Stephen Darlington
As Ilya said, the underlying error is:

> Caused by: java.lang.ClassCastException: 
> org.apache.ignite.internal.binary.BinaryObjectImpl cannot be cast to 
> com.model.Customer
> at 
> com.jio.digitalapi.edif.util.operations.DataPreloadFromThirdPartyDB$1.apply(DataPreloadFromThirdPartyDB.java:36)
>  ~[ignite-util-1.0.1.jar:?]


As a guess — this is not tested — you’d need something like:


IgniteCache cache = ignite.cache(cacheName);
cache.loadCache((k,v) -> {
  String firstName;
  if (v instanceof BinaryObject) {
BinaryObject vb = (BinaryObject)v;
firstName = v.field(“firstName”);
  }
  else {
firstName = v.getFirstName();
  }
  return ("".equalsIgnoreCase(firstName));
});

Regards,
Stephen

> On 22 Jun 2021, at 12:21, Kamlesh Joshi  wrote:
> 
> Sending again to reflect in portal !
>  
> Thanks and Regards,
> Kamlesh Joshi
>  
> From: Kamlesh Joshi 
> Sent: 21 June 2021 17:25
> To: user@ignite.apache.org 
> Subject: Conditional data Preloading from third party persistence
>  
> Hi Igniters,
>  
> Am trying to preload certain data from third party persistence, but am 
> getting below error while doing that. I have been using below snippet for the 
> same. Can anyone guide, if am doing something wrong here. Any specific 
> changes needed to be done on data model side?
>  
> IgniteCache cache = ignite.cache(cacheName);
> cache.loadCache(new IgniteBiPredicate() {
> @Override
> public boolean apply(String k, Customer v) {
>   if ("".equalsIgnoreCase(v.getFirstName())) {
>return true;
>   } else {
>return false;
>   }
> }
> });
>  
>  
> Custom data model jars are already available on cluster class path.
>  
>  
> org.apache.ignite.IgniteException: Failed to load cache: CustomerCache
> at 
> org.apache.ignite.internal.processors.closure.GridClosureProcessor$C2.execute(GridClosureProcessor.java:1858)
>  ~[ignite-core-2.7.6.jar:2.7.6]
> at 
> org.apache.ignite.internal.processors.job.GridJobWorker$2.call(GridJobWorker.java:568)
>  ~[ignite-core-2.7.6.jar:2.7.6]
> at 
> org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6820)
>  [ignite-core-2.7.6.jar:2.7.6]
> at 
> org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:562)
>  [ignite-core-2.7.6.jar:2.7.6]
> at 
> org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:491)
>  [ignite-core-2.7.6.jar:2.7.6]
> at 
> org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:120) 
> [ignite-core-2.7.6.jar:2.7.6]
> at 
> org.apache.ignite.internal.processors.job.GridJobProcessor.processJobExecuteRequest(GridJobProcessor.java:1125)
>  [ignite-core-2.7.6.jar:2.7.6]
> at 
> org.apache.ignite.internal.processors.job.GridJobProcessor$JobExecutionListener.onMessage(GridJobProcessor.java:1923)
>  [ignite-core-2.7.6.jar:2.7.6]
> at 
> org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1569)
>  [ignite-core-2.7.6.jar:2.7.6]
> at 
> org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:1197)
>  [ignite-core-2.7.6.jar:2.7.6]
> at 
> org.apache.ignite.internal.managers.communication.GridIoManager.access$4200(GridIoManager.java:127)
>  [ignite-core-2.7.6.jar:2.7.6]
> at 
> org.apache.ignite.internal.managers.communication.GridIoManager$9.run(GridIoManager.java:1093)
>  [ignite-core-2.7.6.jar:2.7.6]
> at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>  [?:1.8.0_271]
> at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>  [?:1.8.0_271]
> at java.lang.Thread.run(Thread.java:748) [?:1.8.0_271]
> Caused by: org.apache.ignite.IgniteException: Failed to load cache: 
> CustomerCache
> at 
> org.apache.ignite.internal.util.IgniteUtils.convertException(IgniteUtils.java:1029)
>  [ignite-core-2.7.6.jar:2.7.6]
> at 
> org.apache.ignite.internal.processors.cache.GridCacheAdapter$LoadCacheJob.localExecute(GridCacheAdapter.java:5681)
>  ~[ignite-core-2.7.6.jar:2.7.6]
> at 
> org.apache.ignite.internal.processors.cache.GridCacheAdapter$LoadCacheJobV2.localExecute(GridCacheAdapter.java:5725)
>  ~[ignite-core-2.7.6.jar:2.7.6]
> at 
> org.apache.ignite.internal.processors.cache.GridCacheAdapter$TopologyVersionAwareJob.execute(GridCacheAdapter.java:6361)
>  ~[ignite-core-2.7.6.jar:2.7.6]
> at 
> org.apache.ignite.compute.ComputeJobAdapter.call(ComputeJobAdapter.java:132) 
> ~[ignite-core-2.7.6.jar:2.7.6]
> at 
> org.apache.ignite.internal.processors.closure.GridClosureProcessor$C2.execute(GridClosureProcessor.java:1855)
>  ~[ignite-core-2.7.6.jar:2.7.6]
> ... 14 more
> Caused by:

Conditional data Preloading from third party persistence

2021-06-22 Thread Kamlesh Joshi
Sending again to reflect in portal !

Thanks and Regards,
Kamlesh Joshi

From: Kamlesh Joshi
Sent: 21 June 2021 17:25
To: user@ignite.apache.org
Subject: Conditional data Preloading from third party persistence

Hi Igniters,

Am trying to preload certain data from third party persistence, but am getting 
below error while doing that. I have been using below snippet for the same. Can 
anyone guide, if am doing something wrong here. Any specific changes needed to 
be done on data model side?

IgniteCache cache = ignite.cache(cacheName);
cache.loadCache(new IgniteBiPredicate() {
@Override
public boolean apply(String k, Customer v) {
  if ("".equalsIgnoreCase(v.getFirstName())) {
   return true;
  } else {
   return false;
  }
}
});


Custom data model jars are already available on cluster class path.


org.apache.ignite.IgniteException: Failed to load cache: CustomerCache
at 
org.apache.ignite.internal.processors.closure.GridClosureProcessor$C2.execute(GridClosureProcessor.java:1858)
 ~[ignite-core-2.7.6.jar:2.7.6]
at 
org.apache.ignite.internal.processors.job.GridJobWorker$2.call(GridJobWorker.java:568)
 ~[ignite-core-2.7.6.jar:2.7.6]
at 
org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6820)
 [ignite-core-2.7.6.jar:2.7.6]
at 
org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:562)
 [ignite-core-2.7.6.jar:2.7.6]
at 
org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:491)
 [ignite-core-2.7.6.jar:2.7.6]
at 
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:120) 
[ignite-core-2.7.6.jar:2.7.6]
at 
org.apache.ignite.internal.processors.job.GridJobProcessor.processJobExecuteRequest(GridJobProcessor.java:1125)
 [ignite-core-2.7.6.jar:2.7.6]
at 
org.apache.ignite.internal.processors.job.GridJobProcessor$JobExecutionListener.onMessage(GridJobProcessor.java:1923)
 [ignite-core-2.7.6.jar:2.7.6]
at 
org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1569)
 [ignite-core-2.7.6.jar:2.7.6]
at 
org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:1197)
 [ignite-core-2.7.6.jar:2.7.6]
at 
org.apache.ignite.internal.managers.communication.GridIoManager.access$4200(GridIoManager.java:127)
 [ignite-core-2.7.6.jar:2.7.6]
at 
org.apache.ignite.internal.managers.communication.GridIoManager$9.run(GridIoManager.java:1093)
 [ignite-core-2.7.6.jar:2.7.6]
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
[?:1.8.0_271]
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 
[?:1.8.0_271]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_271]
Caused by: org.apache.ignite.IgniteException: Failed to load cache: 
CustomerCache
at 
org.apache.ignite.internal.util.IgniteUtils.convertException(IgniteUtils.java:1029)
 [ignite-core-2.7.6.jar:2.7.6]
at 
org.apache.ignite.internal.processors.cache.GridCacheAdapter$LoadCacheJob.localExecute(GridCacheAdapter.java:5681)
 ~[ignite-core-2.7.6.jar:2.7.6]
at 
org.apache.ignite.internal.processors.cache.GridCacheAdapter$LoadCacheJobV2.localExecute(GridCacheAdapter.java:5725)
 ~[ignite-core-2.7.6.jar:2.7.6]
at 
org.apache.ignite.internal.processors.cache.GridCacheAdapter$TopologyVersionAwareJob.execute(GridCacheAdapter.java:6361)
 ~[ignite-core-2.7.6.jar:2.7.6]
at 
org.apache.ignite.compute.ComputeJobAdapter.call(ComputeJobAdapter.java:132) 
~[ignite-core-2.7.6.jar:2.7.6]
at 
org.apache.ignite.internal.processors.closure.GridClosureProcessor$C2.execute(GridClosureProcessor.java:1855)
 ~[ignite-core-2.7.6.jar:2.7.6]
... 14 more
Caused by: org.apache.ignite.IgniteCheckedException: Failed to load cache: 
CustomerCache
at 
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadCache(GridCacheStoreManagerAdapter.java:543)
 ~[ignite-core-2.7.6.jar:2.7.6]
at 
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter.localLoadCache(GridDhtCacheAdapter.java:630)
 ~[ignite-core-2.7.6.jar:2.7.6]
at 
org.apache.ignite.internal.processors.cache.GridCacheProxyImpl.localLoadCache(GridCacheProxyImpl.java:222)
 ~[ignite-core-2.7.6.jar:2.7.6]
at 
org.apache.ignite.internal.processors.cache.GridCacheAdapter$LoadCacheJob.localExecute(GridCacheAdapter.java:5676)
 ~[ignite-core-2.7.6.jar:2.7.6]
at 
org.apache.ignite.internal.processors.cache.GridCacheAdapter$LoadCacheJobV2.localExecute(GridCacheAdapter.java:5725)
 ~[ignite-core-2.7.6.jar:2.7.6]
at 
org.apache.ignite.internal.processors.cache.GridCacheAdapter$TopologyVersionAwareJob.execute(GridCacheAdapter.java:6361)
 ~[ignite-core-2.7.6.jar:2.7.6]
   

Re: Conditional data Preloading from third party persistence

2021-06-22 Thread Ilya Kasnacheev
Hello!

I guess that your cache store implementation is using BinaryObject to
populate cache instead of POJO. You can try ((BinaryObject)v).deserialize().

Regards,
-- 
Ilya Kasnacheev


пн, 21 июн. 2021 г. в 14:55, Kamlesh Joshi :

> Hi Igniters,
>
>
>
> Am trying to preload certain data from third party persistence, but am
> getting below error while doing that. I have been using below snippet for
> the same. Can anyone guide, if am doing something wrong here. Any specific
> changes needed to be done on data model side?
>
>
>
> *IgniteCache cache = ignite.cache(cacheName);*
>
> *cache.loadCache(new IgniteBiPredicate() {*
>
> *@Override*
>
> *public boolean apply(String k, Customer v) {*
>
> *  if ("".equalsIgnoreCase(v.getFirstName())) {*
>
> *   return true;*
>
> *  } else {*
>
> *   return false;*
>
> *  }*
>
> *}*
>
> *});*
>
>
>
>
>
> *Custom data model jars are already available on cluster class path.*
>
>
>
>
>
> *org.apache.ignite.IgniteException: Failed to load cache: CustomerCache*
>
> *at
> org.apache.ignite.internal.processors.closure.GridClosureProcessor$C2.execute(GridClosureProcessor.java:1858)
> ~[ignite-core-2.7.6.jar:2.7.6]*
>
> *at
> org.apache.ignite.internal.processors.job.GridJobWorker$2.call(GridJobWorker.java:568)
> ~[ignite-core-2.7.6.jar:2.7.6]*
>
> *at
> org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6820)
> [ignite-core-2.7.6.jar:2.7.6]*
>
> *at
> org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:562)
> [ignite-core-2.7.6.jar:2.7.6]*
>
> *at
> org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:491)
> [ignite-core-2.7.6.jar:2.7.6]*
>
> *at
> org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:120)
> [ignite-core-2.7.6.jar:2.7.6]*
>
> *at
> org.apache.ignite.internal.processors.job.GridJobProcessor.processJobExecuteRequest(GridJobProcessor.java:1125)
> [ignite-core-2.7.6.jar:2.7.6]*
>
> *at
> org.apache.ignite.internal.processors.job.GridJobProcessor$JobExecutionListener.onMessage(GridJobProcessor.java:1923)
> [ignite-core-2.7.6.jar:2.7.6]*
>
> *at
> org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1569)
> [ignite-core-2.7.6.jar:2.7.6]*
>
> *at
> org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:1197)
> [ignite-core-2.7.6.jar:2.7.6]*
>
> *at
> org.apache.ignite.internal.managers.communication.GridIoManager.access$4200(GridIoManager.java:127)
> [ignite-core-2.7.6.jar:2.7.6]*
>
> *at
> org.apache.ignite.internal.managers.communication.GridIoManager$9.run(GridIoManager.java:1093)
> [ignite-core-2.7.6.jar:2.7.6]*
>
> *at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> [?:1.8.0_271]*
>
> *at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> [?:1.8.0_271]*
>
> *at java.lang.Thread.run(Thread.java:748) [?:1.8.0_271]*
>
> *Caused by: org.apache.ignite.IgniteException: Failed to load cache:
> CustomerCache*
>
> *at
> org.apache.ignite.internal.util.IgniteUtils.convertException(IgniteUtils.java:1029)
> [ignite-core-2.7.6.jar:2.7.6]*
>
> *at
> org.apache.ignite.internal.processors.cache.GridCacheAdapter$LoadCacheJob.localExecute(GridCacheAdapter.java:5681)
> ~[ignite-core-2.7.6.jar:2.7.6]*
>
> *at
> org.apache.ignite.internal.processors.cache.GridCacheAdapter$LoadCacheJobV2.localExecute(GridCacheAdapter.java:5725)
> ~[ignite-core-2.7.6.jar:2.7.6]*
>
> *at
> org.apache.ignite.internal.processors.cache.GridCacheAdapter$TopologyVersionAwareJob.execute(GridCacheAdapter.java:6361)
> ~[ignite-core-2.7.6.jar:2.7.6]*
>
> *at
> org.apache.ignite.compute.ComputeJobAdapter.call(ComputeJobAdapter.java:132)
> ~[ignite-core-2.7.6.jar:2.7.6]*
>
> *at
> org.apache.ignite.internal.processors.closure.GridClosureProcessor$C2.execute(GridClosureProcessor.java:1855)
> ~[ignite-core-2.7.6.jar:2.7.6]*
>
> *... 14 more*
>
> *Caused by: org.apache.ignite.IgniteCheckedException: Failed to load
> cache: CustomerCache*
>
> *at
> org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadCache(GridCacheStoreManagerAdapter.java:543)
> ~[ignite-core-2.7.6.jar:2.7.6]*
>
> *at
> org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter.localLoadCache(GridDhtCacheAdapter.java:630)
> ~[ignite-core-2.7.6.jar:2.7.6]*
>
> *at
> org.apache.ignite.internal.processors.cache.GridCacheProxyImpl.localLoadCache(GridCacheProxyImpl.java:222)
> ~[ignite-core-2.7.6.jar:2.7.6]*
>
> *at
> org.apache.ignite.internal.processors.cache.GridCacheAdapter$LoadCacheJob.localExecute(GridCacheAdapter.java:5676)
> ~[ignite-core-2.7.6.jar:2.7.6]*
>
> *at