blob: 7380b950fb2728ba5da9b72018148f614e976b8c (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.admin.clustercontroller;
import com.yahoo.config.model.api.Reindexing;
import com.yahoo.documentmodel.NewDocumentType;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
/**
* Context required to configure automatic reindexing for a given cluster controller cluster (for a given content cluster).
*
* @author bjorncs
*/
public class ReindexingContext {
private final Object monitor = new Object();
private final Map<String, Set<NewDocumentType>> documentTypesPerCluster = new HashMap<>();
private final Reindexing reindexing;
private final double windowSizeIncrement;
public ReindexingContext(Reindexing reindexing, double windowSizeIncrement) {
this.reindexing = Objects.requireNonNull(reindexing);
this.windowSizeIncrement = windowSizeIncrement;
}
public void addDocumentType(String clusterId, NewDocumentType type) {
synchronized (monitor) {
documentTypesPerCluster.computeIfAbsent(clusterId, ignored -> new HashSet<>())
.add(type);
}
}
public Collection<String> clusterIds() {
synchronized (monitor) {
return new HashSet<>(documentTypesPerCluster.keySet());
}
}
public Collection<NewDocumentType> documentTypesForCluster(String clusterId) {
synchronized (monitor) {
return new HashSet<>(documentTypesPerCluster.getOrDefault(clusterId, Set.of()));
}
}
public Reindexing reindexing() { return reindexing; }
public double windowSizeIncrement() { return windowSizeIncrement; }
}
|