digital_archon
digital_archon

Reputation: 51

Retrieving all regions as a client cache

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.

Upvotes: 1

Views: 806

Answers (2)

Shuvro Das
Shuvro Das

Reputation: 71

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]);
}

Upvotes: 0

dturanski
dturanski

Reputation: 1723

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

Upvotes: 1

Related Questions