You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Roman Shtykh <rs...@yahoo.com> on 2019/01/16 09:42:03 UTC

Thin client cannot retrieve data that was inserted with the regular Ignite client when using a composite key

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

Re: Thin client cannot retrieve data that was inserted with the regular Ignite client when using a composite key

Posted by Mikhail <mi...@gmail.com>.
Hi Roman,

it looks like a bug for me, at least I don't see anything wrong about your
test case. Also, I can reproduce the issue with the latest master version,
so I filed a ticket:
https://issues.apache.org/jira/browse/IGNITE-10960

Thank you for your report,
Mike.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/