Thin client cannot retrieve data with the composite key when it is put by a 
regular (thick) Ignite client.

Is any additional configuration needed or is it a bug?


    import java.io.Serializable;
    import org.apache.ignite.Ignite;
    import org.apache.ignite.IgniteCache;
    import org.apache.ignite.Ignition;
    import org.apache.ignite.client.ClientCache;
    import org.apache.ignite.client.ClientException;
    import org.apache.ignite.client.IgniteClient;
    import org.apache.ignite.configuration.ClientConfiguration;
    
    public class ThinClientGets {
        final static String CACHE_NAME = "testCache";
    
        public static void main(String[] args) {
            try (Ignite ignite = Ignition.start()) {
                try (IgniteCache<TestKey, Integer> c = 
ignite.getOrCreateCache(CACHE_NAME)) {
                    c.put(new TestKey("a", "0"), 1);
    
                    System.out.println("Val: " + c.get(new TestKey("a", "0")));
                }
    
                try (IgniteCache<String, Integer> c = 
ignite.getOrCreateCache(CACHE_NAME + 2)) {
                    c.put("k1", 1);
    
                    System.out.println("Val: " + c.get("k1"));
                }
    
                // thin client
                System.out.println("-- Getting with a thin client --");
                ClientConfiguration cfg = new 
ClientConfiguration().setAddresses("127.0.0.1:10800");
    
                try (IgniteClient igniteClient = Ignition.startClient(cfg)) {
                    ClientCache<TestKey, Integer> cache = 
igniteClient.cache(CACHE_NAME);
    
                    // null here!
                    System.out.println(cache.get(new TestKey("a", "0")));
    
                    ClientCache<String, Integer> cache2 = 
igniteClient.cache(CACHE_NAME + 2);
    
                    System.out.println(cache2.get("k1"));
                }
                catch (ClientException e) {
                    System.err.println(e.getMessage());
                }
                catch (Exception e) {
                    System.err.format("Unexpected failure: %s\n", e);
    
                }
            }
        }
    
        static class TestKey implements Serializable {
            private final String a;
    
            private final String b;
    
            public TestKey(String a, String b) {
                this.a = a;
                this.b = b;
            }
    
            public String getA() {
                return a;
            }
    
            public String getB() {
                return b;
            }
        }
    }


--
Roman

Reply via email to