public static Set<DistributedMember> getRegionAssociatedMembers(String region,
      final InternalCache cache, boolean returnAll) {
    if (region == null || region.isEmpty()) {
      return Collections.emptySet();
    }

    if (!region.startsWith(SEPARATOR)) {
      region = SEPARATOR + region;
    }

    DistributedRegionMXBean regionMXBean =
        ManagementService.getManagementService(cache).getDistributedRegionMXBean(region);

    if (regionMXBean == null) {
      return Collections.emptySet();
    }

    String[] regionAssociatedMemberNames = regionMXBean.getMembers();
    Set<DistributedMember> matchedMembers = new HashSet<>();
    Set<DistributedMember> allClusterMembers = new HashSet<>(cache.getMembers());
    allClusterMembers.add(cache.getDistributedSystem().getDistributedMember());

    for (DistributedMember member : allClusterMembers) {
      List<String> regionAssociatedMemberNamesList = Arrays.asList(regionAssociatedMemberNames);
      String name = MBeanJMXAdapter.getMemberNameOrUniqueId(member);
      if (regionAssociatedMemberNamesList.contains(name)) {
        matchedMembers.add(member);
        if (!returnAll) {
          return matchedMembers;
        }
      }
    }
    return matchedMembers;
  }
Returns a Set of DistributedMember for members that have the specified <code>region</code>.
<code>returnAll</code> indicates whether to return all members or only the first member we
find.

@param region region path for which members that have this region are required
@param cache cache instance to use to find members
@param returnAll if true, returns all matching members, else returns only first one found.
@return a Set of DistributedMember for members that have the specified <code>region</code>.
geode-core/src/main/java/org/apache/geode/management/internal/util/ManagementUtils.java