blob: 85063b8ef57852776be0568d96f51bbe9cce0c5a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.dispatch.searchcluster;
import com.yahoo.stream.CustomCollectors;
import java.util.Collection;
import java.util.Comparator;
import java.util.LinkedHashSet;
import java.util.Set;
import static java.util.Comparator.comparingInt;
import static java.util.stream.Collectors.toCollection;
import static java.util.stream.Collectors.toSet;
/**
* Simple interface for groups and their nodes in the content cluster
* @author baldersheim
*/
public interface SearchGroups {
Group get(int id);
Set<Integer> keys();
Collection<Group> groups();
default boolean isEmpty() {
return size() == 0;
}
default Set<Node> nodes() {
return groups().stream().flatMap(group -> group.nodes().stream())
.sorted(comparingInt(Node::key))
.collect(toCollection(LinkedHashSet::new));
}
int size();
boolean isPartialGroupCoverageSufficient(Collection<Node> nodes);
}
|