Thanks for help, actually, it works, need to restart server and locator. don’t
know why.
I wire it in this way.
<cache
xmlns="http://geode.apache.org/schema/cache"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://geode.apache.org/schema/cache
http://geode.apache.org/schema/cache/cache-1.0.xsd"
version="1.0">
<cache-server port="40404" />
<pdx>
<pdx-serializer>
<class-name>pojo.MyPdxSerializer</class-name>
</pdx-serializer>
</pdx>
<region name="test">
<region-attributes refid="PARTITION"/>
</region>
</cache>
From: Xiawei Zhang [mailto:[email protected]]
Sent: Thursday, September 07, 2017 10:40 AM
To: [email protected]
Subject: Re: pdx serializer, need help
How do you wire PdxSerializer on the server side?
you might want to check
https://gemfire.docs.pivotal.io/geode/developing/data_serialization/use_pdx_serializer.html<https://urldefense.proofpoint.com/v2/url?u=https-3A__gemfire.docs.pivotal.io_geode_developing_data-5Fserialization_use-5Fpdx-5Fserializer.html&d=DwMFaQ&c=SFszdw3oxIkTvaP4xmzq_apLU3uL-3SxdAPNkldf__Q&r=HB5LZowSGF4DiMmOUsCX6Q&m=2hFmrt3Ab9isU6ABAr-hVroXxKvtz9dWdGKMlV-buFI&s=qx8K9LPyULI65FwVuwPx03Xrtmz1nwDY1RV5uFZgDbY&e=>
and
https://gemfire.docs.pivotal.io/geode/tools_modules/gfsh/command-pages/configure.html#topic_jdkdiqbgphqh<https://urldefense.proofpoint.com/v2/url?u=https-3A__gemfire.docs.pivotal.io_geode_tools-5Fmodules_gfsh_command-2Dpages_configure.html-23topic-5Fjdkdiqbgphqh&d=DwMFaQ&c=SFszdw3oxIkTvaP4xmzq_apLU3uL-3SxdAPNkldf__Q&r=HB5LZowSGF4DiMmOUsCX6Q&m=2hFmrt3Ab9isU6ABAr-hVroXxKvtz9dWdGKMlV-buFI&s=Z2B-8VpEVl3w965-zU_ZhQ68bSg-24bR5U0NvIGKpts&e=>
for pdx configuration either through code or pure gfsh.
-Xiawei
On Thu, 7 Sep 2017 at 11:32 PM, Xu, Nan <[email protected]<mailto:[email protected]>>
wrote:
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]<mailto:[email protected]>
Subject: [External email from
[email protected]<mailto:[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<https://urldefense.proofpoint.com/v2/url?u=http-3A__s.id&d=DwMFaQ&c=SFszdw3oxIkTvaP4xmzq_apLU3uL-3SxdAPNkldf__Q&r=HB5LZowSGF4DiMmOUsCX6Q&m=2hFmrt3Ab9isU6ABAr-hVroXxKvtz9dWdGKMlV-buFI&s=oepOHNowu2KmT51RJULSnKVHKxbO3rnPLA7O5Vcohbk&e=>)
.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<https://urldefense.proofpoint.com/v2/url?u=http-3A__s.id&d=DwMFaQ&c=SFszdw3oxIkTvaP4xmzq_apLU3uL-3SxdAPNkldf__Q&r=HB5LZowSGF4DiMmOUsCX6Q&m=2hFmrt3Ab9isU6ABAr-hVroXxKvtz9dWdGKMlV-buFI&s=oepOHNowu2KmT51RJULSnKVHKxbO3rnPLA7O5Vcohbk&e=>
= reader.readString("id");
s.name<https://urldefense.proofpoint.com/v2/url?u=http-3A__s.name&d=DwMFaQ&c=SFszdw3oxIkTvaP4xmzq_apLU3uL-3SxdAPNkldf__Q&r=HB5LZowSGF4DiMmOUsCX6Q&m=2hFmrt3Ab9isU6ABAr-hVroXxKvtz9dWdGKMlV-buFI&s=c7VGd7Oqrr_Yj19RWRIS6DI-_ToMFuXBG-6LKYjDTHM&e=>
= 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<https://urldefense.proofpoint.com/v2/url?u=http-3A__this.id&d=DwMFaQ&c=SFszdw3oxIkTvaP4xmzq_apLU3uL-3SxdAPNkldf__Q&r=HB5LZowSGF4DiMmOUsCX6Q&m=2hFmrt3Ab9isU6ABAr-hVroXxKvtz9dWdGKMlV-buFI&s=hHMTJFp10orOcYgJxqO8v07Ch74tuq-weZxSVD_nLRM&e=>
= id;
}
String name;
Timestamp time;
public String getName() {
return name;
}
public void setName(String name) {
this.name<https://urldefense.proofpoint.com/v2/url?u=http-3A__this.name&d=DwMFaQ&c=SFszdw3oxIkTvaP4xmzq_apLU3uL-3SxdAPNkldf__Q&r=HB5LZowSGF4DiMmOUsCX6Q&m=2hFmrt3Ab9isU6ABAr-hVroXxKvtz9dWdGKMlV-buFI&s=7mjXXiHhw7Phzj5Ai21hvDR0vpRomGqm0QyIYlLdLVk&e=>
= 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.
----------------------------------------------------------------------
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.