1 回答

TA貢獻1806條經(jīng)驗 獲得超8個贊
在我的例子中,我絕對不能使用@EnableClusterConfiguration(仍然想知道為什么)。根據(jù) John 的說法,我們可以使用 gfsh 創(chuàng)建區(qū)域。由此我想到在 Spring Boot CacheServer 上做同樣的事情。那么,如果我在 CacheServer 定義 POJO 并讓注釋 @EnableEntityDefinedRegions 完成在 CacheServer 端創(chuàng)建區(qū)域的工作,該怎么辦?我又借了
serverRegionShortcut = RegionShortcut.PARTITION_PERSISTENT
來自約翰,但我把它放在
@EnableEntityDefinedRegions
除此之外,我還需要保留我的 PDX 類型(如果我不在 CacheServer 端保留 Pdx 類型,Spring 和/或 Geode Gemfire 不喜歡我)。因此,我使用相同的方法從SpringData Gemfire DiskStore進行持久化,但我在 CacheServer 端實現(xiàn)它,并在 application.properties 中添加一些附加條目來告訴 spring 也持久化 Pdx 類型。
這樣,我就能夠在 CacheServer 端成功創(chuàng)建和持久化 Region,并且還能夠持久化 Pdx。
這是我借用SpringData Gemfire DiskStore的想法制作的完整代碼和 application.properties 。
如果有人能夠告訴我這個解決方法是否是一個好方法,或者是否有其他方法或更好的想法(仍然想知道為什么 @EnableClusterConfiguration 不喜歡我,而其他人對此沒有問題:= (所以,如果有人能夠告訴我我的錯誤在哪里,我真的很感激)。
客戶 :
@SpringBootApplication
@ClientCacheApplication(logLevel = "debug", locators = {@Locator(host = "localhost", port = 10334)})
@EnablePool(name="neptunusPool", servers=@Server(host="localhost", port=41414))
@EnableGemfireRepositories(basePackageClasses= {TitleContentRepository.class})
@EnableEntityDefinedRegions(basePackageClasses= {TitleContent.class
})
//@ReplicateRegion
//@EnableClusterDefinedRegions
//@EnableCachingDefinedRegions
//@EnableGemfireCaching
@EnableIndexing
//@EnableClusterConfiguration
@EnablePdx
public class CommerceHostGeodeApplication {
? ? public static void main(String[] args) {
? ? ? ? SpringApplication.run(CommerceHostGeodeApplication.class, args);
? ? }
}
在客戶端,相同的 POJO、Repository 和 RestController,除了 server.port 定義之外,application.properties 中沒有任何內(nèi)容。
緩存服務(wù)器:
@SpringBootApplication
@CacheServerApplication(locators="localhost[10334]", name="GeodeServerApplication" )
@EnableCacheServer(name="neptunus", autoStartup=true, hostnameForClients = "localhost", port = 41414)
@EnableCachingDefinedRegions
@EnableGemfireCaching
@EnablePdx
@EnableManager
@EnableHttpService
@EnableDiskStore(name = "disk_store")
@EnableEntityDefinedRegions(basePackageClasses= {TitleContent.class
}, serverRegionShortcut = RegionShortcut.PARTITION_PERSISTENT)
public class GeodeServerApplication {
? ? public static void main(String[] args) {
? ? ? ? SpringApplication.run(GeodeServerApplication.class, args);
? ? }
}
CACHESERVER application.properties :
server.port=15010
spring.data.gemfire.disk.store.name=disk_store
spring.data.gemfire.disk.store.directory.location=/Users/ars/geode/data
spring.data.gemfire.pdx.disk-store-name=disk_store
spring.data.gemfire.pdx.persistent=true
spring.data.gemfire.management.use-http=true
CacheServer 啟動后,區(qū)域?qū)⒈粍?chuàng)建并能夠持久/保存到磁盤。
添加回答
舉報