繁体   English   中英

Spring Data Gemfire配置未连接到定位器?

[英]Spring Data Gemfire configuration does not connect to locator?

假设我的目标部署环境中已经运行了Gemfire定位器和cacheserver进程。 目标部署环境使用客户端-服务器拓扑

我有一个Spring 3.1 MVC应用程序,它想使用Gemfire缓存。 我正在使用Spring Data Gemfire 1.2.2和Gemfire 6.6.1

所以我在spring.xml添加了以下spring.xml

<util:properties id="gemfire-props">
    <prop key="log-level">${gemfire.log-level}</prop>
    <prop key="mcast-port">${gemfire.mcast-port}</prop>
    <prop key="locators">${gemfire.locators}</prop>
</util:properties>

<gfe:cache id="gemfireCache" properties-ref="gemfire-props"/>
<gfe:replicated-region id="myCacheRegion" cache-ref="gemfireCache">
    <gfe:cache-listener>
        <ref bean="gemfireCacheLogListener"/>
    </gfe:cache-listener>
    <gfe:entry-ttl timeout="${gemfire.myCacheRegion.ttl}" action="DESTROY"/>
</gfe:replicated-region>

<bean id="gemfireCacheLogListener" class="org.awong.GemfireCacheLogListener"></bean>

<bean id="cacheManager" class="org.springframework.data.gemfire.support.GemfireCacheManager"
    p:cache-ref="gemfireCache">
    <property name="regions">
        <set>
            <ref bean="myCacheRegion"/>
        </set>
    </property>
</bean>

假设外部JAR依赖项都已在Maven中正确定义。 还假设我已加载了一个属性文件,该文件定义了上面引用的属性值。 locators属性被定义为使用已经启动的Gemfire locator的IP和端口。

我相信这应该足够好,这样我就可以使用@Cacheable在MVC应用程序中注释bean。 我希望这些配置可以启动应用程序服务器中的定位器以连接到Gemfire网格,将myCacheRegion添加到Gemfire缓存服务器,然后cacheManager应该能够使用新的缓存区域。

我收到BeanCreationException ,这是由Spring启动时无法连接到定位器引起的:

4-Mar-2013 16:02:08.750 SEVERE org.apache.catalina.core.ApplicationContext.log StandardWrapper.Throwable
 org.springframework.beans.factory.BeanCreationException:
 [rest of stack trace snipped out]
 nested exception is com.gemstone.gemfire.GemFireConfigException: Unable to contact a Locator service.  Operation either timed out or Locator does not exist.
Configured list of locators is "[hostnameOfLocator<v0>:portOfLocator]".

但是,当我部署到目标环境时,由于定位器进程无法连接,因此无法创建Gemfire bean。 我想念什么?

看不到日志很难说。 您的配置看起来还可以。 您在这些过程和locator.log中看到什么错误?

我希望这些配置可以启动应用程序服务器中的定位器。

这些配置不会启动定位器,仅连接到已配置的定位器。 但是您要声明定位器已经启动。 使用定位器时,mcast-port也应始终为0。

一个常见的问题是gemfire.jars必须都具有相同的版本。 SDGF 1.2.2取决于gemfire 7.0。 如果您使用的是gemfire 6.6.1,则需要从pom中的spring-data-gemfire中排除gemfire依赖项。

目标部署使用客户端服务器拓扑。

此配置适用于对等网络。 它仍然应该工作,但是如果您有现有的缓存服务器,则可能希望将其配置为客户端。 该区域是服务器上的副本还是仅是本地数据? 注意,如果只需要@Cacheable,则无需连接到网格。 独立的嵌入式缓存可以正常工作。

您可以尝试配置定位器池,例如:

<gfe:pool id="locatorPool">
    <gfe:locator host="host1" port="port1"/>
    <gfe:locator host="host2" port="port2"/>
</gfe:pool>

然后将您的缓存链接到该池:

<gfe:cache id="gemfireCache" pool-name="locatorPool"/>

暂无
暂无

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

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