如何在 FunctionService.onServer() 中获取区域实例



我正在寻找,我们如何通过 FunctionService.onServer(( 调用在 execute(( 方法中获取区域实例(使用 Apatche Geode1.8(;

这是我的区域创建脚本:

start locator --name=cpmlocator
configure pdx --disk-store=DEFAULT
configure pdx --read-serialized=true
start server --name=cpmserver --initial-heap=1024m --max-heap=262144m --off-heap-memory-size=500m 
--critical-off-heap-percentage=85 --eviction-off-heap-percentage=75 --classpath=C:my_geodemodels.jar --J=-Xdebug --J=-Xrunjdwp:server=y,suspend=n,transport=dt_socket,address=14000;
create region --name=cpmRegion_L1 --type=PARTITION_OVERFLOW
create region --name=cpmRegion_L2 --type=PARTITION_OVERFLOW

客户端代码 :


ClientCache cache = new ClientCacheFactory().addPoolLocator("localhost", 10334).set("log-level", "INFO")
.create();

// create a local region that matches the server region
Region<String, Account> region_L1 = cache.<String, Account> createClientRegionFactory(ClientRegionShortcut.PROXY)
.create("cpmRegion_L1");
Region<String, Account> region_L2 = cache.<String, Account> createClientRegionFactory(ClientRegionShortcut.PROXY)
.create("cpmRegion_L2");

就我而言,我需要通过 FunctionService.onServer(( 在 execute(( 方法中访问 cpmRegion_L1 和cpmRegion_L2区域;

请,任何人,分享代码?

  • 子哈希

可以通过以下代码访问运行函数的成员上的Cache

@Override
public void execute(FunctionContext context) {
Cache cache = context.getCache();
Region<String, Account> region_L1 = cache.getRegion("cpmRegion_L1");
Region<String, Account> region_L2 = cache.getRegion("cpmRegion_L2");
...
}

希望这有帮助。干杯。

最新更新