Confirmed "Compact footer" setting fixed the problem. Thanks a lot.  
-MJ



---Original---
From: "Alex Plehanov"<plehanov.a...@gmail.com&gt;
Date: Mon, Oct 18, 2021 21:34 PM
To: "user"<user@ignite.apache.org&gt;;
Subject: Re: Problem with Cache KV Remote Query


Hello,

How was the entry inserted to the cache? You are trying to get this entry via 
thin client, if the entry was inserted via thick-client (Ignite node) you can 
face such a problem. Ignite thin-client and Ignite nodes have different default 
"Compact footer" property values, so POJO keys are marshalled in different ways 
and treated as different keys for thin-clients and Ignite nodes.&nbsp;
Try to change "Compact footer"&nbsp;property for thin-client configuration:
ClientConfiguration cfg = new ClientConfiguration().setBinaryConfiguration(new 
BinaryConfiguration().setCompactFooter(true)).setAddresses("127.0.0.1:10800");



пн, 18 окт. 2021 г. в 15:02, MJ <6733...@qq.com&gt;:

Hi,




I experienced below problem when testing the “Affinity Colocation” 
functionality. The code is from 
https://ignite.apache.org/docs/latest/data-modeling/affinity-collocation#configuring-affinity-key&nbsp;
 .&nbsp; 


When I run the code in single jvm, it works perfect and successfully retrieved 
the cached object (personCache.get(new PersonKey(1, "company1"))) .
But when I try to run the client code in another new JVM(meanwhile leave the 
server node run in local), something goes wrong (see below).&nbsp; Please can 
anyone elaborate why the first test case succeeded but the second one failed ?


&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Logger log = 
LoggerFactory.getLogger(getClass()); 


&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //success
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Test
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void 
test_iterate() throws ClientException, Exception {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ClientConfiguration cfg = new 
ClientConfiguration().setAddresses("127.0.0.1:10800");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try (IgniteClient client = 
Ignition.startClient(cfg)) {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; ClientCache<PersonKey, Person&gt; cache = client.cache("persons");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; try (QueryCursor<Cache.Entry<PersonKey, Person&gt;&gt; qryCursor 
= cache.query(new ScanQuery<&gt;(null))) {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; qryCursor.forEach(entry -&gt; 
System.out.println("Key = " + entry.getKey() + ", Value = " + 
entry.getValue()));
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }


&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //fail
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Test
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void 
test_query() throws ClientException, Exception {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ClientConfiguration cfg = new 
ClientConfiguration().setAddresses("127.0.0.1:10800");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try (IgniteClient client = 
Ignition.startClient(cfg)) {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; ClientCache<PersonKey, Person&gt; cache = client.cache("persons");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; Person row = cache.get(new PersonKey(1, "company1"));
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; Assert.assertNotNull(row);&nbsp; // no data returned
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; log.info("{}", row);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp;


Thanks,
-MJ

Reply via email to