Btw, I don’t see anything at server log, where should I check this problem?
From: Xu, Nan Sent: Thursday, September 07, 2017 10:23 AM To: [email protected] Subject: [External email from [email protected]] pdx serializer, need help hi, I try to use pdx serializer for a very simple class. After I deploy it to server, the gfsh query prompt me. Really can not see where can go wrong. Can someone give suggestion? Btw, from client side, it works fine as this. public class Get { public static void main(String[] args) throws InterruptedException { Properties prop = new Properties(); prop.setProperty("conserve-sockets","false"); ClientCache cache = new ClientCacheFactory(prop).addPoolLocator("centos", 10334) .setPdxSerializer(new MyPdxSerializer()) .set("log-level", "info") .create(); ClientRegionFactory<String, Simple> regionFactory = cache.createClientRegionFactory(ClientRegionShortcut.PROXY); Region<String, Simple> region = regionFactory.create("test"); Simple s = region.get("key1"); System.out.println("====================:" +s.getId() +" "+ s.getName() + " " + s.getTime()); } } Thanks a lot. Nan On the server query, it breack… gfsh>query --query="select * from /test" Result : false startCount : 0 endCount : 20 Message : Could not deserialize pdx because the pdx serializer's fromData returned false for a pdx of class pojo.Simple Here is my class public class MyPdxSerializer implements PdxSerializer, Declarable { @Override public void init(Properties props) { } @Override public boolean toData(Object o, PdxWriter writer) { if(!(o instanceof Simple)) { return false; } Simple s = (Simple) o; writer.writeString("id", s.id) .writeString("name", s.getName()) .writeObject("time", s.getTime()); return true; } @Override public Object fromData(Class<?> clazz, PdxReader reader) { ; if(!clazz.equals(Simple.class)) { return null; } Simple s = Simple.getInstance(); s.id = reader.readString("id"); s.name = reader.readString("name"); s.time = (Timestamp) reader.readObject("time"); return s; } } And my domain object. public class Simple { public static Simple getInstance(){ return new Simple(); } // private Simple(){} String id; public String getId() { return id; } public void setId(String id) { this.id = id; } String name; Timestamp time; public String getName() { return name; } public void setName(String name) { this.name = name; } public Timestamp getTime() { return time; } public void setTime(Timestamp time) { this.time = time; } } ________________________________ This message, and any attachments, is for the intended recipient(s) only, may contain information that is privileged, confidential and/or proprietary and subject to important terms and conditions available at http://www.bankofamerica.com/emaildisclaimer. If you are not the intended recipient, please delete this message. ---------------------------------------------------------------------- This message, and any attachments, is for the intended recipient(s) only, may contain information that is privileged, confidential and/or proprietary and subject to important terms and conditions available at http://www.bankofamerica.com/emaildisclaimer. If you are not the intended recipient, please delete this message.
