[英]How to define persistence on Local Pivotal GemFire Region?
我有本地Region
,我想將Region
數據持久化到磁盤上。 如何使用DataPolicy
定義它?
我不確定您在這里要問的是什么,問題還不夠詳細...無論哪種方式, DataPolicy
枚舉都具有PERSISTENT_REPLICATE
和PERSISTENT_PARTITION
值,您可以在配置區域使其持久化時使用它們。
希望這可以幫助。
如果您的區域是真正的“本地”,則該區域的數據僅存儲在GemFire數據節點(服務器)或您的應用程序的本地,如果它是集群的客戶端或同級成員(無論哪種方式) ,那么您可以使用正確的Region快捷方式指定數據策略。
例如,如果您的應用程序/安排使用的是ClientCache
(即您的應用程序是緩存客戶端),那么您仍然可以使用ClientRegionShortcut.LOCAL_PERSISTENT
定義僅LOCAL的持久性區域。
如果您的應用程序/安排使用對等Cache
,(即您的應用程序實際上是作為數據節點/服務器,群集中的對等成員參與),那么您仍然可以使用RegionShortcut.LOCAL_PERSISTENT
定義僅LOCAL的持久性區域。
通過GemFire API(對等Cache
):
Cache peerCache = new CacheFactory(..)
.set(..)
.create();
RegionFactory localPersistentServerRegion =
peerCache.createRegionFactory(RegionShortcut.LOCAL_PERSISTENT);
通過GemFire API( ClientCache
):
ClientCache clientCache = new ClientCacheFactory(..)
.set(..)
.create();
ClientRegionFactory localPersistentClientRegion =
clientCache.createClientRegionFactory(ClientRegionShortcut.LOCAL_PERSISTENT);
通過使用SDG XML(對等Cache
):
<gfe:local-region id="ExampleLocalPersistentServerRegion" persistent="true"/>
通過使用SDG XML( ClientCache
):
<gfe:client-region id="ExampleLocalPersistentClientRegion"
shortcut="LOCAL_PERSISTENT"/>
通過使用SDG JavaConfig(對等Cache
):
@Configuration
@PeerCacheApplication
class GemFireConfiguration {
@Bean
LocalRegionFactoryBean exampleLocalPersistentServerRegion(
GemFireCache peerCache) {
LocalRegionFactoryBean exampleRegion =
new LocalRegionFactoryBean();
exampleRegion.setCache(peerCache);
exampleRegion.setClose(false);
exampleRegion.setPersistent(true);
return exampleRegion;
}
通過使用SDG JavaConfig( ClientCache
):
@Configuration
@ClientCacheApplication
class GemFireConfiguration {
@Bean
ClientRegionFactoryBean exampleLocalPersistentClientRegion(
GemFireCache clientCache) {
ClientRegionFactoryBean exampleRegion =
new ClientRegionFactoryBean();
exampleRegion.setCache(peerCache);
exampleRegion.setClose(false);
exampleRegion.setPersistent(true);
return exampleRegion;
}
在SDG中,還有其他使用純基於注釋的配置模型來完成此操作的方法,但這應該可以助您一臂之力。
干杯! -約翰
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.