简体   繁体   English

重要的GemFire 9.3.0:GemFire集群中的Spring Data GemFire XML配置

[英]Pivotal GemFire 9.3.0: Spring Data GemFire XML config in GemFire cluster

I am migrating my GemFire cluster from 8.2.7 (with Spring Data GemFire 1.6.0.RELEASE) to Pivotal GemFire 9.3.0 (SDG 2.0.7.RELEASE). 我正在将GemFire集群从8.2.7(使用Spring Data GemFire 1.6.0.RELEASE)迁移到Pivotal GemFire 9.3.0(SDG 2.0.7.RELEASE)。 I was using spring-context.xml (declared under the initializer tag in cache.xml ) to initialize the Regions while starting cache servers on each node. 我在启动每个节点上的缓存服务器时,使用spring-context.xml (在cache.xmlinitializer标记下声明)初始化区域。

When I try to reuse the same spring-context.xml for Pivotal GemFire 9.3.0, my Spring beans tag is not identified by the gfsh command and I am getting following exception: 当我尝试为Pivotal GemFire 9.3.0重用相同的spring-context.xmlgfsh命令无法识别我的Spring bean标签,并且gfsh以下异常:

Caused by: org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 107; cvc-elt.1: Cannot find the declaration of element 'beans'.

        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)

        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)

spring-context.xml : spring-context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:gfe="http://www.springframework.org/schema/geode"
       xmlns:util="http://www.springframework.org/schema/util"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
                http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/geode http://www.springframework.org/schema/gemfire/spring-geode.xsd
                http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

    <util:properties id="gemfireProperties">
        <prop key="log-level">config</prop>
        <prop key="locators">hostA[10334],hostB[10334]</prop>
    </util:properties>

    <bean id="mappingPdxSerializer" class="org.springframework.data.gemfire.mapping.MappingPdxSerializer"/>

    <gfe:cache properties-ref="gemfireProperties" pdx-serializer-ref="mappingPdxSerializer"/>

    <gfe:replicated-region id="Product">
    </gfe:replicated-region>

    <gfe:replicated-region id="ProductCustomer">
    </gfe:replicated-region>

</beans>

I updated the XML schema paths from " gemfire " to " geode " based on Spring documentation for spring-data-gemfire:2.0.7.RELEASE . 我根据Spring文档的spring-data-gemfire:2.0.7.RELEASE更新了从“ gemfire ”到“ geode ”的XML模式路径。

Trying with GF 9.1.1 and SDGF 2.0.7. 尝试使用GF 9.1.1和SDGF 2.0.7。 (SDGF jar is placed in lib) (SDGF jar放在lib中)

Script: 脚本:

#!/bin/sh
export PATH=$PATH:/var/tmp/user/gemfire/9.1.1:/opt/jdk/1.8.0_71l64/bin/:/var/tmp/user/gemfire/9.1.1/bin/
export GEMFIRE=/var/tmp/user/gemfire/9.1.1/


for i in `ls  /var/tmp/user/gemfire/9.1.1/lib/*.jar`
do
  CLASSPATH=${CLASSPATH}:${i}
done
CLASSPATH=$CLASSPATH:/var/tmp/user/gemfire/9.1.1/config
#echo $CLASSPATH

if [ -e "/var/tmp/user/gemfire/9.1.1/config/spring-context.xml" ]; then
   echo "File exists"
else
 echo "File does not exist"
fi


gfsh start server --name=server1 --server-port=40405 --classpath=$CLASSPATH --spring-xml-location=/var/tmp/user/gemfire/9.1.1/config/spring-context.xml  --locators=hostA[10334],hostB[10334] --mcast-port=0

UPDATE: 更新:

FileNotFoundException thrown : 抛出FileNotFoundException

Caused by: java.io.FileNotFoundException: class path resource [var/tmp/sn17180/gemfire/9.1.1/config/spring-context.xml] cannot be opened because it does not exist

        at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)

        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330)

        ... 17 more

I have given permission to all the files and -e "/" in my script is also printing "File exists". 我已授予所有文件的权限,并且脚本中的-e“ /”也正在打印“文件存在”。

UPDATE: 更新:

cache.xml cache.xml

<?xml version="1.0" encoding="UTF-8"?>
<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">

  <region name="Parent" refid="REPLICATE">
    <region name="Child" refid="REPLICATE"/>
  </region>

</cache>

gemfire-config.xml 的GemFire-config.xml中

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:gfe="http://www.springframework.org/schema/gemfire"
       xmlns:util="http://www.springframework.org/schema/util"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
                http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
                http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

    <util:properties id="gemfireProperties">
        <prop key="locators">xyz[10334],xyx[10334]</prop>
        <prop key="mcast-port">0</prop>
    </util:properties>

    <bean id="autoSerializer" class="org.apache.geode.pdx.ReflectionBasedAutoSerializer"/>

    <gfe:cache properties-ref="gemfireProperties" cache-xml-location="cache.xml" pdx-serializer-ref="autoSerializer" pdx-read-serialized="true"/>   

</beans>

Pivotal GemFire stopped shipping with Spring Data GemFire in the $GEMFIRE_HOME/lib directory as of the 9.x release series. 从9.x版本开始,Pivotal GemFire停止使用$GEMFIRE_HOME/lib目录中的Spring Data GemFire进行运输。 There are 2 primary reasons for this. 这样做有两个主要原因。

1) First, it was somewhat of a conundrum that Pivotal GemFire depended on SDG, which was entirely for gfsh>start server --name=SpringConfiguredServer --spring-xml-location-/path/to/spring/context.xml , when SDG depended on Pivotal GemFire, which clearly forms a circular dependency. 1)首先,Pivotal GemFire依赖于SDG gfsh>start server --name=SpringConfiguredServer --spring-xml-location-/path/to/spring/context.xml ,它完全用于gfsh>start server --name=SpringConfiguredServer --spring-xml-location-/path/to/spring/context.xml ,当SDG依赖于Pivotal GemFire,这显然形成了循环依赖。

2) Pivotal GemFire lags significantly behind the current state of the Spring ecosystem when it pertains to versions. 2)与版本有关时,Pivotal GemFire远远落后于Spring生态系统的当前状态。 Even the latest release, 9.3.0, ships with outdated Spring JARs, eg core Spring Framework 4.3.13.RELEASE , when core Spring Framework 4.3.17.RELEASE is already available as well as 5.0.6.RELEASE , with 5.1 on the horizon. 即使是最新的版本,9.3.0,船舶与过时的春天 JAR文件,如核心Spring框架 4.3.13.RELEASE ,当核心Spring框架 4.3.17.RELEASE已经可用以及5.0.6.RELEASE ,与5.1的地平线。

Having said that, it is still possible to configure and bootstrap your Pivotal GemFire Servers with Spring when started from Gfsh using the start server command, --spring-xml-location option. 话虽如此,当使用start server命令--spring-xml-location选项从Gfsh start server时,仍然可以使用Spring配置和引导您的Pivotal GemFire服务器。 You simply need to download the appropriate version of SDG based on the Pivotal GemFire version you are using (eg (9.3.0)) and put SDG on the classpath when starting the server. 您仅需要根据正在使用的Pivotal GemFire版本下载适当的SDG版本(例如(9.3.0)),然后在启动服务器时将SDG放在类路径中。

NOTE: currently, SDG 2.1.0.M3 (SD Lovelace ) is the only version based on Pivotal GemFire 9.3 and later; 注意:当前, SDG 2.1.0.M3 (SD Lovelace )是基于Pivotal GemFire 9.3和更高版本的唯一版本; currently set to 9.5.0. 当前设置为9.5.0。

NOTE: also not, I don't specifically recall whether I ran into any API breaking changes between upgrading SDG Lovelace progressively from Pivotal GemFire 9.3, then to 9.4 and finally arriving at 9.5. 注意:也不是,我不特别记得我是否遇到过任何在从SDG Lovelace从Pivotal GemFire 9.3逐步升级到9.4并最终达到9.5的过程中发生任何更改的API。 If you have trouble with spring-data-gemfire:2.1.0.M3 , you can also use spring-data-gemfire:2.1.0.M2 which was based on Pivotal GemFire 9.3 at the time. 如果您在使用spring-data-gemfire:2.1.0.M3 ,也可以使用当时基于 Pivotal GemFire 9.3的spring-data-gemfire:2.1.0.M2

So following the recipe above, you would do the following... 因此,按照上面的食谱,您将执行以下操作...

gfsh> start server --name=SpringConfiguredServer --classpath=/file/system/path/to/spring-data-gemfire22.1.0.M3.jar --spring-xml-location=/classpath/to/your/spring-context.xml

This should work! 这应该工作!

Also, you do not need to switch schemas from "gemfire" to "geode". 另外,您无需将架构从“ gemfire”切换到“ geode”。 When you are using Spring Data GemFire, then use the "spring-gemfire" schema. 使用Spring Data GemFire时,请使用“ spring-gemfire”架构。 When you are using Spring Data Geode, then use the "spring-geode" schema. 使用Spring Data Geode时,请使用“ spring-geode”架构。 Either will probably work, but... 两者都可能起作用,但是...

Hope this helps! 希望这可以帮助!

-j -j

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM