0

I am looking for, how do we get the region instance(with Apatche Geode1.8) within the execute() method through FunctionService.onServer() call;

Here is my region creation script :

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_geode\models.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

Client code :


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");

In my case, I need both cpmRegion_L1 & cpmRegion_L2 region’s access inside execute() method through FunctionService.onServer();

Please, anyone, share the code for that ?

  • Subhash
Subhash
  • 11
  • 2

1 Answers1

0

You can get access to the Cache on the member on which the function is running through the following code:

@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");
  ...
}

Hope this helps. Cheers.

Juan Ramos
  • 1,421
  • 1
  • 8
  • 13