1

I am looking for a way to programmatically retrieve all regions and return the count/size. I can see how gfsh has the "list regions" but can't seem to find the backing java api command. I've tried

cache = ClientCacheFactory().addPoolLocator().create();
RegionService regionService =   
clientCache.createAuthenticatedView(properties);

but the resulting regionService.rootRegions is empty. I can get query service and run something like "select count(*) from /UserRegion" but would like to dynamically retrieve the regions.

Greg Chase
  • 173
  • 8

2 Answers2

1

An alternative to using the MBean is to execute a remote function, something like this

dturanski
  • 1,723
  • 1
  • 13
  • 8
  • It sounds like this is the best option if I want to minimize keeping up with connection settings for both the locators and jmx. Thanks! – digital_archon Sep 26 '15 at 21:20
0

You can get the list of region by Gemfire management service through JMX client.

MemberMXBean mbeanProxy =
    (MemberMXBean) MBeanServerInvocationHandler.newProxyInstance(
    mbeanServerConnection, mbeanName, MemberMXBean.class, true);
String[] listRegions = mbeanProxy.listRegions();
for (int i = 0; i < listRegions.length; i++) {
    System.out.println(listRegions[i]);
}
Shuvro Das
  • 71
  • 2