public Set<DistributedMember> findMembers(boolean includeLocators, String... groups) {
    if (groups == null) {
      groups = new String[] {AbstractConfiguration.CLUSTER};
    }

    groups = Arrays.stream(groups).filter(Objects::nonNull).filter(s -> s.length() > 0)
        .toArray(String[]::new);

    if (groups.length == 0) {
      groups = new String[] {AbstractConfiguration.CLUSTER};
    }

    Set<DistributedMember> all = includeLocators ? getAllServersAndLocators() : getAllServers();

    if (Arrays.stream(groups).anyMatch(AbstractConfiguration::isCluster)) {
      return all;
    }

    Set<DistributedMember> matchingMembers = new HashSet<>();
    for (String group : groups) {
      matchingMembers.addAll(
          all.stream().filter(m -> m.getGroups() != null && m.getGroups().contains(group))
              .collect(Collectors.toSet()));
    }
    return matchingMembers;
  }
find members within these groups

@param includeLocators whether to include locators in this search or not
geode-core/src/main/java/org/apache/geode/management/internal/configuration/validators/MemberValidator.java