使用ClientCache在复制区域中进行Pdx序列化

时间:2016-12-09 11:16:00

标签: geode

当使用SB创建Geode客户端缓存时,我在远程Geode实例上遇到PDX序列化问题 - >

@Configuration
public class GeodeClientConfiguration {

@Bean
ClientCache cache() {
    return new ClientCacheFactory()
        .setPdxPersistent(true)
        .setPdxDiskStore("foo")
        .setPdxReadSerialized(true)
        .setPdxSerializer(new ReflectionBasedAutoSerializer(false, "foo.EpgProgram"))
        .create();
}

@Bean
Region<String, List<EpgProgram>> testRegion(final ClientCache cache) {
    return cache.<String, List<EpgProgram>> getRegion("schedule");
}

cache.xml看起来像 - &gt;

<?xml version="1.0" encoding="UTF-8"?>
<client-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">
<pool name="serverPool">
    <locator host="localhost" port="10334"/>
</pool>
<region name="schedule"  refid="CACHING_PROXY">
    <region-attributes pool-name="serverPool"
            scope="global" />
</region>

在Gfsh中,我创建了一个区域

create region --name=/schedule --type=REPLICATE_PERSISTENT

在方法

中测试期间向区域添加EpgProgram列表时
public List<EpgProgram> getScheduleFromWhatson(String channel, LocalDate broadcastDate, Boolean expand) throws RestClientException, URISyntaxException {
    List<EpgProgram> programs = transform(whatsOnServiceInternal.getScheduleFromWhatson(channel, broadcastDate), expand);
    schedule.put(channel, programs);
    return programs;
}

pdx实例似乎是使用我从信息追踪中看到的反射生成的 - &gt;

[info 2016/12/09 11:32:33.361 CET <http-nio-8080-exec-1> tid=0xc8] Auto serializer generating type for class dk.dr.epg.core.EpgProgram for fields: 
printable: private boolean dk.dr.epg.core.EpgProgram.printable
live: private boolean dk.dr.epg.core.EpgProgram.live
rerun: private boolean dk.dr.epg.core.EpgProgram.rerun

但就在那之后我得到一个例外 - &gt;

org.apache.geode.pdx.PdxInitializationException: The PDX metadata must be persistent in a member that has persistent data. See CacheFactory.setPdxPersistent.

错过了我必须设置Pdx persistense的其他任何地方??

Geode版本:1.0.0-incubating。

1 个答案:

答案 0 :(得分:2)

您需要将pdx注册表配置为在服务器上保持持久性。你可以在gfsh中这样做:

gfsh&GT; configure pdx --disk-store = DEFAULT

我认为您需要在此之后重新启动服务器才能使更改生效。