public static Set<String> getAllRegionNames(Cache cache) {
    Set<String> regionNames = new HashSet<>();
    Set<Region<?, ?>> rootRegions = cache.rootRegions();

    for (Region<?, ?> rootRegion : rootRegions) {
      try {
        Set<Region<?, ?>> subRegions = rootRegion.subregions(true);

        for (Region<?, ?> subRegion : subRegions) {
          regionNames.add(subRegion.getFullPath().substring(1));
        }

      } catch (Exception e) {
        logger.debug("Cannot get subregions of " + rootRegion.getFullPath()
            + ". Omitting from the set of region names.", e);
        continue;
      }

      regionNames.add(rootRegion.getFullPath().substring(1));
    }

    return regionNames;
  }
Executes a function with arguments on a set of members, ignoring the departed members.

@param function Function to be executed.
@param args Arguments passed to the function, pass null if you wish to pass no arguments to the
       function.
@param targetMembers Set of members on which the function is to be executed.
geode-core/src/main/java/org/apache/geode/management/internal/util/ManagementUtils.java