@Override
  public void execute(FunctionContext<Void> functionContext) {
    try {
      Cache cache = functionContext.getCache();
      Set<Region<?, ?>> regions = cache.rootRegions(); // should never return a null

      if (regions == null || regions.isEmpty()) {
        functionContext.getResultSender().lastResult(null);
      } else {
        Set<RegionInformation> regionInformationSet = new HashSet<>();

        for (Region<?, ?> region : regions) {
          RegionInformation regInfo = new RegionInformation(region, true);
          regionInformationSet.add(regInfo);
        }
        functionContext.getResultSender()
            .lastResult(regionInformationSet.toArray(new RegionInformation[0]));
      }
    } catch (Exception e) {
      functionContext.getResultSender().sendException(e);
    }
  }
Function that retrieves regions hosted on every member
geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/functions/GetRegionsFunction.java