public Optional<Group> takeGroup(Set<Integer> rejectedGroups) {
        synchronized (this) {
            Optional<GroupStatus> best = scheduler.takeNextGroup(rejectedGroups);

            if (best.isPresent()) {
                GroupStatus gs = best.get();
                gs.allocate();
                Group ret = gs.group;
                log.fine(() -> "Offering <" + ret + "> for query connection");
                return Optional.of(ret);
            } else {
                return Optional.empty();
            }
        }
    }
Select and allocate the search cluster group which is to be used for the next search query.
Callers <b>must</b> call {@link #releaseGroup} symmetrically for each taken allocation.

@param rejectedGroups if not null, the load balancer will only return groups with IDs not in the set
@return the node group to target, or <i>empty</i> if the internal dispatch logic cannot be used
container-search/src/main/java/com/yahoo/search/dispatch/LoadBalancer.java