2013-03-13 45 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"/> 
相關問題