2013-03-13 51 views
0

假设我的Gemfire定位器& cacheserver进程已经在我的目标部署环境中运行。目标部署环境使用client-server topologySpring Data Gemfire配置没有连接到定位器?

我有一个Spring 3.1 MVC应用程序,它想要使用Gemfire缓存。我使用Spring数据的GemFire 1.2.2和6.6.1的GemFire

所以我增加了以下我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定位器的IP和端口。

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

我得到它们由故障引起BeanCreationException s到连接到定位器,当春天启动:

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豆失败是因为定位器创建进程无法连接。我错过了什么?

回答

1

很难说没有看到日志。你的配置看起来不错。你在这些进程和locator.log中看到了哪些错误?

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

这些配置不会启动定位器,只能连接到配置定位器。但是你早些时候说明定位器已经启动了。当使用定位器时,mcast-port也应该始终为0。

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

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

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

+0

谢谢,戴夫! mcost-port设置为0.我已经排除了由SDGF 1.2.2加载的Gemfire。 我曾尝试使用连接到的Spring配置,该配置使用预期的定位器主机名和端口,但我仍然得到相同的异常。 – Alan 2013-03-14 15:48:25

+0

Dave,如果我只需要@Cacheable,那么我们可以使用Gemfire作为独立嵌入式缓存吗?我的客户坚持认为我们只使用Gemfire作为缓存提供者,而不是使用其他提供者,如EhCache。 – Alan 2013-03-14 16:05:47

+0

另外我还浏览了github上的gemfire示例(https://github.com/SpringSource/spring-gemfire-examples),并在您使用SDGF 1.2.1时返回提交。我注意到replicated-cs示例具有与复制区域具有相同标识的客户端区域。如果它们处于相同的应用程序环境中,这不会造成问题,对吗? – Alan 2013-03-14 16:12:23

0

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

<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"/> 
相关问题